forked from osmocom/wireshark
Qt: Add a common hover color.
This commit is contained in:
parent
ce43234c5a
commit
6d319297ae
|
@ -305,19 +305,11 @@ void PacketList::colorsChanged()
|
||||||
|
|
||||||
QString hover_style;
|
QString hover_style;
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
#if defined(Q_OS_MAC)
|
|
||||||
QPalette default_pal = QApplication::palette();
|
|
||||||
default_pal.setCurrentColorGroup(QPalette::Active);
|
|
||||||
QColor hover_color = default_pal.highlight().color();
|
|
||||||
#else
|
|
||||||
QColor hover_color = ColorUtils::alphaBlend(palette().window(), palette().highlight(), 0.5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hover_style = QString(
|
hover_style = QString(
|
||||||
"QTreeView:item:hover {"
|
"QTreeView:item:hover {"
|
||||||
" background-color: %1;"
|
" background-color: %1;"
|
||||||
" color: palette(text);"
|
" color: palette(text);"
|
||||||
"}").arg(hover_color.name(QColor::HexArgb));
|
"}").arg(ColorUtils::hoverBackground().name(QColor::HexArgb));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString active_style = QString();
|
QString active_style = QString();
|
||||||
|
|
|
@ -62,19 +62,11 @@ ProtoTree::ProtoTree(QWidget *parent, epan_dissect_t *edt_fixed) :
|
||||||
setHeaderHidden(true);
|
setHeaderHidden(true);
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
#if defined(Q_OS_MAC)
|
|
||||||
QPalette default_pal = QApplication::palette();
|
|
||||||
default_pal.setCurrentColorGroup(QPalette::Active);
|
|
||||||
QColor hover_color = default_pal.highlight().color();
|
|
||||||
#else
|
|
||||||
QColor hover_color = ColorUtils::alphaBlend(palette().window(), palette().highlight(), 0.5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setStyleSheet(QString(
|
setStyleSheet(QString(
|
||||||
"QTreeView:item:hover {"
|
"QTreeView:item:hover {"
|
||||||
" background-color: %1;"
|
" background-color: %1;"
|
||||||
" color: palette(text);"
|
" color: palette(text);"
|
||||||
"}").arg(hover_color.name(QColor::HexArgb)));
|
"}").arg(ColorUtils::hoverBackground().name(QColor::HexArgb)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Shrink down to a small but nonzero size in the main splitter.
|
// Shrink down to a small but nonzero size in the main splitter.
|
||||||
|
|
|
@ -188,6 +188,17 @@ const QColor ColorUtils::contrastingTextColor(const QColor color)
|
||||||
return QApplication::palette().base().color();
|
return QApplication::palette().base().color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor ColorUtils::hoverBackground()
|
||||||
|
{
|
||||||
|
QPalette hover_palette = QApplication::palette();
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
hover_palette.setCurrentColorGroup(QPalette::Active);
|
||||||
|
return hover_palette.highlight().color();
|
||||||
|
#else
|
||||||
|
return ColorUtils::alphaBlend(hover_palette.window(), hover_palette.highlight(), 0.5);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const QColor ColorUtils::warningBackground()
|
const QColor ColorUtils::warningBackground()
|
||||||
{
|
{
|
||||||
if (themeIsDark()) {
|
if (themeIsDark()) {
|
||||||
|
|
|
@ -70,6 +70,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static const QColor contrastingTextColor(const QColor color);
|
static const QColor contrastingTextColor(const QColor color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an appropriate background color for hovered abstract items.
|
||||||
|
* @return The background color.
|
||||||
|
*/
|
||||||
|
static const QColor hoverBackground();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an appropriate warning background color for the current mode.
|
* Returns an appropriate warning background color for the current mode.
|
||||||
* @return The background color.
|
* @return The background color.
|
||||||
|
|
|
@ -427,8 +427,6 @@ void WelcomePage::on_helpLabel_clicked()
|
||||||
|
|
||||||
void WelcomePage::updateStyleSheets()
|
void WelcomePage::updateStyleSheets()
|
||||||
{
|
{
|
||||||
QColor hover_color = ColorUtils::alphaBlend(palette().window(), palette().highlight(), 0.5);
|
|
||||||
|
|
||||||
QString welcome_ss = QString(
|
QString welcome_ss = QString(
|
||||||
"WelcomePage {"
|
"WelcomePage {"
|
||||||
" padding: 1em;"
|
" padding: 1em;"
|
||||||
|
@ -448,7 +446,7 @@ void WelcomePage::updateStyleSheets()
|
||||||
" color: palette(text);"
|
" color: palette(text);"
|
||||||
"}"
|
"}"
|
||||||
)
|
)
|
||||||
.arg(hover_color.name());
|
.arg(ColorUtils::hoverBackground().name(QColor::HexArgb));
|
||||||
#endif
|
#endif
|
||||||
setStyleSheet(welcome_ss);
|
setStyleSheet(welcome_ss);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue