Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15
kile
fix-user-editable-menus.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-user-editable-menus.patch of Package kile
From: Michel Ludwig <michel.ludwig@kdemail.net> Date: Sun, 27 Apr 2014 18:30:57 +0000 Subject: Use the KXMLGUIFactory::plugActionList mechanism to populate user-editable menus X-Git-Url: http://quickgit.kde.org/?p=kile.git&a=commitdiff&h=883e3e0b936d458f84962f204097655144a78374 --- Use the KXMLGUIFactory::plugActionList mechanism to populate user-editable menus Previously we constructed such menus ourselves and were using 'KXMLGUIFactory::refreshActionProperties()' to load shortcuts for the actions involved. However, due to a limitation in that method (in 'KXMLGUIClient::reloadXML()', more precisely) the XMLGUI for Kile was reset to an unmerged state (without the standard actions). By using 'plugActionList' we don't have to resort to 'refreshActionProperties' any more. BUG: 328712 --- --- a/src/kile.cpp +++ b/src/kile.cpp @@ -25,7 +25,6 @@ #include <KAboutApplicationDialog> #include <KAction> -#include <KActionMenu> #include <KApplication> #include <KConfigGroup> #include <KEditToolBar> @@ -96,6 +95,8 @@ #define KONSOLE_TAB 2 #define PREVIEW_TAB 3 +#define BIBTEX_SETTING 0 +#define BIBLATEX_SETTING 1 /* * Class Kile. */ @@ -126,8 +127,6 @@ m_jScriptManager = new KileScript::Manager(this, m_config.data(), actionCollection(), parent, "KileScript::Manager"); m_codeCompletionManager = new KileCodeCompletion::Manager(this, parent); - - m_mainWindow->setStandardToolBarMenuEnabled(true); m_singlemode = true; @@ -227,7 +226,7 @@ newCaption(); - m_help->setUserhelp(m_manager, m_userHelpActionMenu); // kile user help (dani) + m_help->setUserhelp(m_manager); // kile user help (dani) // process events for correctly displaying the splash screen kapp->processEvents(); @@ -248,7 +247,10 @@ createToolActions(); // this creates the actions for the tools and user tags, which is required before 'activePartGUI' is called createUserTagActions(); + m_mainWindow->setStandardToolBarMenuEnabled(true); m_mainWindow->setupGUI(KXmlGuiWindow::StatusBar | KXmlGuiWindow::Save, "kileui.rc"); + setXMLFile("kileui.rc"); + createShellGUI(true); m_partManager->setActivePart(NULL); // 'createGUI' is called in response to this restoreLastSelectedAction(); // don't call this inside 'setupTools' as it is not compatible with KParts switching! @@ -308,10 +310,7 @@ m_config->deleteGroup("Shortcuts"); } - m_mainWindow->setUpdatesEnabled(false); m_mainWindow->setAutoSaveSettings(QLatin1String("KileMainWindow"),true); - m_mainWindow->guiFactory()->refreshActionProperties(); - m_mainWindow->setUpdatesEnabled(true); } Kile::~Kile() @@ -797,25 +796,21 @@ KileStdActions::setupStdTags(this, this, actionCollection(), m_mainWindow); KileStdActions::setupMathTags(this, actionCollection()); - m_bibTagActionMenu = new KActionMenu(i18n("&Bibliography"), actionCollection()); - m_bibTagActionMenu->setDelayed(false); - actionCollection()->addAction("menu_bibliography", m_bibTagActionMenu); - - createAction(i18n("Clean"), "CleanBib", this, SLOT(cleanBib())); + createAction(i18n("Clean"), "CleanBib", this, SLOT(cleanBib())); m_bibTagSettings = new KSelectAction(i18n("&Settings"),actionCollection()); actionCollection()->addAction("settings_menu_bibliography", m_bibTagSettings); act = createAction(i18n("Settings for BibTeX"), "setting_bibtex", this, SLOT(rebuildBibliographyMenu())); act->setCheckable(true); + act->setData(QVariant(BIBTEX_SETTING)); m_bibTagSettings->addAction(act); act = createAction(i18n("Settings for Biblatex"), "setting_biblatex", this, SLOT(rebuildBibliographyMenu())); act->setCheckable(true); + act->setData(QVariant(BIBLATEX_SETTING)); m_bibTagSettings->addAction(act); m_bibTagSettings->setCurrentAction(action((QString("setting_") + KileConfig::bibliographyType()).toAscii())); - - rebuildBibliographyMenu(); createAction(i18n("Quick Start"), "wizard_document", "quickwizard", this, SLOT(quickDocument())); connect(docManager(), SIGNAL(startWizard()), this, SLOT(quickDocument())); @@ -892,45 +887,86 @@ createAction(i18n("&System Check..."), "settings_perform_check", this, SLOT(slotPerformCheck())); - m_userHelpActionMenu = new KActionMenu(i18n("User Help"), actionCollection()); - actionCollection()->addAction("help_userhelp", m_userHelpActionMenu); - m_pFullScreen = KStandardAction::fullScreen(this, SLOT(slotToggleFullScreen()), m_mainWindow, actionCollection()); } -void Kile::rebuildBibliographyMenu(){ - - KILE_DEBUG() << " current is " << m_bibTagSettings->currentText(); - - QString currentItem = m_bibTagSettings->currentText(); +void Kile::rebuildBibliographyMenu() +{ + KILE_DEBUG() << " current is " << m_bibTagSettings->currentText() << m_bibTagSettings->currentAction()->data(); + + QAction *cleanBibAction = action("CleanBib"); + QAction *bibliographySettingsAction = action("settings_menu_bibliography"); + + Q_FOREACH(QAction *act, m_bibliographyActions) { + if((act == cleanBibAction) || (act == bibliographySettingsAction)) { + continue; + } + act->deleteLater(); + } + m_bibliographyActions.clear(); + QString name; - if( currentItem == i18n("BibTeX") ){ // avoid writing i18n'ed strings to config file + if(m_bibTagSettings->currentAction()->data().toInt() == BIBLATEX_SETTING) { + name = QString("biblatex"); + } + else { name = QString("bibtex"); } - else if ( currentItem == i18n("Biblatex") ){ - name = QString("biblatex"); - } - else { - KILE_DEBUG() << "wrong currentItem in bibliography settings menu"; - name = QString("bibtex"); - } KileConfig::setBibliographyType(name); - m_bibTagActionMenu->menu()->clear(); - - KileStdActions::setupBibTags(this, actionCollection(),m_bibTagActionMenu); - m_bibTagActionMenu->addSeparator(); - m_bibTagActionMenu->addAction(action("CleanBib")); - m_bibTagActionMenu->addSeparator(); - m_bibTagActionMenu->addAction(action("settings_menu_bibliography")); -} - -QAction* Kile::createToolAction(QString toolName) -{ - return createAction(toolName, "tool_" + toolName, - KileTool::iconFor(toolName, m_config.data()), m_signalMapper, SLOT(map())); + + m_bibliographyActions = KileStdActions::setupBibTags(this, actionCollection()); + + QList<QAction*> plugList(m_bibliographyActions); + plugList.append(KileStdActions::createSeparatorAction(actionCollection())); + plugList.append(cleanBibAction); + plugList.append(KileStdActions::createSeparatorAction(actionCollection())); + plugList.append(bibliographySettingsAction); + + unplugActionList("bibliography_actionlist"); + plugActionList("bibliography_actionlist", plugList); +} + +KAction* Kile::createToolAction(QString toolName) +{ + KAction *act = createAction(toolName, "tool_" + toolName, + KileTool::iconFor(toolName, m_config.data()), m_signalMapper, SLOT(map())); + if(toolName == "QuickBuild") { + act->setShortcut(KShortcut("Alt+1"), KAction::DefaultShortcut); + } + else if(toolName == "LaTeX") { + act->setShortcut(KShortcut("Alt+2"), KAction::DefaultShortcut); + } + else if(toolName == "ViewDVI") { + act->setShortcut(KShortcut("Alt+3"), KAction::DefaultShortcut); + } + else if(toolName == "DVItoPS") { + act->setShortcut(KShortcut("Alt+4"), KAction::DefaultShortcut); + } + else if(toolName == "ViewPS") { + act->setShortcut(KShortcut("Alt+5"), KAction::DefaultShortcut); + } + else if(toolName == "PDFLaTeX") { + act->setShortcut(KShortcut("Alt+6"), KAction::DefaultShortcut); + } + else if(toolName == "ViewPDF") { + act->setShortcut(KShortcut("Alt+7"), KAction::DefaultShortcut); + } + else if(toolName == "PStoPDF") { + act->setShortcut(KShortcut("Alt+8"), KAction::DefaultShortcut); + } + else if(toolName == "DVItoPDF") { + act->setShortcut(KShortcut("Alt+9"), KAction::DefaultShortcut); + } + else if(toolName == "BibTeX") { + act->setShortcut(KShortcut("Alt+-"), KAction::DefaultShortcut); + } + else if(toolName == "MakeIndex") { + act->setShortcut(KShortcut("Alt+="), KAction::DefaultShortcut); + } + return act; } void Kile::createToolActions() @@ -951,17 +987,6 @@ { KILE_DEBUG() << "==Kile::setupTools()===================" << endl; - if(!m_buildMenuCompile || !m_buildMenuConvert || !m_buildMenuTopLevel || !m_buildMenuQuickPreview || !m_buildMenuViewer || !m_buildMenuOther){ - KILE_DEBUG() << "BUG, menu pointers are NULL" - << (m_buildMenuCompile == NULL) - << (m_buildMenuConvert == NULL) - << (m_buildMenuTopLevel == NULL) - << (m_buildMenuQuickPreview == NULL) - << (m_buildMenuViewer == NULL) - << (m_buildMenuOther == NULL); - return; - } - QStringList tools = KileTool::toolList(m_config.data()); QString toolMenu, grp; QList<QAction*> *pl; @@ -972,16 +997,6 @@ m_viewActions->saveCurrentAction(); m_convertActions->saveCurrentAction(); m_quickActions->saveCurrentAction(); - - // do plugActionList by hand ... - foreach(act, m_listQuickActions){ - m_buildMenuTopLevel->removeAction(act); - } - - m_buildMenuCompile->clear(); - m_buildMenuConvert->clear(); - m_buildMenuViewer->clear(); - m_buildMenuOther->clear(); m_compilerActions->removeAllActions(); m_viewActions->removeAllActions(); @@ -1047,11 +1062,20 @@ cleanUpActionList(m_listQuickActions, tools); cleanUpActionList(m_listOtherActions, tools); - m_buildMenuTopLevel->insertActions(m_buildMenuQuickPreview->menuAction(),m_listQuickActions); - m_buildMenuCompile->addActions(m_listCompilerActions); - m_buildMenuConvert->addActions(m_listConverterActions); - m_buildMenuViewer->addActions(m_listViewerActions); - m_buildMenuOther->addActions(m_listOtherActions); + unplugActionList("tools_quick_actionlist"); + plugActionList("tools_quick_actionlist", m_listQuickActions); + + unplugActionList("tools_compile_actionlist"); + plugActionList("tools_compile_actionlist", m_listCompilerActions); + + unplugActionList("tools_convert_actionlist"); + plugActionList("tools_convert_actionlist", m_listConverterActions); + + unplugActionList("tools_view_actionlist"); + plugActionList("tools_view_actionlist", m_listViewerActions); + + unplugActionList("tools_other_actionlist"); + plugActionList("tools_other_actionlist", m_listOtherActions); m_compilerActions->restoreCurrentAction(); m_viewActions->restoreCurrentAction(); @@ -1162,6 +1186,10 @@ } m_listUserTagsActions.clear(); + if(!actionCollection()->action("edit_user_tags")) { + createAction(i18n("Edit User Tags..."), "edit_user_tags", this, SLOT(editUserMenu())); + } + QString name, number; KILE_DEBUG() << "# user tags is " << m_listUserTags.size(); @@ -1171,32 +1199,20 @@ KileAction::Tag *tag = new KileAction::Tag(name, QString(), KShortcut(), this, SLOT(insertTag(const KileAction::TagData &)), actionCollection(), "tag_user_" + number, m_listUserTags[i]); + if(i < 10) { + const QString shortcutNumber = (i == 9 ? "0" : QString::number(i + 1)); + tag->setShortcut(KShortcut("Ctrl+Shift+" + shortcutNumber), KAction::DefaultShortcut); + } m_listUserTagsActions.append(tag); } } void Kile::updateUserTagMenu() { - if(!m_userTagMenu){ - KILE_DEBUG() << "no menu for userTags"; - return; - } - - m_userTagMenu->clear(); - QAction *act = createAction(i18n("Edit User Tags..."), "EditUserMenu", this, SLOT(editUserMenu())); - - m_userTagMenu->addAction(act); - m_userTagMenu->addSeparator(); - - QString name, number; KILE_DEBUG() << "# user tags is " << m_listUserTags.size(); - for(QList<QAction*>::iterator i = m_listUserTagsActions.begin(); i != m_listUserTagsActions.end(); ++i) { - m_userTagMenu->addAction(*i); - } - m_mainWindow->setUpdatesEnabled(false); - m_mainWindow->guiFactory()->refreshActionProperties(); - m_mainWindow->setUpdatesEnabled(true); + unplugActionList("user_tags_actionlist"); + plugActionList("user_tags_actionlist", m_listUserTagsActions); } void Kile::restoreFilesAndProjects(bool allowRestore) @@ -1742,12 +1758,11 @@ connect(m_paPrint, SIGNAL(triggered()), ext, SLOT(print())); toolBar("mainToolBar")->addAction(m_paPrint); //plug this action into its default location m_paPrint->setEnabled(true); + m_paPrint->setVisible(true); } else { - if (m_paPrint->associatedWidgets().contains(toolBar("mainToolBar"))) { - toolBar("mainToolBar")->removeAction(m_paPrint); - } m_paPrint->setEnabled(false); + m_paPrint->setVisible(false); } createGUI(part); @@ -1762,16 +1777,10 @@ void Kile::updateUserDefinedMenus() { - m_buildMenuTopLevel = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_build", m_mainWindow)); - m_buildMenuCompile = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_compile", m_mainWindow)); - m_buildMenuConvert = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_convert", m_mainWindow)); - m_buildMenuViewer = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_viewer", m_mainWindow)); - m_buildMenuOther = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_other", m_mainWindow)); - m_buildMenuQuickPreview = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("quickpreview", m_mainWindow)); - m_userTagMenu = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_user_tags", m_mainWindow)); - updateUserTagMenu(); setupTools(); + rebuildBibliographyMenu(); + m_help->rebuildUserHelp(); } void Kile::updateGUI(const QString &wantState) @@ -1843,16 +1852,22 @@ << m_listConverterActions << m_listViewerActions << m_listOtherActions; + // enable or disable list actions for(QList<QAction*>::iterator i = actionList.begin(); i != actionList.end(); ++i) { (*i)->setEnabled(enable); } // enable or disable bibliography menu entries - actionList = m_bibTagActionMenu->menu()->actions(); - for(QList<QAction*>::iterator it = actionList.begin(); it != actionList.end(); ++it) { - (*it)->setEnabled(enable); - } + { + QMenu *menu = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_bibliography", m_mainWindow)); + if(menu) { + Q_FOREACH(QAction *act, menu->actions()) { + act->setEnabled(enable); + } + } + } + QStringList menuList; menuList << "file" << "edit" << "menu_build" << "menu_project" << "menu_latex" << "wizard" << "tools"; for(QStringList::iterator it = menuList.begin(); it != menuList.end(); ++it) { @@ -1889,7 +1904,7 @@ << "menu_preamble" << "menu_lists" << "menu_sectioning" << "references" << "menu_environment" << "menu_listenv" << "menu_tabularenv" << "menu_floatenv" << "menu_code" << "menu_math" << "menu_mathenv" << "menu_mathamsenv" - << "menu_bibliography" << "menu_fontstyles" << "menu_spacing" + << "menu_fontstyles" << "menu_spacing" ; actionlist @@ -1943,7 +1958,6 @@ << "tag_env_matrix" << "tag_env_pmatrix" << "tag_env_vmatrix" << "tag_env_VVmatrix" << "tag_env_bmatrix" << "tag_env_BBmatrix" // bibliography stuff - << "menu_bibliography" << "setting_bibtex" << "setting_biblatex" << "tag_textit" << "tag_textsl" << "tag_textbf" << "tag_underline" << "tag_texttt" << "tag_textsc" << "tag_emph" << "tag_strong" @@ -1991,8 +2005,8 @@ << "file_export_latin4" << "file_export_latin5" << "file_export_latin9" << "file_export_cp1250" << "file_export_cp1252" - << "EditUserMenu" - ; + << "edit_user_tags"; + setMenuItems(projectlist,m_dictMenuProject); setMenuItems(filelist,m_dictMenuFile); setMenuItems(actionlist,m_dictMenuAction); --- a/src/kile.h +++ b/src/kile.h @@ -1,7 +1,7 @@ /*************************************************************************************** begin : sam jui 13 09:50:06 CEST 2002 copyright : (C) 2003 by Jeroen Wijnhout (wijnhout@science.uva.nl) - 2007-2012 by Michel Ludwig (michel.ludwig@kdemail.net) + 2007-2014 by Michel Ludwig (michel.ludwig@kdemail.net) (C) 2009 Thomas Braun (thomas.braun@virtuell-zuhause.de) ***************************************************************************************/ @@ -65,7 +65,6 @@ class KToolBar; class KAction; -class KActionMenu; class KRecentFilesAction; class KToggleFullScreenAction; class KToggleToolBarAction; @@ -143,13 +142,11 @@ QMap<QString,bool> m_dictMenuAction, m_dictMenuFile, m_dictMenuProject; KToolBar *m_toolsToolBar; - KActionMenu *m_userHelpActionMenu; KSelectAction *m_bibTagSettings; ToolbarSelectAction *m_compilerActions, *m_viewActions, *m_convertActions, *m_quickActions; QList<KileAction::TagData> m_listUserTags; QList<userItem> m_listUserTools; - QList<QAction*> m_listUserTagsActions, m_listQuickActions, m_listCompilerActions, m_listConverterActions, m_listViewerActions, m_listOtherActions; - KActionMenu *m_bibTagActionMenu; + QList<QAction*> m_bibliographyActions, m_listUserTagsActions, m_listQuickActions, m_listCompilerActions, m_listConverterActions, m_listViewerActions, m_listOtherActions; KAction *m_paStop, *m_paPrint; KToggleAction *ModeAction, *WatchFileAction; KToggleAction *m_actionMessageView; @@ -167,7 +164,6 @@ KileWidget::SymbolView *m_symbolViewMFUS, *m_symbolViewRelation, *m_symbolViewArrows, *m_symbolViewMiscMath, *m_symbolViewMiscText, *m_symbolViewOperators, *m_symbolViewUser, *m_symbolViewDelimiters, *m_symbolViewGreek, *m_symbolViewSpecial, *m_symbolViewCyrillic; KileWidget::CommandView *m_commandView; KToolBar *m_latexOutputErrorToolBar; - QMenu *m_buildMenuTopLevel, *m_buildMenuCompile, *m_buildMenuConvert, *m_buildMenuViewer, *m_buildMenuOther, *m_buildMenuQuickPreview, *m_userTagMenu; //parts KParts::PartManager *m_partManager; @@ -205,7 +201,7 @@ void setupGraphicTools(); void setupPreviewTools(); void setupActions(); - QAction* createToolAction(QString toolName); + KAction* createToolAction(QString toolName); void createToolActions(); void setupTools(); void updateUserDefinedMenus(); --- a/src/kileactions.h +++ b/src/kileactions.h @@ -19,10 +19,10 @@ #include <KAction> #include <KActionCollection> -#include <KActionMenu> #include <KSelectAction> #include <KDialog> #include <KLineEdit> +#include <KMenu> class QCheckBox; class QLineEdit; --- a/src/kilehelp.cpp +++ b/src/kilehelp.cpp @@ -42,7 +42,7 @@ namespace KileHelp { - Help::Help(KileDocument::EditorExtension *edit, QWidget *mainWindow) : m_mainWindow(mainWindow), m_edit(edit), m_userhelp(NULL) + Help::Help(KileDocument::EditorExtension *edit, KXmlGuiWindow *mainWindow) : m_mainWindow(mainWindow), m_edit(edit), m_userhelp(NULL) { readHelpList("latex-kile.lst", m_dictHelpKile); initTexDocumentation(); @@ -98,16 +98,23 @@ ////////////////////// set parameter/initialize user help ////////////////////// - void Help::setUserhelp(KileTool::Manager *manager, KActionMenu *userHelpActionMenu) + void Help::setUserhelp(KileTool::Manager *manager) { m_manager = manager; - m_userhelp = new UserHelp(manager, userHelpActionMenu, m_mainWindow); + m_userhelp = new UserHelp(manager, m_mainWindow); } void Help::enableUserhelpEntries(bool state) { if(m_userhelp) { m_userhelp->enableUserHelpEntries(state); + } + } + + void Help::rebuildUserHelp() + { + if(m_userhelp) { + m_userhelp->rebuildMenu(); } } ////////////////////// show help ////////////////////// --- a/src/kilehelp.h +++ b/src/kilehelp.h @@ -22,7 +22,7 @@ #include <QString> #include <KConfig> -#include <KActionMenu> +#include <KXmlGuiWindow> #include <KTextEditor/View> #include "dialogs/texdocumentationdialog.h" @@ -59,10 +59,11 @@ Q_OBJECT public: - Help(KileDocument::EditorExtension *edit, QWidget *mainWindow); + Help(KileDocument::EditorExtension *edit, KXmlGuiWindow *mainWindow); ~Help(); - void setUserhelp(KileTool::Manager *manager, KActionMenu *userHelpActionMenu); + void setUserhelp(KileTool::Manager *manager); + void rebuildUserHelp(); void update(); // calls for help @@ -81,7 +82,7 @@ void helpDocBrowser(); private: - QWidget *m_mainWindow; + KXmlGuiWindow *m_mainWindow; KileTool::Manager *m_manager; KileDocument::EditorExtension *m_edit; UserHelp *m_userhelp; --- a/src/kilestdactions.cpp +++ b/src/kilestdactions.cpp @@ -1,5 +1,6 @@ /************************************************************************** * Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) * +* 2014 by Michel Ludwig (michel.ludwig@kdemail.net) * ***************************************************************************/ /*************************************************************************** @@ -13,7 +14,6 @@ #include "kilestdactions.h" -#include <KActionMenu> #include <KConfig> #include <KLocale> #include <KMainWindow> @@ -215,28 +215,27 @@ } -void setupBibTags(const QObject *receiver, KActionCollection *actionCollection, KActionMenu * menu) +QList<QAction*> setupBibTags(const QObject *receiver, KActionCollection *actionCollection) { + QList<QAction*> toReturn; KILE_DEBUG() << "void setupBibTags(const QObject *receiver, KActionCollection *actionCollection)"; QString filename; if(KileConfig::bibliographyType().isEmpty() || KileConfig::bibliographyType() == QString("bibtex") ) { - - menu->addAction(new KileAction::Tag(i18n("Bibliography Style Selection - \\bibliographystyle{}"), i18n("Bibliography Style Selection"), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographystyle", "\\bibliographystyle{","} ",19,0,i18n("The argument to \\bibliographystyle refers to a file style.bst, which defines how your citations will look\nThe standard styles distributed with BibTeX are:\nalpha : sorted alphabetically. Labels are formed from name of author and year of publication.\nplain : sorted alphabetically. Labels are numeric.\nunsrt : like plain, but entries are in order of citation.\nabbrv : like plain, but more compact labels."))); - menu->addAction(new KileAction::Tag(i18n("Bibliography Generation - \\bibliography{}"), i18n("Bibliography Generation"), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliography","\\bibliography{%S", "}\n",14, 0,i18n("The argument to \\bibliography refers to the bib file (without extension)\nwhich should contain your database in BibTeX format.\nKile inserts automatically the base name of the TeX file"))); - menu->addSeparator(); - + toReturn.append(new KileAction::Tag(i18n("Bibliography Style Selection - \\bibliographystyle{}"), i18n("Bibliography Style Selection"), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographystyle", "\\bibliographystyle{","} ",19,0,i18n("The argument to \\bibliographystyle refers to a file style.bst, which defines how your citations will look\nThe standard styles distributed with BibTeX are:\nalpha : sorted alphabetically. Labels are formed from name of author and year of publication.\nplain : sorted alphabetically. Labels are numeric.\nunsrt : like plain, but entries are in order of citation.\nabbrv : like plain, but more compact labels."))); + toReturn.append(new KileAction::Tag(i18n("Bibliography Generation - \\bibliography{}"), i18n("Bibliography Generation"), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliography","\\bibliography{%S", "}\n",14, 0,i18n("The argument to \\bibliography refers to the bib file (without extension)\nwhich should contain your database in BibTeX format.\nKile inserts automatically the base name of the TeX file"))); + toReturn.append(createSeparatorAction(actionCollection)); + filename = KGlobal::dirs()->findResource("appdata", "bibtexentries.rc"); } else if(KileConfig::bibliographyType() == QString("biblatex")){ - - menu->addAction(new KileAction::Tag(i18n("Load Biblatex Package - \\usepackage{biblatex}"), i18n("Load Biblatex Package"), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographyPackage", "\\usepackage{biblatex}\n",QString(),21,0,i18n("This includes the package biblatex"))); - menu->addAction(new KileAction::Tag(i18n("Bibliography Generation - \\bibliography{}"), i18n("Bibliography Generation"), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliography","\\bibliography{%S", "}\n",14, 0,i18n("The argument to \\bibliography refers to the bib file (without extension)\nwhich should contain your database in BibTeX format.\nKile inserts automatically the base name of the TeX file"))); - menu->addAction(new KileAction::Tag(i18n("Print Bibliography"), QString(), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_printbibliography", "\\printbibliography",QString(),18,0,i18n("Prints the complete bibliography"))); - menu->addAction(new KileAction::Tag(i18n("Print Bibliography by Section"), QString(), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographyBySection", "\\bibbysection[","]",14,0,i18n("Print the bibliography for each section"))); - menu->addAction(new KileAction::Tag(i18n("Print List of Shorthands"), QString(), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographyShortHands", "\\printshorthands",QString(),16,0,QString())); - menu->addSeparator(); + toReturn.append(new KileAction::Tag(i18n("Load Biblatex Package - \\usepackage{biblatex}"), i18n("Load Biblatex Package"), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographyPackage", "\\usepackage{biblatex}\n",QString(),21,0,i18n("This includes the package biblatex"))); + toReturn.append(new KileAction::Tag(i18n("Bibliography Generation - \\bibliography{}"), i18n("Bibliography Generation"), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliography","\\bibliography{%S", "}\n",14, 0,i18n("The argument to \\bibliography refers to the bib file (without extension)\nwhich should contain your database in BibTeX format.\nKile inserts automatically the base name of the TeX file"))); + toReturn.append(new KileAction::Tag(i18n("Print Bibliography"), QString(), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_printbibliography", "\\printbibliography",QString(),18,0,i18n("Prints the complete bibliography"))); + toReturn.append(new KileAction::Tag(i18n("Print Bibliography by Section"), QString(), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographyBySection", "\\bibbysection[","]",14,0,i18n("Print the bibliography for each section"))); + toReturn.append(new KileAction::Tag(i18n("Print List of Shorthands"), QString(), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_bibliographyShortHands", "\\printshorthands",QString(),16,0,QString())); + toReturn.append(createSeparatorAction(actionCollection)); /* use this to insert more menu->addAction(new KileAction::Tag(i18n(""), KShortcut(), receiver,SLOT(insertTag(const KileAction::TagData&)), actionCollection,"tag_", "\\",QString(),,0,i18n(""))); Load Biblatex-Package - \usepackage{biblatex} @@ -253,18 +252,20 @@ if(filename.isEmpty()){ KILE_DEBUG() << "found no filename" << endl; - return; + return toReturn; } KConfig *bibCfg = new KConfig(filename, KConfig::SimpleConfig); - if(bibCfg == NULL ) - return; + if(!bibCfg) { + return toReturn; + } QStringList groupList = bibCfg->groupList(); - if( groupList.count() == 0 ) - return; + if(groupList.count() == 0) { + return toReturn; + } QString name, tag, internalName, keys, key; QStringList keyList, optKeyList, altKeyList; @@ -330,8 +331,10 @@ compText.append(optText); } - menu->addAction(new KileAction::Tag(name, QString(), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,internalName,keys,QString(),length,0,compText)); - } + toReturn.append(new KileAction::Tag(name, QString(), KShortcut(), receiver, SLOT(insertTag(const KileAction::TagData&)), actionCollection,internalName,keys,QString(),length,0,compText)); + } + + return toReturn; } void setupMathTags(const QObject *receiver, KActionCollection *actionCollection) @@ -476,5 +479,12 @@ (void) new KileAction::Tag(i18n("Bmatrix - \\begin{Bmatrix}"), i18n("Bmatrix"), "BBmatrix", KShortcut(), receiver, SLOT(insertAmsTag(const KileAction::TagData&)),ac,"tag_env_BBmatrix","\\begin{Bmatrix}\n","%E\n\\end{Bmatrix}\n", 0,1); } + +QAction* createSeparatorAction(QObject *parent) +{ + QAction *act = new QAction(parent); + act->setSeparator(true); + return act; +} } --- a/src/kilestdactions.h +++ b/src/kilestdactions.h @@ -1,11 +1,7 @@ -// -// -// C++ Interface: kilestdactions -// -// Description: -// -// -// Author: Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net>, (C) 2003 +/************************************************************************** +* Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) * +* 2014 by Michel Ludwig (michel.ludwig@kdemail.net) * +***************************************************************************/ /*************************************************************************** * * @@ -22,16 +18,16 @@ #include <QWidget> #include <KActionCollection> -#include <KActionMenu> #include "kileinfo.h" namespace KileStdActions { void setupStdTags(KileInfo *ki, const QObject *receiver, KActionCollection *actionCollection, QWidget *parentWidget); - void setupBibTags(const QObject *receiver, KActionCollection *actionCollection,KActionMenu* menu); + QList<QAction*> setupBibTags(const QObject *receiver, KActionCollection *actionCollection); void setupMathTags(const QObject *receiver, KActionCollection *actionCollection); + QAction* createSeparatorAction(QObject *parent); } #endif --- a/src/kileui.rc +++ b/src/kileui.rc @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="kile" version="40"> -<Menu name="ktexteditor_popup" noMerge="1"> +<kpartgui name="kile" version="41"> +<Menu name="ktexteditor_popup"> <DefineGroup name="popup_operations" /> <Action name="popup_pasteaslatex"/> <Action name="popup_converttolatex"/> @@ -9,7 +9,7 @@ <Action name="popup_quickpreview"/> </Menu> <MenuBar> -<Menu name="file" noMerge="1"><text>&File</text> +<Menu name="file" ><text>&File</text> <Action name="file_new"/> <Separator/> <Action name="file_open"/> @@ -125,6 +125,8 @@ </Menu> <Menu name="menu_build"><text>B&uild</text> <Menu name="quickpreview"><text>QuickPreview</text> + <ActionList name="tools_quick_actionlist" /> + <Separator/> <Action name="quickpreview_selection"/> <Action name="quickpreview_environment"/> <Action name="quickpreview_subdocument"/> @@ -133,12 +135,16 @@ </Menu> <Separator/> <Menu name="menu_compile"><text>&Compile</text> + <ActionList name="tools_compile_actionlist" /> </Menu> <Menu name="menu_convert"><text>C&onvert</text> + <ActionList name="tools_convert_actionlist" /> </Menu> <Menu name="menu_viewer"><text>&View</text> + <ActionList name="tools_view_actionlist" /> </Menu> <Menu name="menu_other"><text>O&ther</text> + <ActionList name="tools_other_actionlist" /> </Menu> <Action name="WatchFile"/> <Separator/> @@ -395,7 +401,9 @@ <Action name="tag_env_cases"/> </Menu> <Separator/> - <Action name="menu_bibliography"/> + <Menu name="menu_bibliography"><text>&Bibliography</text> + <ActionList name="bibliography_actionlist" /> + </Menu> <Separator/> <Menu name="menu_fontstyles"><text>&Font Styles</text> <Action name="tag_textit"/> @@ -456,6 +464,9 @@ <Action name="tag_input"/> <Separator/> <Menu name="menu_user_tags"><text>User Tags</text> + <Action name="edit_user_tags"/> + <Separator/> + <ActionList name="user_tags_actionlist" /> </Menu> </Menu> @@ -498,12 +509,14 @@ <Action name="help_latex_env" /> </Menu> <Separator append="help_whats_this_merge" /> - <Action name="help_userhelp" append="help_whats_this_merge"/> - <Separator/> + <Menu name="menu_userhelp" append="help_whats_this_merge"><text>User Help</text> + <ActionList name="user_help_actionlist" /> + </Menu> + <Separator append="help_whats_this_merge" /> <Action name="help_about_editor" append="about_merge"/> </Menu> </MenuBar> -<ToolBar name="mainToolBar" fullWidth="false" index="1" noMerge="1" hidden="false"><text>Main</text> +<ToolBar name="mainToolBar" fullWidth="false" index="1" hidden="false"><text>Main</text> <Action name="file_new"/> <Action name="file_open"/> <Action name="file_close"/> @@ -617,6 +630,7 @@ <Action name="edit_end_group"/> <Action name="edit_match_group"/> <Action name="edit_close_group"/> + <Action name="edit_user_tags"/> <Action name="help_latex_reference"/> <Action name="help_handbook"/> <Action name="help_tipofday"/> @@ -774,7 +788,6 @@ <Action name="tag_env_gathered"/> <Action name="tag_env_alignedat"/> <Action name="tag_env_cases"/> - <Action name="menu_bibliography"/> <Action name="tag_textit"/> <Action name="tag_textsl"/> <Action name="tag_textbf"/> @@ -888,6 +901,7 @@ <Action name="edit_end_group"/> <Action name="edit_match_group"/> <Action name="edit_close_group"/> + <Action name="edit_user_tags"/> <Action name="help_latex_reference"/> <Action name="help_handbook"/> <Action name="help_tipofday"/> @@ -1050,7 +1064,6 @@ <Action name="tag_env_gathered"/> <Action name="tag_env_alignedat"/> <Action name="tag_env_cases"/> - <Action name="menu_bibliography"/> <Action name="tag_textit"/> <Action name="tag_textsl"/> <Action name="tag_textbf"/> @@ -1161,6 +1174,7 @@ <Action name="edit_end_group"/> <Action name="edit_match_group"/> <Action name="edit_close_group"/> + <Action name="edit_user_tags"/> <Action name="help_latex_reference"/> <Action name="help_handbook"/> <Action name="help_tipofday"/> @@ -1320,7 +1334,6 @@ <Action name="tag_env_gathered"/> <Action name="tag_env_alignedat"/> <Action name="tag_env_cases"/> - <Action name="menu_bibliography"/> <Action name="tag_textit"/> <Action name="tag_textsl"/> <Action name="tag_textbf"/> @@ -1366,27 +1379,4 @@ <Action name="return_to_editor"/> </Disable> </State> -<ActionProperties scheme="Default" version="1"> - <Action shortcut="Alt+1" name="tool_QuickBuild" /> - <Action shortcut="Alt+2" name="tool_LaTeX" /> - <Action shortcut="Alt+3" name="tool_ViewDVI" /> - <Action shortcut="Alt+4" name="tool_DVItoPS" /> - <Action shortcut="Alt+5" name="tool_ViewPS" /> - <Action shortcut="Alt+6" name="tool_PDFLaTeX" /> - <Action shortcut="Alt+7" name="tool_ViewPDF" /> - <Action shortcut="Alt+8" name="tool_PStoPDF" /> - <Action shortcut="Alt+9" name="tool_DVItoPDF" /> - <Action shortcut="Alt+-" name="tool_BibTeX" /> - <Action shortcut="Alt+=" name="tool_MakeIndex" /> - <Action shortcut="CTRL+SHIFT+1" name="tag_user_1" /> - <Action shortcut="CTRL+SHIFT+2" name="tag_user_2" /> - <Action shortcut="CTRL+SHIFT+3" name="tag_user_3" /> - <Action shortcut="CTRL+SHIFT+4" name="tag_user_4" /> - <Action shortcut="CTRL+SHIFT+5" name="tag_user_5" /> - <Action shortcut="CTRL+SHIFT+6" name="tag_user_6" /> - <Action shortcut="CTRL+SHIFT+7" name="tag_user_7" /> - <Action shortcut="CTRL+SHIFT+8" name="tag_user_8" /> - <Action shortcut="CTRL+SHIFT+9" name="tag_user_9" /> - <Action shortcut="CTRL+SHIFT+0" name="tag_user_10" /> -</ActionProperties> </kpartgui> --- a/src/userhelp.cpp +++ b/src/userhelp.cpp @@ -4,7 +4,7 @@ date : Aug 17 2006 version : 0.25 copyright : (C) 2005-2006 by Holger Danielsson (holger.danielsson@t-online.de) - 2008 by Michel Ludwig (michel.ludwig@kdemail.net) + 2008-2014 by Michel Ludwig (michel.ludwig@kdemail.net) **********************************************************************************************/ /*************************************************************************** @@ -27,17 +27,19 @@ #include <KMimeType> #include <KUrl> #include <KRun> +#include <KXMLGUIFactory> #include "kileactions.h" #include "kileconfig.h" #include "kiledebug.h" +#include "kilestdactions.h" #include "dialogs/userhelpdialog.h" namespace KileHelp { -UserHelp::UserHelp(KileTool::Manager *manager, KActionMenu *userHelpActionMenu, QWidget* mainWindow) - : m_manager(manager), m_userHelpActionMenu(userHelpActionMenu), m_mainWindow(mainWindow) +UserHelp::UserHelp(KileTool::Manager *manager, KXmlGuiWindow* mainWindow) + : m_manager(manager), m_mainWindow(mainWindow) { setupUserHelpMenu(); } @@ -97,6 +99,11 @@ } } +void UserHelp::rebuildMenu() +{ + setupUserHelpMenu(); +} + void UserHelp::setupUserHelpMenu() { QStringList menuList; @@ -105,15 +112,13 @@ clearActionList(); - m_userHelpActionMenu->setEnabled(menuList.count() > 0); QList<KUrl>::iterator j = urlList.begin(); for(QStringList::iterator i = menuList.begin(); i != menuList.end(); ++i) { QString menu = *i; // first look, if this entry is a separator if(menu == "-" ) { - QAction *action = m_userHelpActionMenu->addSeparator(); - m_actionList.append(action); + m_actionList.append(KileStdActions::createSeparatorAction(this)); } else { KUrl url = *j; @@ -130,19 +135,25 @@ action->setIcon(KIcon(icon)); } connect(action, SIGNAL(triggered(const KUrl&)), this, SLOT(slotUserHelpActivated(const KUrl&))); - m_userHelpActionMenu->addAction(action); m_actionList.append(action); } ++j; } + + m_mainWindow->unplugActionList("user_help_actionlist"); + m_mainWindow->plugActionList("user_help_actionlist", m_actionList); + enableUserHelpEntries(true); } void UserHelp::enableUserHelpEntries(bool state) { - QStringList menuList; - QList<KUrl> urlList; - readConfig(menuList, urlList); - m_userHelpActionMenu->setEnabled(state && (menuList.size() > 0)); + QMenu *menu = dynamic_cast<QMenu*>(m_mainWindow->guiFactory()->container("menu_userhelp", m_mainWindow)); + if(menu) { + Q_FOREACH(QAction *act, menu->actions()) { + act->setEnabled(state); + } + menu->setEnabled(state && (menu->actions().size() > 0)); + } } void UserHelp::slotUserHelpActivated(const KUrl& url) --- a/src/userhelp.h +++ b/src/userhelp.h @@ -4,7 +4,7 @@ date : Aug 17 2006 version : 0.15 copyright : (C) 2005-2006 by Holger Danielsson (holger.danielsson@t-online.de) - 2008 by Michel Ludwig (michel.ludwig@kdemail.net) + 2008-2014 by Michel Ludwig (michel.ludwig@kdemail.net) ***********************************************************************************************/ /*************************************************************************** @@ -23,8 +23,8 @@ #include <QStringList> #include <QWidget> -#include <KActionMenu> #include <KConfig> +#include <KXmlGuiWindow> #include <KMenuBar> #include <KLocale> #include <KUrl> @@ -39,10 +39,11 @@ Q_OBJECT public: - UserHelp(KileTool::Manager *manager, KActionMenu *userHelpActionMenu, QWidget *mainWindow); + UserHelp(KileTool::Manager *manager, KXmlGuiWindow *mainWindow); ~UserHelp(); void userHelpDialog(); void enableUserHelpEntries(bool state); + void rebuildMenu(); private Q_SLOTS: void slotUserHelpActivated(const KUrl& url); @@ -56,8 +57,7 @@ void setupUserHelpMenu(); KileTool::Manager *m_manager; - KActionMenu *m_userHelpActionMenu; - QWidget *m_mainWindow; + KXmlGuiWindow *m_mainWindow; QList<QAction*> m_actionList; };
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor