From d2645b03f8106ec054259bfb641c4fc0936c7c48 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 9 Jun 2019 17:13:06 +0300 Subject: [PATCH] Added Preferences item in menu bar for OS X. --- src/widgets/Window.cpp | 17 +++++++++++++++++ src/widgets/Window.hpp | 1 + 2 files changed, 18 insertions(+) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index fb5551522..11741e015 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -29,6 +29,7 @@ #include #include +#include #include namespace chatterino { @@ -43,6 +44,10 @@ Window::Window(WindowType type) this->addShortcuts(); this->addLayout(); +#ifdef Q_OS_MACOS + this->addMenuBar(); +#endif + this->signalHolder_.managedConnect( getApp()->accounts->twitch.currentUserChanged, [this] { this->onAccountSelected(); }); @@ -336,6 +341,18 @@ void Window::addShortcuts() }); } +void Window::addMenuBar() +{ + QMenuBar *mainMenu = new QMenuBar(); + mainMenu->setNativeMenuBar(true); + + QMenu *menu = new QMenu(QString()); + mainMenu->addMenu(menu); + QAction *prefs = menu->addAction(QString()); + prefs->setMenuRole(QAction::PreferencesRole); + connect(prefs, &QAction::triggered, this, [] { SettingsDialog::showDialog(); }); +} + #define UGLYMACROHACK1(s) #s #define UGLYMACROHACK(s) UGLYMACROHACK1(s) diff --git a/src/widgets/Window.hpp b/src/widgets/Window.hpp index e27bdfae9..d2c1c1922 100644 --- a/src/widgets/Window.hpp +++ b/src/widgets/Window.hpp @@ -38,6 +38,7 @@ private: void addShortcuts(); void addLayout(); void onAccountSelected(); + void addMenuBar(); WindowType type_;