mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 07:21:12 +00:00
Add setting to change keyboard shortcut and fix another crash
This commit is contained in:
parent
1f699552f7
commit
3d1e640388
@ -326,6 +326,10 @@ void CSMPrefs::State::declare()
|
|||||||
declareShortcut ("orbit-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
|
declareShortcut ("orbit-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
|
||||||
declareShortcut ("orbit-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
|
declareShortcut ("orbit-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
|
||||||
declareShortcut ("orbit-center-selection", "Center On Selected", QKeySequence(Qt::Key_C));
|
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)
|
void CSMPrefs::State::declareCategory (const std::string& key)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
#include "../../model/world/tablemimedata.hpp"
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
#include "../../model/prefs/state.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
|
#include "../../model/prefs/shortcut.hpp"
|
||||||
|
|
||||||
CSVWorld::ScriptEdit::ChangeLock::ChangeLock (ScriptEdit& edit) : mEdit (edit)
|
CSVWorld::ScriptEdit::ChangeLock::ChangeLock (ScriptEdit& edit) : mEdit (edit)
|
||||||
{
|
{
|
||||||
@ -87,6 +88,20 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
|||||||
<<CSMWorld::UniversalId::Type_Script
|
<<CSMWorld::UniversalId::Type_Script
|
||||||
<<CSMWorld::UniversalId::Type_Region;
|
<<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());
|
mHighlighter = new ScriptHighlighter (document.getData(), mode, ScriptEdit::document());
|
||||||
|
|
||||||
connect (&document.getData(), SIGNAL (idListChanged()), this, SLOT (idListChanged()));
|
connect (&document.getData(), SIGNAL (idListChanged()), this, SLOT (idListChanged()));
|
||||||
@ -295,7 +310,7 @@ void CSVWorld::ScriptEdit::commentSelection()
|
|||||||
end.setPosition(end.selectionEnd());
|
end.setPosition(end.selectionEnd());
|
||||||
end.movePosition(QTextCursor::EndOfLine);
|
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(";");
|
begin.insertText(";");
|
||||||
}
|
}
|
||||||
@ -311,7 +326,7 @@ void CSVWorld::ScriptEdit::uncommentSelection()
|
|||||||
end.setPosition(end.selectionEnd());
|
end.setPosition(end.selectionEnd());
|
||||||
end.movePosition(QTextCursor::EndOfLine);
|
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);
|
begin.select(QTextCursor::LineUnderCursor);
|
||||||
QString line = begin.selectedText();
|
QString line = begin.selectedText();
|
||||||
|
|
||||||
@ -346,12 +361,7 @@ void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
|
|||||||
|
|
||||||
void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event)
|
void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QMenu *menu = createStandardContextMenu();
|
mContextMenu->exec(event->globalPos());
|
||||||
menu->addAction("Comment Selection", this, SLOT(commentSelection()));
|
|
||||||
menu->addAction("Uncomment Selection", this, SLOT(uncommentSelection()));
|
|
||||||
|
|
||||||
menu->exec(event->globalPos());
|
|
||||||
delete menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
|
void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||||
|
@ -54,6 +54,7 @@ namespace CSVWorld
|
|||||||
QFont mDefaultFont;
|
QFont mDefaultFont;
|
||||||
QFont mMonoFont;
|
QFont mMonoFont;
|
||||||
int mTabCharCount;
|
int mTabCharCount;
|
||||||
|
QMenu *mContextMenu;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user