summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/ButtonPrefs.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/ButtonPrefs.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/ButtonPrefs.cpp181
1 files changed, 181 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/ButtonPrefs.cpp b/noncore/apps/opie-reader/ButtonPrefs.cpp
new file mode 100644
index 0000000..50365a8
--- a/dev/null
+++ b/noncore/apps/opie-reader/ButtonPrefs.cpp
@@ -0,0 +1,181 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'Prefs.ui'
3**
4** Created: Tue Feb 11 23:53:35 2003
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "ButtonPrefs.h"
10
11#include <qcheckbox.h>
12#include <qlabel.h>
13#include <qpushbutton.h>
14#include <qspinbox.h>
15#include <qlayout.h>
16#include <qvariant.h>
17#include <qtooltip.h>
18#include <qwhatsthis.h>
19#include <qbuttongroup.h>
20#include <qmultilineedit.h>
21#ifdef USECOMBO
22#include <qcombobox.h>
23#else
24#include <qpe/menubutton.h>
25#endif
26#include <qfontdatabase.h>
27
28#include <qlistview.h>
29
30class MyQListViewItem : public QListViewItem
31{
32 orKey o;
33public:
34 MyQListViewItem(const orKey& _o, QListView* p, const QString& c1, const QString& c2, const QString& c3) : QListViewItem(p, c1, c2, c3), o(_o) { }
35 orKey getKey() { return o; }
36};
37
38void CButtonPrefs::mapkey(Qt::ButtonState st, int _key)
39{
40 mapkey(st, _key, action->currentItem());
41}
42
43void CButtonPrefs::mapkey(Qt::ButtonState st, int _key, int act)
44{
45 orKey key(st, _key, ((act == cesScrollMore) || (act == cesScrollLess)));
46 QMap<orKey,QListViewItem*>::Iterator iter = listmap.find(key);
47 if (iter != listmap.end())
48 {
49 lb->takeItem(iter.data());
50 }
51 (*kmap)[key] = act;
52 listmap[key] = new MyQListViewItem(key, lb, key.text(), action->text(act), (key.isScroll()) ? "*":"");
53}
54
55void CButtonPrefs::keyPressEvent(QKeyEvent* e)
56{
57 switch (e->key())
58 {
59 case Key_Shift:
60 case Key_Control:
61 case Key_Meta:
62 case Key_Alt:
63 case Key_CapsLock:
64 case Key_NumLock:
65 case Key_ScrollLock:
66 e->ignore();
67 break;
68 default:
69 mapkey(e->state(), e->key());
70 e->accept();
71 break;
72 }
73}
74
75#ifdef USECOMBO
76void CButtonPrefs::populate(QComboBox *mb)
77#else
78void CButtonPrefs::populate(MenuButton *mb)
79#endif
80{
81 mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
82 mb->insertItem( tr("Open file") );
83 mb->insertItem( tr("Autoscroll") );
84 mb->insertItem( tr("Bookmark") );
85 mb->insertItem( tr("Annotate") );
86 mb->insertItem( tr("Fullscreen") );
87
88 mb->insertItem( tr("Zoom in") );
89 mb->insertItem( tr("Zoom out") );
90 mb->insertItem( tr("Back") );
91 mb->insertItem( tr("Forward") );
92 mb->insertItem( tr("Home") );
93 mb->insertItem( tr("Page up") );
94 mb->insertItem( tr("Page down") );
95 mb->insertItem( tr("Line up") );
96 mb->insertItem( tr("Line down") );
97 mb->insertItem( tr("Beginning") );
98 mb->insertItem( tr("End") );
99 mb->insertItem( tr("Rotate") );
100 mb->insertItem( tr("Scroll faster") );
101 mb->insertItem( tr("Scroll slower") );
102 mb->insertItem( tr("Invert colours") );
103 mb->insertItem( tr("Toggle tools") );
104 mb->insertItem( tr("Toggle scrollbar") );
105 mb->insertItem( tr("Toggle statusbar") );
106 mb->insertItem( tr("Next link") );
107 mb->insertItem( tr("Goto link") );
108}
109
110CButtonPrefs::CButtonPrefs( QMap<orKey, int>* _kmap, QWidget* parent, const char* name, WFlags fl )
111 : QWidget( parent, name, fl ), kmap(_kmap)
112{
113 QVBoxLayout* vo = new QVBoxLayout(this);
114 QHBoxLayout* lo = new QHBoxLayout();
115 setFocusPolicy(QWidget::StrongFocus);
116#ifdef USECOMBO
117 action = new QComboBox( this );
118#else
119 action = new MenuButton( this );
120#endif
121 populate(action);
122 action->setFocusProxy(this);
123
124
125
126 QMultiLineEdit* TextLabel1 = new QMultiLineEdit( this );
127 TextLabel1->setText( tr( "Press the key(s) you want assigned to the highlighted function.\n\nPress the delete button to unmap the key.\n\nUse the \"Close\" button (not the [x]) to finish." ) );
128 TextLabel1->setReadOnly(true);
129 TextLabel1->setWordWrap(QMultiLineEdit::WidgetWidth);
130
131 // lo->addWidget(TextLabel, 0, Qt::AlignTop);
132 // lo->addWidget(action, 0, Qt::AlignTop);
133 lo->addWidget(TextLabel1);
134 lo->addWidget(action);
135 vo->addLayout(lo);
136 lb = new QListView(this);
137 lb->addColumn( tr( "Key" ) );
138 lb->addColumn( tr( "Function" ) );
139 lb->addColumn( tr( "Scroll" ) );
140 lb->setFocusProxy(this);
141 vo->addWidget(lb,1);
142 for (QMap<orKey,int>::Iterator i = kmap->begin(); i != kmap->end(); i++)
143 {
144 listmap[i.key()] = new MyQListViewItem(i.key(), lb, i.key().text(), action->text(i.data()), (i.key().isScroll()) ? "*":"");
145 }
146
147 lo = new QHBoxLayout();
148 QLabel* TextLabel = new QLabel( this, "TextLabel1" );
149 TextLabel->setText( tr( "Debounce" ) );
150 lo->addWidget(TextLabel);
151
152 debounce = new QSpinBox( this, "Debounce" );
153 debounce->setRange(0,1000);
154 lo->addWidget(debounce);
155 lo->addStretch(1);
156 QPushButton* delButton = new QPushButton("Delete", this);
157 connect(delButton, SIGNAL( clicked() ), this, SLOT( erasemapping() ));
158 lo->addWidget(delButton);
159 QPushButton* exitButton = new QPushButton("Close", this);
160 connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotClosed() ) );
161 lo->addWidget(exitButton);
162 vo->addLayout(lo);
163}
164
165void CButtonPrefs::erasemapping()
166{
167 MyQListViewItem* li = (MyQListViewItem*)lb->selectedItem();
168 if (li != NULL)
169 {
170 orKey key(li->getKey());
171 qDebug("Tapped %s", (const char*)key.text());
172 kmap->remove(key);
173 lb->takeItem(listmap[key]);
174 listmap.remove(key);
175 }
176}
177
178CButtonPrefs::~CButtonPrefs()
179{
180 // no need to delete child widgets, Qt does it all for us
181}