# HG changeset patch # User thomas_-_s # Date 1213263706 0 # Node ID 1ce0ba4e86d6abb5a565d6a95fe6f305a7846c87 # Parent 6dda59f4cc5a990abf856dfce0481536761f1c56 Prepared the indenter specific context menu. It already shows up when right clicking on the widget. Now the indent handler needs to implement the load and save functions and the main window needs to get the menu from the IndentHandler. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@723 59b1889a-e5ac-428c-b0c7-476e01d41282 diff -r 6dda59f4cc5a -r 1ce0ba4e86d6 src/indenthandler.cpp --- a/src/indenthandler.cpp Thu Jun 12 09:15:02 2008 +0000 +++ b/src/indenthandler.cpp Thu Jun 12 09:41:46 2008 +0000 @@ -50,6 +50,11 @@ this->mainWindow = mainWindow; indenterSettings = NULL; + menuIndenter = NULL; + actionLoad_Indenter_Config_File = NULL; + actionSave_Indenter_Config_File = NULL; + actionCreateShellScript = NULL; + initIndenterMenu(); // define this widgets size and resize behavior //this->setMaximumWidth(263); @@ -142,6 +147,46 @@ /*! + \brief Initializes the context menu used for some actions like saving the indenter config file. + */ +void IndentHandler::initIndenterMenu() { + if ( menuIndenter == NULL ) { + actionLoad_Indenter_Config_File = new QAction(this); + actionLoad_Indenter_Config_File->setObjectName(QString::fromUtf8("actionLoad_Indenter_Config_File")); + actionLoad_Indenter_Config_File->setIcon(QIcon(QString::fromUtf8(":/mainWindow/load_indent_cfg.png"))); + actionSave_Indenter_Config_File = new QAction(this); + actionSave_Indenter_Config_File->setObjectName(QString::fromUtf8("actionSave_Indenter_Config_File")); + actionSave_Indenter_Config_File->setIcon(QIcon(QString::fromUtf8(":/mainWindow/save_indent_cfg.png"))); + actionCreateShellScript = new QAction(this); + actionCreateShellScript->setObjectName(QString::fromUtf8("actionCreateShellScript")); + actionCreateShellScript->setIcon(QIcon(QString::fromUtf8(":/mainWindow/shell.png"))); + + menuIndenter = new QMenu(this); + menuIndenter->setObjectName(QString::fromUtf8("menuIndenter")); + menuIndenter->addAction(actionLoad_Indenter_Config_File); + menuIndenter->addAction(actionSave_Indenter_Config_File); + menuIndenter->addAction(actionCreateShellScript); + } +} + + +/*! + \brief Returns the context menu used for some actions like saving the indenter config file. + */ +QMenu* IndentHandler::getIndenterMenu() { + return menuIndenter; +} + + +/*! + \brief Opens the context menu, used for some actions like saving the indenter config file, at the event position. + */ +void IndentHandler::contextMenuEvent( QContextMenuEvent *event ) { + getIndenterMenu()->exec( event->globalPos() ); +} + + +/*! \brief Creates the content for a shell script that can be used as a external too call to indent a as parameter defined file. */ @@ -1216,6 +1261,16 @@ void IndentHandler::retranslateUi() { indenterSelectionComboBox->setToolTip( tr("

Shows the currently chosen indenters name and lets you choose other available indenters

") ); indenterParameterHelpButton->setToolTip( tr("Brings you to the online manual of the currently selected indenter, where you can get further help on the possible parameters.") ); + + actionLoad_Indenter_Config_File->setText(QApplication::translate("MainWindowUi", "Load Indenter Config File", 0, QApplication::UnicodeUTF8)); + actionLoad_Indenter_Config_File->setStatusTip(QApplication::translate("MainWindowUi", "Opens a file dialog to load the original config file of the indenter.", 0, QApplication::UnicodeUTF8)); + actionLoad_Indenter_Config_File->setShortcut(QApplication::translate("MainWindowUi", "Alt+O", 0, QApplication::UnicodeUTF8)); + actionSave_Indenter_Config_File->setText(QApplication::translate("MainWindowUi", "Save Indenter Config File", 0, QApplication::UnicodeUTF8)); + actionSave_Indenter_Config_File->setStatusTip(QApplication::translate("MainWindowUi", "Opens a dialog to save the current indenter configuration to a file.", 0, QApplication::UnicodeUTF8)); + actionSave_Indenter_Config_File->setShortcut(QApplication::translate("MainWindowUi", "Alt+S", 0, QApplication::UnicodeUTF8)); + actionCreateShellScript->setText(QApplication::translate("MainWindowUi", "Create Indenter Call Shell Script", 0, QApplication::UnicodeUTF8)); + actionCreateShellScript->setToolTip(QApplication::translate("MainWindowUi", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings", 0, QApplication::UnicodeUTF8)); + actionCreateShellScript->setStatusTip(QApplication::translate("MainWindowUi", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings", 0, QApplication::UnicodeUTF8)); } diff -r 6dda59f4cc5a -r 1ce0ba4e86d6 src/indenthandler.h --- a/src/indenthandler.h Thu Jun 12 09:15:02 2008 +0000 +++ b/src/indenthandler.h Thu Jun 12 09:41:46 2008 +0000 @@ -42,6 +42,9 @@ #include #include #include +#include +#include +#include #include "uiguierrormessage.h" #include "templateBatchScript.h" @@ -66,6 +69,8 @@ QString getManual(); void retranslateUi(); QString getCurrentIndenterName(); + QMenu* getIndenterMenu(); + void contextMenuEvent( QContextMenuEvent *event ); signals: void indenterSettingsChanged(); @@ -80,6 +85,7 @@ void writeConfigFile(QString filePathName, QString parameterString); void readIndentIniFile(QString iniFilePath); bool createIndenterCallString(); + void initIndenterMenu(); //! Holds a reference to all created pages of the toolbox and the pages boxlayout struct ToolBoxPage { @@ -157,6 +163,11 @@ UiGuiErrorMessage *errorMessageDialog; QString indenterExecutableCallString; QString indenterExecutableSuffix; + + QMenu *menuIndenter; + QAction *actionLoad_Indenter_Config_File; + QAction *actionSave_Indenter_Config_File; + QAction *actionCreateShellScript; }; #endif // INDENTHANDLER_H