fix: move DockTabButtons to header for MSVC automoc compatibility

automoc doesn't generate main.moc on MSVC, breaking the build.
Move DockTabButtons (which needs Q_OBJECT) to its own header so
automoc handles it as moc_dock_tab_buttons.cpp instead.
This commit is contained in:
IChooseYou
2026-03-06 06:14:59 -07:00
committed by IChooseYou
parent f981fe456d
commit 8d92957837
4 changed files with 94 additions and 62 deletions

View File

@@ -344,6 +344,11 @@ if(BUILD_TESTING)
endif() endif()
add_test(NAME test_controller COMMAND test_controller) 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 add_executable(test_validation tests/test_validation.cpp
src/editor.cpp src/compose.cpp src/format.cpp src/addressparser.cpp src/controller.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 src/processpicker.cpp src/processpicker.ui src/providerregistry.cpp

65
src/dock_tab_buttons.h Normal file
View File

@@ -0,0 +1,65 @@
#pragma once
#include <QWidget>
#include <QToolButton>
#include <QHBoxLayout>
#include <QIcon>
// 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");
}
};

View File

@@ -480,64 +480,7 @@ public:
} }
}; };
// ── Dock tab button widget (pin + close) ── #include "dock_tab_buttons.h"
// 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");
}
};
static void applyGlobalTheme(const rcx::Theme& theme) { static void applyGlobalTheme(const rcx::Theme& theme) {
QPalette pal; QPalette pal;
@@ -4049,5 +3992,3 @@ int main(int argc, char* argv[]) {
return app.exec(); return app.exec();
} }
// DockTabButtons has Q_OBJECT in main.cpp — need the moc include
#include "main.moc"

View File

@@ -1,5 +1,6 @@
#include "titlebar.h" #include "titlebar.h"
#include "themes/thememanager.h" #include "themes/thememanager.h"
#include <QMenu>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPainter> #include <QPainter>
#include <QStyle> #include <QStyle>
@@ -76,15 +77,35 @@ void TitleBarWidget::applyTheme(const Theme& theme) {
QStringLiteral("QLabel { color: %1; font-size: 12px; font-weight: bold; }") QStringLiteral("QLabel { color: %1; font-size: 12px; font-weight: bold; }")
.arg(theme.text.name())); .arg(theme.text.name()));
// Menu bar palette — hover/bg handled by MenuBarStyle QProxyStyle. // Menu bar palette — all roles used by MenuBarStyle, so live theme
// Set Window + Button to background so Fusion never paints a foreign color. // switches don't rely on app-palette inheritance (which can stall
// once setPalette has been called on a widget).
{ {
QPalette mbPal = m_menuBar->palette(); QPalette mbPal = m_menuBar->palette();
mbPal.setColor(QPalette::Window, theme.background); mbPal.setColor(QPalette::Window, theme.background);
mbPal.setColor(QPalette::Button, theme.background); mbPal.setColor(QPalette::Button, theme.background);
mbPal.setColor(QPalette::ButtonText, theme.text); 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->setPalette(mbPal);
m_menuBar->setAutoFillBackground(false); m_menuBar->setAutoFillBackground(false);
// Propagate to existing QMenu children so dropdown popups update too
for (auto* menu : m_menuBar->findChildren<QMenu*>()) {
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 // Chrome buttons