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 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. void displayLicenseWindow();
  24. };
  25. #endif
  26. @ Implementation is in a separate file.
  27. @(helpmenu.cpp@>=
  28. #include "helpmenu.h"
  29. #include "abouttypica.h"
  30. #include "licensewindow.h"
  31. @<Help menu implementation@>@;
  32. @ The constructor sets an object name for the menu so scripts are able to look
  33. up the menu and add additional items.
  34. @<Help menu implementation@>=
  35. HelpMenu::HelpMenu() : QMenu()
  36. {
  37. setObjectName("helpMenu");
  38. setTitle(tr("Help"));
  39. QAction *aboutTypicaAction = new QAction(tr("About Typica"), this);
  40. aboutTypicaAction->setObjectName("aboutTypicaAction");
  41. addAction(aboutTypicaAction);
  42. connect(aboutTypicaAction, SIGNAL(triggered()), this, SLOT(displayAboutTypica()));
  43. QAction *licenseAction = new QAction(tr("License Information"), this);
  44. licenseAction->setObjectName("licenseAction");
  45. addAction(licenseAction);
  46. connect(licenseAction, SIGNAL(triggered()), this, SLOT(displayLicenseWindow()));
  47. }
  48. @ When "About Typica" is selected from the menu, we display an about box. This
  49. is also handled by a separate class.
  50. @<Help menu implementation@>=
  51. void HelpMenu::displayAboutTypica()
  52. {
  53. AboutTypica *aboutBox = new AboutTypica;
  54. aboutBox->show();
  55. }
  56. @ Similarly, the "License Information" menu item brings up a window with
  57. appropriate information.
  58. @<Help menu implementation@>=
  59. void HelpMenu::displayLicenseWindow()
  60. {
  61. LicenseWindow *window = new LicenseWindow;
  62. window->show();
  63. }