Skip to content

Commit

Permalink
Supported "kinetic scrolling" as an option in Kvantum Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujan committed Oct 10, 2019
1 parent a943331 commit 3413464
Show file tree
Hide file tree
Showing 25 changed files with 4,886 additions and 4,565 deletions.
4 changes: 4 additions & 0 deletions Kvantum/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
V0.12.1
---------
* Added a hacking option for kinetic scrolling to Kvantum Manager. Although Qt's kinetic scrolling has bugs, it doesn't cause crashes with Qt ≥ 5.13.1.

V0.12.0
---------
* Basic support for FreeBSD.
Expand Down
2 changes: 1 addition & 1 deletion Kvantum/NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Latest version:

8 Oct 2019, V0.12.1
10 Oct 2019, V0.12.1

See "ChangeLog" for changes.
8 changes: 8 additions & 0 deletions Kvantum/kvantummanager/KvantumManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ KvantumManager::KvantumManager (const QString& lang, QWidget *parent) : QMainWin
modifiedSuffix_ = " (" + tr ("modified") + ")";
kvDefault_ = "Kvantum (" + tr ("default") + ")";

#if (QT_VERSION < QT_VERSION_CHECK(5,13,1))
ui->checkBoxKineticScrolling->setEnabled (false);
#endif

ui->openTheme->setIcon(symbolicIcon::icon (":/Icons/data/document-open.svg"));
ui->deleteTheme->setIcon(symbolicIcon::icon (":/Icons/data/edit-delete.svg"));
ui->useTheme->setIcon(symbolicIcon::icon (":/Icons/data/dialog-ok.svg"));
Expand Down Expand Up @@ -881,6 +885,7 @@ void KvantumManager::defaultThemeButtons()
ui->checkBoxDark->setChecked (defaultSettings.value ("respect_darkness").toBool());
ui->checkBoxGrip->setChecked (defaultSettings.value ("force_size_grip").toBool());
ui->checkBoxScrollJump->setChecked (defaultSettings.value ("middle_click_scroll").toBool());
ui->checkBoxKineticScrolling->setChecked (defaultSettings.value ("kinetic_scrolling").toBool());
ui->checkBoxJumpWorkaround->setChecked (defaultSettings.value ("scroll_jump_workaround").toBool());
ui->checkBoxNormalBtn->setChecked (defaultSettings.value ("normal_default_pushbutton").toBool());
ui->checkBoxIconlessBtn->setChecked (defaultSettings.value ("iconless_pushbutton").toBool());
Expand Down Expand Up @@ -1394,6 +1399,7 @@ void KvantumManager::tabChanged (int index)
ui->checkBoxDark->setChecked (themeSettings.value ("respect_darkness").toBool());
ui->checkBoxGrip->setChecked (themeSettings.value ("force_size_grip").toBool());
ui->checkBoxScrollJump->setChecked (themeSettings.value ("middle_click_scroll").toBool());
ui->checkBoxKineticScrolling->setChecked (themeSettings.value ("kinetic_scrolling").toBool());
ui->checkBoxJumpWorkaround->setChecked (themeSettings.value ("scroll_jump_workaround").toBool());
ui->checkBoxNormalBtn->setChecked (themeSettings.value ("normal_default_pushbutton").toBool());
ui->checkBoxIconlessBtn->setChecked (themeSettings.value ("iconless_pushbutton").toBool());
Expand Down Expand Up @@ -2090,6 +2096,7 @@ void KvantumManager::writeConfig()
hackKeys.insert("respect_darkness", boolToStr (ui->checkBoxDark->isChecked()));
hackKeys.insert("force_size_grip", boolToStr (ui->checkBoxGrip->isChecked()));
hackKeys.insert("middle_click_scroll", boolToStr (ui->checkBoxScrollJump->isChecked()));
hackKeys.insert("kinetic_scrolling", boolToStr (ui->checkBoxKineticScrolling->isChecked()));
hackKeys.insert("scroll_jump_workaround", boolToStr (ui->checkBoxJumpWorkaround->isChecked()));
hackKeys.insert("normal_default_pushbutton", boolToStr (ui->checkBoxNormalBtn->isChecked()));
hackKeys.insert("iconless_pushbutton", boolToStr (ui->checkBoxIconlessBtn->isChecked()));
Expand Down Expand Up @@ -2164,6 +2171,7 @@ void KvantumManager::writeConfig()
if (themeSettings.value ("normal_default_pushbutton").toBool() != ui->checkBoxNormalBtn->isChecked()
|| themeSettings.value ("iconless_pushbutton").toBool() != ui->checkBoxIconlessBtn->isChecked()
|| themeSettings.value ("middle_click_scroll").toBool() != ui->checkBoxScrollJump->isChecked()
|| themeSettings.value ("kinetic_scrolling").toBool() != ui->checkBoxKineticScrolling->isChecked()
|| themeSettings.value ("opaque_colors").toBool() != ui->checkBoxOpaqueColors->isChecked()
|| qMin(qMax(themeSettings.value ("tint_on_mouseover").toInt(),0),100) != ui->spinTint->value()
|| qMin(qMax(themeSettings.value ("disabled_icon_opacity").toInt(),0),100) != ui->spinOpacity->value())
Expand Down
518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_be.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_cs.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_cy.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_de.ts

Large diffs are not rendered by default.

522 changes: 270 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_eo.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_es.ts

Large diffs are not rendered by default.

530 changes: 272 additions & 258 deletions Kvantum/kvantummanager/data/translations/kvantummanager_et.ts

Large diffs are not rendered by default.

520 changes: 267 additions & 253 deletions Kvantum/kvantummanager/data/translations/kvantummanager_fr.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_id.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_it.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_ja.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_lt.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_nb_NO.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_nl.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_pl.ts

Large diffs are not rendered by default.

518 changes: 266 additions & 252 deletions Kvantum/kvantummanager/data/translations/kvantummanager_pt_BR.ts

Large diffs are not rendered by default.

520 changes: 267 additions & 253 deletions Kvantum/kvantummanager/data/translations/kvantummanager_sk_SK.ts

Large diffs are not rendered by default.

52 changes: 33 additions & 19 deletions Kvantum/kvantummanager/kvantummanager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,21 @@ as far as possible.</string>
</property>
</widget>
</item>
<item row="7" column="3">
<item row="8" column="1">
<widget class="QCheckBox" name="checkBoxGrip">
<property name="toolTip">
<string>Show size grips of dialogs and statusbars
as far as possible.</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show size grips of dialogs and statusbars as far as possible?&lt;/p&gt;&lt;p&gt;By default, the application decides whether they should be shown, but this hack could be useful for resizing windows easily when there is no window border.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Force size grips</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QLabel" name="labelTint">
<property name="toolTip">
<string>The highlight color is used for tinting.
Expand All @@ -630,7 +644,7 @@ Hard-coded icons/styles may not respect this key.</string>
</property>
</widget>
</item>
<item row="7" column="4">
<item row="8" column="4">
<widget class="QSpinBox" name="spinTint">
<property name="toolTip">
<string>The highlight color is used for tinting.
Expand All @@ -647,21 +661,18 @@ Hard-coded icons/styles may not respect this key.</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="checkBoxGrip">
<item row="9" column="1">
<widget class="QCheckBox" name="checkBoxScrollJump">
<property name="toolTip">
<string>Show size grips of dialogs and statusbars
as far as possible.</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show size grips of dialogs and statusbars as far as possible?&lt;/p&gt;&lt;p&gt;By default, the application decides whether they should be shown, but this hack could be useful for resizing windows easily when there is no window border.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>By default, the scroll slider jumps to a position
when the scrollbar is left clicked.</string>
</property>
<property name="text">
<string>Force size grips</string>
<string>Scroll jump with middle click</string>
</property>
</widget>
</item>
<item row="8" column="3">
<item row="9" column="3">
<widget class="QLabel" name="labelOpacity">
<property name="toolTip">
<string>Useful with monochrome icon sets and
Expand All @@ -676,7 +687,7 @@ reduced by other means.</string>
</property>
</widget>
</item>
<item row="8" column="4">
<item row="9" column="4">
<widget class="QSpinBox" name="spinOpacity">
<property name="toolTip">
<string>Useful with monochrome icon sets and
Expand All @@ -697,18 +708,21 @@ reduced by other means.</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="checkBoxScrollJump">
<item row="10" column="1">
<widget class="QCheckBox" name="checkBoxKineticScrolling">
<property name="toolTip">
<string>By default, the scroll slider jumps to a position
when the scrollbar is left clicked.</string>
<string>Scroll some scrollable widgets by flicking them
with the left mouse button.

Warning: Qt's kinetic scrolling has bugs and may
seriously interfere with other jobs.</string>
</property>
<property name="text">
<string>Scroll jump with middle click</string>
<string>Kinetic scrolling</string>
</property>
</widget>
</item>
<item row="9" column="3">
<item row="10" column="3">
<widget class="QLabel" name="labelLxqtMenu">
<property name="toolTip">
<string>Has effect only when the main menu is NOT styled by LXQt.
Expand All @@ -723,7 +737,7 @@ or through logging out and in again.</string>
</property>
</widget>
</item>
<item row="9" column="4">
<item row="10" column="4">
<widget class="QSpinBox" name="spinLxqtMenu">
<property name="toolTip">
<string>Has effect only when the main menu is NOT styled by LXQt.
Expand Down
35 changes: 34 additions & 1 deletion Kvantum/style/polishing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <QDialog>
#include <QLayout> // only for forceSizeGrip
#include <QCompleter> // only for combo menu change in Kvantum Manager
#include <QScroller>

namespace Kvantum
{
Expand Down Expand Up @@ -771,11 +772,26 @@ void Style::polish(QWidget *widget)
}
else if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea*>(widget))
{
QWidget *vp = sa->viewport();
#if (QT_VERSION >= QT_VERSION_CHECK(5,13,1))
if(hspec_.kinetic_scrolling
&& vp && !vp->testAttribute(Qt::WA_StyleSheetTarget) && !QScroller::hasScroller(vp)
&& !widget->autoFillBackground() && !widget->inherits("QComboBoxListView")
&& !widget->inherits("QTextEdit") && !widget->inherits("QPlainTextEdit")
&& !widget->inherits("KSignalPlotter"))
{
QScroller::grabGesture(vp, QScroller::LeftMouseButtonGesture);
auto sp = QScroller::scroller(vp)->scrollerProperties();
sp.setScrollMetric(QScrollerProperties::OvershootScrollTime, static_cast<qreal>(0.3));
sp.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, static_cast<qreal>(0.1));
sp.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, static_cast<qreal>(0.1));
QScroller::scroller(vp)->setScrollerProperties(sp);
}
#endif
if (/*sa->frameShape() == QFrame::NoFrame &&*/ // Krita and digiKam aren't happy with this
sa->backgroundRole() == QPalette::Window
|| sa->backgroundRole() == QPalette::Button) // inside toolbox
{
QWidget *vp = sa->viewport();
if (vp && (vp->backgroundRole() == QPalette::Window
|| vp->backgroundRole() == QPalette::Button))
{ // remove ugly flat backgrounds (when the window backround is styled)
Expand Down Expand Up @@ -1101,6 +1117,23 @@ void Style::unpolish(QWidget *widget)
else if (qobject_cast<QToolBox*>(widget))
widget->setBackgroundRole(QPalette::Button);

#if (QT_VERSION >= QT_VERSION_CHECK(5,13,1))
if (hspec_.kinetic_scrolling)
{
if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea*>(widget))
{
QWidget *vp = sa->viewport();
if (vp && !vp->testAttribute(Qt::WA_StyleSheetTarget)
&& !widget->autoFillBackground() && !widget->inherits("QComboBoxListView")
&& !widget->inherits("QTextEdit") && !widget->inherits("QPlainTextEdit")
&& !widget->inherits("KSignalPlotter"))
{
QScroller::ungrabGesture(vp);
}
}
}
#endif

if (qobject_cast<QMenu*>(widget) || widget->inherits("QTipLabel"))
{
if (blurHelper_)
Expand Down
3 changes: 3 additions & 0 deletions Kvantum/style/themeconfig/ThemeConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ hacks_spec ThemeConfig::getHacksSpec() const
v = getValue(KSL("Hacks"),KSL("middle_click_scroll"));
r.middle_click_scroll = v.toBool();

v = getValue(KSL("Hacks"),KSL("kinetic_scrolling"));
r.kinetic_scrolling = v.toBool();

v = getValue(KSL("Hacks"),KSL("scroll_jump_workaround"));
r.scroll_jump_workaround = v.toBool();

Expand Down
3 changes: 3 additions & 0 deletions Kvantum/style/themeconfig/specs.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ typedef struct {
/* should the scroll jump be done by middle clicking?
(By default, it's done by left clicking.) */
bool middle_click_scroll;
/* enable kinetic scrolling? */
bool kinetic_scrolling;
/* workaround for annoying Qt5 scroll jumps? */
bool scroll_jump_workaround;
} hacks_spec;
Expand Down Expand Up @@ -609,6 +611,7 @@ static inline void default_hacks_spec(hacks_spec &hspec) {
hspec.iconless_menu = false;
hspec.single_top_toolbar = false;
hspec.middle_click_scroll = false;
hspec.kinetic_scrolling = false;
hspec.scroll_jump_workaround = false;
}
}
Expand Down

0 comments on commit 3413464

Please sign in to comment.