VirtualBox

Changeset 12010 in vbox for trunk


Ignore:
Timestamp:
Sep 2, 2008 10:08:52 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
35922
Message:

FE/Qt4: Unified the Help menu (using the VBoxHelpActions struct).

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleWnd.h

    r12007 r12010  
    2525
    2626#include "COMDefs.h"
     27
    2728#include "QIWithRetranslateUI.h"
     29
     30#include "VBoxProblemReporter.h"
    2831
    2932/* Qt includes */
     
    3235#include <QColor>
    3336#include <QDialog>
    34 
    3537
    3638#ifdef VBOX_WITH_DEBUGGER_GUI
     
    239241
    240242    // Help actions
    241     QAction *helpContentsAction;
    242     QAction *helpWebAction;
    243     QAction *helpRegisterAction;
    244     QAction *helpUpdateAction;
    245     QAction *helpAboutAction;
    246     QAction *helpResetMessagesAction;
     243    VBoxHelpActions mHelpActions;
    247244
    248245    // Machine popup menus
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h

    r11399 r12010  
    198198};
    199199
    200 // VBoxGlobal
     200// VBoxGlobal class
    201201////////////////////////////////////////////////////////////////////////////////
    202202
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxProblemReporter.h

    r11228 r12010  
    3030#include <QObject>
    3131
     32class QAction;
     33class QMenu;
     34
     35// VBoxHelpActions class
     36////////////////////////////////////////////////////////////////////////////////
     37
     38/**
     39 * Help Menu action container.
     40 *
     41 * Contains actions for all help menu items and methods to insert them to a
     42 * QMenu and to perform NLS string translation.
     43 *
     44 * Instances of this class are to be created as members of QWidget classes that
     45 * need a Help menu. The containing class usually passes itself as an argument
     46 * to the #setup() method and then calls #addTo() to add actions to its Help
     47 * menu. The #retranslateUi() method is called when it is necessary to
     48 * re-translate all action NLS according to the current language.
     49 */
     50struct VBoxHelpActions
     51{
     52    VBoxHelpActions()
     53        : contentsAction (NULL), webAction (NULL)
     54        , resetMessagesAction (NULL), registerAction (NULL)
     55        , updateAction (NULL), aboutAction (NULL)
     56        {}
     57
     58    void setup (QObject *aParent);
     59    void addTo (QMenu *aMenu);
     60    void retranslateUi();
     61
     62    QAction *contentsAction;
     63    QAction *webAction;
     64    QAction *resetMessagesAction;
     65    QAction *registerAction;
     66    QAction *updateAction;
     67    QAction *aboutAction;
     68};
     69
     70// VBoxProblemReporter class
     71////////////////////////////////////////////////////////////////////////////////
     72
     73/**
     74 * The VBoxProblemReporter class is a central place to handle all problem/error
     75 * situations that happen during application runtime and require the user's
     76 * attention.
     77 *
     78 * The role of this class is to describe the problem and/or the cause of the
     79 * error to the user and give him the opportunity to select an action (when
     80 * appropriate).
     81 *
     82 * Every problem sutiation has its own (correspondingly named) method in this
     83 * class that takes a list of arguments necessary to describe the situation and
     84 * to provide the appropriate actions. The method then returns the choice to the
     85 * caller.
     86 */
    3287class VBoxProblemReporter : public QObject
    3388{
     
    3691public:
    3792
    38     enum Type {
     93    enum Type
     94    {
    3995        Info = 1,
    4096        Question,
     
    44100        GuruMeditation
    45101    };
    46     enum {
     102
     103    enum
     104    {
    47105        AutoConfirmed = 0x8000
    48106    };
     
    339397};
    340398
     399/**
     400 * Shortcut to the static VBoxProblemReporter::instance() method, for
     401 * convenience.
     402 */
    341403inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
    342404
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h

    r11107 r12010  
    2727
    2828#include "QIWithRetranslateUI.h"
     29
    2930#include "VBoxGlobal.h"
     31#include "VBoxProblemReporter.h"
    3032
    3133/* Qt includes */
     
    126128    QAction *vmRefreshAction;
    127129    QAction *vmShowLogsAction;
    128     QAction *helpContentsAction;
    129     QAction *helpWebAction;
    130     QAction *helpRegisterAction;
    131     QAction *helpUpdateAction;
    132     QAction *helpAboutAction;
    133     QAction *helpResetMessagesAction;
     130
     131    VBoxHelpActions mHelpActions;
    134132
    135133    /* The vm list view/model */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp

    r12007 r12010  
    276276    /* Help menu actions */
    277277
    278     helpContentsAction = new QAction (this);
    279     helpContentsAction->setIcon (VBoxGlobal::iconSet (":/help_16px.png"));
    280     helpWebAction = new QAction (this);
    281     helpWebAction->setIcon (VBoxGlobal::iconSet (":/site_16px.png"));
    282     helpRegisterAction = new QAction (this);
    283     helpRegisterAction->setIcon (VBoxGlobal::iconSet (":/register_16px.png",
    284                                                       ":/register_disabled_16px.png"));
    285     helpUpdateAction = new QAction (this);
    286     helpUpdateAction->setIcon (VBoxGlobal::iconSet (":/refresh_16px.png",
    287                                                     ":/refresh_disabled_16px.png"));
    288     helpAboutAction = new QAction (this);
    289     helpAboutAction->setIcon (VBoxGlobal::iconSet (":/about_16px.png"));
    290     helpResetMessagesAction = new QAction (this);
    291     helpResetMessagesAction->setIcon (VBoxGlobal::iconSet (":/reset_16px.png"));
     278    mHelpActions.setup (this);
    292279
    293280    ///// Menubar ///////////////////////////////////////////////////////////
     
    385372    mMainMenu->addMenu (mHelpMenu);
    386373
    387     mHelpMenu->addAction (helpContentsAction);
    388     mHelpMenu->addAction (helpWebAction);
    389     mHelpMenu->addSeparator();
    390 #ifdef VBOX_WITH_REGISTRATION
    391     mHelpMenu->addAction (helpRegisterAction);
    392     helpRegisterAction->setEnabled (vboxGlobal().virtualBox().
    393         GetExtraData (VBoxDefs::GUI_RegistrationDlgWinID).isEmpty());
    394 #endif
    395     mHelpMenu->addAction (helpUpdateAction);
    396     helpUpdateAction->setEnabled (vboxGlobal().virtualBox().
    397         GetExtraData (VBoxDefs::GUI_UpdateDlgWinID).isEmpty());
    398     mHelpMenu->addAction (helpAboutAction);
    399     mHelpMenu->addSeparator();
    400     mHelpMenu->addAction (helpResetMessagesAction);
     374    mHelpActions.addTo (mHelpMenu);
    401375
    402376    ///// Status bar ////////////////////////////////////////////////////////
     
    555529    connect (mDevicesNetworkMenu, SIGNAL (aboutToHide()),
    556530             this, SLOT (clearStatusBar()));
    557 
    558     connect (helpContentsAction, SIGNAL (triggered()),
    559              &vboxProblem(), SLOT (showHelpHelpDialog()));
    560     connect (helpWebAction, SIGNAL (triggered()),
    561              &vboxProblem(), SLOT (showHelpWebDialog()));
    562     connect (helpRegisterAction, SIGNAL (triggered()),
    563              &vboxGlobal(), SLOT (showRegistrationDialog()));
    564     connect (helpUpdateAction, SIGNAL (triggered()),
    565              &vboxGlobal(), SLOT (showUpdateDialog()));
    566     connect (&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
    567              helpRegisterAction, SLOT (setEnabled (bool)));
    568     connect (&vboxGlobal(), SIGNAL (canShowUpdDlg (bool)),
    569              helpUpdateAction, SLOT (setEnabled (bool)));
    570     connect (helpAboutAction, SIGNAL (triggered()),
    571              &vboxProblem(), SLOT (showHelpAboutDialog()));
    572     connect (helpResetMessagesAction, SIGNAL (triggered()),
    573              &vboxProblem(), SLOT (resetSuppressedMessages()));
    574531
    575532    connect (fd_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
     
    15911548    /* Help actions */
    15921549
    1593     helpContentsAction->setText (tr ("&Contents..."));
    1594     helpContentsAction->setShortcut (QKeySequence::HelpContents);
    1595     helpContentsAction->setStatusTip (tr ("Show the online help contents"));
    1596 
    1597     helpWebAction->setText (tr ("&VirtualBox Web Site..."));
    1598     helpWebAction->setStatusTip (
    1599         tr ("Open the browser and go to the VirtualBox product web site"));
    1600 
    1601     helpRegisterAction->setText (tr ("R&egister VirtualBox..."));
    1602     helpRegisterAction->setStatusTip (
    1603         tr ("Open VirtualBox registration form"));
    1604 
    1605     helpUpdateAction->setText (tr ("C&heck for a new version..."));
    1606     helpUpdateAction->setStatusTip (
    1607         tr ("Check for a new VirtualBox version"));
    1608 
    1609     helpAboutAction->setText (tr ("&About VirtualBox..."));
    1610     helpAboutAction->setStatusTip (tr ("Show a dialog with product information"));
    1611 
    1612     helpResetMessagesAction->setText (tr ("&Reset All Warnings"));
    1613     helpResetMessagesAction->setStatusTip (
    1614         tr ("Cause all suppressed warnings and messages to be shown again"));
     1550    mHelpActions.retranslateUi();
    16151551
    16161552    /* Devices menu submenus */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp

    r11955 r12010  
    40974097}
    40984098
     4099/**
     4100 * Shows the VirtualBox registration dialog.
     4101 *
     4102 * @note that this method is not part of VBoxProblemReporter (like e.g.
     4103 *       VBoxProblemReporter::showHelpAboutDialog()) because it is tied to
     4104 *       VBoxCallback::OnExtraDataChange() handling performed by VBoxGlobal.
     4105 *
     4106 * @param aForce
     4107 */
    40994108void VBoxGlobal::showRegistrationDialog (bool aForce)
    41004109{
     
    41344143}
    41354144
     4145/**
     4146 * Shows the VirtualBox version check & update dialog.
     4147 *
     4148 * @note that this method is not part of VBoxProblemReporter (like e.g.
     4149 *       VBoxProblemReporter::showHelpAboutDialog()) because it is tied to
     4150 *       VBoxCallback::OnExtraDataChange() handling performed by VBoxGlobal.
     4151 *
     4152 * @param aForce
     4153 */
    41364154void VBoxGlobal::showUpdateDialog (bool aForce)
    41374155{
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxProblemReporter.cpp

    r12009 r12010  
    4242# include <QPushButton>
    4343#endif
     44#include <QAction>
     45#include <QMenu>
    4446
    4547#include <iprt/err.h>
     
    5153#endif
    5254
     55////////////////////////////////////////////////////////////////////////////////
     56// VBoxProgressDialog class
     57////////////////////////////////////////////////////////////////////////////////
     58
    5359/**
    54  *  A QProgressDialog enhancement that allows to:
     60 * A QProgressDialog enhancement that allows to:
    5561 *
    56  *  1) prevent closing the dialog when it has no cancel button;
    57  *  2) effectively track the IProgress object completion
    58  *     (w/o using IProgress::waitForCompletion() and w/o blocking the UI thread
    59  *     in any other way for too long).
     62 * 1) prevent closing the dialog when it has no cancel button;
     63 * 2) effectively track the IProgress object completion (w/o using
     64 *    IProgress::waitForCompletion() and w/o blocking the UI thread in any other
     65 *    way for too long).
    6066 *
    61  *  @note The CProgress instance is passed as a non-const reference to the
    62  *        constructor (to memorize COM errors if they happen), and therefore
    63  *        must not be destroyed before the created VBoxProgressDialog instance
    64  *        is destroyed.
     67 * @note The CProgress instance is passed as a non-const reference to the
     68 *       constructor (to memorize COM errors if they happen), and therefore must
     69 *       not be destroyed before the created VBoxProgressDialog instance is
     70 *       destroyed.
    6571 */
    6672class VBoxProgressDialog : public QProgressDialog
     
    187193const char *VBoxProgressDialog::sOpDescTpl = "%1... (%2/%3)";
    188194
    189 
    190 /** @class VBoxProblemReporter
    191  *
    192  *  The VBoxProblemReporter class is a central place to handle all
    193  *  problem/error situations that happen during application
    194  *  runtime and require the user's attention. Its role is to
    195  *  describe the problem and/or the cause of the error to the user and give
    196  *  him the opportunity to select an action (when appropriate).
    197  *
    198  *  Every problem sutiation has its own (correspondingly named) method in
    199  *  this class that takes a list of arguments necessary to describe the
    200  *  situation and to provide the appropriate actions. The method then
    201  *  returns the choice to the caller.
    202  */
     195////////////////////////////////////////////////////////////////////////////////
     196// VBoxHelpActions class
     197////////////////////////////////////////////////////////////////////////////////
     198
     199void VBoxHelpActions::setup (QObject *aParent)
     200{
     201    AssertReturnVoid (contentsAction == NULL);
     202
     203    contentsAction = new QAction (aParent);
     204    contentsAction->setIcon (VBoxGlobal::iconSet (":/help_16px.png"));
     205
     206    webAction = new QAction (aParent);
     207    webAction->setIcon (VBoxGlobal::iconSet (":/site_16px.png"));
     208
     209    resetMessagesAction = new QAction (aParent);
     210    resetMessagesAction->setIcon (VBoxGlobal::iconSet (":/reset_16px.png"));
     211
     212    registerAction = new QAction (aParent);
     213    registerAction->setIcon (VBoxGlobal::iconSet (":/register_16px.png",
     214                                                  ":/register_disabled_16px.png"));
     215    updateAction = new QAction (aParent);
     216    updateAction->setIcon (VBoxGlobal::iconSet (":/refresh_16px.png",
     217                                                ":/refresh_disabled_16px.png"));
     218    aboutAction = new QAction (aParent);
     219    aboutAction->setIcon (VBoxGlobal::iconSet (":/about_16px.png"));
     220
     221    QObject::connect (contentsAction, SIGNAL (triggered()),
     222                      &vboxProblem(), SLOT (showHelpHelpDialog()));
     223    QObject::connect (webAction, SIGNAL (triggered()),
     224                      &vboxProblem(), SLOT (showHelpWebDialog()));
     225    QObject::connect (resetMessagesAction, SIGNAL (triggered()),
     226                      &vboxProblem(), SLOT (resetSuppressedMessages()));
     227    QObject::connect (registerAction, SIGNAL (triggered()),
     228                      &vboxGlobal(), SLOT (showRegistrationDialog()));
     229    QObject::connect (updateAction, SIGNAL (triggered()),
     230                      &vboxGlobal(), SLOT (showUpdateDialog()));
     231    QObject::connect (aboutAction, SIGNAL (triggered()),
     232                      &vboxProblem(), SLOT (showHelpAboutDialog()));
     233
     234    QObject::connect (&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
     235                      registerAction, SLOT (setEnabled (bool)));
     236    QObject::connect (&vboxGlobal(), SIGNAL (canShowUpdDlg (bool)),
     237                      updateAction, SLOT (setEnabled (bool)));
     238}
     239
     240void VBoxHelpActions::addTo (QMenu *aMenu)
     241{
     242    AssertReturnVoid (contentsAction != NULL);
     243
     244    aMenu->addAction (contentsAction);
     245    aMenu->addAction (webAction);
     246    aMenu->addSeparator();
     247
     248    aMenu->addAction (resetMessagesAction);
     249    aMenu->addSeparator();
     250
     251#ifdef VBOX_WITH_REGISTRATION
     252    aMenu->addAction (registerAction);
     253    registerAction->setEnabled (vboxGlobal().virtualBox().
     254        GetExtraData (VBoxDefs::GUI_RegistrationDlgWinID).isEmpty());
     255#endif
     256
     257    aMenu->addAction (updateAction);
     258    updateAction->setEnabled (vboxGlobal().virtualBox().
     259        GetExtraData (VBoxDefs::GUI_UpdateDlgWinID).isEmpty());
     260
     261    aMenu->addSeparator();
     262    aMenu->addAction (aboutAction);
     263}
     264
     265void VBoxHelpActions::retranslateUi()
     266{
     267    AssertReturnVoid (contentsAction != NULL);
     268
     269    contentsAction->setText (VBoxProblemReporter::tr ("&Contents..."));
     270    contentsAction->setShortcut (QKeySequence::HelpContents);
     271    contentsAction->setStatusTip (VBoxProblemReporter::tr (
     272        "Show the online help contents"));
     273
     274    webAction->setText (VBoxProblemReporter::tr ("&VirtualBox Web Site..."));
     275    webAction->setStatusTip (VBoxProblemReporter::tr (
     276        "Open the browser and go to the VirtualBox product web site"));
     277
     278    resetMessagesAction->setText (VBoxProblemReporter::tr ("&Reset All Warnings"));
     279    resetMessagesAction->setStatusTip (VBoxProblemReporter::tr (
     280        "Cause all suppressed warnings and messages to be shown again"));
     281
     282    registerAction->setText (VBoxProblemReporter::tr ("R&egister VirtualBox..."));
     283    registerAction->setStatusTip (VBoxProblemReporter::tr (
     284        "Open VirtualBox registration form"));
     285
     286    updateAction->setText (VBoxProblemReporter::tr ("C&heck for Updates..."));
     287    updateAction->setStatusTip (VBoxProblemReporter::tr (
     288        "Check for a new VirtualBox version"));
     289
     290    aboutAction->setText (VBoxProblemReporter::tr ("&About VirtualBox..."));
     291    aboutAction->setStatusTip (VBoxProblemReporter::tr (
     292        "Show a dialog with product information"));
     293}
     294
     295////////////////////////////////////////////////////////////////////////////////
     296// VBoxProblemReporter class
     297////////////////////////////////////////////////////////////////////////////////
    203298
    204299/**
     
    21912286}
    21922287
    2193 /** @fn vboxProblem
    2194  *
    2195  *  Shortcut to the static VBoxProblemReporter::instance() method, for
    2196  *  convenience.
    2197  */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp

    r11978 r12010  
    438438        ":/vm_show_logs_disabled_32px.png", "show_logs_disabled_16px.png"));
    439439
    440     helpContentsAction = new QAction (this);
    441     helpContentsAction->setIcon (VBoxGlobal::iconSet (":/help_16px.png"));
    442     helpWebAction = new QAction (this);
    443     helpWebAction->setIcon (VBoxGlobal::iconSet (":/site_16px.png"));
    444     helpRegisterAction = new QAction (this);
    445     helpRegisterAction->setIcon (VBoxGlobal::iconSet (":/register_16px.png",
    446                                                       ":/register_disabled_16px.png"));
    447     helpUpdateAction = new QAction (this);
    448     helpUpdateAction->setIcon (VBoxGlobal::iconSet (":/refresh_16px.png",
    449                                                     ":/refresh_disabled_16px.png"));
    450     helpAboutAction = new QAction (this);
    451     helpAboutAction->setIcon (VBoxGlobal::iconSet (":/about_16px.png"));
    452     helpResetMessagesAction = new QAction (this);
    453     helpResetMessagesAction->setIcon (VBoxGlobal::iconSet (":/reset_16px.png"));
     440    mHelpActions.setup (this);
    454441
    455442    /* subwidgets */
     
    573560
    574561    mHelpMenu = menuBar()->addMenu (QString::null);
    575     mHelpMenu->addAction (helpContentsAction);
    576     mHelpMenu->addAction (helpWebAction);
    577     mHelpMenu->addSeparator();
    578 #ifdef VBOX_WITH_REGISTRATION
    579     mHelpMenu->addAction (helpRegisterAction);
    580     helpRegisterAction->setEnabled (vboxGlobal().virtualBox().
    581         GetExtraData (VBoxDefs::GUI_RegistrationDlgWinID).isEmpty());
    582 #endif
    583     mHelpMenu->addAction (helpUpdateAction);
    584     helpUpdateAction->setEnabled (vboxGlobal().virtualBox().
    585         GetExtraData (VBoxDefs::GUI_UpdateDlgWinID).isEmpty());
    586     mHelpMenu->addAction (helpAboutAction);
    587     mHelpMenu->addSeparator();
    588     mHelpMenu->addAction (helpResetMessagesAction);
     562    mHelpActions.addTo (mHelpMenu);
    589563
    590564    retranslateUi();
     
    660634    connect (vmRefreshAction, SIGNAL (triggered()), this, SLOT (vmRefresh()));
    661635    connect (vmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
    662 
    663     connect (helpContentsAction, SIGNAL (triggered()),
    664              &vboxProblem(), SLOT (showHelpHelpDialog()));
    665     connect (helpWebAction, SIGNAL (triggered()),
    666              &vboxProblem(), SLOT (showHelpWebDialog()));
    667     connect (helpRegisterAction, SIGNAL (triggered()),
    668              &vboxGlobal(), SLOT (showRegistrationDialog()));
    669     connect (helpUpdateAction, SIGNAL (triggered()),
    670              &vboxGlobal(), SLOT (showUpdateDialog()));
    671     connect (&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
    672              helpRegisterAction, SLOT (setEnabled (bool)));
    673     connect (&vboxGlobal(), SIGNAL (canShowUpdDlg (bool)),
    674              helpUpdateAction, SLOT (setEnabled (bool)));
    675     connect (helpAboutAction, SIGNAL (triggered()),
    676              &vboxProblem(), SLOT (showHelpAboutDialog()));
    677     connect (helpResetMessagesAction, SIGNAL (triggered()),
    678              &vboxProblem(), SLOT (resetSuppressedMessages()));
    679636
    680637    connect (mVMListView, SIGNAL (currentChanged()),
     
    12261183        tr ("Show the log files of the selected virtual machine"));
    12271184
    1228     helpContentsAction->setText (tr ("&Contents..."));
    1229     helpContentsAction->setShortcut (QKeySequence::HelpContents);
    1230     helpContentsAction->setStatusTip (tr ("Show the online help contents"));
    1231 
    1232     helpWebAction->setText (tr ("&VirtualBox Web Site..."));
    1233     helpWebAction->setStatusTip (
    1234         tr ("Open the browser and go to the VirtualBox product web site"));
    1235 
    1236     helpRegisterAction->setText (tr ("R&egister VirtualBox..."));
    1237     helpRegisterAction->setStatusTip (
    1238         tr ("Open VirtualBox registration form"));
    1239 
    1240     helpUpdateAction->setText (tr ("C&heck for update..."));
    1241     helpUpdateAction->setStatusTip (
    1242         tr ("Check server for VirtualBox updates"));
    1243 
    1244     helpAboutAction->setText (tr ("&About VirtualBox..."));
    1245     helpAboutAction->setStatusTip (tr ("Show a dialog with product information"));
    1246 
    1247     helpResetMessagesAction->setText (tr ("&Reset All Warnings"));
    1248     helpResetMessagesAction->setStatusTip (
    1249         tr ("Cause all suppressed warnings and messages to be shown again"));
     1185    mHelpActions.retranslateUi();
    12501186
    12511187    mFileMenu->setTitle (tr("&File"));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette