feat: support horizontal scroll modifiers

This commit is contained in:
sithlord48
2026-02-13 17:29:35 -05:00
committed by Chris Rizzitello
parent f6b1546f8b
commit 042abd699d
11 changed files with 262 additions and 137 deletions

View File

@ -204,7 +204,7 @@ QVariant Settings::defaultValue(const QString &key)
if (key == Daemon::LogFile)
return QStringLiteral("%1/%2-daemon.log").arg(Settings::settingsPath(), kAppId);
if (key == Client::YScrollScale)
if (key == Client::YScrollScale || key == Client::XScrollScale)
return 1.0;
return QVariant();

View File

@ -35,7 +35,9 @@ public:
struct Client
{
inline static const auto InvertYScroll = QStringLiteral("client/invertYScroll");
inline static const auto InvertXScroll = QStringLiteral("client/invertXScroll");
inline static const auto YScrollScale = QStringLiteral("client/yScrollScale");
inline static const auto XScrollScale = QStringLiteral("client/xScrollScale");
inline static const auto LanguageSync = QStringLiteral("client/languageSync");
inline static const auto RemoteHost = QStringLiteral("client/remoteHost");
inline static const auto XdpRestoreToken = QStringLiteral("client/xdpRestoreToken");
@ -192,9 +194,11 @@ private:
inline static const QStringList m_validKeys = {
Settings::Client::InvertYScroll
, Settings::Client::InvertXScroll
, Settings::Client::LanguageSync
, Settings::Client::RemoteHost
, Settings::Client::YScrollScale
, Settings::Client::XScrollScale
, Settings::Client::XdpRestoreToken
, Settings::Core::CoreMode
, Settings::Core::Interface
@ -247,6 +251,7 @@ private:
, Settings::Core::UseWlClipboard
, Settings::Server::ExternalConfig
, Settings::Client::InvertYScroll
, Settings::Client::InvertXScroll
, Settings::Log::ToFile
, Settings::Log::GuiDebug
};

View File

@ -22,8 +22,10 @@ class ISecondaryScreen
public:
ISecondaryScreen()
{
m_invertScroll = Settings::value(Settings::Client::InvertYScroll).toBool();
m_scrollScale = std::clamp(Settings::value(Settings::Client::YScrollScale).toDouble(), 0.1, 10.0);
m_invertYScroll = Settings::value(Settings::Client::InvertYScroll).toBool();
m_yScrollScale = std::clamp(Settings::value(Settings::Client::YScrollScale).toDouble(), 0.1, 10.0);
m_invertXScroll = Settings::value(Settings::Client::InvertXScroll).toBool();
m_xScrollScale = std::clamp(Settings::value(Settings::Client::XScrollScale).toDouble(), 0.1, 10.0);
}
virtual ~ISecondaryScreen() = default;
@ -63,21 +65,34 @@ public:
*/
ScrollDelta applyScrollModifier(ScrollDelta delta) const
{
delta.y = static_cast<int32_t>(m_invertScroll ? delta.y * -m_scrollScale : delta.y * m_scrollScale);
delta.y = static_cast<int32_t>(m_invertYScroll ? delta.y * -m_yScrollScale : delta.y * m_yScrollScale);
delta.x = static_cast<int32_t>(m_invertXScroll ? delta.x * -m_xScrollScale : delta.x * m_xScrollScale);
return delta;
}
private:
/**
* @brief this member is used to modify the scroll direction.
* @brief this member is used to modify the verical scroll direction.
* It is used in the applyScrollModifier method
*/
bool m_invertScroll = false;
bool m_invertYScroll = false;
/**
* @brief this member is used to modify the scroll scale.
* @brief this member is used to modify the vertical scroll scale.
* It is used in the applyScrollModifier method
*/
double m_scrollScale = 1.0;
double m_yScrollScale = 1.0;
/**
* @brief this member is used to modify the horizontal scroll direction.
* It is used in the applyScrollModifier method
*/
bool m_invertXScroll = false;
/**
* @brief this member is used to modify the horizontal scroll scale.
* It is used in the applyScrollModifier method
*/
double m_xScrollScale = 1.0;
//@}
};

View File

@ -55,20 +55,26 @@ void ClientConfigDialog::initConnections() const
connect(ui->cbLanguageSync, &QCheckBox::checkStateChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons);
connect(ui->cbYScrollInvert, &QCheckBox::checkStateChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons);
connect(ui->sbYScrollScale, &QDoubleSpinBox::valueChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons);
connect(ui->cbXScrollInvert, &QCheckBox::checkStateChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons);
connect(ui->sbXScrollScale, &QDoubleSpinBox::valueChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons);
}
bool ClientConfigDialog::isModified() const
{
return (ui->cbLanguageSync->isChecked() != Settings::value(Settings::Client::LanguageSync).toBool()) ||
(ui->cbYScrollInvert->isChecked() != Settings::value(Settings::Client::InvertYScroll).toBool()) ||
(ui->sbYScrollScale->value() != Settings::value(Settings::Client::YScrollScale).toDouble());
(ui->sbYScrollScale->value() != Settings::value(Settings::Client::YScrollScale).toDouble()) ||
(ui->cbXScrollInvert->isChecked() != Settings::value(Settings::Client::InvertXScroll).toBool()) ||
(ui->sbXScrollScale->value() != Settings::value(Settings::Client::XScrollScale).toDouble());
}
bool ClientConfigDialog::isDefault() const
{
return (ui->cbLanguageSync->isChecked() == Settings::defaultValue(Settings::Client::LanguageSync).toBool()) &&
(ui->cbYScrollInvert->isChecked() == Settings::defaultValue(Settings::Client::InvertYScroll).toBool()) &&
(ui->sbYScrollScale->value() == Settings::defaultValue(Settings::Client::YScrollScale).toDouble());
(ui->sbYScrollScale->value() == Settings::defaultValue(Settings::Client::YScrollScale).toDouble()) &&
(ui->cbXScrollInvert->isChecked() == Settings::defaultValue(Settings::Client::InvertXScroll).toBool()) &&
(ui->sbXScrollScale->value() == Settings::defaultValue(Settings::Client::XScrollScale).toDouble());
}
void ClientConfigDialog::setButtonBoxEnabledButtons() const
@ -84,6 +90,8 @@ void ClientConfigDialog::load()
ui->cbLanguageSync->setChecked(Settings::value(Settings::Client::LanguageSync).toBool());
ui->cbYScrollInvert->setChecked(Settings::value(Settings::Client::InvertYScroll).toBool());
ui->sbYScrollScale->setValue(Settings::value(Settings::Client::YScrollScale).toDouble());
ui->cbXScrollInvert->setChecked(Settings::value(Settings::Client::InvertXScroll).toBool());
ui->sbXScrollScale->setValue(Settings::value(Settings::Client::XScrollScale).toDouble());
}
void ClientConfigDialog::resetToDefault()
@ -91,6 +99,8 @@ void ClientConfigDialog::resetToDefault()
ui->cbLanguageSync->setChecked(Settings::defaultValue(Settings::Client::LanguageSync).toBool());
ui->cbYScrollInvert->setChecked(Settings::defaultValue(Settings::Client::InvertYScroll).toBool());
ui->sbYScrollScale->setValue(Settings::defaultValue(Settings::Client::YScrollScale).toDouble());
ui->cbXScrollInvert->setChecked(Settings::defaultValue(Settings::Client::InvertXScroll).toBool());
ui->sbXScrollScale->setValue(Settings::defaultValue(Settings::Client::XScrollScale).toDouble());
}
void ClientConfigDialog::save()
@ -98,5 +108,7 @@ void ClientConfigDialog::save()
Settings::setValue(Settings::Client::LanguageSync, ui->cbLanguageSync->isChecked());
Settings::setValue(Settings::Client::InvertYScroll, ui->cbYScrollInvert->isChecked());
Settings::setValue(Settings::Client::YScrollScale, ui->sbYScrollScale->value());
Settings::setValue(Settings::Client::InvertXScroll, ui->cbXScrollInvert->isChecked());
Settings::setValue(Settings::Client::XScrollScale, ui->sbXScrollScale->value());
QDialog::accept();
}

View File

@ -2,14 +2,6 @@
<ui version="4.0">
<class>ClientConfigDialog</class>
<widget class="QDialog" name="ClientConfigDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>148</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
@ -28,70 +20,132 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbYScrollInvert">
<property name="text">
<string>Invert vertical scroll direction on this computer</string>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Scroll Modifiers</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="2">
<widget class="QCheckBox" name="cbYScrollInvert">
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="cbXScrollInvert">
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item row="5" column="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="lblScrollSpeed">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbYScrollScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="4">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="lblXScrollSpeed">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbXScrollScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="lblHScroll">
<property name="text">
<string>Horizontal Scroll</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="lblVScroll">
<property name="text">
<string>Vertical Scroll</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="lblScrollSpeed">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical Scroll Scale</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbYScrollScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@ -105,38 +159,5 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ClientConfigDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ClientConfigDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -150,12 +150,24 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished">Utilice el idioma del teclado del servidor en esta computadora</translation>
</message>
<message>
<source>Invert vertical scroll direction on this computer</source>
<translation type="unfinished">Invertir la dirección del desplazamiento vertical en este ordenador</translation>
<source>Scroll Modifiers</source>
<translation type="unfinished">Modificadores de desplazamiento</translation>
</message>
<message>
<source>Vertical Scroll Scale</source>
<translation type="unfinished">Escala de desplazamiento vertical</translation>
<source>Invert</source>
<translation type="unfinished">Invertir</translation>
</message>
<message>
<source>Horizontal Scroll</source>
<translation type="unfinished">Desplazamiento horizontal</translation>
</message>
<message>
<source>Vertical Scroll</source>
<translation type="unfinished">Desplazamiento vertical</translation>
</message>
<message>
<source>Scale</source>
<translation type="unfinished">Escala</translation>
</message>
<message>
<source>Close and save changes</source>

View File

@ -150,12 +150,24 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished">Usa la lingua della tastiera del server su questo computer</translation>
</message>
<message>
<source>Invert vertical scroll direction on this computer</source>
<translation type="unfinished">Inverti la direzione dello scorrimento verticale su questo computer</translation>
<source>Scroll Modifiers</source>
<translation type="unfinished">Modificatori di scorrimento</translation>
</message>
<message>
<source>Vertical Scroll Scale</source>
<translation type="unfinished">Scala di scorrimento verticale</translation>
<source>Invert</source>
<translation type="unfinished">Invertire</translation>
</message>
<message>
<source>Horizontal Scroll</source>
<translation type="unfinished">Scorrimento orizzontale</translation>
</message>
<message>
<source>Vertical Scroll</source>
<translation type="unfinished">Scorrimento verticale</translation>
</message>
<message>
<source>Scale</source>
<translation type="unfinished">Scala</translation>
</message>
<message>
<source>Close and save changes</source>

View File

@ -150,12 +150,24 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished">使</translation>
</message>
<message>
<source>Invert vertical scroll direction on this computer</source>
<translation type="unfinished"></translation>
<source>Scroll Modifiers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vertical Scroll Scale</source>
<translation type="unfinished"></translation>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Horizontal Scroll</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vertical Scroll</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scale</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Close and save changes</source>

View File

@ -150,12 +150,24 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished"> </translation>
</message>
<message>
<source>Invert vertical scroll direction on this computer</source>
<translation type="unfinished"> </translation>
<source>Scroll Modifiers</source>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Vertical Scroll Scale</source>
<translation type="unfinished"> </translation>
<source>Invert</source>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Horizontal Scroll</source>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Vertical Scroll</source>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Scale</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Close and save changes</source>

View File

@ -150,12 +150,24 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished">Использовать язык клавиатуры сервера на этом компьютере</translation>
</message>
<message>
<source>Invert vertical scroll direction on this computer</source>
<translation type="unfinished">Инвертировать направление вертикальной прокрутки на этом компьютере</translation>
<source>Scroll Modifiers</source>
<translation type="unfinished">Модификаторы прокрутки</translation>
</message>
<message>
<source>Vertical Scroll Scale</source>
<translation type="unfinished">Вертикальная шкала прокрутки</translation>
<source>Invert</source>
<translation type="unfinished">Инвертировать</translation>
</message>
<message>
<source>Horizontal Scroll</source>
<translation type="unfinished">Горизонтальная прокрутка</translation>
</message>
<message>
<source>Vertical Scroll</source>
<translation type="unfinished">Вертикальная прокрутка</translation>
</message>
<message>
<source>Scale</source>
<translation type="unfinished">Шкала</translation>
</message>
<message>
<source>Close and save changes</source>

View File

@ -150,12 +150,24 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished">使</translation>
</message>
<message>
<source>Invert vertical scroll direction on this computer</source>
<translation type="unfinished"></translation>
<source>Scroll Modifiers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vertical Scroll Scale</source>
<translation type="unfinished"></translation>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Horizontal Scroll</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vertical Scroll</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scale</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Close and save changes</source>