Ticket #2078: view_menu.diff
File view_menu.diff, 13.0 KB (added by , 18 years ago) |
---|
-
mythcontrols/keygrabber.h
25 25 // MythTV headers 26 26 #include <mythtv/mythdialogs.h> 27 27 28 29 28 /** \class KeyGrabPopupBox 30 29 * \brief Captures a key. 31 30 * … … 94 93 Q_OBJECT 95 94 96 95 public: 97 enum actions { kSave, kC ancel, };96 enum actions { kSave, kChangeView, kCancel, }; 98 97 99 98 /// \brief Create a new action window. Does not pop-up menu. 100 99 OptionsMenu(MythMainWindow *window); … … 103 102 int GetOption(void) { return ExecPopup(this,SLOT(Cancel())); } 104 103 105 104 public slots: 106 void Save(void) { done(OptionsMenu::kSave); } 107 void Cancel(void) { done(OptionsMenu::kCancel); } 105 void Save(void) { done(OptionsMenu::kSave); } 106 void ChangeView(void) { done(OptionsMenu::kChangeView); } 107 void Cancel(void) { done(OptionsMenu::kCancel); } 108 108 }; 109 109 110 110 -
mythcontrols/mythcontrols.cpp
37 37 #include <mythtv/mythdialogs.h> 38 38 39 39 // MythControls headers 40 #include "keygrabber.h" 40 41 #include "mythcontrols.h" 41 #include "keygrabber.h"42 42 43 43 static QString key_to_display(const QString &key); 44 44 static QString display_to_key(const QString &key); … … 53 53 */ 54 54 MythControls::MythControls(MythMainWindow *parent, bool &ok) 55 55 : MythThemedDialog(parent, "controls", "controls-", "controls"), 56 m_ focusedUIElement(NULL),56 m_currentView(kActionsByContext), m_focusedUIElement(NULL), 57 57 m_leftList(NULL), m_rightList(NULL), 58 58 m_description(NULL), 59 59 m_leftDescription(NULL), m_rightDescription(NULL), 60 m_bindings(NULL), m_container(NULL) 60 m_bindings(NULL), m_container(NULL) 61 61 { 62 62 bzero(m_actionButtons, sizeof(void*) * Action::kMaximumNumberOfBindings); 63 63 m_contexts.setAutoDelete(true); … … 221 221 RefreshKeyInformation(); 222 222 } 223 223 224 /// \brief Chagne the view. 225 void MythControls::ChangeView(void) 226 { 227 ViewMenu popup(gContext->GetMainWindow(), m_currentView); 228 229 switch(popup.GetOption()) 230 { 231 case ViewMenu::kContextAction: 232 m_currentView = kActionsByContext; 233 234 if ((m_leftListType != kContextList) || 235 (m_rightListType != kActionList)) 236 { 237 m_leftListType = kContextList; 238 m_rightListType = kActionList; 239 UpdateLists(); 240 241 if (m_focusedUIElement != m_leftList) 242 { 243 ChangeListFocus(m_leftList, 244 (m_focusedUIElement == m_rightList) ? 245 m_rightList : NULL); 246 } 247 } 248 break; 249 case ViewMenu::kContextKey: 250 251 m_currentView = kKeysByContext; 252 253 if ((m_leftListType != kContextList) || 254 (m_rightListType != kKeyList)) 255 { 256 m_leftListType = kContextList; 257 m_rightListType = kKeyList; 258 UpdateLists(); 259 260 if (m_focusedUIElement != m_leftList) 261 { 262 ChangeListFocus(m_leftList, 263 (m_focusedUIElement == m_rightList) ? 264 m_rightList : NULL); 265 } 266 } 267 break; 268 case ViewMenu::kKeyContext: 269 270 m_currentView = kContextsByKey; 271 272 if ((m_leftListType != kKeyList) || 273 (m_rightListType != kContextList)) 274 { 275 m_leftListType = kKeyList; 276 m_rightListType = kContextList; 277 UpdateLists(); 278 279 if (m_focusedUIElement != m_leftList) 280 { 281 ChangeListFocus(m_leftList, 282 (m_focusedUIElement == m_rightList) ? 283 m_rightList : NULL); 284 } 285 } 286 break; 287 default: 288 break; 289 } 290 } 291 292 224 293 void MythControls::keyPressEvent(QKeyEvent *e) 225 294 { 226 295 bool handled = false; … … 238 307 m_focusedUIElement->looseFocus(); 239 308 240 309 OptionsMenu popup(gContext->GetMainWindow()); 241 if (OptionsMenu::kSave == popup.GetOption())242 Save();243 310 311 switch (popup.GetOption()) 312 { 313 case OptionsMenu::kSave: Save(); 314 break; 315 case OptionsMenu::kChangeView: 316 ChangeView(); 317 break; 318 default: 319 break; 320 } 321 244 322 m_focusedUIElement->takeFocus(); 245 323 } 246 324 else if (action == "SELECT") … … 327 405 else if (m_focusedUIElement == m_rightList) 328 406 m_rightList->MoveDown(UIListBtnType::MovePage); 329 407 } 330 else if (action == "1")331 {332 if ((m_leftListType != kContextList) ||333 (m_rightListType != kActionList))334 {335 m_leftListType = kContextList;336 m_rightListType = kActionList;337 UpdateLists();338 339 if (m_focusedUIElement != m_leftList)340 {341 ChangeListFocus(m_leftList,342 (m_focusedUIElement == m_rightList) ?343 m_rightList : NULL);344 }345 }346 else347 {348 handled = false;349 }350 }351 else if (action == "2")352 {353 if ((m_leftListType != kContextList) ||354 (m_rightListType != kKeyList))355 {356 m_leftListType = kContextList;357 m_rightListType = kKeyList;358 UpdateLists();359 360 if (m_focusedUIElement != m_leftList)361 {362 ChangeListFocus(m_leftList,363 (m_focusedUIElement == m_rightList) ?364 m_rightList : NULL);365 }366 }367 else368 {369 handled = false;370 }371 }372 else if (action == "3")373 {374 if ((m_leftListType != kKeyList) ||375 (m_rightListType != kContextList))376 {377 m_leftListType = kKeyList;378 m_rightListType = kContextList;379 UpdateLists();380 381 if (m_focusedUIElement != m_leftList)382 {383 ChangeListFocus(m_leftList,384 (m_focusedUIElement == m_rightList) ?385 m_rightList : NULL);386 }387 }388 else389 {390 handled = false;391 }392 }393 408 else 394 409 { 395 410 handled = false; … … 846 861 return; 847 862 } 848 863 849 BindingList *list = m_keyToBindingsMap[key]; 850 Binding *binding = NULL; 864 ConfirmMenu popup(gContext->GetMainWindow(), tr("Delete this binding?")); 851 865 852 for (BindingList::iterator it = list->begin(); it != list->end(); ++it) 853 { 854 Binding *b = *it; 855 if (b->context == context) 856 binding = b; 857 } 858 859 if (!binding) 860 { 861 InvalidBindingPopup popup(gContext->GetMainWindow()); 862 popup.GetOption(); 866 if (popup.GetOption() != ConfirmMenu::kConfirm) 863 867 return; 864 }865 868 866 if ( binding->contextFrom != context)869 if (!m_bindings->RemoveActionKey(context, action, key)) 867 870 { 868 ConfirmMenu popup(gContext->GetMainWindow(),869 tr("Delete this key binding from context %1?")870 .arg(binding->contextFrom));871 872 if (popup.GetOption() != ConfirmMenu::kConfirm)873 return;874 }875 else876 {877 ConfirmMenu popup(gContext->GetMainWindow(),878 tr("Delete this binding?"));879 880 if (popup.GetOption() != ConfirmMenu::kConfirm)881 return;882 }883 884 if (!m_bindings->RemoveActionKey(binding->contextFrom, action, key))885 {886 871 InvalidBindingPopup popup(gContext->GetMainWindow()); 887 872 popup.GetOption(); 888 873 return; … … 1204 1189 return key; 1205 1190 } 1206 1191 1192 /** \brief Create the view menu. 1193 * \param window The main window. 1194 * \param current The current view type. 1195 */ 1196 ViewMenu::ViewMenu(MythMainWindow *window, ViewType current) 1197 : MythPopupBox(window, "mcviewmenu") 1198 { 1199 addLabel(tr("Change View"), Large, false); 1200 1201 switch(current) 1202 { 1203 case kKeysByContext: 1204 addButton(tr("Actions By Context"), this, SLOT(ActionsByContext())); 1205 addButton(tr("Contexts By Key"), this, SLOT(ContextsByKey())); 1206 break; 1207 case kContextsByKey: 1208 addButton(tr("Actions By Context"), this, SLOT(ActionsByContext())); 1209 addButton(tr("Keys By Context"), this, SLOT(KeysByContext())); 1210 break; 1211 default: 1212 addButton(tr("Keys By Context"), this, SLOT(KeysByContext())); 1213 addButton(tr("Contexts By Key"), this, SLOT(ContextsByKey())); 1214 break; 1215 } 1216 1217 addButton(tr("Cancel"), this, SLOT(Cancel()))->setFocus(); 1218 } 1219 1207 1220 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
mythcontrols/mythcontrols.h
29 29 30 30 #include "keybindings.h" 31 31 32 33 typedef enum { kActionsByContext, kKeysByContext, kContextsByKey} ViewType; 34 35 /** \class ViewMenu 36 * \brief Prompts the user to change the view. 37 */ 38 class ViewMenu : public MythPopupBox 39 { 40 Q_OBJECT 41 42 public: 43 44 /// \brief The available views 45 enum actions { kContextAction, kContextKey, kKeyContext, kCancel}; 46 47 /** \brief Creates a new view dialog box. 48 * \param window The main MythTV window. 49 * \param first The first button's caption 50 * \param second The second button's caption 51 */ 52 ViewMenu(MythMainWindow *window, ViewType current); 53 54 /// \brief Execute the option popup. 55 int GetOption(void) { return ExecPopup(this,SLOT(Cancel())); } 56 57 public slots: 58 59 void ActionsByContext(void) { done(ViewMenu::kContextAction); } 60 void KeysByContext(void) { done(ViewMenu::kContextKey); } 61 void ContextsByKey(void) { done(ViewMenu::kKeyContext); } 62 void Cancel(void) { done(ViewMenu::kCancel); } 63 }; 64 65 32 66 class Binding 33 67 { 34 68 public: … … 83 117 void LoadData(const QString &hostname); 84 118 void ChangeButtonFocus(int direction); 85 119 void ChangeListFocus(UIListBtnType *focus, UIListBtnType *unfocus); 120 void ChangeView(void); 86 121 void AddBindings(QDict<Binding> &bindings, const QString &context, 87 122 const QString &contextParent, int bindlevel); 88 123 … … 106 141 void Save(void) { m_bindings->CommitChanges(); } 107 142 108 143 private: 144 ViewType m_currentView; 109 145 UIType *m_focusedUIElement; 110 146 UIListBtnType *m_leftList; 111 147 UIListBtnType *m_rightList; -
mythcontrols/controls-ui.xml
46 46 <container name="controls"> 47 47 <area>20,20,780,450</area> 48 48 49 <textarea name="options" draworder="1" align="center">50 <font>options</font>51 <area>0,0,780,30</area>52 <value>(1) Contexts / Actions (2) Contexts / Keys (3) Keys / Contexts</value>53 </textarea>54 55 49 <textarea name="leftdesc" draworder="1" align="center"> 56 50 <font>info</font> 57 <area>0, 40,370,20</area>51 <area>0,0,370,20</area> 58 52 <value>Contexts</value> 59 53 </textarea> 60 54 61 55 <listbtnarea name="leftlist" draworder="0"> 62 <area>0, 60,370,380</area>56 <area>0,30,370,420</area> 63 57 <gradient type="unselected" start="#505050" end="#000000" alpha="100"/> 64 58 <gradient type="selected" start="#52CA38" end="#349838" alpha="255"/> 65 59 <fcnfont name="active" function="active"/> … … 69 63 70 64 <textarea name="rightdesc" draworder="1" align="center"> 71 65 <font>info</font> 72 <area>390, 40,370,20</area>66 <area>390,0,370,20</area> 73 67 <value>Actions</value> 74 68 </textarea> 75 69 76 70 <listbtnarea name="rightlist" draworder="0"> 77 <area>390, 60,370,380</area>71 <area>390,30,370,420</area> 78 72 <gradient type="unselected" start="#505050" end="#000000" alpha="100"/> 79 73 <gradient type="selected" start="#52CA38" end="#349838" alpha="255"/> 80 74 <fcnfont name="active" function="active"/> -
mythcontrols/keygrabber.cpp
126 126 { 127 127 addLabel(tr("Options"), Large, false); 128 128 addButton(QObject::tr("Save"), this, SLOT(Save())); 129 addButton(QObject::tr("Change View"), this, SLOT(ChangeView())); 129 130 addButton(QObject::tr("Cancel"), this, SLOT(Cancel()))->setFocus(); 130 131 } 131 132