ToolBarManager::ToolBarManager(QMainWindow *configureableMainWindow, QWidget *parent, QMenu *toolBarMenu, const QDesignerActions *actions, const QList<QToolBar *> &toolbars, const QList<QDesignerToolWindow*> &toolWindows) : QObject(parent), m_configureableMainWindow(configureableMainWindow), m_parent(parent), m_toolBarMenu(toolBarMenu), m_manager(new QtToolBarManager(this)), m_configureAction(new QAction(tr("Configure Toolbars..."), this)), m_toolbars(toolbars) { m_configureAction->setMenuRole(QAction::NoRole); m_configureAction->setObjectName(QLatin1String("__qt_configure_tool_bars_action")); connect(m_configureAction, SIGNAL(triggered()), this, SLOT(configureToolBars())); m_manager->setMainWindow(configureableMainWindow); foreach(QToolBar *tb, m_toolbars) { const QString title = tb->windowTitle(); m_manager->addToolBar(tb, title); addActionsToToolBarManager(tb->actions(), title, m_manager); } addActionsToToolBarManager(actions->windowActions()->actions(), tr("Window"), m_manager); addActionsToToolBarManager(actions->helpActions()->actions(), tr("Help"), m_manager); // Filter out the device profile preview actions which have int data(). ActionList previewActions = actions->styleActions()->actions(); ActionList::iterator it = previewActions.begin(); for ( ; (*it)->isSeparator() || (*it)->data().type() == QVariant::Int; ++it) ; previewActions.erase(previewActions.begin(), it); addActionsToToolBarManager(previewActions, tr("Style"), m_manager); const QString dockTitle = tr("Dock views"); foreach (QDesignerToolWindow *tw, toolWindows) { if (QAction *action = tw->action()) m_manager->addAction(action, dockTitle); } m_manager->addAction(m_configureAction, tr("Toolbars")); updateToolBarMenu(); }
void Kiten::setupActions() { /* Add the basic quit/print/prefs actions, use the gui factory for keybindings */ (void) KStandardAction::quit( this, SLOT(close()), actionCollection() ); //Why the heck is KSA:print adding it's own toolbar!? // (void) KStandardAction::print(this, SLOT(print()), actionCollection()); (void) KStandardAction::preferences( this, SLOT(slotConfigure()), actionCollection() ); //old style cast seems needed here, (const QObject*) KStandardAction::keyBindings( (const QObject*)guiFactory() , SLOT(configureShortcuts()) , actionCollection() ); /* Setup the Go-to-learn-mode actions */ /* TODO: put back when Dictionary Editor is reorganised */ // (void) new KAction( i18n( "&Dictionary Editor..." ) // , "document-properties" // , 0 // , this // , SLOT(createEEdit()) // , actionCollection() // , "dict_editor"); QAction *radselect = actionCollection()->addAction( "radselect" ); radselect->setText( i18n( "Radical Selector" ) ); // radselect->setIcon( "edit-find" ); actionCollection()->setDefaultShortcut(radselect, Qt::CTRL+Qt::Key_R ); connect(radselect, &QAction::triggered, this, &Kiten::radicalSearch); QAction *kanjibrowser = actionCollection()->addAction( "kanjibrowser" ); kanjibrowser->setText( i18n( "Kanji Browser" ) ); actionCollection()->setDefaultShortcut(kanjibrowser, Qt::CTRL+Qt::Key_K ); connect(kanjibrowser, &QAction::triggered, this, &Kiten::kanjiBrowserSearch); /* Setup the Search Actions and our custom Edit Box */ _inputManager = new SearchStringInput( this ); QAction *searchButton = actionCollection()->addAction( "search" ); searchButton->setText( i18n( "S&earch" ) ); // Set the search button to search connect(searchButton, &QAction::triggered, this, &Kiten::searchFromEdit); searchButton->setIcon( KStandardGuiItem::find().icon() ); // That's not it, that's "find as you type"... // connect( Edit, SIGNAL(completion(QString)), // this, SLOT(searchFromEdit()) ); /* Setup our widgets that handle preferences */ // deinfCB = new KToggleAction( i18n( "&Deinflect Verbs in Regular Search" ) // , 0 // , this // , SLOT(kanjiDictChange()) // , actionCollection() // , "deinf_toggle" ); _autoSearchToggle = actionCollection()->add<KToggleAction>( "autosearch_toggle" ); _autoSearchToggle->setText( i18n( "&Automatically Search Clipboard Selections" ) ); _irAction = actionCollection()->add<QAction>( "search_in_results" ); _irAction->setText( i18n( "Search &in Results" ) ); connect(_irAction, &QAction::triggered, this, &Kiten::searchInResults); QAction *actionFocusResultsView; actionFocusResultsView = actionCollection()->addAction( "focusresultview" , this , SLOT(focusResultsView()) ); actionCollection()->setDefaultShortcut(actionFocusResultsView, Qt::Key_Escape ); actionFocusResultsView->setText( i18n( "Focus result view" ) ); (void) KStandardAction::configureToolbars( this , SLOT(configureToolBars()) , actionCollection() ); //TODO: this should probably be a standard action /* globalShortcutsAction = actionCollection()->addAction( "options_configure_global_keybinding" ); globalShortcutsAction->setText( i18n( "Configure &Global Shortcuts..." ) ); connect( globalShortcutsAction, SIGNAL(triggered()), this, SLOT(configureGlobalKeys()) ); */ //TODO: implement this //_globalSearchAction = actionCollection()->add<KToggleAction>( "search_on_the_spot" ); //_globalSearchAction->setText( i18n( "On The Spo&t Search" ) ); //KAction *temp = qobject_cast<KAction*>( _globalSearchAction ); //KShortcut shrt( "Ctrl+Alt+S" ); //globalSearchAction->setGlobalShortcut(shrt); //FIXME: Why does this take ~50 seconds to return!? //connect(globalSearchAction, SIGNAL(triggered()), this, SLOT(searchOnTheSpot())); _backAction = KStandardAction::back( this, SLOT(back()), actionCollection() ); _forwardAction = KStandardAction::forward( this, SLOT(forward()), actionCollection() ); _backAction->setEnabled( false ); _forwardAction->setEnabled( false ); }