author | zecke <zecke> | 2004-04-13 14:53:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-13 14:53:58 (UTC) |
commit | b51d88d7b0b517b71ae3b59d8228335f38ca9fc7 (patch) (unidiff) | |
tree | 302377973a897934c944c7a126e5e0a510694979 /libopie2/examples | |
parent | c4c842558e1457f64d43b237f24f6ea1a4f9d76b (diff) | |
download | opie-b51d88d7b0b517b71ae3b59d8228335f38ca9fc7.zip opie-b51d88d7b0b517b71ae3b59d8228335f38ca9fc7.tar.gz opie-b51d88d7b0b517b71ae3b59d8228335f38ca9fc7.tar.bz2 |
Split the KeyConfig Manager and Widget into Ui and Core parts
Adjust the only user...
Don't add a 2nd example to core but mention the one for the classes
in opieui/okeyconfigwidget
-rw-r--r-- | libopie2/examples/opiecore/okeyconfigmanager/README | 1 | ||||
-rw-r--r-- | libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp | 30 | ||||
-rw-r--r-- | libopie2/examples/opieui/okeyconfigwidget/testwidget.h | 10 |
3 files changed, 21 insertions, 20 deletions
diff --git a/libopie2/examples/opiecore/okeyconfigmanager/README b/libopie2/examples/opiecore/okeyconfigmanager/README new file mode 100644 index 0000000..327b7c2 --- a/dev/null +++ b/libopie2/examples/opiecore/okeyconfigmanager/README | |||
@@ -0,0 +1 @@ | |||
See opieui/okeyconfigwidget for an example of possible usage \ No newline at end of file | |||
diff --git a/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp b/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp index 10b52f9..5c7bac2 100644 --- a/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp +++ b/libopie2/examples/opieui/okeyconfigwidget/testwidget.cpp | |||
@@ -8,121 +8,121 @@ | |||
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::Core::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" ) ); | 55 | diag.setCaption( tr( "Manage Keys" ) ); |
56 | 56 | ||
57 | QHBoxLayout *lay = new QHBoxLayout( &diag ); | 57 | QHBoxLayout *lay = new QHBoxLayout( &diag ); |
58 | Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget( &diag, "key config" ); | 58 | Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget( &diag, "key config" ); |
59 | wid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 59 | wid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
60 | wid->insert( tr("MainWindow Options" ), m_manager ); | 60 | wid->insert( tr("MainWindow Options" ), m_manager ); |
61 | wid->load(); | 61 | wid->load(); |
62 | 62 | ||
63 | lay->addWidget( wid ); | 63 | lay->addWidget( wid ); |
64 | 64 | ||
65 | if ( QPEApplication::execDialog( &diag ) == QDialog::Accepted ) { | 65 | if ( QPEApplication::execDialog( &diag ) == QDialog::Accepted ) { |
66 | wid->save(); | 66 | wid->save(); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | TestMainWindow::TestMainWindow( QWidget* parent, const char* slot, WFlags fl ) | 70 | TestMainWindow::TestMainWindow( QWidget* parent, const char* slot, WFlags fl ) |
71 | : Opie::Ui::OListView( parent, slot, fl) | 71 | : Opie::Ui::OListView( parent, slot, fl) |
72 | { | 72 | { |
73 | addColumn( tr( "A Doo" ) ); | 73 | addColumn( tr( "A Doo" ) ); |
74 | addColumn( tr( "B Doo" ) ); | 74 | addColumn( tr( "B Doo" ) ); |
75 | 75 | ||
76 | m_config = new Opie::Core::OConfig( "test_config_foo" ); | 76 | m_config = new Opie::Core::OConfig( "test_config_foo" ); |
77 | 77 | ||
78 | /* generate the black list */ | 78 | /* generate the black list */ |
79 | Opie::Ui::OKeyPair::List blackList; | 79 | Opie::Core::OKeyPair::List blackList; |
80 | blackList.append( Opie::Ui::OKeyPair::leftArrowKey() ); | 80 | blackList.append( Opie::Core::OKeyPair::leftArrowKey() ); |
81 | blackList.append( Opie::Ui::OKeyPair::rightArrowKey() ); | 81 | blackList.append( Opie::Core::OKeyPair::rightArrowKey() ); |
82 | blackList.append( Opie::Ui::OKeyPair::downArrowKey() ); | 82 | blackList.append( Opie::Core::OKeyPair::downArrowKey() ); |
83 | blackList.append( Opie::Ui::OKeyPair::upArrowKey() ); | 83 | blackList.append( Opie::Core::OKeyPair::upArrowKey() ); |
84 | 84 | ||
85 | m_manager = new Opie::Ui::OKeyConfigManager( m_config, "Key Group", | 85 | m_manager = new Opie::Core::OKeyConfigManager( m_config, "Key Group", |
86 | blackList, false, this, "Key Manager" ); | 86 | blackList, false, this, "Key Manager" ); |
87 | 87 | ||
88 | m_manager->addKeyConfig( Opie::Ui::OKeyConfigItem( tr( "Delete Action" ), "delete_key", QPixmap(), | 88 | m_manager->addKeyConfig( Opie::Core::OKeyConfigItem( tr( "Delete Action" ), "delete_key", QPixmap(), |
89 | 10, Opie::Ui::OKeyPair( Qt::Key_D, Qt::ShiftButton ), this, | 89 | 10, Opie::Core::OKeyPair( Qt::Key_D, Qt::ShiftButton ), this, |
90 | SLOT(slotDelete(QWidget*,QKeyEvent*)) ) ); | 90 | SLOT(slotDelete(QWidget*,QKeyEvent*)) ) ); |
91 | m_manager->addKeyConfig( Opie::Ui::OKeyConfigItem( tr( "Show Action" ), "show_key", QPixmap(), | 91 | m_manager->addKeyConfig( Opie::Core::OKeyConfigItem( tr( "Show Action" ), "show_key", QPixmap(), |
92 | 11, Opie::Ui::OKeyPair( Qt::Key_S, Qt::AltButton ) ) ); | 92 | 11, Opie::Core::OKeyPair( Qt::Key_S, Qt::AltButton ) ) ); |
93 | 93 | ||
94 | connect(m_manager, SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), | 94 | connect(m_manager, SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Core::OKeyConfigItem&)), |
95 | this, SLOT(slotAction(QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem&)) ); | 95 | this, SLOT(slotAction(QWidget*, QKeyEvent*, const Opie::Core::OKeyConfigItem&)) ); |
96 | // when commenting the line below out the keyPressEvent will work | 96 | // when commenting the line below out the keyPressEvent will work |
97 | m_manager->handleWidget( this ); | 97 | m_manager->handleWidget( this ); |
98 | m_manager->load(); | 98 | m_manager->load(); |
99 | } | 99 | } |
100 | 100 | ||
101 | TestMainWindow::~TestMainWindow() { | 101 | TestMainWindow::~TestMainWindow() { |
102 | m_manager->save(); | 102 | m_manager->save(); |
103 | delete m_config; | 103 | delete m_config; |
104 | } | 104 | } |
105 | 105 | ||
106 | Opie::Ui::OKeyConfigManager* TestMainWindow::manager() { | 106 | Opie::Core::OKeyConfigManager* TestMainWindow::manager() { |
107 | return m_manager; | 107 | return m_manager; |
108 | } | 108 | } |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * This only works if we do not handle the even with m_manager->handleWidget( this ) | 111 | * This only works if we do not handle the even with m_manager->handleWidget( this ) |
112 | * So this is only for demo purposes | 112 | * So this is only for demo purposes |
113 | */ | 113 | */ |
114 | void TestMainWindow::keyPressEvent( QKeyEvent* ev ) { | 114 | void TestMainWindow::keyPressEvent( QKeyEvent* ev ) { |
115 | qWarning( "String is "+ m_manager->handleKeyEvent( ev ).text() ); | 115 | qWarning( "String is "+ m_manager->handleKeyEvent( ev ).text() ); |
116 | qWarning( "Id was %d %d %d %d", m_manager->handleKeyEventId( ev ),ev->key(),ev->state(), ev->ascii() ); | 116 | qWarning( "Id was %d %d %d %d", m_manager->handleKeyEventId( ev ),ev->key(),ev->state(), ev->ascii() ); |
117 | ev->ignore(); | 117 | ev->ignore(); |
118 | } | 118 | } |
119 | 119 | ||
120 | void TestMainWindow::slotDelete( QWidget* wid, QKeyEvent* ev ) { | 120 | void TestMainWindow::slotDelete( QWidget* wid, QKeyEvent* ev ) { |
121 | qWarning( "Slot Delete %d %d %d", wid, ev->key(), ev->state() ); | 121 | qWarning( "Slot Delete %d %d %d", wid, ev->key(), ev->state() ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void TestMainWindow::slotAction( QWidget* wid, QKeyEvent* ev, const Opie::Ui::OKeyConfigItem& item) { | 124 | void TestMainWindow::slotAction( QWidget* wid, QKeyEvent* ev, const Opie::Core::OKeyConfigItem& item) { |
125 | qWarning( "Slot Action %d %d %d %s %d", wid, ev->key(), ev->state(), item.text().latin1(), item.id() ); | 125 | qWarning( "Slot Action %d %d %d %s %d", wid, ev->key(), ev->state(), item.text().latin1(), item.id() ); |
126 | } | 126 | } |
127 | 127 | ||
128 | #include "testwidget.moc" | 128 | #include "testwidget.moc" |
diff --git a/libopie2/examples/opieui/okeyconfigwidget/testwidget.h b/libopie2/examples/opieui/okeyconfigwidget/testwidget.h index b95c225..6ecb346 100644 --- a/libopie2/examples/opieui/okeyconfigwidget/testwidget.h +++ b/libopie2/examples/opieui/okeyconfigwidget/testwidget.h | |||
@@ -1,40 +1,40 @@ | |||
1 | #ifndef TEST_WIDGET_H | 1 | #ifndef TEST_WIDGET_H |
2 | #define TEST_WIDGET_H | 2 | #define TEST_WIDGET_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | #include <opie2/olistview.h> | 6 | #include <opie2/olistview.h> |
7 | 7 | ||
8 | namespace Opie{ | 8 | namespace Opie{ |
9 | namespace Ui{ | 9 | namespace Ui{ |
10 | class OTabWidget; | 10 | class OTabWidget; |
11 | class OKeyConfigManager; | ||
12 | class OListView; | 11 | class OListView; |
13 | class OKeyConfigItem; | ||
14 | } | 12 | } |
15 | namespace Core { | 13 | namespace Core { |
16 | class OConfig; | 14 | class OConfig; |
15 | class OKeyConfigManager; | ||
16 | class OKeyConfigItem; | ||
17 | } | 17 | } |
18 | } | 18 | } |
19 | class QKeyEvent; | 19 | class QKeyEvent; |
20 | 20 | ||
21 | 21 | ||
22 | class TestMainWindow : public Opie::Ui::OListView { | 22 | class TestMainWindow : public Opie::Ui::OListView { |
23 | Q_OBJECT | 23 | Q_OBJECT |
24 | public: | 24 | public: |
25 | 25 | ||
26 | TestMainWindow(QWidget* parent, const char*, WFlags fl ); | 26 | TestMainWindow(QWidget* parent, const char*, WFlags fl ); |
27 | ~TestMainWindow(); | 27 | ~TestMainWindow(); |
28 | 28 | ||
29 | Opie::Ui::OKeyConfigManager *manager(); | 29 | Opie::Core::OKeyConfigManager *manager(); |
30 | protected: | 30 | protected: |
31 | void keyPressEvent( QKeyEvent* ); | 31 | void keyPressEvent( QKeyEvent* ); |
32 | private slots: | 32 | private slots: |
33 | void slotDelete( QWidget*, QKeyEvent* ); | 33 | void slotDelete( QWidget*, QKeyEvent* ); |
34 | void slotAction( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); | 34 | void slotAction( QWidget*, QKeyEvent*, const Opie::Core::OKeyConfigItem& ); |
35 | private: | 35 | private: |
36 | Opie::Core::OConfig *m_config; | 36 | Opie::Core::OConfig *m_config; |
37 | Opie::Ui::OKeyConfigManager *m_manager; | 37 | Opie::Core::OKeyConfigManager *m_manager; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | #endif | 40 | #endif |