-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing tap gestures to undo, redo and some other stuff, as well as different rotation modes when twisting. Can be configured in the preferences under the new Touch tab. Implements #1174.
- Loading branch information
1 parent
2b5c177
commit a9a838f
Showing
21 changed files
with
547 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "desktop/dialogs/settingsdialog/touch.h" | ||
#include "desktop/settings.h" | ||
#include "desktop/utils/widgetutils.h" | ||
#include <QButtonGroup> | ||
#include <QComboBox> | ||
#include <QFormLayout> | ||
#include <QVBoxLayout> | ||
#include <QWidget> | ||
|
||
namespace dialogs { | ||
namespace settingsdialog { | ||
|
||
Touch::Touch(desktop::settings::Settings &settings, QWidget *parent) | ||
: Page(parent) | ||
{ | ||
init(settings); | ||
} | ||
|
||
void Touch::setUp(desktop::settings::Settings &settings, QVBoxLayout *layout) | ||
{ | ||
initMode(settings, utils::addFormSection(layout)); | ||
utils::addFormSeparator(layout); | ||
initTouchActions(settings, utils::addFormSection(layout)); | ||
utils::addFormSeparator(layout); | ||
initTapActions(settings, utils::addFormSection(layout)); | ||
} | ||
|
||
void Touch::initMode(desktop::settings::Settings &settings, QFormLayout *form) | ||
{ | ||
QButtonGroup *touchMode = utils::addRadioGroup( | ||
form, tr("Touch mode:"), true, | ||
{ | ||
{tr("Touchscreen"), false}, | ||
{tr("Gestures"), true}, | ||
}); | ||
settings.bindTouchGestures(touchMode); | ||
} | ||
|
||
void Touch::initTapActions( | ||
desktop::settings::Settings &settings, QFormLayout *form) | ||
{ | ||
QComboBox *oneFingerTap = new QComboBox; | ||
QComboBox *twoFingerTap = new QComboBox; | ||
QComboBox *threeFingerTap = new QComboBox; | ||
QComboBox *fourFingerTap = new QComboBox; | ||
for(QComboBox *tap : | ||
{oneFingerTap, twoFingerTap, threeFingerTap, fourFingerTap}) { | ||
tap->addItem( | ||
tr("No action"), int(desktop::settings::TouchTapAction::Nothing)); | ||
tap->addItem(tr("Undo"), int(desktop::settings::TouchTapAction::Undo)); | ||
tap->addItem(tr("Redo"), int(desktop::settings::TouchTapAction::Redo)); | ||
tap->addItem( | ||
tr("Hide docks"), | ||
int(desktop::settings::TouchTapAction::HideDocks)); | ||
tap->addItem( | ||
tr("Toggle color picker"), | ||
int(desktop::settings::TouchTapAction::ColorPicker)); | ||
tap->addItem( | ||
tr("Toggle eraser"), | ||
int(desktop::settings::TouchTapAction::Eraser)); | ||
tap->addItem( | ||
tr("Toggle erase mode"), | ||
int(desktop::settings::TouchTapAction::EraseMode)); | ||
tap->addItem( | ||
tr("Toggle recolor mode"), | ||
int(desktop::settings::TouchTapAction::RecolorMode)); | ||
} | ||
|
||
settings.bindOneFingerTap(oneFingerTap, Qt::UserRole); | ||
settings.bindTwoFingerTap(twoFingerTap, Qt::UserRole); | ||
settings.bindThreeFingerTap(threeFingerTap, Qt::UserRole); | ||
settings.bindFourFingerTap(fourFingerTap, Qt::UserRole); | ||
|
||
settings.bindTouchGestures(twoFingerTap, &QComboBox::setDisabled); | ||
settings.bindTouchGestures(threeFingerTap, &QComboBox::setDisabled); | ||
settings.bindTouchGestures(fourFingerTap, &QComboBox::setDisabled); | ||
|
||
form->addRow(tr("One-finger tap:"), oneFingerTap); | ||
form->addRow(tr("Two-finger tap:"), twoFingerTap); | ||
form->addRow(tr("Three-finger tap:"), threeFingerTap); | ||
form->addRow(tr("Four-finger tap:"), fourFingerTap); | ||
} | ||
|
||
void Touch::initTouchActions( | ||
desktop::settings::Settings &settings, QFormLayout *form) | ||
{ | ||
QComboBox *oneFingerTouch = new QComboBox; | ||
oneFingerTouch->setSizeAdjustPolicy(QComboBox::AdjustToContents); | ||
oneFingerTouch->addItem( | ||
tr("No action"), int(desktop::settings::OneFingerTouchAction::Nothing)); | ||
oneFingerTouch->addItem( | ||
tr("Draw"), int(desktop::settings::OneFingerTouchAction::Draw)); | ||
oneFingerTouch->addItem( | ||
tr("Pan canvas"), int(desktop::settings::OneFingerTouchAction::Pan)); | ||
oneFingerTouch->addItem( | ||
tr("Guess"), int(desktop::settings::OneFingerTouchAction::Guess)); | ||
settings.bindOneFingerTouch(oneFingerTouch, Qt::UserRole); | ||
form->addRow(tr("One-finger touch:"), oneFingerTouch); | ||
|
||
QComboBox *twoFingerPinch = new QComboBox; | ||
twoFingerPinch->setSizeAdjustPolicy(QComboBox::AdjustToContents); | ||
twoFingerPinch->addItem( | ||
tr("No action"), int(desktop::settings::TwoFingerPinchAction::Nothing)); | ||
twoFingerPinch->addItem( | ||
tr("Zoom"), int(desktop::settings::TwoFingerPinchAction::Zoom)); | ||
settings.bindTwoFingerPinch(twoFingerPinch, Qt::UserRole); | ||
form->addRow(tr("Two-finger pinch:"), twoFingerPinch); | ||
|
||
QComboBox *twoFingerTwist = new QComboBox; | ||
twoFingerTwist->setSizeAdjustPolicy(QComboBox::AdjustToContents); | ||
twoFingerTwist->addItem( | ||
tr("No action"), int(desktop::settings::TwoFingerPinchAction::Nothing)); | ||
twoFingerTwist->addItem( | ||
tr("Rotate canvas"), | ||
int(desktop::settings::TwoFingerTwistAction::Rotate)); | ||
twoFingerTwist->addItem( | ||
tr("Free rotate canvas"), | ||
int(desktop::settings::TwoFingerTwistAction::RotateNoSnap)); | ||
twoFingerTwist->addItem( | ||
tr("Ratchet rotate canvas"), | ||
int(desktop::settings::TwoFingerTwistAction::RotateDiscrete)); | ||
settings.bindTwoFingerTwist(twoFingerTwist, Qt::UserRole); | ||
form->addRow(tr("Two-finger twist:"), twoFingerTwist); | ||
} | ||
|
||
} // namespace settingsdialog | ||
} // namespace dialogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#ifndef DESKTOP_DIALOGS_SETTINGSDIALOG_TOUCH_H | ||
#define DESKTOP_DIALOGS_SETTINGSDIALOG_TOUCH_H | ||
#include "desktop/dialogs/settingsdialog/page.h" | ||
|
||
class QFormLayout; | ||
|
||
namespace desktop { | ||
namespace settings { | ||
class Settings; | ||
} | ||
} | ||
|
||
namespace dialogs { | ||
namespace settingsdialog { | ||
|
||
class Touch final : public Page { | ||
Q_OBJECT | ||
public: | ||
Touch(desktop::settings::Settings &settings, QWidget *parent = nullptr); | ||
|
||
protected: | ||
void | ||
setUp(desktop::settings::Settings &settings, QVBoxLayout *layout) override; | ||
|
||
private: | ||
void initMode(desktop::settings::Settings &settings, QFormLayout *form); | ||
|
||
void | ||
initTapActions(desktop::settings::Settings &settings, QFormLayout *form); | ||
|
||
void | ||
initTouchActions(desktop::settings::Settings &settings, QFormLayout *form); | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.