Ticket #3987: firstPlugin.diff
File firstPlugin.diff, 11.4 KB (added by , 17 years ago) |
---|
-
mythtv/libs/libmythui/myththemedmenu.h
7 7 class MythThemedMenuPrivate; 8 8 class MythThemedMenuState; 9 9 10 /** 11 * Finds and parses menu and theme files then applies them to screen then handles actions 12 * captured by those elements. 13 */ 10 14 class MythThemedMenu : public MythScreenType 11 15 { 12 16 Q_OBJECT 13 17 public: 18 /** 19 * @param cdir directory where theme is stored 20 * @param menufile name of menu file 21 * @param parent the screen stack that owns this UI type 22 * @param name the name of this UI type 23 * @param allowreorder will buttons be inserted into new rows or pushed back 24 * @param state theme state associated with this menu 25 */ 14 26 MythThemedMenu(const char *cdir, const char *menufile, 15 27 MythScreenStack *parent, const char *name, 16 28 bool allowreorder = true, MythThemedMenuState *state = NULL); 17 29 ~MythThemedMenu(); 18 30 31 /** 32 * @return true if the theme has been found 33 */ 19 34 bool foundTheme(void); 20 35 36 /** 37 * Set the themed menus callback state 38 *@param lcallback the callback state 39 *@param data information about the callback state 40 */ 21 41 void setCallback(void (*lcallback)(void *, QString &), void *data); 22 42 void setKillable(void); 23 43 24 44 QString getSelection(void); 25 45 26 46 void ReloadTheme(void); 47 48 /** 49 * @brief Set the exit key to the appropriate button type depending on the database 50 * context, or set it not to not allow exiting just yet. 51 */ 27 52 void ReloadExitKey(void); 28 53 virtual void aboutToShow(void); 29 54 30 55 protected: 56 /** 57 * @return true if handled 58 */ 31 59 virtual bool keyPressEvent(QKeyEvent *e); 60 61 /** 62 * @brief Interpret mouse gestures on the UI as key events 63 * @param origtype the orriginating element type from the screen 64 * @param ge the mouse gesture event 65 */ 32 66 virtual void gestureEvent(MythUIType *origtype, MythGestureEvent *ge); 33 67 34 68 private: 69 /** 70 * Initialize creation of a mythThemedMenu 71 * @param cdir directory where theme is stored 72 * @param menufile name of menu file 73 */ 35 74 void Init(const char *cdir, const char *menufile); 36 75 37 76 MythThemedMenuPrivate *d; -
mythtv/libs/libmythui/myththemedmenu.cpp
88 88 89 89 class MythThemedMenuPrivate; 90 90 91 /** 92 * @class MyththemedMenuState 93 * @brief Private class that controls the settings of buttons, logos, backgrounds, 94 * texts, and more, for the MythThemedMenu class. 95 */ 91 96 class MythThemedMenuState: public XMLParseBase 92 97 { 93 98 public: 94 99 MythThemedMenuState(); 95 100 ~MythThemedMenuState(); 96 101 102 /** 103 * @brief Parse the menu from the given dir for background, button, logo, arrow, 104 * and font settings 105 * @param dir directory where setting may be found 106 * @param menuname name of menu file from which settings are parsed 107 * @return true if file exists, opens, and parses correctly 108 */ 97 109 bool parseSettings(const QString &dir, const QString &menuname); 98 110 111 /** 112 * @brief Parse through the element's tags and set the button's 113 * area, spread, center, rows, columns and visible lower limit. 114 * @param &dir the directory path of background 115 * @param element QDomElement with information about the background 116 */ 99 117 void parseBackground(const QString &dir, QDomElement &element); 118 119 /** 120 * @brief Parse through the element's tags and set the logo's image and position 121 * @param dir the directory where logo images may be found 122 * @param element the DOM element whose nodes describe the logo 123 */ 100 124 void parseLogo(const QString &dir, QDomElement &element); 125 126 /** 127 * @brief Parse through the element's tags to set the arrows image and position 128 * @param dir directory where arrow images may be found 129 * @param element DOM element dealing with arrow image and position 130 */ 101 131 void parseArrow(const QString &dir, QDomElement &element, bool up); 132 133 /** 134 * @brief Parse through the element's tags and set the title's image (and 135 * subsequent mode) and position 136 * @param dir directory where title images may be found 137 * @param element DOM element dealing with the title 138 */ 102 139 void parseTitle(const QString &dir, QDomElement &element); 140 141 /** 142 * @brief Parse through the element's tags and set the button's 143 * definition as normal, active, text, or activetext. 144 * @param dir the directory where the button images may be found 145 * @param element the DOM element whose nodes define Buttons 146 */ 103 147 void parseButtonDefinition(const QString &dir, QDomElement &element); 148 149 /** 150 * @brief Parse through the element's tags and set the button's image, activeimage, 151 * watermarkimage, and offset 152 * @param dir directory where buttom images may be found 153 * @param element DOM element dealing with button attributes 154 */ 104 155 void parseButton(const QString &dir, QDomElement &element); 105 156 157 /** 158 * @brief Parse through the element's tags and set the text's area, 159 * fontsize, fontname, positioning, and decorations 160 * @param attributes text attributes whose font face will be set 161 * @param element DOM element dealing with text 162 */ 106 163 void parseText(TextAttributes &attributes, QDomElement &element); 164 165 /** 166 * @brief Parse through the element's tags and set the outline's color 167 * and size 168 * @param attributes text attributes whose font outline will be set 169 * @param element DOM element dealing with outline 170 */ 107 171 void parseOutline(TextAttributes &attributes, QDomElement &element); 108 void parseShadow(TextAttributes &attributes, QDomElement &element);109 172 173 /** 174 * @brief Parse through the element's tags and set the shadow's color, 175 * offset, and alpha. 176 * @param attributes text attributes whose font shadow will be set 177 * @param element DOM dealing with shadow 178 */ 179 void parseShadow(TextAttributes &attributes, QDomElement &element); 180 110 181 void Reset(void); 182 183 /** 184 * @brief Set buttons, logo, title icons and text, arrows and watermarks back to 185 * the defaults 186 */ 111 187 void setDefaults(void); 112 188 113 189 ButtonIcon *getButtonIcon(const QString &type); … … 167 243 class MythThemedMenuPrivate: public XMLParseBase 168 244 { 169 245 public: 170 MythThemedMenuPrivate(MythThemedMenu *lparent, const char *cdir, 246 /** 247 * @param lparent menu that owns this instance 248 * @param cdir directory where theme is stored 249 * @param lstate corresponding settings of the theme 250 */ 251 MythThemedMenuPrivate(MythThemedMenu *lparent, const char *cdir, 171 252 MythThemedMenuState *lstate); 172 253 ~MythThemedMenuPrivate(); 173 254 255 /** 256 * @brief Delegate key event to appropriate action for keyHandler() 257 * @param e key pressed 258 * @return true if key event was properly handled 259 */ 174 260 bool keyPressHandler(QKeyEvent *e); 261 262 /** 263 * @brief Interpret key presses on the menu into the appropriate actions 264 * @param actions list of key presses to be interpreted 265 * @param fullexit should this be allowed to exit the program if other conditions 266 * are right 267 */ 175 268 bool keyHandler(QStringList &actions, bool fullexit); 176 269 270 /** 271 * @brief Reset and reparse everything 272 * @return true if theme was reloaded correctly 273 */ 177 274 bool ReloadTheme(void); 178 275 276 /** 277 * @brief Parse the themebuttons to be added based on the name of the menu file 278 * provided in the parameters 279 * @param menuname name of menu file 280 * @return true if passed mainmenu.xml 281 */ 179 282 bool parseMenu(const QString &menuname); 180 283 284 /** 285 * @brief Parse the element's tags and set the ThemeButton's type, text, depends, 286 * and action. Then add the button. 287 * @param element DOM element describing features of the themeButton 288 */ 181 289 void parseThemeButton(QDomElement &element); 182 290 291 /** 292 * @brief Create a new MythThemedButton based on the MythThemedMenuState m_state 293 * and the type, text, alt-text and action provided in the parameters. 294 * @param type type of button to be created 295 * @param text text to appear on the button 296 * @param alttext alttext to appear when required 297 * @param action actions to be associated with button 298 */ 183 299 void addButton(const QString &type, const QString &text, 184 300 const QString &alttext, const QStringList &action); 301 302 /** 303 * @brief Properly lay out all of the buttons that were added with addButton 304 * @return true if there are more than 0 rows or columns 305 */ 185 306 bool layoutButtons(void); 307 308 /** 309 * @brief Place buttons in position and set them visible and active 310 * @param resetpos whether or not to reset the active button to the first one on the 311 * buttonlist 312 */ 186 313 void positionButtons(bool resetpos); 187 314 bool makeRowVisible(int newrow, int oldrow); 188 315 316 /** 317 * @brief Handle actions from the menu requested by the user such as "exectv, jump, 318 * or menu 319 * @param action the action to be handled 320 * @return true if the action is not to EXEC another program 321 */ 189 322 bool handleAction(const QString &action); 190 323 bool findDepends(const QString &fileList); 324 325 /** 326 * @brief Locate the appropriate menu file from which to parse the menu 327 * @param menuname the name of the menu file you want to find 328 * @return the directory in which the menu file is found 329 */ 191 330 QString findMenuFile(const QString &menuname); 192 331 332 /** 333 * @brief Show scroll arrows if needed 334 */ 193 335 void checkScrollArrows(void); 194 336 337 /** 338 * Check timestamp and password settings against database and 339 * @param timestamp_setting time settings to be checked 340 * @param password_setting password to be checked 341 * @param text the message text to be displayed 342 * @return true if pin code checks out 343 */ 195 344 bool checkPinCode(const QString ×tamp_setting, 196 345 const QString &password_setting, 197 346 const QString &text); 198 347 348 /** 349 * Set up UI according to the corresponding mythThemedMenuState 350 */ 199 351 void SetupUITypes(); 200 352 353 /** 354 * @brief Interpret mouse gestures on the UI as key events 355 * @param origtype the orriginating element type from the screen 356 * @param ge the mouse gesture event 357 * @return true if the gesture event was click or left 358 */ 201 359 bool gestureEvent(MythUIType *origtype, MythGestureEvent *ge); 202 360 203 361 void updateLCD(void); … … 261 419 Reset(); 262 420 } 263 421 422 264 423 void MythThemedMenuState::Reset(void) 265 424 { 266 425 if (logo) … … 2105 2264 2106 2265 return ""; 2107 2266 } 2108 2109 2267 bool MythThemedMenuPrivate::handleAction(const QString &action) 2110 2268 { 2111 2269 if (action.left(5) == "EXEC ") … … 2215 2373 return true; 2216 2374 } 2217 2375 2376 2218 2377 bool MythThemedMenuPrivate::findDepends(const QString &fileList) 2219 2378 { 2220 2379 QStringList files = QStringList::split(" ", fileList); … … 2374 2533 d->foundtheme = false; 2375 2534 } 2376 2535 2536 2377 2537 bool MythThemedMenu::keyPressEvent(QKeyEvent *e) 2378 2538 { 2379 2539 if (d->ignorekeys)