forked from qt-creator/qt-creator
FakeVim: Disable cursor blinking by default
Add an option to enable Task-number: QTCREATORBUG-21613 Change-Id: Ia0553f0b89b22c1d5b47487cd6e5b3c3a523cd6d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -108,6 +108,7 @@ FakeVimSettings::FakeVimSettings()
|
||||
createAction(ConfigTildeOp, false, "TildeOp", "top");
|
||||
createAction(ConfigShowCmd, true, "ShowCmd", "sc");
|
||||
createAction(ConfigRelativeNumber, false, "RelativeNumber", "rnu");
|
||||
createAction(ConfigBlinkingCursor, false, "BlinkingCursor", "cb");
|
||||
createAction(ConfigScrollOff, 0, "ScrollOff", "so");
|
||||
createAction(ConfigBackspace, QString("indent,eol,start"), "ConfigBackspace", "bs");
|
||||
createAction(ConfigIsKeyword, QString("@,48-57,_,192-255,a-z,A-Z"), "IsKeyword", "isk");
|
||||
|
@@ -106,7 +106,9 @@ enum FakeVimSettingsCode
|
||||
ConfigClipboard,
|
||||
ConfigShowCmd,
|
||||
ConfigScrollOff,
|
||||
ConfigRelativeNumber
|
||||
ConfigRelativeNumber,
|
||||
|
||||
ConfigBlinkingCursor
|
||||
};
|
||||
|
||||
class FakeVimSettings
|
||||
|
@@ -130,6 +130,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxBlinkingCursor">
|
||||
<property name="text">
|
||||
<string>Blinking cursor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxShowMarks">
|
||||
<property name="text">
|
||||
|
@@ -83,6 +83,7 @@
|
||||
#include <QAbstractTableModel>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QGuiApplication>
|
||||
#include <QItemDelegate>
|
||||
#include <QPainter>
|
||||
#include <QPlainTextEdit>
|
||||
@@ -91,6 +92,7 @@
|
||||
#include <QSettings>
|
||||
#include <QStackedWidget>
|
||||
#include <QStandardPaths>
|
||||
#include <QStyleHints>
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
#include <QTextEdit>
|
||||
@@ -426,6 +428,7 @@ QWidget *FakeVimOptionPage::widget()
|
||||
m_group.insert(theFakeVimSetting(ConfigShowCmd), m_ui.checkBoxShowCmd);
|
||||
|
||||
m_group.insert(theFakeVimSetting(ConfigRelativeNumber), m_ui.checkBoxRelativeNumber);
|
||||
m_group.insert(theFakeVimSetting(ConfigBlinkingCursor), m_ui.checkBoxBlinkingCursor);
|
||||
|
||||
connect(m_ui.pushButtonCopyTextEditorSettings, &QAbstractButton::clicked,
|
||||
this, &FakeVimOptionPage::copyTextEditorSettings);
|
||||
@@ -529,6 +532,7 @@ public:
|
||||
void fold(FakeVimHandler *handler, int depth, bool fold);
|
||||
void maybeReadVimRc();
|
||||
void setShowRelativeLineNumbers(const QVariant &value);
|
||||
void updateCursorBlinking(const QVariant &value);
|
||||
|
||||
void resetCommandBuffer();
|
||||
void showCommandBuffer(FakeVimHandler *handler, const QString &contents,
|
||||
@@ -569,6 +573,8 @@ public:
|
||||
|
||||
MiniBuffer *m_miniBuffer = nullptr;
|
||||
FakeVimPluginRunData *runData = nullptr;
|
||||
|
||||
int m_savedCursorFlashTime = 0;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@@ -1223,6 +1229,8 @@ bool FakeVimPluginPrivate::initialize()
|
||||
this, &FakeVimPluginPrivate::maybeReadVimRc);
|
||||
connect(theFakeVimSetting(ConfigRelativeNumber), &SavedAction::valueChanged,
|
||||
this, &FakeVimPluginPrivate::setShowRelativeLineNumbers);
|
||||
connect(theFakeVimSetting(ConfigBlinkingCursor), &SavedAction::valueChanged,
|
||||
this, &FakeVimPluginPrivate::updateCursorBlinking);
|
||||
|
||||
// Delayed operations.
|
||||
connect(this, &FakeVimPluginPrivate::delayedQuitRequested,
|
||||
@@ -1235,6 +1243,8 @@ bool FakeVimPluginPrivate::initialize()
|
||||
maybeReadVimRc();
|
||||
// << "MODE: " << theFakeVimSetting(ConfigUseFakeVim)->value();
|
||||
|
||||
updateCursorBlinking(theFakeVimSetting(ConfigBlinkingCursor)->value());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1854,6 +1864,7 @@ void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value)
|
||||
Find::setUseFakeVim(on);
|
||||
setUseFakeVimInternal(on);
|
||||
setShowRelativeLineNumbers(theFakeVimSetting(ConfigRelativeNumber)->value());
|
||||
updateCursorBlinking(theFakeVimSetting(ConfigBlinkingCursor)->value());
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
||||
@@ -1884,6 +1895,15 @@ void FakeVimPluginPrivate::setShowRelativeLineNumbers(const QVariant &value)
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::updateCursorBlinking(const QVariant &value)
|
||||
{
|
||||
if (m_savedCursorFlashTime == 0)
|
||||
m_savedCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime();
|
||||
|
||||
bool blink = value.toBool() || !theFakeVimSetting(ConfigUseFakeVim)->value().toBool();
|
||||
QGuiApplication::styleHints()->setCursorFlashTime(blink ? m_savedCursorFlashTime : 0);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::handleExCommand(FakeVimHandler *handler, bool *handled, const ExCommand &cmd)
|
||||
{
|
||||
QTC_ASSERT(handler, return);
|
||||
|
Reference in New Issue
Block a user