diff --git a/CMakeLists.txt b/CMakeLists.txt index a63b047..5044d66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,6 +344,11 @@ if(BUILD_TESTING) endif() add_test(NAME test_controller COMMAND test_controller) + add_executable(grab_tabs tests/grab_tabs.cpp + src/themes/theme.cpp src/themes/thememanager.cpp src/resources.qrc) + target_include_directories(grab_tabs PRIVATE src) + target_link_libraries(grab_tabs PRIVATE ${QT}::Widgets ${QT}::Svg ${QT}::Test) + add_executable(test_validation tests/test_validation.cpp src/editor.cpp src/compose.cpp src/format.cpp src/addressparser.cpp src/controller.cpp src/processpicker.cpp src/processpicker.ui src/providerregistry.cpp diff --git a/src/dock_tab_buttons.h b/src/dock_tab_buttons.h new file mode 100644 index 0000000..7709029 --- /dev/null +++ b/src/dock_tab_buttons.h @@ -0,0 +1,65 @@ +#pragma once + +#include +#include +#include +#include + +// Dock tab button widget (pin + close) +// Placed on the right side of each dock tab via QTabBar::setTabButton. +class DockTabButtons : public QWidget { + Q_OBJECT +public: + QToolButton* pinBtn; + QToolButton* closeBtn; + bool pinned = false; + + explicit DockTabButtons(QWidget* parent = nullptr) : QWidget(parent) { + auto* hl = new QHBoxLayout(this); + hl->setContentsMargins(0, 0, 0, 0); + hl->setSpacing(0); + + pinBtn = new QToolButton(this); + pinBtn->setAutoRaise(true); + pinBtn->setCursor(Qt::PointingHandCursor); + pinBtn->setFixedSize(16, 16); + pinBtn->setToolTip("Pin tab"); + updatePinIcon(); + hl->addWidget(pinBtn); + + closeBtn = new QToolButton(this); + closeBtn->setAutoRaise(true); + closeBtn->setCursor(Qt::PointingHandCursor); + closeBtn->setFixedSize(16, 16); + closeBtn->setToolTip("Close tab"); + closeBtn->setIcon(QIcon(":/vsicons/close.svg")); + closeBtn->setIconSize(QSize(12, 12)); + hl->addWidget(closeBtn); + + connect(pinBtn, &QToolButton::clicked, this, [this]() { + pinned = !pinned; + updatePinIcon(); + emit pinToggled(pinned); + }); + } + + void applyTheme(const QColor& hover) { + QString style = QStringLiteral( + "QToolButton { border: none; padding: 1px; border-radius: 0px; }" + "QToolButton:hover { background: %1; }").arg(hover.name()); + pinBtn->setStyleSheet(style); + closeBtn->setStyleSheet(style); + } + + void setPinned(bool p) { pinned = p; updatePinIcon(); emit pinToggled(pinned); } + +signals: + void pinToggled(bool pinned); + +private: + void updatePinIcon() { + pinBtn->setIcon(QIcon(pinned ? ":/vsicons/pinned.svg" : ":/vsicons/pin.svg")); + pinBtn->setIconSize(QSize(12, 12)); + pinBtn->setToolTip(pinned ? "Unpin tab" : "Pin tab"); + } +}; diff --git a/src/main.cpp b/src/main.cpp index 45fd3eb..9e51d11 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -480,64 +480,7 @@ public: } }; -// ── Dock tab button widget (pin + close) ── -// Placed on the right side of each dock tab via QTabBar::setTabButton. -class DockTabButtons : public QWidget { - Q_OBJECT -public: - QToolButton* pinBtn; - QToolButton* closeBtn; - bool pinned = false; - - explicit DockTabButtons(QWidget* parent = nullptr) : QWidget(parent) { - auto* hl = new QHBoxLayout(this); - hl->setContentsMargins(0, 0, 0, 0); - hl->setSpacing(0); - - pinBtn = new QToolButton(this); - pinBtn->setAutoRaise(true); - pinBtn->setCursor(Qt::PointingHandCursor); - pinBtn->setFixedSize(16, 16); - pinBtn->setToolTip("Pin tab"); - updatePinIcon(); - hl->addWidget(pinBtn); - - closeBtn = new QToolButton(this); - closeBtn->setAutoRaise(true); - closeBtn->setCursor(Qt::PointingHandCursor); - closeBtn->setFixedSize(16, 16); - closeBtn->setToolTip("Close tab"); - closeBtn->setIcon(QIcon(":/vsicons/close.svg")); - closeBtn->setIconSize(QSize(12, 12)); - hl->addWidget(closeBtn); - - connect(pinBtn, &QToolButton::clicked, this, [this]() { - pinned = !pinned; - updatePinIcon(); - emit pinToggled(pinned); - }); - } - - void applyTheme(const QColor& hover) { - QString style = QStringLiteral( - "QToolButton { border: none; padding: 1px; border-radius: 0px; }" - "QToolButton:hover { background: %1; }").arg(hover.name()); - pinBtn->setStyleSheet(style); - closeBtn->setStyleSheet(style); - } - - void setPinned(bool p) { pinned = p; updatePinIcon(); emit pinToggled(pinned); } - -signals: - void pinToggled(bool pinned); - -private: - void updatePinIcon() { - pinBtn->setIcon(QIcon(pinned ? ":/vsicons/pinned.svg" : ":/vsicons/pin.svg")); - pinBtn->setIconSize(QSize(12, 12)); - pinBtn->setToolTip(pinned ? "Unpin tab" : "Pin tab"); - } -}; +#include "dock_tab_buttons.h" static void applyGlobalTheme(const rcx::Theme& theme) { QPalette pal; @@ -4049,5 +3992,3 @@ int main(int argc, char* argv[]) { return app.exec(); } -// DockTabButtons has Q_OBJECT in main.cpp — need the moc include -#include "main.moc" diff --git a/src/titlebar.cpp b/src/titlebar.cpp index d390af6..24210ff 100644 --- a/src/titlebar.cpp +++ b/src/titlebar.cpp @@ -1,5 +1,6 @@ #include "titlebar.h" #include "themes/thememanager.h" +#include #include #include #include @@ -76,15 +77,35 @@ void TitleBarWidget::applyTheme(const Theme& theme) { QStringLiteral("QLabel { color: %1; font-size: 12px; font-weight: bold; }") .arg(theme.text.name())); - // Menu bar palette — hover/bg handled by MenuBarStyle QProxyStyle. - // Set Window + Button to background so Fusion never paints a foreign color. + // Menu bar palette — all roles used by MenuBarStyle, so live theme + // switches don't rely on app-palette inheritance (which can stall + // once setPalette has been called on a widget). { QPalette mbPal = m_menuBar->palette(); mbPal.setColor(QPalette::Window, theme.background); mbPal.setColor(QPalette::Button, theme.background); mbPal.setColor(QPalette::ButtonText, theme.text); + mbPal.setColor(QPalette::Text, theme.text); + mbPal.setColor(QPalette::Highlight, theme.selected); + mbPal.setColor(QPalette::Link, theme.indHoverSpan); + mbPal.setColor(QPalette::AlternateBase, theme.surface); + mbPal.setColor(QPalette::Dark, theme.border); + mbPal.setColor(QPalette::Mid, theme.hover); m_menuBar->setPalette(mbPal); m_menuBar->setAutoFillBackground(false); + + // Propagate to existing QMenu children so dropdown popups update too + for (auto* menu : m_menuBar->findChildren()) { + QPalette mp = menu->palette(); + mp.setColor(QPalette::Window, theme.background); + mp.setColor(QPalette::WindowText, theme.text); + mp.setColor(QPalette::Text, theme.text); + mp.setColor(QPalette::Highlight, theme.selected); + mp.setColor(QPalette::Link, theme.indHoverSpan); + mp.setColor(QPalette::AlternateBase, theme.surface); + mp.setColor(QPalette::Dark, theme.border); + menu->setPalette(mp); + } } // Chrome buttons