summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Matyushin <[email protected]>2015-07-12 02:57:22 +0300
committerVyacheslav Matyushin <[email protected]>2015-07-12 02:57:22 +0300
commit03d4462c79e4481d32466bff6b457751659ca79a (patch)
treefe62a22a20b1c22483e5c7c92ad4ca29c137f20e
parent3d929ec183cfd8b44711d3b5c0eaa3238ccc2f0c (diff)
Hide category submenus if they are empty.
-rw-r--r--src/mainWindow.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp
index 649ea98..1cd4628 100644
--- a/src/mainWindow.cpp
+++ b/src/mainWindow.cpp
@@ -841,6 +841,8 @@ void MainWindow::setupLogModeMenu()
// Sets up the Logs menu
QList<QAction *> menuLogModeActions;
+ int serviceItems = 0;
+ int othersItems = 0;
KActionMenu *servicesAction = new KActionMenu(
QIcon::fromTheme(QLatin1String("preferences-system-session-services")), i18n("Services"), this);
@@ -848,16 +850,22 @@ void MainWindow::setupLogModeMenu()
= new KActionMenu(QIcon::fromTheme(QLatin1String("preferences-other")), i18n("Others"), this);
foreach (LogModeAction *logModeAction, Globals::instance().logModeActions()) {
- if (logModeAction->category() == LogModeAction::RootCategory)
+ if (logModeAction->category() == LogModeAction::RootCategory) {
menuLogModeActions.append(logModeAction->actionMenu());
- else if (logModeAction->category() == LogModeAction::ServicesCategory)
+ } else if (logModeAction->category() == LogModeAction::ServicesCategory) {
+ serviceItems++;
servicesAction->addAction(logModeAction->actionMenu());
- else if (logModeAction->category() == LogModeAction::OthersCategory)
+ } else if (logModeAction->category() == LogModeAction::OthersCategory) {
othersAction->addAction(logModeAction->actionMenu());
+ othersItems++;
+ }
}
- menuLogModeActions.append(servicesAction);
- menuLogModeActions.append(othersAction);
+ if (serviceItems)
+ menuLogModeActions.append(servicesAction);
+
+ if (othersItems)
+ menuLogModeActions.append(othersAction);
// Menu dynamic action list
unplugActionList(QLatin1String("log_mode_list"));