fix: contextmenu getInstance added

This commit is contained in:
Andreas Stallinger
2017-03-23 12:53:06 +01:00
parent 591b66fe77
commit d33e137451
3 changed files with 37 additions and 28 deletions
+2 -2
View File
@@ -58,14 +58,14 @@ void QtUndoRedo::redo()
void QtUndoRedo::setUndoButtonEnabled(bool enabled)
{
m_undoButton->setEnabled(enabled);
QtContextMenu::enableUndo(enabled);
QtContextMenu::getInstance()->enableUndo(enabled);
}
void QtUndoRedo::setRedoButtonEnabled(bool enabled)
{
m_redoButton->setEnabled(enabled);
QtContextMenu::enableRedo(enabled);
QtContextMenu::getInstance()->enableRedo(enabled);
}
void QtUndoRedo::refreshStyle()
+31 -24
View File
@@ -23,30 +23,7 @@ QtContextMenu::QtContextMenu(QContextMenuEvent* event, QWidget* origin)
: m_menu(origin)
, m_point(event->globalPos())
{
if (!s_instance)
{
s_instance = new QtContextMenu();
s_undoAction = new QAction(tr("Back"), s_instance);
s_undoAction->setStatusTip(tr("Go back to last active symbol"));
s_undoAction->setToolTip(tr("Go back to last active symbol"));
connect(s_undoAction, SIGNAL(triggered()), s_instance, SLOT(undoActionTriggered()));
s_redoAction = new QAction(tr("Forward"), s_instance);
s_redoAction->setStatusTip(tr("Go forward to next active symbol"));
s_redoAction->setToolTip(tr("Go forward to next active symbol"));
connect(s_redoAction, SIGNAL(triggered()), s_instance, SLOT(redoActionTriggered()));
s_copyFullPathAction = new QAction(tr("Copy Full Path"), s_instance);
s_copyFullPathAction->setStatusTip(tr("Copies the path of this file to the clipboard"));
s_copyFullPathAction->setToolTip(tr("Copies the path of this file to the clipboard"));
connect(s_copyFullPathAction, SIGNAL(triggered()), s_instance, SLOT(copyFullPathActionTriggered()));
s_openContainingFolderAction = new QAction(tr("Open Containing Folder"), s_instance);
s_openContainingFolderAction->setStatusTip(tr("Opens the folder that contains this file"));
s_openContainingFolderAction->setToolTip(tr("Opens the folder that contains this file"));
connect(s_openContainingFolderAction, SIGNAL(triggered()), s_instance, SLOT(openContainingFolderActionTriggered()));
}
getInstance();
addUndoActions();
}
@@ -80,6 +57,36 @@ void QtContextMenu::addFileActions(FilePath filePath)
addAction(s_openContainingFolderAction);
}
QtContextMenu* QtContextMenu::getInstance()
{
if (!s_instance)
{
s_instance = new QtContextMenu();
s_undoAction = new QAction(tr("Back"), s_instance);
s_undoAction->setStatusTip(tr("Go back to last active symbol"));
s_undoAction->setToolTip(tr("Go back to last active symbol"));
connect(s_undoAction, SIGNAL(triggered()), s_instance, SLOT(undoActionTriggered()));
s_redoAction = new QAction(tr("Forward"), s_instance);
s_redoAction->setStatusTip(tr("Go forward to next active symbol"));
s_redoAction->setToolTip(tr("Go forward to next active symbol"));
connect(s_redoAction, SIGNAL(triggered()), s_instance, SLOT(redoActionTriggered()));
s_copyFullPathAction = new QAction(tr("Copy Full Path"), s_instance);
s_copyFullPathAction->setStatusTip(tr("Copies the path of this file to the clipboard"));
s_copyFullPathAction->setToolTip(tr("Copies the path of this file to the clipboard"));
connect(s_copyFullPathAction, SIGNAL(triggered()), s_instance, SLOT(copyFullPathActionTriggered()));
s_openContainingFolderAction = new QAction(tr("Open Containing Folder"), s_instance);
s_openContainingFolderAction->setStatusTip(tr("Opens the folder that contains this file"));
s_openContainingFolderAction->setToolTip(tr("Opens the folder that contains this file"));
connect(s_openContainingFolderAction, SIGNAL(triggered()), s_instance, SLOT(openContainingFolderActionTriggered()));
}
return s_instance;
}
void QtContextMenu::addSeparator()
{
m_menu.addSeparator();
+4 -2
View File
@@ -21,12 +21,14 @@ public:
void addUndoActions();
void addFileActions(FilePath filePath);
static QtContextMenu* getInstance();
void addSeparator();
void show();
static void enableUndo(bool enabled);
static void enableRedo(bool enabled);
void enableUndo(bool enabled);
void enableRedo(bool enabled);
private slots:
void undoActionTriggered();