Remove translation manager menu when unloading the plugin.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-06-08 18:45:13 +02:00
parent fb4dc15fe7
commit 828f31a2a4
2 changed files with 33 additions and 10 deletions

View file

@ -47,6 +47,7 @@ namespace TranslationManager
CMainWindow::CMainWindow(QWidget *parent) CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
menu = NULL;
_ui.setupUi(this); _ui.setupUi(this);
_ui.mdiArea->closeAllSubWindows(); _ui.mdiArea->closeAllSubWindows();
@ -59,10 +60,37 @@ CMainWindow::CMainWindow(QWidget *parent)
connect(Core::ICore::instance(), SIGNAL(changeSettings()), this, SLOT(readSettings())); connect(Core::ICore::instance(), SIGNAL(changeSettings()), this, SLOT(readSettings()));
readSettings(); readSettings();
createToolbar(); createToolbar();
createMenus();
m_undoStack = new QUndoStack(this); 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 // Functions that will insert the plugin buttons
void CMainWindow::createToolbar() void CMainWindow::createToolbar()
{ {
@ -126,17 +154,8 @@ void CMainWindow::createToolbar()
mergeSingleFileAct->setStatusTip(tr("Merge worksheet file from local or remote directory")); mergeSingleFileAct->setStatusTip(tr("Merge worksheet file from local or remote directory"));
connect(mergeSingleFileAct, SIGNAL(triggered()), this, SLOT(mergeSingleFile())); connect(mergeSingleFileAct, SIGNAL(triggered()), this, SLOT(mergeSingleFile()));
// Windows menu
Core::ICore *core = Core::ICore::instance(); Core::ICore *core = Core::ICore::instance();
Core::MenuManager *menuManager = core->menuManager(); 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 // Undo, Redo actions
QAction *undoAction = menuManager->action(Core::Constants::UNDO); QAction *undoAction = menuManager->action(Core::Constants::UNDO);

View file

@ -58,7 +58,7 @@ class CMainWindow : public QMainWindow
public: public:
CMainWindow(QWidget *parent = 0); CMainWindow(QWidget *parent = 0);
virtual ~CMainWindow() {} ~CMainWindow();
QUndoStack *m_undoStack; QUndoStack *m_undoStack;
public: public:
@ -96,6 +96,7 @@ private:
void updateToolbar(QMdiSubWindow *window); void updateToolbar(QMdiSubWindow *window);
bool verifySettings(); bool verifySettings();
void readSettings(); void readSettings();
void removeMenus();
void createMenus(); void createMenus();
void createToolbar(); void createToolbar();
void initializeSettings(bool georges); void initializeSettings(bool georges);
@ -105,6 +106,9 @@ private:
CEditorWorksheet *getEditorByWorksheetType(const QString &type); CEditorWorksheet *getEditorByWorksheetType(const QString &type);
bool isWorksheetEditor(QString filename); bool isWorksheetEditor(QString filename);
bool isPhraseEditor(QString filename); bool isPhraseEditor(QString filename);
QMenu *menu;
}; };
class CCoreListener : public Core::ICoreListener class CCoreListener : public Core::ICoreListener