Skip to content

Commit

Permalink
macOS: Make tray use native menu optinally
Browse files Browse the repository at this point in the history
Can be enabled with:

Fixes #1652
  • Loading branch information
hluk committed May 10, 2021
1 parent 6c0f6ad commit afb0961
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/common/appconfig.h
Expand Up @@ -373,6 +373,11 @@ struct native_menu_bar : Config<bool> {
#endif
};

struct native_tray_menu : Config<bool> {
static QString name() { return "native_tray_menu"; }
static Value defaultValue() { return false; }
};

struct script_paste_delay_ms : Config<int> {
static QString name() { return "script_paste_delay_ms"; }
static Value defaultValue() { return 250; }
Expand Down
1 change: 1 addition & 0 deletions src/gui/configurationmanager.cpp
Expand Up @@ -340,6 +340,7 @@ void ConfigurationManager::initOptions()
bind<Config::filter_case_insensitive>();

bind<Config::native_menu_bar>();
bind<Config::native_tray_menu>();

bind<Config::script_paste_delay_ms>();

Expand Down
4 changes: 4 additions & 0 deletions src/gui/mainwindow.cpp
Expand Up @@ -2594,6 +2594,7 @@ void MainWindow::loadSettings(QSettings &settings, AppConfig &appConfig)
updateIcon();

menuBar()->setNativeMenuBar( appConfig.option<Config::native_menu_bar>() );
m_options.nativeTrayMenu = appConfig.option<Config::native_tray_menu>();

ui->searchBar->loadSettings();

Expand Down Expand Up @@ -2738,6 +2739,9 @@ void MainWindow::onTrayActionTriggered(const QVariantMap &data, bool omitPaste)

void MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason)
{
if (m_options.nativeTrayMenu)
return;

if ( reason == QSystemTrayIcon::MiddleClick
|| (m_options.trayMenuOpenOnLeftClick && reason == QSystemTrayIcon::Trigger) )
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/mainwindow.h
Expand Up @@ -86,6 +86,7 @@ struct MainWindowOptions {
bool trayCurrentTab = false;
QString trayTabName;
int trayItems = 5;
bool nativeTrayMenu = false;
bool trayImages = true;
bool trayMenuOpenOnLeftClick = false;
int transparency = 0;
Expand Down

0 comments on commit afb0961

Please sign in to comment.