-rw-r--r-- | libopie2/examples/opieui/okeyconfigwidget/keyconfig.pro | 4 | ||||
-rw-r--r-- | libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/libopie2/examples/opieui/okeyconfigwidget/keyconfig.pro b/libopie2/examples/opieui/okeyconfigwidget/keyconfig.pro index 07188d9..7c60384 100644 --- a/libopie2/examples/opieui/okeyconfigwidget/keyconfig.pro +++ b/libopie2/examples/opieui/okeyconfigwidget/keyconfig.pro | |||
@@ -1,12 +1,12 @@ | |||
1 | CONFIG += qt | 1 | CONFIG += qt |
2 | 2 | ||
3 | TEMPLATE = app | 3 | TEMPLATE = app |
4 | SOURCES = ../../../../noncore/graphics/opie-eye/lib/okeyconfigwidget.cpp testwidget.cpp | 4 | SOURCES = testwidget.cpp |
5 | HEADERS = ../../../../noncore/graphics/opie-eye/lib/okeyconfigwidget.h testwidget.h | 5 | HEADERS = testwidget.h |
6 | 6 | ||
7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/graphics/opie-eye/lib/ | 7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/noncore/graphics/opie-eye/lib/ |
8 | DESTPATH += $(OPIEDIR)/include | 8 | DESTPATH += $(OPIEDIR)/include |
9 | 9 | ||
10 | LIBS += -lopieui2 -lopiecore2 | 10 | LIBS += -lopieui2 -lopiecore2 |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp b/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp index 5553166..10b52f9 100644 --- a/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp +++ b/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp | |||
@@ -1,102 +1,104 @@ | |||
1 | #include "testwidget.h" | 1 | #include "testwidget.h" |
2 | 2 | ||
3 | #include "okeyconfigwidget.h" | 3 | #include <opie2/okeyconfigwidget.h> |
4 | 4 | ||
5 | #include <opie2/oapplicationfactory.h> | 5 | #include <opie2/oapplicationfactory.h> |
6 | #include <opie2/otabwidget.h> | 6 | #include <opie2/otabwidget.h> |
7 | 7 | ||
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | #include <qevent.h> | 10 | #include <qevent.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
13 | #include <qmainwindow.h> | 13 | #include <qmainwindow.h> |
14 | #include <qdialog.h> | 14 | #include <qdialog.h> |
15 | 15 | ||
16 | 16 | ||
17 | /** | 17 | /** |
18 | * QObject with signals and slots inside a .cpp | 18 | * QObject with signals and slots inside a .cpp |
19 | * requires the .moc at the bottom! and a run of qmake | 19 | * requires the .moc at the bottom! and a run of qmake |
20 | */ | 20 | */ |
21 | class MainWindow : public QMainWindow { | 21 | class MainWindow : public QMainWindow { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | static QString appName() { | 24 | static QString appName() { |
25 | return QString::fromLatin1("keyconfig"); | 25 | return QString::fromLatin1("keyconfig"); |
26 | } | 26 | } |
27 | MainWindow( QWidget*, const char*, WFlags fl ); | 27 | MainWindow( QWidget*, const char*, WFlags fl ); |
28 | ~MainWindow() {} | 28 | ~MainWindow() {} |
29 | private slots: | 29 | private slots: |
30 | void slotClicked(); | 30 | void slotClicked(); |
31 | private: | 31 | private: |
32 | Opie::Ui::OKeyConfigManager *m_manager; | 32 | Opie::Ui::OKeyConfigManager *m_manager; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | 35 | ||
36 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> ) | 36 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> ) |
37 | 37 | ||
38 | 38 | ||
39 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) | 39 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) |
40 | : QMainWindow( parent, name, fl ) | 40 | : QMainWindow( parent, name, fl ) |
41 | { | 41 | { |
42 | QVBoxLayout *lay = new QVBoxLayout( this ); | 42 | QVBoxLayout *lay = new QVBoxLayout( this ); |
43 | QPushButton *btn = new QPushButton( tr("Configure" ), this ); | 43 | QPushButton *btn = new QPushButton( tr("Configure" ), this ); |
44 | TestMainWindow *wid = new TestMainWindow( this, "name", 0 ); | 44 | TestMainWindow *wid = new TestMainWindow( this, "name", 0 ); |
45 | 45 | ||
46 | lay->addWidget( btn ); | 46 | lay->addWidget( btn ); |
47 | lay->addWidget( wid ); | 47 | lay->addWidget( wid ); |
48 | m_manager = wid->manager(); | 48 | m_manager = wid->manager(); |
49 | 49 | ||
50 | connect( btn, SIGNAL(clicked()), this, SLOT(slotClicked()) ); | 50 | connect( btn, SIGNAL(clicked()), this, SLOT(slotClicked()) ); |
51 | } | 51 | } |
52 | 52 | ||
53 | void MainWindow::slotClicked() { | 53 | void MainWindow::slotClicked() { |
54 | QDialog diag( this, "name", true ); | 54 | QDialog diag( this, "name", true ); |
55 | diag.setCaption( tr( "Manage Keys" ) ); | ||
56 | |||
55 | QHBoxLayout *lay = new QHBoxLayout( &diag ); | 57 | QHBoxLayout *lay = new QHBoxLayout( &diag ); |
56 | Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget( &diag, "key config" ); | 58 | Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget( &diag, "key config" ); |
57 | wid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 59 | wid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
58 | wid->insert( tr("MainWindow Options" ), m_manager ); | 60 | wid->insert( tr("MainWindow Options" ), m_manager ); |
59 | wid->load(); | 61 | wid->load(); |
60 | 62 | ||
61 | lay->addWidget( wid ); | 63 | lay->addWidget( wid ); |
62 | 64 | ||
63 | if ( QPEApplication::execDialog( &diag ) == QDialog::Accepted ) { | 65 | if ( QPEApplication::execDialog( &diag ) == QDialog::Accepted ) { |
64 | wid->save(); | 66 | wid->save(); |
65 | } | 67 | } |
66 | } | 68 | } |
67 | 69 | ||
68 | TestMainWindow::TestMainWindow( QWidget* parent, const char* slot, WFlags fl ) | 70 | TestMainWindow::TestMainWindow( QWidget* parent, const char* slot, WFlags fl ) |
69 | : Opie::Ui::OListView( parent, slot, fl) | 71 | : Opie::Ui::OListView( parent, slot, fl) |
70 | { | 72 | { |
71 | addColumn( tr( "A Doo" ) ); | 73 | addColumn( tr( "A Doo" ) ); |
72 | addColumn( tr( "B Doo" ) ); | 74 | addColumn( tr( "B Doo" ) ); |
73 | 75 | ||
74 | m_config = new Opie::Core::OConfig( "test_config_foo" ); | 76 | m_config = new Opie::Core::OConfig( "test_config_foo" ); |
75 | 77 | ||
76 | /* generate the black list */ | 78 | /* generate the black list */ |
77 | Opie::Ui::OKeyPair::List blackList; | 79 | Opie::Ui::OKeyPair::List blackList; |
78 | blackList.append( Opie::Ui::OKeyPair::leftArrowKey() ); | 80 | blackList.append( Opie::Ui::OKeyPair::leftArrowKey() ); |
79 | blackList.append( Opie::Ui::OKeyPair::rightArrowKey() ); | 81 | blackList.append( Opie::Ui::OKeyPair::rightArrowKey() ); |
80 | blackList.append( Opie::Ui::OKeyPair::downArrowKey() ); | 82 | blackList.append( Opie::Ui::OKeyPair::downArrowKey() ); |
81 | blackList.append( Opie::Ui::OKeyPair::upArrowKey() ); | 83 | blackList.append( Opie::Ui::OKeyPair::upArrowKey() ); |
82 | 84 | ||
83 | m_manager = new Opie::Ui::OKeyConfigManager( m_config, "Key Group", | 85 | m_manager = new Opie::Ui::OKeyConfigManager( m_config, "Key Group", |
84 | blackList, false, this, "Key Manager" ); | 86 | blackList, false, this, "Key Manager" ); |
85 | 87 | ||
86 | m_manager->addKeyConfig( Opie::Ui::OKeyConfigItem( tr( "Delete Action" ), "delete_key", QPixmap(), | 88 | m_manager->addKeyConfig( Opie::Ui::OKeyConfigItem( tr( "Delete Action" ), "delete_key", QPixmap(), |
87 | 10, Opie::Ui::OKeyPair( Qt::Key_D, Qt::ShiftButton ), this, | 89 | 10, Opie::Ui::OKeyPair( Qt::Key_D, Qt::ShiftButton ), this, |
88 | SLOT(slotDelete(QWidget*,QKeyEvent*)) ) ); | 90 | SLOT(slotDelete(QWidget*,QKeyEvent*)) ) ); |
89 | m_manager->addKeyConfig( Opie::Ui::OKeyConfigItem( tr( "Show Action" ), "show_key", QPixmap(), | 91 | m_manager->addKeyConfig( Opie::Ui::OKeyConfigItem( tr( "Show Action" ), "show_key", QPixmap(), |
90 | 11, Opie::Ui::OKeyPair( Qt::Key_S, Qt::AltButton ) ) ); | 92 | 11, Opie::Ui::OKeyPair( Qt::Key_S, Qt::AltButton ) ) ); |
91 | 93 | ||
92 | connect(m_manager, SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), | 94 | connect(m_manager, SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), |
93 | this, SLOT(slotAction(QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem&)) ); | 95 | this, SLOT(slotAction(QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem&)) ); |
94 | // when commenting the line below out the keyPressEvent will work | 96 | // when commenting the line below out the keyPressEvent will work |
95 | m_manager->handleWidget( this ); | 97 | m_manager->handleWidget( this ); |
96 | m_manager->load(); | 98 | m_manager->load(); |
97 | } | 99 | } |
98 | 100 | ||
99 | TestMainWindow::~TestMainWindow() { | 101 | TestMainWindow::~TestMainWindow() { |
100 | m_manager->save(); | 102 | m_manager->save(); |
101 | delete m_config; | 103 | delete m_config; |
102 | } | 104 | } |