Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_key_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 <QWidgetAction>
11#include <QMenu>
12#include <QTimer>
13
14#include "kis_icon_utils.h"
15
16#include "ui_kis_key_input_editor.h"
17
19{
20public:
21 Private() { }
22
23 Ui::KisKeyInputEditor *ui {nullptr};
24};
25
27 : QPushButton(parent), d(new Private)
28{
29 QWidget *popup = new QWidget();
30
31 d->ui = new Ui::KisKeyInputEditor;
32 d->ui->setupUi(popup);
33
34 d->ui->clearKeysButton->setIcon(KisIconUtils::loadIcon("edit-clear"));
35
36 QWidgetAction *action = new QWidgetAction(this);
37 action->setDefaultWidget(popup);
38
39 QMenu *menu = new QMenu(this);
40 menu->addAction(action);
41 setMenu(menu);
42
43 QTimer::singleShot(0, this, SLOT(showMenu()));
44
45 connect(d->ui->keysButton, SIGNAL(dataChanged()), SLOT(updateLabel()));
46 connect(d->ui->clearKeysButton, SIGNAL(clicked(bool)), d->ui->keysButton, SLOT(clear()));
47}
48
50{
51 delete d->ui;
52 delete d;
53}
54
56{
57 return d->ui->keysButton->keys();
58}
59
61{
62 d->ui->keysButton->setKeys(newKeys);
64}
65
67{
68 setText(KisShortcutConfiguration::keysToText(d->ui->keysButton->keys()));
69}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisKeyInputEditor(QWidget *parent=nullptr)
QList< Qt::Key > keys() const
void setKeys(const QList< Qt::Key > &newKeys)
static QString keysToText(const QList< Qt::Key > &keys)
QIcon loadIcon(const QString &name)