Commit 1ee961e4 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Tomaz Canabrava
Browse files

add config option for whether mouse tracking should be enabled by default

parent fb35320c
Pipeline #100615 passed with stage
in 1 minute and 57 seconds
......@@ -130,7 +130,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
{AlternateScrolling, "AlternateScrolling", INTERACTION_GROUP, QVariant::Bool},
{AllowEscapedLinks, "AllowEscapedLinks", INTERACTION_GROUP, QVariant::Bool},
{EscapedLinksSchema, "EscapedLinksSchema", INTERACTION_GROUP, QVariant::String},
{ColorFilterEnabled, "ColorFilterEnabled", INTERACTION_GROUP, QVariant::Bool}
{ColorFilterEnabled, "ColorFilterEnabled", INTERACTION_GROUP, QVariant::Bool},
{AllowMouseTracking, "AllowMouseTracking", INTERACTION_GROUP, QVariant::Bool}
// Encoding
,
......@@ -187,6 +188,7 @@ void Profile::useFallback()
setProperty(TerminalCenter, false);
setProperty(MouseWheelZoomEnabled, true);
setProperty(AlternateScrolling, true);
setProperty(AllowMouseTracking, true);
#ifdef Q_OS_MACOS
setProperty(KeyBindings, QStringLiteral("macos"));
......
......@@ -345,6 +345,9 @@ public:
* when hovered by the mouse pointer.
*/
ColorFilterEnabled,
/** (bool) Allows mouse tracking */
AllowMouseTracking
};
Q_ENUM(Property)
......
......@@ -155,8 +155,10 @@ SessionController::SessionController(Session *sessionParam, TerminalDisplay *vie
connect(view(), &TerminalDisplay::compositeFocusChanged, this, &SessionController::viewFocusChangeHandler);
Profile::Ptr currentProfile = SessionManager::instance()->sessionProfile(session());
// install filter on the view to highlight URLs and files
updateFilterList(SessionManager::instance()->sessionProfile(session()));
updateFilterList(currentProfile);
// listen for changes in session, we might need to change the enabled filters
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, this, &Konsole::SessionController::updateFilterList);
......@@ -236,6 +238,11 @@ SessionController::SessionController(Session *sessionParam, TerminalDisplay *vie
setupSearchBar();
_searchBar->setVisible(_isSearchBarEnabled);
// Setup default state for mouse tracking
const bool allowMouseTracking = currentProfile->property<bool>(Profile::AllowMouseTracking);
view()->setAllowMouseTracking(allowMouseTracking);
actionCollection()->action(QStringLiteral("allow-mouse-tracking"))->setChecked(allowMouseTracking);
}
SessionController::~SessionController()
......@@ -570,7 +577,7 @@ void SessionController::toggleAllowMouseTracking()
return;
}
_view->setAllowMouseTracking(action->isChecked());
_sessionDisplayConnection->view()->setAllowMouseTracking(action->isChecked());
}
void SessionController::removeSearchFilter()
......@@ -747,7 +754,6 @@ void SessionController::setupCommonActions()
action = collection->addAction(QStringLiteral("allow-mouse-tracking"), this, &SessionController::toggleAllowMouseTracking);
action->setText(i18nc("@item:inmenu Allows terminal applications to request mouse tracking", "Allow mouse tracking"));
action->setCheckable(true);
action->setChecked(true); // the default state
// Read-only
action = collection->addAction(QStringLiteral("view-readonly"), this, &SessionController::toggleReadOnly);
......
......@@ -2074,6 +2074,11 @@ void TerminalDisplay::setAllowMouseTracking(bool allow)
resetCursor();
}
bool TerminalDisplay::allowsMouseTracking() const
{
return _allowMouseTracking;
}
void TerminalDisplay::resetCursor()
{
setCursor(usesMouseTracking() ? Qt::ArrowCursor : Qt::IBeamCursor);
......
......@@ -273,6 +273,7 @@ public:
* user turns it on/off while mouse tracking is requested.
*/
void setAllowMouseTracking(const bool allow);
bool allowsMouseTracking() const;
bool hasCompositeFocus() const
{
......
......@@ -719,6 +719,11 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr &profile)
_appearanceUi->useFontLineCharactersButton->setChecked(profile->useFontLineCharacters());
connect(_appearanceUi->useFontLineCharactersButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::useFontLineCharacters);
_mouseUi->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled());
connect(_mouseUi->enableMouseWheelZoomButton, &QCheckBox::toggled, this,
&Konsole::EditProfileDialog::toggleMouseWheelZoom);
// cursor options
_appearanceUi->enableBlinkingCursorButton->setChecked(profile->property<bool>(Profile::BlinkingCursorEnabled));
connect(_appearanceUi->enableBlinkingCursorButton, &QToolButton::toggled, this, &EditProfileDialog::toggleBlinkingCursor);
......@@ -897,6 +902,11 @@ void EditProfileDialog::toggleAllowColorFilter(bool enable)
updateTempProfileProperty(Profile::ColorFilterEnabled, enable);
}
void EditProfileDialog::toggleAllowMouseTracking(bool allow)
{
updateTempProfileProperty(Profile::AllowMouseTracking, allow);
}
void EditProfileDialog::updateColorSchemeList(const QString &selectedColorSchemeName)
{
if (_appearanceUi->colorSchemeList->model() == nullptr) {
......@@ -1614,6 +1624,8 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr &profile)
connect(_mouseUi->enableAlternateScrollingButton, &QPushButton::toggled, this, &EditProfileDialog::toggleAlternateScrolling);
_mouseUi->allowColorFilters->setChecked(profile->property<bool>(Profile::ColorFilterEnabled));
connect(_mouseUi->allowColorFilters, &QPushButton::toggled, this, &EditProfileDialog::toggleAllowColorFilter);
_mouseUi->allowMouseTrackingButton->setChecked(profile->property<bool>(Profile::AllowMouseTracking));
connect(_mouseUi->allowMouseTrackingButton, &QPushButton::toggled, this, &EditProfileDialog::toggleAllowMouseTracking);
// setup middle click paste mode
const auto middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
......
......@@ -195,6 +195,7 @@ private Q_SLOTS:
void pasteFromClipboard();
void toggleAlternateScrolling(bool enable);
void toggleAllowColorFilter(bool enable);
void toggleAllowMouseTracking(bool allow);
void TripleClickModeChanged(int);
void wordCharactersChanged(const QString &);
......
......@@ -446,6 +446,16 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="allowMouseTrackingButton">
<property name="toolTip">
<string>Some terminal applications have mouse support, this allows them to get it by default. It can be toggled on/off while running as well.</string>
</property>
<property name="text">
<string>Allow terminal applications to handle clicks and drags</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment