1 /****************************************************************************
5 Copyright (C) 2003 Mike Pilone <mpilone@slac.com>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
8 Distributed under the terms of the GNU General Public License version 2.
10 ****************************************************************************/
14 #include <QPushButton>
17 #include <kmessagebox.h>
19 #include "gesturerecordpage.h"
20 #include "gesturerecorder.h"
21 #include "gesturedrawer.h"
26 GestureRecordPage::GestureRecordPage(const QString
&gesture
,
27 QWidget
*parent
, const char *name
)
29 _recorder(NULL
), _resetButton(NULL
),
30 _tryOne(NULL
), _tryTwo(NULL
), _tryThree(NULL
), _gest(QString()),
37 message
= i18n("Draw the gesture you would like to record below. Press "
38 "and hold the left mouse button while drawing, and release "
39 "when you have finished.\n\n"
40 "You will be required to draw the gesture 3 times. After "
41 "each drawing, if they match, the indicators below will "
42 "change to represent which step you are on.\n\n"
43 "If at any point they do not match, you will be required to "
44 "restart. If you want to force a restart, use the reset "
45 "button below.\n\nDraw here:");
47 QLabel
*label
= new QLabel(message
,this);
48 label
->setObjectName("label");
49 label
->setAlignment(Qt::AlignLeft
| Qt::AlignVCenter
);
50 label
->setWordWrap( true );
52 _recorder
= new GestureRecorder(this, "recorder");
53 _recorder
->setMinimumHeight(150);
54 setStretchFactor(_recorder
, 1);
55 connect(_recorder
, SIGNAL(recorded(const QString
&)),
56 this, SLOT(slotRecorded(const QString
&)));
58 KHBox
*hBox
= new KHBox(this);
60 _tryOne
= new GestureDrawer(hBox
, "tryOne");
61 _tryTwo
= new GestureDrawer(hBox
, "tryTwo");
62 _tryThree
= new GestureDrawer(hBox
, "tryThree");
64 QWidget
*spacer
= new QWidget(hBox
);
65 spacer
->setObjectName( "spacer" );
66 hBox
->setStretchFactor(spacer
, 1);
68 _resetButton
= new QPushButton(i18n("&Reset"), hBox
);
69 _resetButton
->setObjectName("resetButton");
71 connect(_resetButton
, SIGNAL(clicked()),
72 this, SLOT(slotResetClicked()));
77 if (!gesture
.isNull())
79 slotRecorded(gesture
);
80 slotRecorded(gesture
);
81 slotRecorded(gesture
);
84 emit
gestureRecorded(false);
87 GestureRecordPage::~GestureRecordPage()
91 void GestureRecordPage::slotRecorded(const QString
&data
)
98 _tryOne
->setData(_gest
);
107 _tryTwo
->setData(data
);
112 KMessageBox::sorry(this, i18n("Your gestures did not match."));
122 _tryThree
->setData(data
);
124 emit
gestureRecorded(true);
128 KMessageBox::sorry(this, i18n("Your gestures did not match."));
134 KMessageBox::information(this, i18n("You have already completed the three required drawings. Either press 'Ok' to save or 'Reset' to try again."));
138 void GestureRecordPage::slotResetClicked()
142 _tryOne
->setData(QString());
143 _tryTwo
->setData(QString());
144 _tryThree
->setData(QString());
148 emit
gestureRecorded(false);
151 } // namespace KHotKeys
153 #include "gesturerecordpage.moc"