Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_wheel_input_editor.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 * SPDX-FileCopyrightText: 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9
10#include "ui_kis_wheel_input_editor.h"
11#include <QMenu>
12#include <QWidgetAction>
13#include <QTimer>
14
15#include "kis_icon_utils.h"
16
18{
19public:
20 Private() { }
21
22 Ui::KisWheelInputEditor *ui {nullptr};
23};
24
26 : QPushButton(parent), d(new Private)
27{
28 QWidget *popup = new QWidget();
29
30 d->ui = new Ui::KisWheelInputEditor;
31 d->ui->setupUi(popup);
32 d->ui->wheelButton->setType(KisInputButton::WheelType);
33
34 d->ui->clearModifiersButton->setIcon(KisIconUtils::loadIcon("edit-clear"));
35 d->ui->clearWheelButton->setIcon(KisIconUtils::loadIcon("edit-clear"));
36
37 QWidgetAction *action = new QWidgetAction(this);
38 action->setDefaultWidget(popup);
39
40 QMenu *menu = new QMenu(this);
41 menu->addAction(action);
42 setMenu(menu);
43
44 QTimer::singleShot(0, this, SLOT(showMenu()));
45
46 connect(d->ui->wheelButton, SIGNAL(dataChanged()), SLOT(updateLabel()));
47 connect(d->ui->modifiersButton, SIGNAL(dataChanged()), SLOT(updateLabel()));
48 connect(d->ui->clearWheelButton, SIGNAL(clicked(bool)), d->ui->wheelButton, SLOT(clear()));
49 connect(d->ui->clearModifiersButton, SIGNAL(clicked(bool)), d->ui->modifiersButton, SLOT(clear()));
50}
51
53{
54 delete d->ui;
55 delete d;
56}
57
59{
60 return d->ui->modifiersButton->keys();
61}
62
64{
65 d->ui->modifiersButton->setKeys(newKeys);
67}
68
70{
71 return d->ui->wheelButton->wheel();
72}
73
75{
76 d->ui->wheelButton->setWheel(newWheel);
78}
79
81{
83 d->ui->modifiersButton->keys(),
84 d->ui->wheelButton->wheel()));
85}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
@ WheelType
Detect and store mouse wheel movement.
static QString wheelInputToText(const QList< Qt::Key > &keys, MouseWheelMovement wheel)
void setWheel(KisShortcutConfiguration::MouseWheelMovement newWheel)
KisWheelInputEditor(QWidget *parent=nullptr)
KisShortcutConfiguration::MouseWheelMovement wheel() const
void setKeys(const QList< Qt::Key > &newKeys)
QList< Qt::Key > keys() const
QIcon loadIcon(const QString &name)