File indexing completed on 2024-04-28 16:44:48

0001 /* SPDX-FileCopyrightText: 2009 Michael Jansen <kde@michael-jansen.biz>
0002 
0003    SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #include "edit_gesture_dialog.h"
0007 
0008 #include <KLocalizedString>
0009 
0010 #include <QDialogButtonBox>
0011 #include <QLabel>
0012 #include <QLayout>
0013 
0014 EditGestureDialog::EditGestureDialog(const KHotKeys::StrokePoints &pointData, QWidget *parent)
0015     : QDialog(parent)
0016     , _recorder(this)
0017     , _pointData(pointData)
0018 {
0019     setWindowTitle(i18n("Edit Gesture"));
0020 
0021     QString message(
0022         i18n("Draw the gesture you would like to record below. Press "
0023              "and hold the left mouse button while drawing, and release "
0024              "when you have finished."));
0025 
0026     QLabel *label = new QLabel(message, this);
0027     label->setWordWrap(true);
0028 
0029     QVBoxLayout *layout = new QVBoxLayout;
0030     layout->addWidget(label);
0031     layout->addWidget(&_recorder);
0032 
0033     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0034 
0035     layout->addWidget(buttonBox);
0036 
0037     setLayout(layout);
0038 
0039     connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
0040     connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
0041     connect(&_recorder, SIGNAL(recorded(KHotKeys::StrokePoints)), SLOT(recorded(KHotKeys::StrokePoints)));
0042 }
0043 
0044 EditGestureDialog::~EditGestureDialog()
0045 {
0046 }
0047 
0048 KHotKeys::StrokePoints EditGestureDialog::pointData() const
0049 {
0050     return _pointData;
0051 }
0052 
0053 void EditGestureDialog::recorded(const KHotKeys::StrokePoints &data)
0054 {
0055     _pointData = data;
0056     accept();
0057 }
0058 
0059 #include "moc_edit_gesture_dialog.cpp"