Skip to content

Commit

Permalink
Merge remote-tracking branch 'filewave/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
oclero committed Jan 23, 2024
2 parents 75d09bc + b7eae5a commit 611c831
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/include/oclero/qlementine/style/QlementineStyle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class QlementineStyle : public QCommonStyle {

virtual QColor const& frameBackgroundColor(MouseState const mouse) const;

virtual QColor const& buttonBackgroundColor(MouseState const mouse, ColorRole const role) const;
virtual QColor const& buttonForegroundColor(MouseState const mouse, ColorRole const role) const;
virtual QColor const& buttonBackgroundColor(MouseState const mouse, ColorRole const role, const QWidget* w = nullptr) const;
virtual QColor const& buttonForegroundColor(MouseState const mouse, ColorRole const role, const QWidget* w = nullptr) const;

virtual QColor const& toolButtonBackgroundColor(MouseState const mouse, ColorRole const role) const;
virtual QColor const& toolButtonForegroundColor(MouseState const mouse, ColorRole const role) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CommandLinkButton : public QCommandLinkButton {
explicit CommandLinkButton(const QString& text, const QString& description, QWidget* parent = nullptr);
explicit CommandLinkButton(
const QIcon& icon, const QString& text, const QString& description, QWidget* parent = nullptr);
~CommandLinkButton();
~CommandLinkButton() override;

public:
QSize sizeHint() const override;
Expand Down
8 changes: 5 additions & 3 deletions lib/src/style/QlementineStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ void QlementineStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption* opt
const auto isFlat = optButton->features.testFlag(QStyleOptionButton::Flat);
const auto mouse = isFlat ? getToolButtonMouseState(opt->state) : getMouseState(opt->state);
const auto role = getColorRole(opt->state, isDefault);
const auto& bgColor = buttonBackgroundColor(mouse, role);
const auto& bgColor = buttonBackgroundColor(mouse, role, w);
const auto& currentBgColor =
_impl->animations.animateBackgroundColor(w, bgColor, _impl->theme.animationDuration);
const auto radiuses = optRoundedButton ? optRoundedButton->radiuses : RadiusesF{ _impl->theme.borderRadius };
Expand Down Expand Up @@ -5125,7 +5125,8 @@ QColor const& QlementineStyle::frameBackgroundColor(MouseState const mouse) cons
return _impl->theme.backgroundColorMain1;
}

QColor const& QlementineStyle::buttonBackgroundColor(MouseState const mouse, ColorRole const role) const {
QColor const& QlementineStyle::buttonBackgroundColor(MouseState const mouse, ColorRole const role, const QWidget* w) const {
Q_UNUSED(w)
const auto primary = role == ColorRole::Primary;

switch (mouse) {
Expand All @@ -5143,7 +5144,8 @@ QColor const& QlementineStyle::buttonBackgroundColor(MouseState const mouse, Col
}
}

QColor const& QlementineStyle::buttonForegroundColor(MouseState const mouse, ColorRole const role) const {
QColor const& QlementineStyle::buttonForegroundColor(MouseState const mouse, ColorRole const role, const QWidget* w) const {
Q_UNUSED(w)
const auto primary = role == ColorRole::Primary;

switch (mouse) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/style/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ void Theme::initializeFromJson(QJsonDocument const& jsonDoc) {
TRY_GET_COLOR_ATTRIBUTE(jsonObj, secondaryColorForegroundDisabled);
secondaryColorForegroundTransparent = colorWithAlpha(secondaryColorForeground, 0);

TRY_GET_COLOR_ATTRIBUTE(jsonObj, semiTransparentColor1);
TRY_GET_COLOR_ATTRIBUTE(jsonObj, semiTransparentColor2);
TRY_GET_COLOR_ATTRIBUTE(jsonObj, semiTransparentColor3);
TRY_GET_COLOR_ATTRIBUTE(jsonObj, semiTransparentColor4);
semiTransparentColorTransparent = colorWithAlpha(semiTransparentColor1, 0);

TRY_GET_COLOR_ATTRIBUTE(jsonObj, statusColorSuccess);
TRY_GET_COLOR_ATTRIBUTE(jsonObj, statusColorSuccessHovered);
TRY_GET_COLOR_ATTRIBUTE(jsonObj, statusColorSuccessPressed);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/utils/ImageUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ QPixmap getTintedPixmap(const QPixmap& input, const QColor& color) {
}

QString getColorizedPixmapKey(QPixmap const& pixmap, QColor const& color) {
return QString("qlementine_color_%1_%2").arg(toHex(pixmap.cacheKey())).arg(toHex(color.rgba()));
return QString("qlementine_color_%1_%2").arg(toHex(pixmap.cacheKey()), toHex(color.rgba()));
}

QString getTintedPixmapKey(QPixmap const& pixmap, QColor const& color) {
return QString("qlementine_tint_%1_%2").arg(toHex(pixmap.cacheKey())).arg(toHex(color.rgba()));
return QString("qlementine_tint_%1_%2").arg(toHex(pixmap.cacheKey()), toHex(color.rgba()));
}

QPixmap getCachedPixmap(QPixmap const& input, QColor const& color, ColorizeMode mode) {
Expand Down
28 changes: 14 additions & 14 deletions lib/src/utils/StyleUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,20 @@ bool shouldNotHaveWheelEvents(const QWidget* w) {
|| qobject_cast<const QAbstractSpinBox*>(w);
}

int getTabIndex(const QStyleOptionTab* optTab, [[maybe_unused]]const QWidget* parentWidget) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return optTab->tabIndex;
#else
if (const auto* optTabV4 = qstyleoption_cast<const QStyleOptionTabV4*>(optTab)) {
return optTabV4->tabIndex;
}

if (const auto* tabBar = qobject_cast<const QTabBar*>(parentWidget)) {
return tabBar->tabAt(optTab->rect.topLeft());
}

return -1;
#endif
int getTabIndex(const QStyleOptionTab* optTab, const QWidget* parentWidget) {
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
if (const auto* optTabV4 = qstyleoption_cast<const QStyleOptionTab*>(optTab)) {
#else
if (const auto* optTabV4 = qstyleoption_cast<const QStyleOptionTabV4*>(optTab)) {
#endif
return optTabV4->tabIndex;
}

if (const auto* tabBar = qobject_cast<const QTabBar*>(parentWidget)) {
return tabBar->tabAt(optTab->rect.topLeft());
}

return -1;
}

int getTabCount(const QWidget* parentWidget) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/WidgetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void centerWidget(QWidget* widget, QWidget* host) {
const auto& hostRect = host->geometry();
widget->move(hostRect.center() - widget->rect().center());
} else {
const auto screenGeometry = QGuiApplication::screens()[0]->geometry();
const auto screenGeometry = QGuiApplication::screens().constFirst()->geometry();
const auto x = (screenGeometry.width() - widget->width()) / 2;
const auto y = (screenGeometry.height() - widget->height()) / 2;
widget->move(x, y);
Expand Down

0 comments on commit 611c831

Please sign in to comment.