summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-27 12:38:26 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-28 13:15:51 (GMT)
commit04dce67996a9318494c79c2617e3c88620e8e19e (patch)
tree1e1a41aaef4e84b6da3ea93262529f19a4332886
parent5b11fd593b954504343bdb418c54a8e7913d9c7c (diff)
Make the URL hint keyboard modifiers configurable
Instead of hardcoding CTRL which was a bit annoying add checkboxes to the profile edit dialog to let the user select which keys to use. REVIEW: 128778
-rw-r--r--src/EditProfileDialog.cpp26
-rw-r--r--src/EditProfileDialog.h2
-rw-r--r--src/EditProfileDialog.ui61
-rw-r--r--src/Profile.cpp4
-rw-r--r--src/Profile.h6
-rw-r--r--src/ProfileReader.cpp16
-rw-r--r--src/TerminalDisplay.cpp4
-rw-r--r--src/TerminalDisplay.h14
-rw-r--r--src/ViewManager.cpp2
9 files changed, 98 insertions, 37 deletions
diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp
index a85cd5b..ec3216a 100644
--- a/src/EditProfileDialog.cpp
+++ b/src/EditProfileDialog.cpp
@@ -1066,10 +1066,6 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
{
BooleanOption options[] = {
{
- _ui->enableUrlHints , Profile::EnableUrlHints ,
- SLOT(toggleEnableUrlHints(bool))
- },
- {
_ui->enableBlinkingTextButton , Profile::BlinkingTextEnabled ,
SLOT(toggleBlinkingText(bool))
},
@@ -1089,6 +1085,19 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
};
setupCheckBoxes(options , profile);
+ // Setup the URL hints modifier checkboxes
+ {
+ int modifiers = profile->property<int>(Profile::UrlHintsModifiers);
+ _ui->urlHintsModifierShift->setChecked(modifiers & Qt::ShiftModifier);
+ _ui->urlHintsModifierCtrl->setChecked(modifiers & Qt::ControlModifier);
+ _ui->urlHintsModifierAlt->setChecked(modifiers & Qt::AltModifier);
+ _ui->urlHintsModifierMeta->setChecked(modifiers & Qt::MetaModifier);
+ connect(_ui->urlHintsModifierShift, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier);
+ connect(_ui->urlHintsModifierCtrl, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier);
+ connect(_ui->urlHintsModifierAlt, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier);
+ connect(_ui->urlHintsModifierMeta, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier);
+ }
+
const int lineSpacing = profile->lineSpacing();
_ui->lineSpacingSpinner->setValue(lineSpacing);
@@ -1197,9 +1206,14 @@ void EditProfileDialog::TripleClickModeChanged(int newValue)
{
updateTempProfileProperty(Profile::TripleClickMode, newValue);
}
-void EditProfileDialog::toggleEnableUrlHints(bool enable)
+void EditProfileDialog::updateUrlHintsModifier(bool)
{
- updateTempProfileProperty(Profile::EnableUrlHints, enable);
+ Qt::KeyboardModifiers modifiers;
+ if (_ui->urlHintsModifierShift->isChecked()) modifiers |= Qt::ShiftModifier;
+ if (_ui->urlHintsModifierCtrl->isChecked()) modifiers |= Qt::ControlModifier;
+ if (_ui->urlHintsModifierAlt->isChecked()) modifiers |= Qt::AltModifier;
+ if (_ui->urlHintsModifierMeta->isChecked()) modifiers |= Qt::MetaModifier;
+ updateTempProfileProperty(Profile::UrlHintsModifiers, int(modifiers));
}
void EditProfileDialog::toggleBlinkingText(bool enable)
{
diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h
index 1195c14..bb2896f 100644
--- a/src/EditProfileDialog.h
+++ b/src/EditProfileDialog.h
@@ -174,7 +174,7 @@ private slots:
void togglebidiRendering(bool);
void lineSpacingChanged(int);
void toggleBlinkingCursor(bool);
- void toggleEnableUrlHints(bool);
+ void updateUrlHintsModifier(bool);
void setCursorShape(int);
void autoCursorColor();
diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui
index 1acec37..8358bd3 100644
--- a/src/EditProfileDialog.ui
+++ b/src/EditProfileDialog.ui
@@ -1087,22 +1087,61 @@
</property>
<layout class="QVBoxLayout">
<item>
- <widget class="QCheckBox" name="enableUrlHints">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Show URL hint overlays that can be triggered when holding down CTRL.</string>
- </property>
+ <widget class="QLabel" name="urlHintsLabel">
<property name="text">
- <string>Enable URL hints</string>
+ <string>Show URL hints when these keys are pressed:</string>
</property>
</widget>
</item>
<item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="urlHintsModifierSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="urlHintsModifierShift">
+ <property name="text">
+ <string>Shift</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="urlHintsModifierCtrl">
+ <property name="text">
+ <string>Control</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="urlHintsModifierAlt">
+ <property name="text">
+ <string>Alt</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="urlHintsModifierMeta">
+ <property name="text">
+ <string>Meta</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
<widget class="QCheckBox" name="enableBlinkingTextButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
diff --git a/src/Profile.cpp b/src/Profile.cpp
index 06fe5b1..a8cec60 100644
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -91,7 +91,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { ScrollFullPage , "ScrollFullPage" , SCROLLING_GROUP , QVariant::Bool }
// Terminal Features
- , { EnableUrlHints , "EnableUrlHints" , TERMINAL_GROUP , QVariant::Bool }
+ , { UrlHintsModifiers , "UrlHintsModifiers" , TERMINAL_GROUP , QVariant::Int }
, { BlinkingTextEnabled , "BlinkingTextEnabled" , TERMINAL_GROUP , QVariant::Bool }
, { FlowControlEnabled , "FlowControlEnabled" , TERMINAL_GROUP , QVariant::Bool }
, { BidiRenderingEnabled , "BidiRenderingEnabled" , TERMINAL_GROUP , QVariant::Bool }
@@ -176,7 +176,7 @@ FallbackProfile::FallbackProfile()
setProperty(ScrollFullPage, false);
setProperty(FlowControlEnabled, true);
- setProperty(EnableUrlHints, false);
+ setProperty(UrlHintsModifiers, 0);
setProperty(BlinkingTextEnabled, true);
setProperty(UnderlineLinksEnabled, true);
setProperty(OpenLinksByDirectClickEnabled, false);
diff --git a/src/Profile.h b/src/Profile.h
index de74afa..84a0acc 100644
--- a/src/Profile.h
+++ b/src/Profile.h
@@ -252,10 +252,8 @@ public:
* increases/decreases the terminal font size.
*/
MouseWheelZoomEnabled,
- /** (bool) Enables showing a hint for all visible URLs
- * which allows activating URLs with the keyboard.
- */
- EnableUrlHints
+ /** (int) Keyboard modifiers to show URL hints */
+ UrlHintsModifiers
};
/**
diff --git a/src/ProfileReader.cpp b/src/ProfileReader.cpp
index 716f9ca..ab8d30a 100644
--- a/src/ProfileReader.cpp
+++ b/src/ProfileReader.cpp
@@ -37,6 +37,9 @@ using namespace Konsole;
// FIXME: A dup line from Profile.cpp - redo these
static const char GENERAL_GROUP[] = "General";
+static const char FEATURES_GROUP[] = "Terminal Features";
+static const char URLHINTS_KEY[] = "EnableUrlHints";
+static const char URLHINTSMODIFIERS_KEY[] = "UrlHintsModifiers";
QStringList KDE4ProfileReader::findProfiles()
{
@@ -94,6 +97,19 @@ bool KDE4ProfileReader::readProfile(const QString& path , Profile::Ptr profile ,
profile->setProperty(Profile::Arguments, shellCommand.arguments());
}
+ // Check if the user earlier had set the URL hints option, and in that case set the default
+ // URL hints modifier to the earlier default.
+ if (config.hasGroup(FEATURES_GROUP)) {
+ KConfigGroup features = config.group(FEATURES_GROUP);
+ if (features.hasKey(URLHINTS_KEY)) {
+ bool enable = features.readEntry(URLHINTS_KEY, false);
+ if (enable && !features.hasKey(URLHINTSMODIFIERS_KEY)) {
+ features.writeEntry(URLHINTSMODIFIERS_KEY, int(Qt::ControlModifier));
+ }
+ features.deleteEntry(URLHINTS_KEY);
+ }
+ }
+
profile->setProperty(Profile::UntranslatedName, general.readEntryUntranslated("Name"));
// Read remaining properties
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index 555a991..abeeda1 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -358,8 +358,8 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
, _textBlinking(false)
, _cursorBlinking(false)
, _hasTextBlinker(false)
+ , _urlHintsModifiers(Qt::NoModifier)
, _showUrlHint(false)
- , _enableShowUrlHint(false)
, _underlineLinks(true)
, _openLinksByDirectClick(false)
, _ctrlRequiredForDrag(true)
@@ -3115,7 +3115,7 @@ void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode m
void TerminalDisplay::keyPressEvent(QKeyEvent* event)
{
- if (_enableShowUrlHint && event->modifiers() & Qt::ControlModifier) {
+ if (event->modifiers() == _urlHintsModifiers) {
int hintSelected = event->key() - 0x31;
if (hintSelected >= 0 && hintSelected < 10 && hintSelected < _filterChain->hotSpots().count()) {
_filterChain->hotSpots().at(hintSelected)->activate();
diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h
index 93c98ab..b3ffba7 100644
--- a/src/TerminalDisplay.h
+++ b/src/TerminalDisplay.h
@@ -461,17 +461,11 @@ public:
}
/**
- * Enables or disables showing hints on URLs when ctrl is pressed
+ * Sets the modifiers that shows URL hints when they are pressed
* Defaults to disabled.
*/
- void setEnableUrlHints(bool on) {
- _enableShowUrlHint = on;
- }
- /**
- * Returns the status of the BiDi rendering in this widget.
- */
- bool areUrlHintsEnabled() const {
- return _enableShowUrlHint;
+ void setUrlHintsModifiers(int modifiers) {
+ _urlHintsModifiers = Qt::KeyboardModifiers(modifiers);
}
/**
@@ -887,8 +881,8 @@ private:
QTimer* _blinkTextTimer;
QTimer* _blinkCursorTimer;
+ Qt::KeyboardModifiers _urlHintsModifiers;
bool _showUrlHint;
- bool _enableShowUrlHint;
bool _underlineLinks; // Underline URL and hosts on mouse hover
bool _openLinksByDirectClick; // Open URL and hosts by single mouse click
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index b1efc0a..ba3b72e 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -813,7 +813,7 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
view->setOpenLinksByDirectClick(profile->property<bool>(Profile::OpenLinksByDirectClickEnabled));
- view->setEnableUrlHints(profile->property<bool>(Profile::EnableUrlHints));
+ view->setUrlHintsModifiers(profile->property<int>(Profile::UrlHintsModifiers));
int middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
if (middleClickPasteMode == Enum::PasteFromX11Selection)