From ec22b01086299786fc3165523fc01bd2127870ea Mon Sep 17 00:00:00 2001 From: sagcan Date: Fri, 28 Aug 2020 20:17:31 +0200 Subject: [PATCH] Disable Plugins menu if no plugins are installed (#2318) (#2401) --- .../user-docs/menus/menu-bar/plugins-menu.rst | 2 +- src/core/MainWindow.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/source/user-docs/menus/menu-bar/plugins-menu.rst b/docs/source/user-docs/menus/menu-bar/plugins-menu.rst index 7a210a0a..8d0fcbd2 100644 --- a/docs/source/user-docs/menus/menu-bar/plugins-menu.rst +++ b/docs/source/user-docs/menus/menu-bar/plugins-menu.rst @@ -5,4 +5,4 @@ Plugins Sub-Menu ---------------------------------------- **Description:** This menu will contain the windows and views created by the loaded plugins. By default, this menu is empty unless plugins added their actions and items to the menu. -**Steps:** Windows -> Plugins \ No newline at end of file +**Steps:** Windows -> Plugins diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 75e071c4..6f2dcf2f 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -236,10 +236,23 @@ void MainWindow::initUI() connect(ui->actionDocumentation, &QAction::triggered, this, &MainWindow::documentationClicked); /* Setup plugins interfaces */ - for (auto &plugin : Plugins()->getPlugins()) { + const auto &plugins = Plugins()->getPlugins(); + for (auto &plugin : plugins) { plugin->setupInterface(this); } + // Check if plugins are loaded and display tooltips accordingly + ui->menuWindows->setToolTipsVisible(true); + if (plugins.empty()) { + ui->menuPlugins->menuAction()->setToolTip( + tr("No plugins are installed. Check the plugins section on Cutter documentation to learn more.")); + ui->menuPlugins->setEnabled(false); + } else if (ui->menuPlugins->isEmpty()) { + ui->menuPlugins->menuAction()->setToolTip( + tr("The installed plugins didn't add entries to this menu.")); + ui->menuPlugins->setEnabled(false); + } + #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) ui->actionGrouped_dock_dragging->setVisible(false); #endif