-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index 1991381..56f4746 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -55,260 +55,260 @@ namespace Internal { | |||
55 | QString keyToString( const OKeyPair& pair ) { | 55 | QString keyToString( const OKeyPair& pair ) { |
56 | int mod = 0; | 56 | int mod = 0; |
57 | if ( pair.modifier() & Qt::ShiftButton ) | 57 | if ( pair.modifier() & Qt::ShiftButton ) |
58 | mod |= Qt::SHIFT; | 58 | mod |= Qt::SHIFT; |
59 | if ( pair.modifier() & Qt::ControlButton ) | 59 | if ( pair.modifier() & Qt::ControlButton ) |
60 | mod |= Qt::CTRL; | 60 | mod |= Qt::CTRL; |
61 | if ( pair.modifier() & Qt::AltButton ) | 61 | if ( pair.modifier() & Qt::AltButton ) |
62 | mod |= Qt::ALT; | 62 | mod |= Qt::ALT; |
63 | 63 | ||
64 | return QAccel::keyToString( mod + pair.keycode() ); | 64 | return QAccel::keyToString( mod + pair.keycode() ); |
65 | } | 65 | } |
66 | 66 | ||
67 | struct OKeyConfigWidgetPrivate{ | 67 | struct OKeyConfigWidgetPrivate{ |
68 | OKeyConfigWidgetPrivate(const QString& = QString::null, | 68 | OKeyConfigWidgetPrivate(const QString& = QString::null, |
69 | OKeyConfigManager* = 0); | 69 | OKeyConfigManager* = 0); |
70 | bool operator==( const OKeyConfigWidgetPrivate& ); | 70 | bool operator==( const OKeyConfigWidgetPrivate& ); |
71 | QString name; | 71 | QString name; |
72 | OKeyConfigManager *manager; | 72 | OKeyConfigManager *manager; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, | 75 | OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, |
76 | OKeyConfigManager* man ) | 76 | OKeyConfigManager* man ) |
77 | : name( _name ), manager( man ){} | 77 | : name( _name ), manager( man ){} |
78 | 78 | ||
79 | bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { | 79 | bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { |
80 | if ( manager != item.manager) return false; | 80 | if ( manager != item.manager) return false; |
81 | if ( name != item.name ) return false; | 81 | if ( name != item.name ) return false; |
82 | 82 | ||
83 | return true; | 83 | return true; |
84 | } | 84 | } |
85 | 85 | ||
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | //////////////////////// | 91 | //////////////////////// |
92 | //////////////////////// | 92 | //////////////////////// |
93 | //////// Widget Starts Here | 93 | //////// Widget Starts Here |
94 | 94 | ||
95 | 95 | ||
96 | 96 | ||
97 | 97 | ||
98 | /** | 98 | /** |
99 | * | 99 | * |
100 | * This is a c'tor. You still need to pass the OKeyConfigManager | 100 | * This is a c'tor. You still need to pass the OKeyConfigManager |
101 | * and then issue a load. | 101 | * and then issue a load. |
102 | * The default mode is Immediate | 102 | * The default mode is Immediate |
103 | * | 103 | * |
104 | */ | 104 | */ |
105 | OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl ) | 105 | OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl ) |
106 | : QWidget( parent, name, fl ) { | 106 | : QWidget( parent, name, fl ) { |
107 | initUi(); | 107 | initUi(); |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | /** | 112 | /** |
113 | * c'tor | 113 | * c'tor |
114 | */ | 114 | */ |
115 | OKeyConfigWidget::~OKeyConfigWidget() { | 115 | OKeyConfigWidget::~OKeyConfigWidget() { |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | /** | 119 | /** |
120 | * @internal | 120 | * @internal |
121 | */ | 121 | */ |
122 | void OKeyConfigWidget::initUi() { | 122 | void OKeyConfigWidget::initUi() { |
123 | QBoxLayout *layout = new QVBoxLayout( this ); | 123 | QBoxLayout *layout = new QVBoxLayout( this ); |
124 | QGridLayout *gridLay = new QGridLayout( 2, 2 ); | 124 | QGridLayout *gridLay = new QGridLayout( 2, 2 ); |
125 | layout->addLayout( gridLay, 10 ); | 125 | layout->addLayout( gridLay, 10 ); |
126 | gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth | 126 | gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth |
127 | 127 | ||
128 | /* | 128 | /* |
129 | * LISTVIEW with the Keys | 129 | * LISTVIEW with the Keys |
130 | */ | 130 | */ |
131 | m_view = new Opie::Ui::OListView( this ); | 131 | m_view = new Opie::Ui::OListView( this ); |
132 | m_view->setFocus(); | 132 | m_view->setFocus(); |
133 | m_view->setAllColumnsShowFocus( true ); | 133 | m_view->setAllColumnsShowFocus( true ); |
134 | m_view->addColumn( tr("Pixmap") ); | 134 | m_view->addColumn( tr("Pixmap") ); |
135 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); | 135 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); |
136 | m_view->addColumn( tr("Key" ) ); | 136 | m_view->addColumn( tr("Key" ) ); |
137 | m_view->addColumn( tr("Default Key" ) ); | 137 | m_view->addColumn( tr("Default Key" ) ); |
138 | m_view->setRootIsDecorated( true ); | 138 | m_view->setRootIsDecorated( true ); |
139 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), | 139 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), |
140 | this, SLOT(slotListViewItem(QListViewItem*)) ); | 140 | this, SLOT(slotListViewItem(QListViewItem*)) ); |
141 | 141 | ||
142 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); | 142 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); |
143 | 143 | ||
144 | /* | 144 | /* |
145 | * GROUP with button info | 145 | * GROUP with button info |
146 | */ | 146 | */ |
147 | 147 | ||
148 | QGroupBox *box = new QGroupBox( this ); | 148 | QGroupBox *box = new QGroupBox( this ); |
149 | box ->setTitle( tr("Shortcut for Selected Action") ); | 149 | box ->setTitle( tr("Shortcut for Selected Action") ); |
150 | box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); | 150 | box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); |
151 | layout->addWidget( box, 1 ); | 151 | layout->addWidget( box, 1 ); |
152 | 152 | ||
153 | gridLay = new QGridLayout( box, 3, 4 ); | 153 | gridLay = new QGridLayout( box, 3, 4 ); |
154 | gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); | 154 | gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); |
155 | gridLay->setMargin( 4 ); | 155 | gridLay->setMargin( 4 ); |
156 | 156 | ||
157 | QButtonGroup *gr = new QButtonGroup( box ); | 157 | QButtonGroup *gr = new QButtonGroup( box ); |
158 | gr->hide(); | 158 | gr->hide(); |
159 | gr->setExclusive( true ); | 159 | gr->setExclusive( true ); |
160 | 160 | ||
161 | QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); | 161 | QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); |
162 | connect( rad, SIGNAL(clicked()), | 162 | connect( rad, SIGNAL(clicked()), |
163 | this, SLOT(slotNoKey()) ); | 163 | this, SLOT(slotNoKey()) ); |
164 | gr->insert( rad, 10 ); | 164 | gr->insert( rad, 10 ); |
165 | gridLay->addWidget( rad, 1, 0 ); | 165 | gridLay->addWidget( rad, 1, 0 ); |
166 | m_none = rad; | 166 | m_none = rad; |
167 | 167 | ||
168 | rad = new QRadioButton( tr("&Default" ), box ); | 168 | rad = new QRadioButton( tr("&Default" ), box ); |
169 | connect( rad, SIGNAL(clicked()), | 169 | connect( rad, SIGNAL(clicked()), |
170 | this, SLOT(slotDefaultKey()) ); | 170 | this, SLOT(slotDefaultKey()) ); |
171 | gr->insert( rad, 11 ); | 171 | gr->insert( rad, 11 ); |
172 | gridLay->addWidget( rad, 1, 1 ); | 172 | gridLay->addWidget( rad, 1, 1 ); |
173 | m_def = rad; | 173 | m_def = rad; |
174 | 174 | ||
175 | rad = new QRadioButton( tr("C&ustom"), box ); | 175 | rad = new QRadioButton( tr("C&ustom"), box ); |
176 | connect( rad, SIGNAL(clicked()), | 176 | connect( rad, SIGNAL(clicked()), |
177 | this, SLOT(slotCustomKey()) ); | 177 | this, SLOT(slotCustomKey()) ); |
178 | gr->insert( rad, 12 ); | 178 | gr->insert( rad, 12 ); |
179 | gridLay->addWidget( rad, 1, 2 ); | 179 | gridLay->addWidget( rad, 1, 2 ); |
180 | m_cus = rad; | 180 | m_cus = rad; |
181 | 181 | ||
182 | m_btn = new QPushButton( tr("Configure Key"), box ); | 182 | m_btn = new QPushButton( tr("Configure Key"), box ); |
183 | gridLay->addWidget( m_btn, 1, 4 ); | 183 | gridLay->addWidget( m_btn, 1, 3 ); |
184 | 184 | ||
185 | m_lbl= new QLabel( tr( "Default: " ), box ); | 185 | m_lbl= new QLabel( tr( "Default: " ), box ); |
186 | gridLay->addWidget( m_lbl, 2, 0 ); | 186 | gridLay->addMultiCellWidget( m_lbl, 2, 2, 0, 3 ); |
187 | 187 | ||
188 | connect(m_btn, SIGNAL(clicked()), | 188 | connect(m_btn, SIGNAL(clicked()), |
189 | this, SLOT(slotConfigure())); | 189 | this, SLOT(slotConfigure())); |
190 | 190 | ||
191 | m_box = box; | 191 | m_box = box; |
192 | } | 192 | } |
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Set the ChangeMode. | 195 | * Set the ChangeMode. |
196 | * You need to call this function prior to load | 196 | * You need to call this function prior to load |
197 | * If you call this function past load the behaviour is undefined | 197 | * If you call this function past load the behaviour is undefined |
198 | * But caling load again is safe | 198 | * But caling load again is safe |
199 | */ | 199 | */ |
200 | void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { | 200 | void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { |
201 | m_mode = mode; | 201 | m_mode = mode; |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | /** | 205 | /** |
206 | * return the current mode | 206 | * return the current mode |
207 | */ | 207 | */ |
208 | OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { | 208 | OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { |
209 | return m_mode; | 209 | return m_mode; |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | /** | 213 | /** |
214 | * insert these items before calling load | 214 | * insert these items before calling load |
215 | */ | 215 | */ |
216 | void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { | 216 | void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { |
217 | Opie::Ui::Internal::OKeyConfigWidgetPrivate root( str, man ); | 217 | Opie::Ui::Internal::OKeyConfigWidgetPrivate root( str, man ); |
218 | m_list.append(root); | 218 | m_list.append(root); |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | /** | 222 | /** |
223 | * loads the items and allows editing them | 223 | * loads the items and allows editing them |
224 | */ | 224 | */ |
225 | void OKeyConfigWidget::load() { | 225 | void OKeyConfigWidget::load() { |
226 | Opie::Ui::Internal::OKeyConfigWidgetPrivateList::Iterator it; | 226 | Opie::Ui::Internal::OKeyConfigWidgetPrivateList::Iterator it; |
227 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 227 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
228 | OListViewItem *item = new OListViewItem( m_view, (*it).name ); | 228 | OListViewItem *item = new OListViewItem( m_view, (*it).name ); |
229 | OKeyConfigItem::List list = (*it).manager->keyConfigList(); | 229 | OKeyConfigItem::List list = (*it).manager->keyConfigList(); |
230 | for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt ) | 230 | for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt ) |
231 | (void )new Opie::Ui::Internal::OKeyListViewItem(*keyIt, (*it).manager, item ); | 231 | (void )new Opie::Ui::Internal::OKeyListViewItem(*keyIt, (*it).manager, item ); |
232 | 232 | ||
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * Saves if in Queue Mode. It'll update the supplied | 237 | * Saves if in Queue Mode. It'll update the supplied |
238 | * OKeyConfigManager objects. | 238 | * OKeyConfigManager objects. |
239 | * If in Queue mode it'll just return | 239 | * If in Queue mode it'll just return |
240 | */ | 240 | */ |
241 | void OKeyConfigWidget::save() { | 241 | void OKeyConfigWidget::save() { |
242 | /* | 242 | /* |
243 | * Iterate over all config items | 243 | * Iterate over all config items |
244 | */ | 244 | */ |
245 | QListViewItemIterator it( m_view ); | 245 | QListViewItemIterator it( m_view ); |
246 | while ( it.current() ) { | 246 | while ( it.current() ) { |
247 | if (it.current()->parent() ) { | 247 | if (it.current()->parent() ) { |
248 | Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( it.current() ); | 248 | Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( it.current() ); |
249 | OKeyConfigManager *man = item->manager(); | 249 | OKeyConfigManager *man = item->manager(); |
250 | man->removeKeyConfig( item->origItem() ); | 250 | man->removeKeyConfig( item->origItem() ); |
251 | man->addKeyConfig( item->item() ); | 251 | man->addKeyConfig( item->item() ); |
252 | } | 252 | } |
253 | ++it; | 253 | ++it; |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | /** | 260 | /** |
261 | * @internal | 261 | * @internal |
262 | */ | 262 | */ |
263 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | 263 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { |
264 | if ( !_item || !_item->parent() ) { | 264 | if ( !_item || !_item->parent() ) { |
265 | m_box->setEnabled( false ); | 265 | m_box->setEnabled( false ); |
266 | m_none->setChecked( true ); | 266 | m_none->setChecked( true ); |
267 | m_btn ->setEnabled( false ); | 267 | m_btn ->setEnabled( false ); |
268 | m_def ->setChecked( false ); | 268 | m_def ->setChecked( false ); |
269 | m_cus ->setChecked( false ); | 269 | m_cus ->setChecked( false ); |
270 | }else{ | 270 | }else{ |
271 | m_box->setEnabled( true ); | 271 | m_box->setEnabled( true ); |
272 | Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( _item ); | 272 | Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( _item ); |
273 | OKeyConfigItem keyItem= item->item(); | 273 | OKeyConfigItem keyItem= item->item(); |
274 | m_lbl->setText( tr("Default: " )+ item->text( 3 ) ); | 274 | m_lbl->setText( tr("Default: " )+ item->text( 3 ) ); |
275 | if ( keyItem.keyPair().isEmpty() ) { | 275 | if ( keyItem.keyPair().isEmpty() ) { |
276 | m_none->setChecked( true ); | 276 | m_none->setChecked( true ); |
277 | m_btn ->setEnabled( false ); | 277 | m_btn ->setEnabled( false ); |
278 | m_def ->setChecked( false ); | 278 | m_def ->setChecked( false ); |
279 | m_cus ->setChecked( false ); | 279 | m_cus ->setChecked( false ); |
280 | }else { | 280 | }else { |
281 | m_none->setChecked( false ); | 281 | m_none->setChecked( false ); |
282 | m_cus ->setChecked( true ); | 282 | m_cus ->setChecked( true ); |
283 | m_btn ->setEnabled( true ); | 283 | m_btn ->setEnabled( true ); |
284 | m_def ->setChecked( false ); | 284 | m_def ->setChecked( false ); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | void OKeyConfigWidget::slotNoKey() { | 289 | void OKeyConfigWidget::slotNoKey() { |
290 | m_none->setChecked( true ); | 290 | m_none->setChecked( true ); |
291 | m_cus ->setChecked( false ); | 291 | m_cus ->setChecked( false ); |
292 | m_btn ->setEnabled( false ); | 292 | m_btn ->setEnabled( false ); |
293 | m_def ->setChecked( false ); | 293 | m_def ->setChecked( false ); |
294 | 294 | ||
295 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) | 295 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) |
296 | return; | 296 | return; |
297 | 297 | ||
298 | 298 | ||
299 | 299 | ||
300 | /* | 300 | /* |
301 | * If immediate we need to remove and readd the key | 301 | * If immediate we need to remove and readd the key |
302 | */ | 302 | */ |
303 | Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem()); | 303 | Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem()); |
304 | updateItem( item, OKeyPair::emptyKey() ); | 304 | updateItem( item, OKeyPair::emptyKey() ); |
305 | } | 305 | } |
306 | 306 | ||
307 | void OKeyConfigWidget::slotDefaultKey() { | 307 | void OKeyConfigWidget::slotDefaultKey() { |
308 | m_none->setChecked( false ); | 308 | m_none->setChecked( false ); |
309 | m_cus ->setChecked( false ); | 309 | m_cus ->setChecked( false ); |
310 | m_btn ->setEnabled( false ); | 310 | m_btn ->setEnabled( false ); |
311 | m_def ->setChecked( true ); | 311 | m_def ->setChecked( true ); |
312 | 312 | ||
313 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) | 313 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) |
314 | return; | 314 | return; |