VirtualBox

Changeset 5803 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 20, 2007 1:55:28 PM (17 years ago)
Author:
vboxsync
Message:

FE/Qt: Improved most reminder messages (capture input, go fullscreen etc) so that the action they represent can be canceled now; Fixed tiny problem reporter's regressions.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r5759 r5803  
    208208    QPoint captured_pos;
    209209
     210        bool mDisableAutoCapture : 1;
     211
    210212    enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
    211213    uint8_t mPressedKeys [128];
     
    214216    bool mIsHostkeyPressed : 1;
    215217    bool mIsHostkeyAlone : 1;
     218
    216219    /** kbd_captured value during the the last host key press or release */
    217220    bool hostkey_in_capture : 1;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r5544 r5803  
    117117    void updateAppearanceOf (int element);
    118118
    119     void toggleFullscreenMode (bool, bool);
     119    bool toggleFullscreenMode (bool, bool);
    120120
    121121private slots:
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r5774 r5803  
    242242    void cannotDownloadGuestAdditions (const QString &aURL,
    243243                                       const QString &aReason);
    244     int confirmDownloadAdditions (const QString &aURL, ulong aSize);
    245     int confirmMountAdditions (const QString &aURL, const QString &aSrc);
     244    bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
     245    bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
    246246    void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
    247247    void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
     
    254254                             const QString &aResult);
    255255
    256     bool remindAboutInputCapture();
    257     bool remindAboutAutoCapture();
    258     bool remindAboutMouseIntegration (bool supportsAbsolute);
     256    bool confirmInputCapture();
     257    void remindAboutAutoCapture();
     258    void remindAboutMouseIntegration (bool aSupportsAbsolute);
    259259    bool remindAboutPausedVMInput();
    260260
    261261    bool remindAboutInaccessibleMedia();
    262262
    263     void remindAboutGoingFullscreen (const QString &hotKey,
    264                                      const QString &hostKey);
    265     void remindAboutGoingSeamless (const QString &hotKey,
    266                                    const QString &hostKey);
     263    bool confirmGoingFullscreen (const QString &aHotKey);
     264    bool confirmGoingSeamless (const QString &aHotKey);
    267265
    268266    void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
     
    273271    bool confirmVMReset (QWidget *aParent);
    274272
    275     int remindAboutUnsetHD (QWidget *aParent);
     273    bool confirmHardDisklessMachine (QWidget *aParent);
    276274
    277275    void cannotRunInSelectorMode();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r5761 r5803  
    604604    , mouse_absolute (false)
    605605    , mouse_integration (true)
     606    , mDisableAutoCapture (false)
    606607    , mIsHostkeyPressed (false)
    607608    , mIsHostkeyAlone (false)
     
    19351936
    19361937/**
    1937  *  Called on every focus change
    1938  *  and also to forcibly capture/uncapture the input in situations similar
    1939  *  to gaining or losing focus.
     1938 *  Called on every focus change and also to forcibly capture/uncapture the
     1939 *  input in situations similar to gaining or losing focus.
    19401940 *
    19411941 *  @param aHasFocus True if the window got focus and false otherwise.
     
    19461946    {
    19471947#ifdef RT_OS_WINDOWS
    1948         if (   gs.autoCapture()
     1948        if (   !mDisableAutoCapture && gs.autoCapture()
    19491949            && GetAncestor (winId(), GA_ROOT) == GetForegroundWindow())
    19501950#else
    1951         if (gs.autoCapture())
     1951        if (!mDisableAutoCapture && gs.autoCapture())
    19521952#endif /* RT_OS_WINDOWS */
    19531953        {
     
    22122212            {
    22132213                mIsHostkeyPressed = false;
     2214
    22142215                if (mIsHostkeyAlone)
    22152216                {
     
    22222223                    {
    22232224                        bool captured = kbd_captured;
     2225                        bool ok = true;
    22242226                        if (!captured)
    2225                             vboxProblem().remindAboutInputCapture();
    2226                         captureKbd (!captured, false);
    2227                         if (!(mouse_absolute && mouse_integration))
    2228                             captureMouse (kbd_captured);
     2227                        {
     2228                            /* temporarily disable auto capture that will take
     2229                             * place after this dialog is dismissed because
     2230                             * the capture state is to be defined by the
     2231                             * dialog result itself */
     2232                            mDisableAutoCapture = true;
     2233                            ok = vboxProblem().confirmInputCapture();
     2234                            mDisableAutoCapture = false;
     2235                        }
     2236                        if (ok)
     2237                        {
     2238                            captureKbd (!captured, false);
     2239                            if (!(mouse_absolute && mouse_integration))
     2240                                captureMouse (kbd_captured);
     2241                        }
    22292242                    }
    22302243                }
     2244
    22312245                if (isRunning())
    22322246                    sendChangedKeyStates();
     2247
    22332248                emitSignal = true;
    22342249            }
     
    25522567                else if (isRunning())
    25532568                {
    2554                     vboxProblem().remindAboutInputCapture();
    2555                     captureKbd (true);
    2556                     captureMouse (true);
     2569                    /* temporarily disable auto capture that will take
     2570                     * place after this dialog is dismissed because
     2571                     * the capture state is to be defined by the
     2572                     * dialog result itself */
     2573                    mDisableAutoCapture = true;
     2574                    bool ok = vboxProblem().confirmInputCapture();
     2575                    mDisableAutoCapture = false;
     2576                    if (ok)
     2577                    {
     2578                        captureKbd (true);
     2579                        captureMouse (true);
     2580                    }
    25572581                }
    25582582            }
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r5648 r5803  
    19021902}
    19031903
    1904 void VBoxConsoleWnd::toggleFullscreenMode (bool aOn, bool aSeamless)
     1904/**
     1905 * @return @c true if successfully performed the requested operation and false
     1906 * otherwise.
     1907 */
     1908bool VBoxConsoleWnd::toggleFullscreenMode (bool aOn, bool aSeamless)
    19051909{
    19061910    if (aSeamless)
    19071911    {
    1908         /* Check if it is necessary to enter/leave seamless mode. */
    1909         if (aOn && (!mIsSeamlessSupported || mIsFullscreen) ||
    1910             !aOn && !mIsSeamless)
    1911             return;
     1912        /* Check if it is necessary to enter/leave seamless mode. We assert
     1913         * here because the corresponding actions must be properly disabled by
     1914         * the below code to give the user an adequate feedback and prevent
     1915         * from calling this method. */
     1916        AssertReturn (aOn && mIsSeamlessSupported && !mIsFullscreen ||
     1917                      !aOn && mIsSeamless,
     1918                      false);
    19121919
    19131920        /* Check if the Guest Video RAM enough for the seamless mode. */
     
    19271934                screen.height(), QColor::numBitPlanes());
    19281935            vmSeamlessAction->setOn (false);
    1929             return;
    1930         }
    1931     }
    1932 
    1933     AssertReturnVoid (console);
    1934     AssertReturnVoid ((hidden_children.isEmpty() == aOn));
    1935     if (aSeamless)
    1936         AssertReturnVoid (mIsSeamless != aOn);
    1937     else
    1938         AssertReturnVoid (mIsFullscreen != aOn);
     1936            return false;
     1937        }
     1938    }
     1939
     1940    AssertReturn (console, false);
     1941    AssertReturn ((hidden_children.isEmpty() == aOn), false);
     1942    AssertReturn (aSeamless && mIsSeamless != aOn ||
     1943                  !aSeamless && mIsFullscreen != aOn, false);
    19391944
    19401945    if (aOn)
     
    19451950        hotKey = QStringList::split ('\t', hotKey) [1];
    19461951        Assert (!hotKey.isEmpty());
    1947         /* Get the host key name. */
    1948         QString hostKey = QIHotKeyEdit::keyName (vboxGlobal().settings()
    1949                                                              .hostKey());
     1952
    19501953        /* Show the info message. */
    1951         aSeamless ? vboxProblem().remindAboutGoingSeamless (hotKey, hostKey) :
    1952                     vboxProblem().remindAboutGoingFullscreen (hotKey, hostKey);
     1954        bool ok = aSeamless ?
     1955            vboxProblem().confirmGoingSeamless (hotKey) :
     1956            vboxProblem().confirmGoingFullscreen (hotKey);
     1957        if (!ok)
     1958            return false;
    19531959    }
    19541960
     
    21092115        console->toggleFSMode();
    21102116    }
     2117
    21112118    if (wasHidden)
    21122119        hide();
     2120
     2121    return true;
    21132122}
    21142123
     
    21192128void VBoxConsoleWnd::vmFullscreen (bool aOn)
    21202129{
    2121     toggleFullscreenMode (aOn, false);
     2130    bool ok = toggleFullscreenMode (aOn, false /* aSeamless */);
     2131    if (!ok)
     2132    {
     2133        /* on failure, restore the previous button state */
     2134        vmFullscreenAction->blockSignals (true);
     2135        vmFullscreenAction->setOn (!aOn);
     2136        vmFullscreenAction->blockSignals (false);
     2137    }
    21222138}
    21232139
    21242140void VBoxConsoleWnd::vmSeamless (bool aOn)
    21252141{
    2126     toggleFullscreenMode (aOn, true);
     2142    bool ok = toggleFullscreenMode (aOn, true /* aSeamless */);
     2143    if (!ok)
     2144    {
     2145        /* on failure, restore the previous button state */
     2146        vmSeamlessAction->blockSignals (true);
     2147        vmSeamlessAction->setOn (!aOn);
     2148        vmSeamlessAction->blockSignals (false);
     2149    }
    21272150}
    21282151
     
    30743097 *  at the point of code where it is not expected at all (example:
    30753098 *  VBoxConsoleView::mouseEvent() calling
    3076  *  VBoxProblemReporter::remindAboutInputCapture()). Instead, an attempt to
     3099 *  VBoxProblemReporter::confirmInputCapture()). Instead, an attempt to
    30773100 *  close the current modal widget is done and tryClose() is rescheduled for
    30783101 *  later execution using a single-shot zero timer.
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxDownloaderWgt.cpp

    r5154 r5803  
    249249                    //  emit a signal when it is done saving the downloaded file
    250250                    //  (succeeded or failed).
    251                     int rc = vboxProblem().confirmMountAdditions (mUrl.toString(),
    252                                                QDir::convertSeparators (mTarget));
    253                     if (rc == QIMessageBox::Yes)
     251                    if (vboxProblem()
     252                            .confirmMountAdditions (mUrl.toString(),
     253                                                    QDir::convertSeparators (mTarget)))
    254254                        vboxGlobal().consoleWnd().installGuestAdditionsFrom (mTarget);
    255255                    QTimer::singleShot (0, this, SLOT (suicide()));
     
    350350
    351351    /* Ask user about GA image downloading */
    352     int rc = vboxProblem().confirmDownloadAdditions (mUrl.toString(), aSize);
    353     if (rc == QIMessageBox::Yes)
     352    if (vboxProblem().confirmDownloadAdditions (mUrl.toString(), aSize))
    354353    {
    355354        mIsChecking = false;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r5802 r5803  
    2424
    2525#include "VBoxAboutDlg.h"
     26
     27#include "QIHotKeyEdit.h"
    2628
    2729#include <qmessagebox.h>
     
    13391341}
    13401342
    1341 int VBoxProblemReporter::confirmDownloadAdditions (const QString &aURL,
     1343bool VBoxProblemReporter::confirmDownloadAdditions (const QString &aURL,
    13421344                                                   ulong aSize)
    13431345{
     
    13511353}
    13521354
    1353 int VBoxProblemReporter::confirmMountAdditions (const QString &aURL,
     1355bool VBoxProblemReporter::confirmMountAdditions (const QString &aURL,
    13541356                                                const QString &aSrc)
    13551357{
     
    14431445}
    14441446
    1445 /** @return false if the dialog wasn't actually shown (i.e. it was autoconfirmed) */
    1446 bool VBoxProblemReporter::remindAboutInputCapture()
    1447 {
    1448     int rc = message (&vboxGlobal().consoleWnd(), Info,
     1447/**
     1448 *  @return @c true if the user has confirmed input capture (this is always
     1449 *  the case if the dialog was autoconfirmed).
     1450 */
     1451bool VBoxProblemReporter::confirmInputCapture()
     1452{
     1453    return messageOkCancel (&vboxGlobal().consoleWnd(), Info,
    14491454        tr ("<p>You have <b>clicked the mouse</b> inside the Virtual Machine display "
    14501455            "or pressed the <b>host key</b>. This will cause the Virtual Machine to "
     
    14611466            "with the mouse icon placed nearby, indicate the current keyboard "
    14621467            "and mouse capture state."
    1463             "</p>"),
    1464         "remindAboutInputCapture");
    1465 
    1466     return !(rc & AutoConfirmed);
    1467 }
    1468 
    1469 /** @return false if the dialog wasn't actually shown (i.e. it was autoconfirmed) */
    1470 bool VBoxProblemReporter::remindAboutAutoCapture()
    1471 {
    1472     int rc = message ( &vboxGlobal().consoleWnd(), Info,
     1468            "</p>") +
     1469        tr ("<p>The host key is currently defined as <b>%1</b>.</p>",
     1470            "additional message box paragraph")
     1471            .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
     1472        "confirmInputCapture",
     1473        tr ("Capture", "do input capture"));
     1474}
     1475
     1476void VBoxProblemReporter::remindAboutAutoCapture()
     1477{
     1478    message (&vboxGlobal().consoleWnd(), Info,
    14731479        tr ("<p>You have the <b>Auto capture keyboard</b> option turned on. "
    14741480            "This will cause the Virtual Machine to automatically <b>capture</b> "
     
    14851491            "with the mouse icon placed nearby, indicate the current keyboard "
    14861492            "and mouse capture state."
    1487             "</p>"),
     1493            "</p>") +
     1494        tr ("<p>The host key is currently defined as <b>%1</b>.</p>",
     1495            "additional message box paragraph")
     1496            .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
    14881497        "remindAboutAutoCapture");
    1489 
    1490     return !(rc & AutoConfirmed);
    1491 }
    1492 
    1493 /** @return false if the dialog wasn't actually shown (i.e. it was autoconfirmed) */
    1494 bool VBoxProblemReporter::remindAboutMouseIntegration (bool supportsAbsolute)
     1498}
     1499
     1500void VBoxProblemReporter::remindAboutMouseIntegration (bool aSupportsAbsolute)
    14951501{
    14961502    static const char *kNames [2] =
     
    15041510    {
    15051511        QWidget *outdated =
    1506             VBoxGlobal::findWidget (NULL, kNames [int (!supportsAbsolute)],
     1512            VBoxGlobal::findWidget (NULL, kNames [int (!aSupportsAbsolute)],
    15071513                                    "QIMessageBox");
    15081514        if (outdated)
     
    15101516    }
    15111517
    1512     if (supportsAbsolute)
    1513     {
    1514         int rc = message (&vboxGlobal().consoleWnd(), Info,
     1518    if (aSupportsAbsolute)
     1519    {
     1520        message (&vboxGlobal().consoleWnd(), Info,
    15151521            tr ("<p>The Virtual Machine reports that the guest OS supports "
    15161522                "<b>mouse pointer integration</b>. This means that you do not "
     
    15331539                "</p>"),
    15341540            kNames [1] /* aAutoConfirmId */);
    1535 
    1536         return !(rc & AutoConfirmed);
    15371541    }
    15381542    else
    15391543    {
    1540         int rc = message (&vboxGlobal().consoleWnd(), Info,
     1544        message (&vboxGlobal().consoleWnd(), Info,
    15411545            tr ("<p>The Virtual Machine reports that the guest OS does not "
    15421546                "support <b>mouse pointer integration</b> in the current video "
     
    15451549                "mouse inside the guest OS.</p>"),
    15461550            kNames [0] /* aAutoConfirmId */);
    1547 
    1548         return !(rc & AutoConfirmed);
    1549     }
    1550 }
    1551 
    1552 /** @return false if the dialog wasn't actually shown (i.e. it was autoconfirmed) */
     1551    }
     1552}
     1553
     1554/**
     1555 * @return @c false if the dialog wasn't actually shown (i.e. it was
     1556 * autoconfirmed).
     1557 */
    15531558bool VBoxProblemReporter::remindAboutPausedVMInput()
    15541559{
     
    15891594
    15901595/**
    1591  *  @param  fullscreen hot key as defined in the menu
    1592  *  @param  current host key as in the global settings
    1593  *  @return true if the user has chosen to go fullscreen.
     1596 *  @param aHotKey Fullscreen hot key as defined in the menu.
     1597 *
     1598 *  @return @c true if the user has chosen to go fullscreen (this is always
     1599 *  the case if the dialog was autoconfirmed).
    15941600 */
    1595 void VBoxProblemReporter::remindAboutGoingFullscreen (const QString &hotKey,
    1596                                                       const QString &hostKey)
    1597 {
    1598     int rc = message (&vboxGlobal().consoleWnd(), Info,
     1601bool VBoxProblemReporter::confirmGoingFullscreen (const QString &aHotKey)
     1602{
     1603    return messageOkCancel (&vboxGlobal().consoleWnd(), Info,
    15991604        tr ("<p>The virtual machine window will be now switched to "
    16001605            "<b>fullscreen</b> mode. "
     
    16041609            "<p>Note that the main menu bar is hidden in fullscreen mode. You "
    16051610            "can access it by pressing <b>Host+Home</b>.</p>")
    1606             .arg (hotKey).arg (hostKey),
    1607         "remindAboutGoingFullscreen");
    1608     NOREF(rc);
     1611            .arg (aHotKey)
     1612            .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
     1613        "confirmGoingFullscreen",
     1614        tr ("Switch", "fullscreen"));
    16091615}
    16101616
    16111617/**
    1612  *  @param  fullscreen hot key as defined in the menu
    1613  *  @param  current host key as in the global settings
    1614  *  @return true if the user has chosen to go fullscreen.
     1618 *  @param aHotKey Seamless hot key as defined in the menu.
     1619 *
     1620 *  @return @c true if the user has chosen to go seamless (this is always
     1621 *  the case if the dialog was autoconfirmed).
    16151622 */
    1616 void VBoxProblemReporter::remindAboutGoingSeamless (const QString &hotKey,
    1617                                                     const QString &hostKey)
    1618 {
    1619     int rc = message (&vboxGlobal().consoleWnd(), Info,
     1623bool VBoxProblemReporter::confirmGoingSeamless (const QString &aHotKey)
     1624{
     1625    return messageOkCancel (&vboxGlobal().consoleWnd(), Info,
    16201626        tr ("<p>The virtual machine window will be now switched to "
    16211627            "<b>Seamless</b> mode. "
     
    16251631            "<p>Note that the main menu bar is hidden in seamless mode. You "
    16261632            "can access it by pressing <b>Host+Home</b>.</p>")
    1627             .arg (hotKey).arg (hostKey),
    1628         "remindAboutGoingSeamless");
    1629     NOREF(rc);
     1633            .arg (aHotKey)
     1634            .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
     1635        "confirmGoingSeamless",
     1636        tr ("Switch", "seamless"));
    16301637}
    16311638
     
    16981705
    16991706/**
    1700  *  Returns @c true if the user has selected to reset the machine.
     1707 *  @return @c true if the user has selected to reset the machine.
    17011708 */
    17021709bool VBoxProblemReporter::confirmVMReset (QWidget *aParent)
     
    17101717}
    17111718
    1712 int VBoxProblemReporter::remindAboutUnsetHD (QWidget *aParent)
     1719/**
     1720 *  @return @c true if the user has selected to continue without attaching a
     1721 *  hard disk.
     1722 */
     1723bool VBoxProblemReporter::confirmHardDisklessMachine (QWidget *aParent)
    17131724{
    17141725    return message (aParent, Warning,
     
    17191730            "Run Wizard.</p><p>Do you want to continue?</p>"),
    17201731        0, /* aAutoConfirmId */
    1721         QIMessageBox::Yes,
    1722         QIMessageBox::No | QIMessageBox::Default | QIMessageBox::Escape);
     1732        QIMessageBox::Ok,
     1733        QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
     1734        0,
     1735        tr ("Continue", "no hard disk attached"),
     1736        tr ("Go Back", "no hard disk attached")) == QIMessageBox::Ok;
    17231737}
    17241738
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewVMWzd.ui.h

    r5292 r5803  
    241241        if (!mediaCombo->currentItem())
    242242        {
    243             int result = vboxProblem().remindAboutUnsetHD (this);
    244             if (result == QIMessageBox::No)
     243            if (!vboxProblem().confirmHardDisklessMachine (this))
    245244                return;
    246245        }
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