Fix existing context menu in script editor

0.6.1
PlutonicOverkill 8 years ago
parent 3d1e640388
commit 6063d8e31b

@ -88,19 +88,15 @@ CSVWorld::ScriptEdit::ScriptEdit(
<<CSMWorld::UniversalId::Type_Script <<CSMWorld::UniversalId::Type_Script
<<CSMWorld::UniversalId::Type_Region; <<CSMWorld::UniversalId::Type_Region;
mContextMenu = createStandardContextMenu(); mCommentAction = new QAction (tr ("Comment Selection"), this);
connect(mCommentAction, SIGNAL (triggered()), this, SLOT (commentSelection()));
CSMPrefs::Shortcut *commentShortcut = new CSMPrefs::Shortcut("script-editor-comment", this);
commentShortcut->associateAction(mCommentAction);
QAction* comment = new QAction (tr ("Comment Selection"), this); mUncommentAction = new QAction (tr ("Uncomment Selection"), this);
connect(comment, SIGNAL (triggered()), this, SLOT (commentSelection())); connect(mUncommentAction, SIGNAL (triggered()), this, SLOT (uncommentSelection()));
CSMPrefs::Shortcut* commentShortcut = new CSMPrefs::Shortcut("script-editor-comment", this); CSMPrefs::Shortcut *uncommentShortcut = new CSMPrefs::Shortcut("script-editor-uncomment", this);
commentShortcut->associateAction(comment); uncommentShortcut->associateAction(mUncommentAction);
mContextMenu->addAction(comment);
QAction* uncomment = new QAction (tr ("Uncomment Selection"), this);
connect(uncomment, SIGNAL (triggered()), this, SLOT (uncommentSelection()));
CSMPrefs::Shortcut* uncommentShortcut = new CSMPrefs::Shortcut("script-editor-uncomment", this);
uncommentShortcut->associateAction(uncomment);
mContextMenu->addAction(uncomment);
mHighlighter = new ScriptHighlighter (document.getData(), mode, ScriptEdit::document()); mHighlighter = new ScriptHighlighter (document.getData(), mode, ScriptEdit::document());
@ -361,7 +357,12 @@ void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event) void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event)
{ {
mContextMenu->exec(event->globalPos()); QMenu *menu = createStandardContextMenu();
menu->addAction(mCommentAction);
menu->addAction(mUncommentAction);
menu->exec(event->globalPos());
delete menu;
} }
void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event) void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event)

@ -6,6 +6,7 @@
#include <QVector> #include <QVector>
#include <QTimer> #include <QTimer>
#include <QFont> #include <QFont>
#include <QAction>
#include "../../model/world/universalid.hpp" #include "../../model/world/universalid.hpp"
@ -54,7 +55,8 @@ namespace CSVWorld
QFont mDefaultFont; QFont mDefaultFont;
QFont mMonoFont; QFont mMonoFont;
int mTabCharCount; int mTabCharCount;
QMenu *mContextMenu; QAction *mCommentAction;
QAction *mUncommentAction;
protected: protected:

Loading…
Cancel
Save