VirtualBox

Ignore:
Timestamp:
Mar 18, 2015 2:32:10 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: General page: Cleanup rework to prepare to the encryption settings integration (step 1).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r53397 r54831  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919# include <precomp.h>
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    21 
    2221/* Qt includes: */
    2322# include <QDir>
    2423# include <QLineEdit>
    25 
    2624/* GUI includes: */
    2725# include "QIWidgetValidator.h"
     
    2927# include "UIMessageCenter.h"
    3028# include "UIConverter.h"
    31 
    3229#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    33 
    3430
    3531UIMachineSettingsGeneral::UIMachineSettingsGeneral()
    3632    : m_fHWVirtExEnabled(false)
    3733{
    38     /* Apply UI decorations */
    39     Ui::UIMachineSettingsGeneral::setupUi (this);
    40 
    41     /* Setup validators */
    42     m_pNameAndSystemEditor->nameEditor()->setValidator(new QRegExpValidator(QRegExp(".+"), this));
    43 
    44     /* Shared Clipboard mode */
    45     mCbClipboard->addItem (""); /* KClipboardMode_Disabled */
    46     mCbClipboard->addItem (""); /* KClipboardMode_HostToGuest */
    47     mCbClipboard->addItem (""); /* KClipboardMode_GuestToHost */
    48     mCbClipboard->addItem (""); /* KClipboardMode_Bidirectional */
    49 
    50     /* Drag'n'drop mode */
    51     mCbDragAndDrop->addItem (""); /* KDnDMode_Disabled */
    52     mCbDragAndDrop->addItem (""); /* KDnDMode_HostToGuest */
    53     mCbDragAndDrop->addItem (""); /* KDnDMode_GuestToHost */
    54     mCbDragAndDrop->addItem (""); /* KDnDMode_Bidirectional */
    55 
    56 #ifdef Q_WS_MAC
    57     mTeDescription->setMinimumHeight (150);
    58 #endif /* Q_WS_MAC */
    59 
    60     /* Prepare validation: */
    61     prepareValidation();
    62 
    63     /* Applying language settings */
     34    /* Prepare: */
     35    prepare();
     36
     37    /* Translate: */
    6438    retranslateUi();
    6539}
     
    6943    return m_pNameAndSystemEditor->type();
    7044}
     45
     46bool UIMachineSettingsGeneral::is64BitOSTypeSelected() const
     47{
     48    return m_pNameAndSystemEditor->type().GetIs64Bit();
     49}
     50
     51#ifdef VBOX_WITH_VIDEOHWACCEL
     52bool UIMachineSettingsGeneral::isWindowsOSTypeSelected() const
     53{
     54    return m_pNameAndSystemEditor->type().GetFamilyId() == "Windows";
     55}
     56#endif /* VBOX_WITH_VIDEOHWACCEL */
    7157
    7258void UIMachineSettingsGeneral::setHWVirtExEnabled(bool fEnabled)
     
    8369}
    8470
    85 bool UIMachineSettingsGeneral::is64BitOSTypeSelected() const
    86 {
    87     return m_pNameAndSystemEditor->type().GetIs64Bit();
    88 }
    89 
    90 #ifdef VBOX_WITH_VIDEOHWACCEL
    91 bool UIMachineSettingsGeneral::isWindowsOSTypeSelected() const
    92 {
    93     return m_pNameAndSystemEditor->type().GetFamilyId() == "Windows";
    94 }
    95 #endif /* VBOX_WITH_VIDEOHWACCEL */
    96 
    97 /* Load data to cache from corresponding external object(s),
    98  * this task COULD be performed in other than GUI thread: */
    9971void UIMachineSettingsGeneral::loadToCacheFrom(QVariant &data)
    10072{
     
    12496}
    12597
    126 /* Load data to corresponding widgets from cache,
    127  * this task SHOULD be performed in GUI thread only: */
    12898void UIMachineSettingsGeneral::getFromCache()
    12999{
     
    147117}
    148118
    149 /* Save data from corresponding widgets to cache,
    150  * this task SHOULD be performed in GUI thread only: */
    151119void UIMachineSettingsGeneral::putToCache()
    152120{
     
    167135}
    168136
    169 /* Save data from cache to corresponding external object(s),
    170  * this task COULD be performed in other than GUI thread: */
    171137void UIMachineSettingsGeneral::saveFromCacheTo(QVariant &data)
    172138{
     
    195161            {
    196162                m_machine.SetOSTypeId(generalData.m_strGuestOsTypeId);
    197 
    198163                CVirtualBox vbox = vboxGlobal().virtualBox();
    199164                CGuestOSType newType = vbox.GetGuestOSType(generalData.m_strGuestOsTypeId);
    200165                m_machine.SetCPUProperty(KCPUPropertyType_LongMode, newType.GetIs64Bit());
    201166            }
    202 
    203167            /* Advanced tab: */
    204168            m_machine.SetSnapshotFolder(generalData.m_strSnapshotsFolder);
     
    246210}
    247211
    248 void UIMachineSettingsGeneral::setOrderAfter (QWidget *aWidget)
    249 {
    250     /* Basic tab-order */
    251     setTabOrder (aWidget, mTwGeneral->focusProxy());
    252     setTabOrder (mTwGeneral->focusProxy(), m_pNameAndSystemEditor);
    253 
    254     /* Advanced tab-order */
    255     setTabOrder (m_pNameAndSystemEditor, mPsSnapshot);
    256     setTabOrder (mPsSnapshot, mCbClipboard);
    257     setTabOrder (mCbClipboard, mCbDragAndDrop);
    258 
    259     /* Description tab-order */
    260     setTabOrder (mCbDragAndDrop, mTeDescription);
     212void UIMachineSettingsGeneral::setOrderAfter(QWidget *pWidget)
     213{
     214    /* Basic tab-order: */
     215    setTabOrder(pWidget, mTwGeneral->focusProxy());
     216    setTabOrder(mTwGeneral->focusProxy(), m_pNameAndSystemEditor);
     217
     218    /* Advanced tab-order: */
     219    setTabOrder(m_pNameAndSystemEditor, mPsSnapshot);
     220    setTabOrder(mPsSnapshot, mCbClipboard);
     221    setTabOrder(mCbClipboard, mCbDragAndDrop);
     222
     223    /* Description tab-order: */
     224    setTabOrder(mCbDragAndDrop, mTeDescription);
    261225}
    262226
    263227void UIMachineSettingsGeneral::retranslateUi()
    264228{
    265     /* Translate uic generated strings */
    266     Ui::UIMachineSettingsGeneral::retranslateUi (this);
    267 
    268     /* Path selector */
    269     mPsSnapshot->setWhatsThis (tr ("Holds the path where snapshots of this "
    270                                    "virtual machine will be stored. Be aware that "
    271                                    "snapshots can take quite a lot of disk "
    272                                    "space."));
    273 
    274     /* Shared Clipboard mode */
    275     mCbClipboard->setItemText (0, gpConverter->toString (KClipboardMode_Disabled));
    276     mCbClipboard->setItemText (1, gpConverter->toString (KClipboardMode_HostToGuest));
    277     mCbClipboard->setItemText (2, gpConverter->toString (KClipboardMode_GuestToHost));
    278     mCbClipboard->setItemText (3, gpConverter->toString (KClipboardMode_Bidirectional));
    279 
    280     /* Drag'n'drop mode */
    281     mCbDragAndDrop->setItemText (0, gpConverter->toString (KDnDMode_Disabled));
    282     mCbDragAndDrop->setItemText (1, gpConverter->toString (KDnDMode_HostToGuest));
    283     mCbDragAndDrop->setItemText (2, gpConverter->toString (KDnDMode_GuestToHost));
    284     mCbDragAndDrop->setItemText (3, gpConverter->toString (KDnDMode_Bidirectional));
    285 }
    286 
    287 void UIMachineSettingsGeneral::prepareValidation()
    288 {
    289     /* Prepare validation: */
    290     connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(revalidate()));
    291     connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString&)), this, SLOT(revalidate()));
     229    /* Translate uic generated strings: */
     230    Ui::UIMachineSettingsGeneral::retranslateUi(this);
     231
     232    /* Translate path selector: */
     233    mPsSnapshot->setWhatsThis(tr("Holds the path where snapshots of this "
     234                                 "virtual machine will be stored. Be aware that "
     235                                 "snapshots can take quite a lot of disk space."));
     236    /* Translate Shared Clipboard mode combo: */
     237    mCbClipboard->setItemText(0, gpConverter->toString(KClipboardMode_Disabled));
     238    mCbClipboard->setItemText(1, gpConverter->toString(KClipboardMode_HostToGuest));
     239    mCbClipboard->setItemText(2, gpConverter->toString(KClipboardMode_GuestToHost));
     240    mCbClipboard->setItemText(3, gpConverter->toString(KClipboardMode_Bidirectional));
     241    /* Translate Drag'n'drop mode combo: */
     242    mCbDragAndDrop->setItemText(0, gpConverter->toString(KDnDMode_Disabled));
     243    mCbDragAndDrop->setItemText(1, gpConverter->toString(KDnDMode_HostToGuest));
     244    mCbDragAndDrop->setItemText(2, gpConverter->toString(KDnDMode_GuestToHost));
     245    mCbDragAndDrop->setItemText(3, gpConverter->toString(KDnDMode_Bidirectional));
     246}
     247
     248void UIMachineSettingsGeneral::prepare()
     249{
     250    /* Apply UI decorations: */
     251    Ui::UIMachineSettingsGeneral::setupUi(this);
     252
     253    /* Prepare pages: */
     254    preparePageBasic();
     255    preparePageAdvanced();
     256    preparePageDescription();
     257}
     258
     259void UIMachineSettingsGeneral::preparePageBasic()
     260{
     261    /* Name and OS Type widget was created in the .ui file: */
     262    AssertPtrReturnVoid(m_pNameAndSystemEditor);
     263    {
     264        /* Configure Name and OS Type widget: */
     265        m_pNameAndSystemEditor->nameEditor()->setValidator(new QRegExpValidator(QRegExp(".+"), this));
     266        connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(revalidate()));
     267        connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString&)), this, SLOT(revalidate()));
     268    }
     269}
     270
     271void UIMachineSettingsGeneral::preparePageAdvanced()
     272{
     273    /* Shared Clipboard mode combo was created in the .ui file: */
     274    AssertPtrReturnVoid(mCbClipboard);
     275    {
     276        /* Configure Shared Clipboard mode combo: */
     277        mCbClipboard->addItem (""); /* KClipboardMode_Disabled */
     278        mCbClipboard->addItem (""); /* KClipboardMode_HostToGuest */
     279        mCbClipboard->addItem (""); /* KClipboardMode_GuestToHost */
     280        mCbClipboard->addItem (""); /* KClipboardMode_Bidirectional */
     281    }
     282    /* Drag&drop mode combo was created in the .ui file: */
     283    AssertPtrReturnVoid(mCbDragAndDrop);
     284    {
     285        /* Configure Drag&drop mode combo: */
     286        mCbDragAndDrop->addItem (""); /* KDnDMode_Disabled */
     287        mCbDragAndDrop->addItem (""); /* KDnDMode_HostToGuest */
     288        mCbDragAndDrop->addItem (""); /* KDnDMode_GuestToHost */
     289        mCbDragAndDrop->addItem (""); /* KDnDMode_Bidirectional */
     290    }
     291}
     292
     293void UIMachineSettingsGeneral::preparePageDescription()
     294{
     295    /* Description text editor was created in the .ui file: */
     296    AssertPtrReturnVoid(mTeDescription);
     297    {
     298        /* Configure Description text editor: */
     299#ifdef Q_WS_MAC
     300        mTeDescription->setMinimum(150);
     301#endif /* Q_WS_MAC */
     302    }
    292303}
    293304
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r53397 r54831  
    44
    55/*
    6  * Copyright (C) 2006-2014 Oracle Corporation
     6 * Copyright (C) 2006-2015 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515 */
    1616
    17 #ifndef __UIMachineSettingsGeneral_h__
    18 #define __UIMachineSettingsGeneral_h__
     17#ifndef ___UIMachineSettingsGeneral_h___
     18#define ___UIMachineSettingsGeneral_h___
    1919
    20 /* Local includes: */
     20/* GUI includes: */
    2121#include "UISettingsPage.h"
    2222#include "UIMachineSettingsGeneral.gen.h"
    2323
    24 /* Machine settings / General page / Data: */
     24/** Machine settings: General page: Data structure. */
    2525struct UIDataSettingsMachineGeneral
    2626{
    27     /* Default constructor: */
     27    /** Constructor. */
    2828    UIDataSettingsMachineGeneral()
    2929        : m_strName(QString())
     
    3535        , m_strDescription(QString()) {}
    3636
    37     /* Functions: */
     37    /** Returns whether passed @a other is equal to this. */
    3838    bool equal(const UIDataSettingsMachineGeneral &other) const
    3939    {
     
    4747    }
    4848
    49     /* Operators: */
     49    /** Operator== implementation which returns whether passed @a other is equal to this. */
    5050    bool operator==(const UIDataSettingsMachineGeneral &other) const { return equal(other); }
     51    /** Operator!= implementation which returns whether passed @a other is differs from this. */
    5152    bool operator!=(const UIDataSettingsMachineGeneral &other) const { return !equal(other); }
    5253
    53     /* Variables: */
     54    /** Holds the VM name. */
    5455    QString m_strName;
     56    /** Holds the VM OS type ID. */
    5557    QString m_strGuestOsTypeId;
     58
     59    /** Holds the VM snapshot folder. */
    5660    QString m_strSnapshotsFolder;
     61    /** Holds the default VM snapshot folder. */
    5762    QString m_strSnapshotsHomeDir;
     63
     64    /** Holds the VM shared clipboard mode. */
    5865    KClipboardMode m_clipboardMode;
     66    /** Holds the VM drag&drop mode. */
    5967    KDnDMode m_dndMode;
     68
     69    /** Holds the VM description. */
    6070    QString m_strDescription;
    6171};
    6272typedef UISettingsCache<UIDataSettingsMachineGeneral> UICacheSettingsMachineGeneral;
    6373
    64 /* Machine settings / General page: */
     74/** Machine settings: General page. */
    6575class UIMachineSettingsGeneral : public UISettingsPageMachine,
    66                               public Ui::UIMachineSettingsGeneral
     76                                 public Ui::UIMachineSettingsGeneral
    6777{
    6878    Q_OBJECT;
     
    7080public:
    7181
     82    /** Constructor. */
    7283    UIMachineSettingsGeneral();
    7384
     85    /** Returns the VM OS type ID. */
    7486    CGuestOSType guestOSType() const;
    75     void setHWVirtExEnabled(bool fEnabled);
     87    /** Returns whether 64bit OS type ID is selected. */
    7688    bool is64BitOSTypeSelected() const;
    7789#ifdef VBOX_WITH_VIDEOHWACCEL
     90    /** Returns whether Windows OS type ID is selected. */
    7891    bool isWindowsOSTypeSelected() const;
    7992#endif /* VBOX_WITH_VIDEOHWACCEL */
    8093
     94    /** Defines whether HW virtualization extension is enabled. */
     95    void setHWVirtExEnabled(bool fEnabled);
     96
    8197protected:
    8298
    83     /* Load data to cache from corresponding external object(s),
    84      * this task COULD be performed in other than GUI thread: */
     99    /** Loads data into the cache from the corresponding external object(s).
     100      * @note This task COULD be performed in other than GUI thread. */
    85101    void loadToCacheFrom(QVariant &data);
    86     /* Load data to corresponding widgets from cache,
    87      * this task SHOULD be performed in GUI thread only: */
     102    /** Loads data into the corresponding widgets from the cache,
     103      * @note This task SHOULD be performed in GUI thread only! */
    88104    void getFromCache();
    89105
    90     /* Page changed: */
     106    /** Returns whether the page was changed: */
    91107    bool changed() const { return m_cache.wasChanged(); }
    92108
    93     /* Save data from corresponding widgets to cache,
    94      * this task SHOULD be performed in GUI thread only: */
     109    /** Saves the data from the corresponding widgets into the cache,
     110      * @note This task SHOULD be performed in GUI thread only! */
    95111    void putToCache();
    96     /* Save data from cache to corresponding external object(s),
    97      * this task COULD be performed in other than GUI thread: */
     112    /** Save data from the cache into the corresponding external object(s).
     113      * @note This task COULD be performed in other than GUI thread. */
    98114    void saveFromCacheTo(QVariant &data);
    99115
    100     /* API: Validation stuff: */
     116    /** Validation routine. */
    101117    bool validate(QList<UIValidationMessage> &messages);
    102118
    103     void setOrderAfter (QWidget *aWidget);
     119    /** Tab-order assignment routine. */
     120    void setOrderAfter(QWidget *aWidget);
    104121
     122    /** Translation routine. */
    105123    void retranslateUi();
    106124
    107125private:
    108126
    109     /* Helper: Prepare stuff: */
    110     void prepareValidation();
     127    /** Prepare routine. */
     128    void prepare();
     129    /** Prepare 'Basic' page routine. */
     130    void preparePageBasic();
     131    /** Prepare 'Advanced' page routine. */
     132    void preparePageAdvanced();
     133    /** Prepare 'Description' page routine. */
     134    void preparePageDescription();
    111135
     136    /** Polish routine. */
    112137    void polishPage();
    113138
    114     /* Cache: */
     139    /** Holds the page cache. */
     140    UICacheSettingsMachineGeneral m_cache;
     141
     142    /** Holds whether HW virtualization extension is enabled. */
    115143    bool m_fHWVirtExEnabled;
    116     UICacheSettingsMachineGeneral m_cache;
    117144};
    118145
    119 #endif // __UIMachineSettingsGeneral_h__
    120 
     146#endif / !___UIMachineSettingsGeneral_h___ */
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