+ QList<QPair<QString, KAction *> > viewActions;
+ QPair <QString, KAction *> pair;
+ KAction *showTimeline = new KAction(i18n("Timeline"), this);
+ showTimeline->setCheckable(true);
+ showTimeline->setChecked(true);
+ connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
+
+ KMenu *viewMenu = static_cast<KMenu*>(factory()->container("dockwindows", this));
+ pair.first = showTimeline->text();
+ pair.second = showTimeline;
+ viewActions.append(pair);
+
+ QList <QDockWidget *> docks = findChildren<QDockWidget *>();
+ for (int i = 0; i < docks.count(); i++) {
+ QDockWidget* dock = docks.at(i);
+ QAction * a = dock->toggleViewAction();
+ if (!a) continue;
+ KAction* dockInformations = new KAction(this);
+ dockInformations->setText(a->text());
+ dockInformations->setCheckable(true);
+ dockInformations->setChecked(!dock->isHidden());
+ // HACK: since QActions cannot be used in KActionCategory to allow shortcut, we create a duplicate KAction of the dock QAction and link them
+ connect(a,SIGNAL(toggled(bool)), dockInformations, SLOT(setChecked(bool)));
+ connect(dockInformations,SIGNAL(triggered(bool)), a, SLOT(trigger()));
+ pair.first = dockInformations->text();
+ pair.second = dockInformations;
+ viewActions.append(pair);
+ }
+
+ // Sort dock view action by name
+ qSort(viewActions.begin(), viewActions.end(), sortByNames);
+ // Populate view menu
+ for (int i = 0; i < viewActions.count(); i++)
+ viewMenu->addAction(guiActions->addAction(viewActions.at(i).first, viewActions.at(i).second));
+