Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles/base/BaseStyle.cpp')
-rw-r--r--src/gui/styles/base/BaseStyle.cpp62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/gui/styles/base/BaseStyle.cpp b/src/gui/styles/base/BaseStyle.cpp
index aac9daf1c..104e1d4d9 100644
--- a/src/gui/styles/base/BaseStyle.cpp
+++ b/src/gui/styles/base/BaseStyle.cpp
@@ -54,6 +54,8 @@
#include <cmath>
+#include "core/Resources.h"
+
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT int qt_defaultDpiX();
QT_END_NAMESPACE
@@ -282,6 +284,17 @@ namespace Phantom
? highlightedOutlineOf(pal)
: Grad(pal.color(QPalette::WindowText), pal.color(QPalette::Window)).sample(0.5);
}
+
+#ifdef Q_OS_MACOS
+ QColor tabBarBase(const QPalette& pal)
+ {
+ return hack_isLightPalette(pal) ? QRgb(0xD1D1D1) : QRgb(0x252525);
+ }
+ QColor tabBarBaseInactive(const QPalette& pal)
+ {
+ return hack_isLightPalette(pal) ? QRgb(0xF4F4F4) : QRgb(0x282828);
+ }
+#endif
} // namespace DeriveColors
namespace SwatchColors
@@ -328,6 +341,9 @@ namespace Phantom
S_itemView_headerOnLine,
S_scrollbarGutter_disabled,
+ S_tabBarBase,
+ S_tabBarBase_inactive,
+
// Aliases
S_progressBar = S_highlight,
S_progressBar_specular = S_highlight_specular,
@@ -340,7 +356,7 @@ namespace Phantom
enum
{
- Num_SwatchColors = SwatchColors::S_scrollbarGutter_disabled + 1,
+ Num_SwatchColors = SwatchColors::S_tabBarBase_inactive + 1,
Num_ShadowSteps = 3,
};
@@ -443,6 +459,14 @@ namespace Phantom
colors[S_itemView_headerOnLine] = Dc::itemViewHeaderOnLineColorOf(pal);
colors[S_scrollbarGutter_disabled] = colors[S_window];
+#ifdef Q_OS_MACOS
+ colors[S_tabBarBase] = Dc::tabBarBase(pal);
+ colors[S_tabBarBase_inactive] = Dc::tabBarBaseInactive(pal);
+#else
+ colors[S_tabBarBase] = pal.color(QPalette::Active, QPalette::Window);
+ colors[S_tabBarBase_inactive] = pal.color(QPalette::Inactive, QPalette::Window);
+#endif
+
brushes[S_none] = Qt::NoBrush;
for (int i = S_none + 1; i < Num_SwatchColors; ++i) {
// todo try to reuse
@@ -1551,6 +1575,12 @@ void BaseStyle::drawPrimitive(PrimitiveElement elem,
auto tbb = qstyleoption_cast<const QStyleOptionTabBarBase*>(option);
if (!tbb)
break;
+
+#ifdef Q_OS_MACOS
+ painter->fillRect(widget->rect(),
+ swatch.color(option->state & QStyle::State_Active ? S_tabBarBase : S_tabBarBase_inactive));
+#endif
+
Qt::Edge edge = Qt::TopEdge;
switch (tbb->shape) {
case QTabBar::RoundedNorth:
@@ -2253,6 +2283,21 @@ void BaseStyle::drawControl(ControlElement element,
auto toolBar = qstyleoption_cast<const QStyleOptionToolBar*>(option);
if (!toolBar)
break;
+
+#ifdef Q_OS_MACOS
+ if (auto* mainWindow = qobject_cast<QMainWindow*>(widget->window())) {
+ // Fill toolbar background with transparent pixels to reveal the
+ // gradient background drawn by the Cocoa platform plugin.
+ // Inspired by qmacstyle_mac.mm.
+ if (m_drawNativeMacOsToolBar && toolBar && toolBar->toolBarArea == Qt::TopToolBarArea
+ && mainWindow->unifiedTitleAndToolBarOnMac()) {
+ painter->setCompositionMode(QPainter::CompositionMode_Source);
+ painter->fillRect(option->rect, Qt::transparent);
+ break;
+ }
+ }
+#endif
+
painter->fillRect(option->rect, option->palette.window().color());
bool isFloating = false;
if (auto tb = qobject_cast<const QToolBar*>(widget)) {
@@ -3036,6 +3081,21 @@ QPalette BaseStyle::standardPalette() const
return QCommonStyle::standardPalette();
}
+QIcon BaseStyle::standardIcon(StandardPixmap sp, const QStyleOption* opt, const QWidget* widget) const
+{
+ switch (sp) {
+ case SP_ToolBarHorizontalExtensionButton:
+ return resources()->icon("chevron-double-down");
+ case SP_ToolBarVerticalExtensionButton:
+ return resources()->icon("chevron-double-right");
+ case SP_LineEditClearButton:
+ return resources()->icon(
+ QString("edit-clear-locationbar-").append((opt->direction == Qt::LeftToRight) ? "rtl" : "ltr"));
+ default:
+ return QCommonStyle::standardIcon(sp, opt, widget);
+ }
+}
+
void BaseStyle::drawComplexControl(ComplexControl control,
const QStyleOptionComplex* option,
QPainter* painter,