Add setting to change keyboard shortcut and fix another crash

0.6.1
PlutonicOverkill 8 years ago
parent 1f699552f7
commit 3d1e640388

@ -326,6 +326,10 @@ void CSMPrefs::State::declare()
declareShortcut ("orbit-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
declareShortcut ("orbit-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
declareShortcut ("orbit-center-selection", "Center On Selected", QKeySequence(Qt::Key_C));
declareSubcategory ("Script Editor");
declareShortcut ("script-editor-comment", "Comment Selection", QKeySequence());
declareShortcut ("script-editor-uncomment", "Uncomment Selection", QKeySequence());
}
void CSMPrefs::State::declareCategory (const std::string& key)

@ -14,6 +14,7 @@
#include "../../model/world/universalid.hpp"
#include "../../model/world/tablemimedata.hpp"
#include "../../model/prefs/state.hpp"
#include "../../model/prefs/shortcut.hpp"
CSVWorld::ScriptEdit::ChangeLock::ChangeLock (ScriptEdit& edit) : mEdit (edit)
{
@ -87,6 +88,20 @@ CSVWorld::ScriptEdit::ScriptEdit(
<<CSMWorld::UniversalId::Type_Script
<<CSMWorld::UniversalId::Type_Region;
mContextMenu = createStandardContextMenu();
QAction* comment = new QAction (tr ("Comment Selection"), this);
connect(comment, SIGNAL (triggered()), this, SLOT (commentSelection()));
CSMPrefs::Shortcut* commentShortcut = new CSMPrefs::Shortcut("script-editor-comment", this);
commentShortcut->associateAction(comment);
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());
connect (&document.getData(), SIGNAL (idListChanged()), this, SLOT (idListChanged()));
@ -295,7 +310,7 @@ void CSVWorld::ScriptEdit::commentSelection()
end.setPosition(end.selectionEnd());
end.movePosition(QTextCursor::EndOfLine);
for (; begin < end; begin.movePosition(QTextCursor::StartOfLine), begin.movePosition(QTextCursor::Down))
for (; begin < end; begin.movePosition(QTextCursor::EndOfLine), begin.movePosition(QTextCursor::Right))
{
begin.insertText(";");
}
@ -311,7 +326,7 @@ void CSVWorld::ScriptEdit::uncommentSelection()
end.setPosition(end.selectionEnd());
end.movePosition(QTextCursor::EndOfLine);
for (; begin < end; begin.movePosition(QTextCursor::StartOfLine), begin.movePosition(QTextCursor::Down)) {
for (; begin < end; begin.movePosition(QTextCursor::EndOfLine), begin.movePosition(QTextCursor::Right)) {
begin.select(QTextCursor::LineUnderCursor);
QString line = begin.selectedText();
@ -346,12 +361,7 @@ void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
menu->addAction("Comment Selection", this, SLOT(commentSelection()));
menu->addAction("Uncomment Selection", this, SLOT(uncommentSelection()));
menu->exec(event->globalPos());
delete menu;
mContextMenu->exec(event->globalPos());
}
void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event)

@ -54,6 +54,7 @@ namespace CSVWorld
QFont mDefaultFont;
QFont mMonoFont;
int mTabCharCount;
QMenu *mContextMenu;
protected:

Loading…
Cancel
Save