Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

helpmenu.w 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. @* The Help Menu.
  2. \noindent Every window has a help menu that is inserted at the end of any
  3. configuration defined menus. At present this only serves to have a place to
  4. hold the "About Typica" menu item which brings up an appropriate about box, but
  5. there is the possibility that future developments will introduce other items
  6. that should be included in this menu.
  7. @<Insert help menu@>=
  8. HelpMenu *helpMenu = new HelpMenu();
  9. window->menuBar()->addMenu(helpMenu);
  10. @ Since the help menu is represented by its own class, we must have a
  11. declaration for that class. This is a trivial case.
  12. @(helpmenu.h@>=
  13. #include <QMenu>
  14. #ifndef HelpMenuHeader
  15. #define HelpMenuHeader
  16. class HelpMenu : public QMenu
  17. {
  18. Q_OBJECT
  19. public:
  20. HelpMenu();
  21. public slots:
  22. void displayAboutTypica();
  23. };
  24. #endif
  25. @ Implementation is in a separate file.
  26. @(helpmenu.cpp@>=
  27. #include "helpmenu.h"
  28. #include "abouttypica.h"
  29. @<Help menu implementation@>@;
  30. @ The constructor sets an object name for the menu so scripts are able to look
  31. up the menu and add additional items. The "About Typica" menu item also has an
  32. object name which can be used to provide custom handling if this is desired.
  33. The |triggered()| signal from that item is immediately connected to a handler
  34. for displaying an about box.
  35. @<Help menu implementation@>=
  36. HelpMenu::HelpMenu() : QMenu()
  37. {
  38. setObjectName("helpMenu");
  39. setTitle(tr("Help"));
  40. QAction *aboutTypicaAction = new QAction(tr("About Typica"), this);
  41. aboutTypicaAction->setObjectName("aboutTypicaAction");
  42. addAction(aboutTypicaAction);
  43. connect(aboutTypicaAction, SIGNAL(triggered()), this, SLOT(displayAboutTypica()));
  44. }
  45. @ When "About Typica" is selected from the menu, we display an about box. This
  46. is also handled by a separate class.
  47. @<Help menu implementation@>=
  48. void HelpMenu::displayAboutTypica()
  49. {
  50. AboutTypica *aboutBox = new AboutTypica;
  51. aboutBox->show();
  52. }