VirtualBox

Changeset 66569 in vbox


Ignore:
Timestamp:
Apr 14, 2017 11:13:47 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114596
Message:

FE/Qt: Get rid of VBoxGlobalSettings: Moving host-key combination handling into extra-data manager.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobalSettings.cpp

    r65702 r66569  
    2929# include "UIExtraDataDefs.h"
    3030# include "VBoxGlobalSettings.h"
    31 # include "UIHostComboEditor.h"
    3231
    3332/* COM includes: */
     
    5251{
    5352    /* default settings */
    54 #if defined (VBOX_WS_WIN)
    55     hostCombo = "163"; // VK_RCONTROL
    56 #elif defined (VBOX_WS_X11)
    57     hostCombo = "65508"; // XK_Control_R
    58 #elif defined (VBOX_WS_MAC)
    59     hostCombo = "55"; // QZ_LMETA
    60 #else
    61 # warning "port me!"
    62 #endif
    6353#if defined(VBOX_WS_X11) && defined(DEBUG)
    6454    autoCapture = false;
     
    7666VBoxGlobalSettingsData::VBoxGlobalSettingsData (const VBoxGlobalSettingsData &that)
    7767{
    78     hostCombo = that.hostCombo;
    7968    autoCapture = that.autoCapture;
    8069    guiFeatures = that.guiFeatures;
     
    9382{
    9483    return this == &that ||
    95         (hostCombo == that.hostCombo &&
    96          autoCapture == that.autoCapture &&
     84        (autoCapture == that.autoCapture &&
    9785         guiFeatures == that.guiFeatures &&
    9886         languageId  == that.languageId &&
     
    122110gPropertyMap[] =
    123111{
    124     { "GUI/Input/HostKeyCombination",              "hostCombo",               "0|\\d*[1-9]\\d*(,\\d*[1-9]\\d*)?(,\\d*[1-9]\\d*)?", true },
    125112    { "GUI/Input/AutoCapture",                     "autoCapture",             "true|false", true },
    126113    { "GUI/Customizations",                        "guiFeatures",             "\\S+", true },
     
    131118    { "GUI/HostScreenSaverDisabled",               "hostScreenSaverDisabled", "true|false", true }
    132119};
    133 
    134 void VBoxGlobalSettings::setHostCombo (const QString &hostCombo)
    135 {
    136     if (!UIHostCombo::isValidKeyCombo (hostCombo))
    137     {
    138         last_err = tr ("'%1' is an invalid host-combination code-sequence.").arg (hostCombo);
    139         return;
    140     }
    141     mData()->hostCombo = hostCombo;
    142     resetError();
    143 }
    144120
    145121bool VBoxGlobalSettings::isFeatureActive (const char *aFeature) const
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobalSettings.h

    r62493 r66569  
    3737private:
    3838
    39     QString hostCombo;
    4039    bool autoCapture;
    4140    QString guiFeatures;
     
    5453{
    5554    Q_OBJECT
    56     Q_PROPERTY (QString hostCombo READ hostCombo WRITE setHostCombo)
    5755    Q_PROPERTY (bool autoCapture READ autoCapture WRITE setAutoCapture)
    5856    Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures)
     
    7573
    7674    // Properties
    77 
    78     QString hostCombo() const { return data()->hostCombo; }
    79     void setHostCombo (const QString &hostCombo);
    8075
    8176    bool autoCapture() const { return data()->autoCapture; }
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r62493 r66569  
    5454const char* UIExtraDataDefs::GUI_Input_SelectorShortcuts = "GUI/Input/SelectorShortcuts";
    5555const char* UIExtraDataDefs::GUI_Input_MachineShortcuts = "GUI/Input/MachineShortcuts";
     56const char* UIExtraDataDefs::GUI_Input_HostKeyCombination = "GUI/Input/HostKeyCombination";
    5657
    5758/* Settings: Storage: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r64659 r66569  
    8383        /** Holds Runtime UI shortcut overrides. */
    8484        extern const char* GUI_Input_MachineShortcuts;
     85        /** Holds Runtime UI host-key combination. */
     86        extern const char* GUI_Input_HostKeyCombination;
    8587    /** @} */
    8688
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r63626 r66569  
    4040# include "UIDesktopWidgetWatchdog.h"
    4141# include "UIExtraDataManager.h"
     42# include "UIHostComboEditor.h"
    4243# include "UIMainEventListener.h"
    4344# include "VBoxGlobalSettings.h"
     
    23372338}
    23382339
     2340QString UIExtraDataManager::hostKeyCombination()
     2341{
     2342    /* Acquire host-key combination: */
     2343    QString strHostCombo = extraDataString(GUI_Input_HostKeyCombination);
     2344    /* Invent some sane default if it's absolutely wrong or invalid: */
     2345    QRegularExpression reTemplate("0|[1-9]\\d*(,[1-9]\\d*)?(,[1-9]\\d*)?");
     2346    if (!reTemplate.match(strHostCombo).hasMatch() || !UIHostCombo::isValidKeyCombo(strHostCombo))
     2347    {
     2348#if   defined (VBOX_WS_MAC)
     2349        strHostCombo = "55"; // QZ_LMETA
     2350#elif defined (VBOX_WS_WIN)
     2351        strHostCombo = "163"; // VK_RCONTROL
     2352#elif defined (VBOX_WS_X11)
     2353        strHostCombo = "65508"; // XK_Control_R
     2354#else
     2355# warning "port me!"
     2356#endif
     2357    }
     2358    /* Return host-combo: */
     2359    return strHostCombo;
     2360}
     2361
     2362void UIExtraDataManager::setHostKeyCombination(const QString &strHostCombo)
     2363{
     2364    /* Do not save anything if it's absolutely wrong or invalid: */
     2365    QRegularExpression reTemplate("0|[1-9]\\d*(,[1-9]\\d*)?(,[1-9]\\d*)?");
     2366    if (!reTemplate.match(strHostCombo).hasMatch() || !UIHostCombo::isValidKeyCombo(strHostCombo))
     2367        return;
     2368    /* Define host-combo: */
     2369    setExtraDataString(GUI_Input_HostKeyCombination, strHostCombo);
     2370}
     2371
    23392372QStringList UIExtraDataManager::shortcutOverrides(const QString &strPoolExtraDataID)
    23402373{
     
    39864019            else if (strKey == GUI_Input_MachineShortcuts)
    39874020                emit sigRuntimeUIShortcutChange();
     4021            /* Runtime UI host-key combintation changed? */
     4022            else if (strKey == GUI_Input_HostKeyCombination)
     4023                emit sigRuntimeUIHostKeyCombinationChange();
    39884024        }
    39894025    }
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r62493 r66569  
    6767    /** Notifies about Runtime UI keyboard shortcut change. */
    6868    void sigRuntimeUIShortcutChange();
     69    /** Notifies about Runtime UI host-key combination change. */
     70    void sigRuntimeUIHostKeyCombinationChange();
    6971
    7072    /** Notifies about menu-bar configuration change. */
     
    193195    /** @name Settings: Keyboard
    194196      * @{ */
     197        /** Returns the Runtime UI host-key combination. */
     198        QString hostKeyCombination();
     199        /** Defines the Runtime UI host-key combination. */
     200        void setHostKeyCombination(const QString &strHostCombo);
     201
    195202        /** Returns shortcut overrides for shortcut-pool with @a strPoolExtraDataID. */
    196203        QStringList shortcutOverrides(const QString &strPoolExtraDataID);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r66566 r66569  
    20712071                         "This icon, together with the mouse icon placed nearby, indicate the current keyboard and mouse capture state.</p>") +
    20722072                      tr("<p>The host key is currently defined as <b>%1</b>.</p>", "additional message box paragraph")
    2073                          .arg(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),
     2073                         .arg(UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
    20742074                      "confirmInputCapture",
    20752075                      AlertButton_Ok | AlertButtonOption_Default,
     
    20912091                             "<p>Note that the main menu bar is hidden in full-screen mode. "
    20922092                             "You can access it by pressing <b>Host+Home</b>.</p>")
    2093                              .arg(strHotKey, UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),
     2093                             .arg(strHotKey, UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
    20942094                          "confirmGoingFullscreen",
    20952095                          tr("Switch"));
     
    21042104                             "<p>Note that the main menu bar is hidden in seamless mode. "
    21052105                             "You can access it by pressing <b>Host+Home</b>.</p>")
    2106                              .arg(strHotKey, UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),
     2106                             .arg(strHotKey, UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
    21072107                          "confirmGoingSeamless",
    21082108                          tr("Switch"));
     
    21172117                             "<p>Note that the main menu bar is hidden in scaled mode. "
    21182118                             "You can access it by pressing <b>Host+Home</b>.</p>")
    2119                              .arg(strHotKey, UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),
     2119                             .arg(strHotKey, UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
    21202120                          "confirmGoingScale",
    21212121                          tr("Switch"));
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp

    r62493 r66569  
    434434          QApplication::translate("UIMessageCenter", "<p>The host key is currently defined as <b>%1</b>.</p>",
    435435                                                     "additional message box paragraph")
    436                                                      .arg(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),
     436                                                     .arg(UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
    437437          true);
    438438}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r65257 r66569  
    10051005    {
    10061006        /* Make sure host-combination label will be updated: */
    1007         connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),
     1007        connect(gEDataManager, SIGNAL(sigRuntimeUIHostKeyCombinationChange()),
    10081008                this, SLOT(sltUpdateAppearance()));
    10091009        /* Translate finally: */
     
    10161016    void sltUpdateAppearance()
    10171017    {
    1018         setText(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo()));
     1018        setText(UIHostCombo::toReadableString(gEDataManager->hostKeyCombination()));
    10191019    }
    10201020
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r66495 r66569  
    533533            if (!fSentRESEND)
    534534            {
    535                 QList <unsigned> shortCodes = UIHostCombo::modifiersToScanCodes(m_globalSettings.hostCombo());
     535                QList <unsigned> shortCodes = UIHostCombo::modifiersToScanCodes(gEDataManager->hostKeyCombination());
    536536                QVector <LONG> codes;
    537537                foreach (unsigned idxCode, shortCodes)
     
    572572#ifdef VBOX_WS_MAC
    573573    unsigned int hostComboModifierMask = 0;
    574     QList<int> hostCombo = UIHostCombo::toKeyCodeList(m_globalSettings.hostCombo());
     574    QList<int> hostCombo = UIHostCombo::toKeyCodeList(gEDataManager->hostKeyCombination());
    575575    for (int i = 0; i < hostCombo.size(); ++i)
    576576        hostComboModifierMask |= ::DarwinKeyCodeToDarwinModifierMask(hostCombo.at(i));
     
    19011901                           ? IsExtKeyPressed : IsKeyPressed;
    19021902    if (   (event.flags & 0x80) /* released */
    1903         && (   (   UIHostCombo::toKeyCodeList(m_globalSettings.hostCombo()).contains(event.vkCode)
     1903        && (   (   UIHostCombo::toKeyCodeList(gEDataManager->hostKeyCombination()).contains(event.vkCode)
    19041904                && !m_fIsHostkeyInCapture)
    19051905            ||    (  m_pressedKeys[event.scanCode & 0x7F]
     
    19781978{
    19791979    /* Get host-combo key list: */
    1980     QSet<int> allHostComboKeys = UIHostCombo::toKeyCodeList(m_globalSettings.hostCombo()).toSet();
     1980    QSet<int> allHostComboKeys = UIHostCombo::toKeyCodeList(gEDataManager->hostKeyCombination()).toSet();
    19811981    /* Get the type of key - simple or extended: */
    19821982    uint8_t uWhatPressed = fFlags & KeyExtended ? IsExtKeyPressed : IsKeyPressed;
     
    21552155{
    21562156    /* Get host-combo key list: */
    2157     QSet<int> allHostComboKeys = UIHostCombo::toKeyCodeList(m_globalSettings.hostCombo()).toSet();
     2157    QSet<int> allHostComboKeys = UIHostCombo::toKeyCodeList(gEDataManager->hostKeyCombination()).toSet();
    21582158
    21592159    /* Update the map of pressed host-combo keys: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r66568 r66569  
    3535# include "UIHotKeyEditor.h"
    3636# include "UIShortcutPool.h"
     37# include "UIExtraDataManager.h"
    3738# include "VBoxGlobalSettings.h"
    3839
     
    892893
    893894    /* Gather old input data: */
    894     oldInputData.shortcuts() << UIDataShortcutRow(m_pMachineTable, UIHostCombo::hostComboCacheKey(), tr("Host Key Combination"),  m_settings.hostCombo(), QString());
     895    oldInputData.shortcuts() << UIDataShortcutRow(m_pMachineTable, UIHostCombo::hostComboCacheKey(), tr("Host Key Combination"),  gEDataManager->hostKeyCombination(), QString());
    895896    const QMap<QString, UIShortcut> &shortcuts = gShortcutPool->shortcuts();
    896897    const QList<QString> shortcutKeys = shortcuts.keys();
     
    957958        const QString strHostComboData = iHostComboItemData != -1 ? m_pCache->data().shortcuts().at(iHostComboItemData).currentSequence() : QString();
    958959        if (strHostComboData != strHostComboBase)
    959             m_settings.setHostCombo(strHostComboData);
     960            gEDataManager->setHostKeyCombination(strHostComboData);
    960961
    961962        /* Save other new shortcuts from the cache: */
Note: See TracChangeset for help on using the changeset viewer.

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