diff --git a/src/main.cpp b/src/main.cpp index 990252bf..295cc672 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) #ifdef Q_OS_WIN if(Config().getUseFramelessWindow()){ - auto titleBar = new WindowsTitleBar(&w, w.windowTitle(), w.menuBar()); + auto titleBar = new WindowsTitleBar(&w, w.menuBar()); // QObject::connect(&w, &ModManager::menuBarChanged, titleBar, &WindowsTitleBar::updateMenuBar); auto frameless = new FramelessWrapper(nullptr, &w, titleBar); QObject::connect(&w, &ModManager::closed, frameless, &FramelessWrapper::close); diff --git a/src/ui/framelesswrapper.cpp b/src/ui/framelesswrapper.cpp index a11f718c..84ad80af 100644 --- a/src/ui/framelesswrapper.cpp +++ b/src/ui/framelesswrapper.cpp @@ -18,7 +18,7 @@ #include "config.hpp" FramelessWrapper::FramelessWrapper(QWidget *parent, QWidget *widget, QMenuBar *menuBar) : - FramelessWrapper(parent, widget, new WindowsTitleBar(nullptr, widget->windowTitle(), menuBar)) + FramelessWrapper(parent, widget, new WindowsTitleBar(widget, menuBar)) { titleBar_->setParentWidget(this); } @@ -47,22 +47,6 @@ FramelessWrapper::FramelessWrapper(QWidget *parent, QWidget *widget, WindowsTitl #endif //Q_OS_WIN } -QWidget *FramelessWrapper::makeFrameless(QMainWindow *window) -{ - window->menuBar()->hide(); - auto wrapper = new FramelessWrapper(qobject_cast(window->parent()), - window, - window->menuBar()); - return wrapper; -} - -QWidget *FramelessWrapper::makeFrameless(QDialog *dialog) -{ - auto wrapper = new FramelessWrapper(qobject_cast(dialog->parent()), - dialog); - return wrapper; -} - void FramelessWrapper::updateBlur() { #ifdef Q_OS_WIN diff --git a/src/ui/framelesswrapper.h b/src/ui/framelesswrapper.h index 94ffb2e5..448122bd 100644 --- a/src/ui/framelesswrapper.h +++ b/src/ui/framelesswrapper.h @@ -14,8 +14,6 @@ class FramelessWrapper : public QMainWindow public: FramelessWrapper(QWidget *parent, QWidget *widget, QMenuBar *menuBar = nullptr); FramelessWrapper(QWidget *parent, QWidget *widget, WindowsTitleBar *titleBar); - static QWidget *makeFrameless(QMainWindow *window); - static QWidget *makeFrameless(QDialog *dialog); private slots: void updateBlur(); diff --git a/src/ui/modmanager.cpp b/src/ui/modmanager.cpp index f0d313f9..e221ddc2 100644 --- a/src/ui/modmanager.cpp +++ b/src/ui/modmanager.cpp @@ -320,7 +320,7 @@ void ModManager::on_action_About_Mod_Manager_triggered() auto dialog = new AboutDialog(this); #ifdef Q_OS_WIN if(config_.getUseFramelessWindow()){ - auto frameless = FramelessWrapper::makeFrameless(dialog); + auto frameless = new FramelessWrapper(this, dialog); frameless->show(); } else #endif diff --git a/src/ui/windowstitlebar.cpp b/src/ui/windowstitlebar.cpp index bef24b4a..ee265abe 100644 --- a/src/ui/windowstitlebar.cpp +++ b/src/ui/windowstitlebar.cpp @@ -13,19 +13,23 @@ #include #endif -WindowsTitleBar::WindowsTitleBar(QWidget *parent, const QString &title, QMenuBar *menuBar) : +WindowsTitleBar::WindowsTitleBar(QWidget *parent, QMenuBar *menuBar) : QWidget(parent), ui(new Ui::WindowsTitleBar), parentWidget_(parent), menuBar_(menuBar) { ui->setupUi(this); -// setMouseTracking(true); ui->closeButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_TitleBarCloseButton)); ui->maxButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_TitleBarMaxButton)); ui->minButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_TitleBarMinButton)); - ui->titleText->setText(title); updateMenuBar(); + auto updateWindowTitle = [=]{ + ui->titleText->setText(parent->windowTitle() + " - " + + qApp->applicationDisplayName()); + }; + updateWindowTitle(); + connect(parent, &QWidget::windowTitleChanged, this, updateWindowTitle); } WindowsTitleBar::~WindowsTitleBar() diff --git a/src/ui/windowstitlebar.h b/src/ui/windowstitlebar.h index 9492632d..e71e3749 100644 --- a/src/ui/windowstitlebar.h +++ b/src/ui/windowstitlebar.h @@ -14,19 +14,17 @@ class WindowsTitleBar : public QWidget Q_OBJECT public: - explicit WindowsTitleBar(QWidget *parent = nullptr, const QString &title = QString(), QMenuBar *menuBar = nullptr); + explicit WindowsTitleBar(QWidget *parent = nullptr, QMenuBar *menuBar = nullptr); ~WindowsTitleBar(); void setIconVisible(bool bl); void setParentWidget(QWidget *newParentWidget); - #ifdef Q_OS_WIN bool hitTest(QPoint pos, long *result); #endif //Q_OS_WIN public slots: void updateMenuBar(); - void setMaximumed(); void setNormal();