diff --git a/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp b/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp index d80ffe3f5..244a5a92c 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp +++ b/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp @@ -47,6 +47,7 @@ namespace TranslationManager CMainWindow::CMainWindow(QWidget *parent) : QMainWindow(parent) { + menu = NULL; _ui.setupUi(this); _ui.mdiArea->closeAllSubWindows(); @@ -59,10 +60,37 @@ CMainWindow::CMainWindow(QWidget *parent) connect(Core::ICore::instance(), SIGNAL(changeSettings()), this, SLOT(readSettings())); readSettings(); createToolbar(); + createMenus(); m_undoStack = new QUndoStack(this); } +CMainWindow::~CMainWindow() +{ + removeMenus(); +} + +void CMainWindow::removeMenus() +{ + delete menu; + menu = NULL; +} + +void CMainWindow::createMenus() +{ + // Windows menu + Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); + QMenu *m = menuManager->menuBar()->addMenu( "Translation Manager" ); + if( m != NULL ) + { + windowMenu = m->addMenu("Window"); + menu = m; + } + + updateWindowsList(); + connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowsList())); +} + // Functions that will insert the plugin buttons void CMainWindow::createToolbar() { @@ -126,17 +154,8 @@ void CMainWindow::createToolbar() mergeSingleFileAct->setStatusTip(tr("Merge worksheet file from local or remote directory")); connect(mergeSingleFileAct, SIGNAL(triggered()), this, SLOT(mergeSingleFile())); - // Windows menu Core::ICore *core = Core::ICore::instance(); Core::MenuManager *menuManager = core->menuManager(); - QMenu *m = menuManager->menuBar()->addMenu( "Translation Manager" ); - if( m != NULL ) - { - windowMenu = m->addMenu("Window"); - } - - updateWindowsList(); - connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowsList())); // Undo, Redo actions QAction *undoAction = menuManager->action(Core::Constants::UNDO); diff --git a/code/studio/src/plugins/translation_manager/translation_manager_main_window.h b/code/studio/src/plugins/translation_manager/translation_manager_main_window.h index c67f282e0..73bccdd8e 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_main_window.h +++ b/code/studio/src/plugins/translation_manager/translation_manager_main_window.h @@ -58,7 +58,7 @@ class CMainWindow : public QMainWindow public: CMainWindow(QWidget *parent = 0); - virtual ~CMainWindow() {} + ~CMainWindow(); QUndoStack *m_undoStack; public: @@ -96,6 +96,7 @@ private: void updateToolbar(QMdiSubWindow *window); bool verifySettings(); void readSettings(); + void removeMenus(); void createMenus(); void createToolbar(); void initializeSettings(bool georges); @@ -105,6 +106,9 @@ private: CEditorWorksheet *getEditorByWorksheetType(const QString &type); bool isWorksheetEditor(QString filename); bool isPhraseEditor(QString filename); + + + QMenu *menu; }; class CCoreListener : public Core::ICoreListener