summaryrefslogtreecommitdiffstats
path: root/khotkeys/kcontrol/gesturerecordpage.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /khotkeys/kcontrol/gesturerecordpage.cpp
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khotkeys/kcontrol/gesturerecordpage.cpp')
-rw-r--r--khotkeys/kcontrol/gesturerecordpage.cpp147
1 files changed, 147 insertions, 0 deletions
diff --git a/khotkeys/kcontrol/gesturerecordpage.cpp b/khotkeys/kcontrol/gesturerecordpage.cpp
new file mode 100644
index 000000000..e24beaaf3
--- /dev/null
+++ b/khotkeys/kcontrol/gesturerecordpage.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+
+ KHotKeys
+
+ Copyright (C) 2003 Mike Pilone <mpilone@slac.com>
+ Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
+
+ Distributed under the terms of the GNU General Public License version 2.
+
+****************************************************************************/
+
+#include <qwidget.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "gesturerecordpage.h"
+#include "gesturerecorder.h"
+#include "gesturedrawer.h"
+
+namespace KHotKeys
+{
+
+GestureRecordPage::GestureRecordPage(const QString &gesture,
+ QWidget *parent, const char *name)
+ : QVBox(parent, name),
+ _recorder(NULL), _resetButton(NULL),
+ _tryOne(NULL), _tryTwo(NULL), _tryThree(NULL), _gest(QString::null),
+ _tryCount(1)
+ {
+ QString message;
+
+ message = i18n("Draw the gesture you would like to record below. Press "
+ "and hold the left mouse button while drawing, and release "
+ "when you have finished.\n\n"
+ "You will be required to draw the gesture 3 times. After "
+ "each drawing, if they match, the indicators below will "
+ "change to represent which step you are on.\n\n"
+ "If at any point they do not match, you will be required to "
+ "restart. If you want to force a restart, use the reset "
+ "button below.\n\nDraw here:");
+
+ QLabel *label = new QLabel(message, this, "label");
+ label->setAlignment(QLabel::AlignLeft | QLabel::WordBreak |
+ QLabel::AlignVCenter);
+
+ _recorder = new GestureRecorder(this, "recorder");
+ _recorder->setMinimumHeight(150);
+ setStretchFactor(_recorder, 1);
+ connect(_recorder, SIGNAL(recorded(const QString &)),
+ this, SLOT(slotRecorded(const QString &)));
+
+ QHBox *hBox = new QHBox(this, "hbox");
+
+ _tryOne = new GestureDrawer(hBox, "tryOne");
+ _tryTwo = new GestureDrawer(hBox, "tryTwo");
+ _tryThree = new GestureDrawer(hBox, "tryThree");
+
+ QWidget *spacer = new QWidget(hBox, "spacer");
+ hBox->setStretchFactor(spacer, 1);
+
+ _resetButton = new QPushButton(i18n("&Reset"), hBox, "resetButton");
+ connect(_resetButton, SIGNAL(clicked()),
+ this, SLOT(slotResetClicked()));
+
+
+
+ // initialize
+ if (!gesture.isNull())
+ {
+ slotRecorded(gesture);
+ slotRecorded(gesture);
+ slotRecorded(gesture);
+ }
+ else
+ emit gestureRecorded(false);
+ }
+
+GestureRecordPage::~GestureRecordPage()
+ {
+ }
+
+void GestureRecordPage::slotRecorded(const QString &data)
+ {
+ switch (_tryCount)
+ {
+ case 1:
+ {
+ _gest = data;
+ _tryOne->setData(_gest);
+ _tryCount++;
+ }
+ break;
+
+ case 2:
+ {
+ if (_gest == data)
+ {
+ _tryTwo->setData(data);
+ _tryCount++;
+ }
+ else
+ {
+ KMessageBox::sorry(this, i18n("Your gestures did not match."));
+ slotResetClicked();
+ }
+ break;
+ }
+
+ case 3:
+ {
+ if (_gest == data)
+ {
+ _tryThree->setData(data);
+ _tryCount++;
+ emit gestureRecorded(true);
+ }
+ else
+ {
+ KMessageBox::sorry(this, i18n("Your gestures did not match."));
+ slotResetClicked();
+ }
+ break;
+ }
+ default:
+ KMessageBox::information(this, i18n("You have already completed the three required drawings. Either press 'Ok' to save or 'Reset' to try again."));
+ }
+ }
+
+void GestureRecordPage::slotResetClicked()
+ {
+ _gest = QString::null;
+
+ _tryOne->setData(QString::null);
+ _tryTwo->setData(QString::null);
+ _tryThree->setData(QString::null);
+
+ _tryCount = 1;
+
+ emit gestureRecorded(false);
+ }
+
+} // namespace KHotKeys
+
+#include "gesturerecordpage.moc"