mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
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:
65
src/dock_tab_buttons.h
Normal file
65
src/dock_tab_buttons.h
Normal 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");
|
||||
}
|
||||
};
|
||||
61
src/main.cpp
61
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"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "titlebar.h"
|
||||
#include "themes/thememanager.h"
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
@@ -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<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
|
||||
|
||||
Reference in New Issue
Block a user