VirtualBox

Changeset 17053 in vbox for trunk


Ignore:
Timestamp:
Feb 24, 2009 10:44:37 AM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: more clean up

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

Legend:

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

    r17049 r17053  
    4343    bool isValid() const { return mAppliance != NULL; }
    4444
     45    static int minGuestRAM() { return mMinGuestRAM; }
     46    static int maxGuestRAM() { return mMaxGuestRAM; }
     47    static int minGuestCPUCount() { return mMinGuestCPUCount; }
     48    static int maxGuestCPUCount() { return mMaxGuestCPUCount; }
     49
    4550public slots:
    4651    void restoreDefaults();
     
    5055
    5156private:
     57    static void initSystemSettings();
     58
    5259    /* Private member vars */
    5360    CAppliance *mAppliance;
    5461    VirtualSystemModel *mModel;
     62
     63    static int mMinGuestRAM;
     64    static int mMaxGuestRAM;
     65    static int mMinGuestCPUCount;
     66    static int mMaxGuestCPUCount;
    5567};
    5668
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxImportApplianceWzd.h

    r17049 r17053  
    3030class QIWidgetValidator;
    3131
    32 class VBoxImportAppliance
    33 {
    34 public:
    35     static void import (QWidget *aParent = NULL);
    36 
    37     static int minGuestRAM() { return mMinGuestRAM; }
    38     static int maxGuestRAM() { return mMaxGuestRAM; }
    39     static int minGuestCPUCount() { return mMinGuestCPUCount; }
    40     static int maxGuestCPUCount() { return mMaxGuestCPUCount; }
    41 
    42 private:
    43     /* Private member vars */
    44     static void initSystemSettings();
    45 
    46     static int mMinGuestRAM;
    47     static int mMaxGuestRAM;
    48     static int mMinGuestCPUCount;
    49     static int mMaxGuestCPUCount;
    50 };
    51 
    5232class VBoxImportApplianceWzd : public QIWithRetranslateUI<QIAbstractWizard>,
    5333                               public Ui::VBoxImportApplianceWzd
     
    7151
    7252private:
     53    /* Private member vars */
    7354    QIWidgetValidator *mWValFileSelector;
    7455};
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxImportApplianceWgt.cpp

    r17049 r17053  
    408408                {
    409409                    QSpinBox *e = new QSpinBox (aParent);
    410                     e->setRange (VBoxImportAppliance::minGuestCPUCount(), VBoxImportAppliance::maxGuestCPUCount());
     410                    e->setRange (VBoxImportApplianceWgt::minGuestCPUCount(), VBoxImportApplianceWgt::maxGuestCPUCount());
    411411                    editor = e;
    412412                    break;
     
    415415                {
    416416                    QSpinBox *e = new QSpinBox (aParent);
    417                     e->setRange (VBoxImportAppliance::minGuestRAM(), VBoxImportAppliance::maxGuestRAM());
     417                    e->setRange (VBoxImportApplianceWgt::minGuestRAM(), VBoxImportApplianceWgt::maxGuestRAM());
    418418                    e->setSuffix (" " + VBoxImportApplianceWgt::tr ("MB"));
    419419                    editor = e;
     
    961961// VBoxImportApplianceWgt
    962962
     963int VBoxImportApplianceWgt::mMinGuestRAM = -1;
     964int VBoxImportApplianceWgt::mMaxGuestRAM = -1;
     965int VBoxImportApplianceWgt::mMinGuestCPUCount = -1;
     966int VBoxImportApplianceWgt::mMaxGuestCPUCount = -1;
     967
    963968VBoxImportApplianceWgt::VBoxImportApplianceWgt (QWidget *aParent)
    964969    : QIWithRetranslateUI<QWidget> (aParent)
     
    966971    , mModel (NULL)
    967972{
     973    /* Make sure all static content is properly initialized */
     974    initSystemSettings();
     975
    968976    /* Apply UI decorations */
    969977    Ui::VBoxImportApplianceWgt::setupUi (this);
     
    10881096}
    10891097
     1098/* static */
     1099void VBoxImportApplianceWgt::initSystemSettings()
     1100{
     1101    if (mMinGuestRAM == -1)
     1102    {
     1103        /* We need some global defaults from the current VirtualBox
     1104           installation */
     1105        CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties();
     1106        mMinGuestRAM = sp.GetMinGuestRAM();
     1107        mMaxGuestRAM = sp.GetMaxGuestRAM();
     1108        mMinGuestCPUCount = sp.GetMinGuestCPUCount();
     1109        mMaxGuestCPUCount = sp.GetMaxGuestCPUCount();
     1110    }
     1111}
     1112
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxImportApplianceWzd.cpp

    r17049 r17053  
    2929
    3030////////////////////////////////////////////////////////////////////////////////
    31 // VBoxImportAppliance
    32 
    33 int VBoxImportAppliance::mMinGuestRAM = -1;
    34 int VBoxImportAppliance::mMaxGuestRAM = -1;
    35 int VBoxImportAppliance::mMinGuestCPUCount = -1;
    36 int VBoxImportAppliance::mMaxGuestCPUCount = -1;
    37 
    38 /* static */
    39 void VBoxImportAppliance::import (QWidget *aParent /* = NULL */)
    40 {
    41     initSystemSettings();
    42 
    43     VBoxImportApplianceWzd importWzd (aParent);
    44     if (importWzd.exec() == QDialog::Accepted)
    45     {
    46     }
    47     return;
    48 
    49 #if 0
    50     /* We need a file to import; request one from the user */
    51     QString file = VBoxGlobal::getOpenFileName ("",
    52                                                 VBoxGlobal::tr ("Open Virtualization Format (%1)").arg ("*.ovf"),
    53                                                 aParent,
    54                                                 VBoxGlobal::tr ("Select an appliance to import"));
    55 //    QString file = "/home/poetzsch/projects/innotek/plan9.ovf";
    56 //    QString file = "/Users/poetzsch/projects/innotek/plan9.ovf";
    57     if (!file.isEmpty())
    58     {
    59         CVirtualBox vbox = vboxGlobal().virtualBox();
    60         /* Create a appliance object */
    61         CAppliance appliance = vbox.CreateAppliance();
    62         bool fResult = appliance.isOk();
    63         if (fResult)
    64         {
    65             /* Read the appliance */
    66             appliance.Read (file);
    67             fResult = appliance.isOk();
    68             if (fResult)
    69             {
    70                 /* Now we have to interpret that stuff */
    71                 appliance.Interpret();
    72                 fResult = appliance.isOk();
    73                 if (fResult)
    74                 {
    75                     /* Let the user do some tuning */
    76                     VBoxImportApplianceWgt settingsDlg (&appliance, aParent);
    77                     if (settingsDlg.exec() == QDialog::Accepted)
    78                     {
    79                         /* Start the import asynchronously */
    80                         CProgress progress;
    81                         progress = appliance.ImportMachines();
    82                         fResult = appliance.isOk();
    83                         if (fResult)
    84                         {
    85                             /* Show some progress, so the user know whats going on */
    86                             vboxProblem().showModalProgressDialog (progress, VBoxImportApplianceWgt::tr ("Importing Appliance ..."), aParent);
    87                             if (!progress.isOk() || progress.GetResultCode() != 0)
    88                             {
    89                                 vboxProblem().cannotImportAppliance (progress, appliance);
    90                                 return;
    91                             }
    92                         }
    93                     }
    94                 }
    95             }
    96         }
    97         if (!fResult)
    98             vboxProblem().cannotImportAppliance (appliance);
    99     }
    100 #endif
    101 }
    102 
    103 /* static */
    104 void VBoxImportAppliance::initSystemSettings()
    105 {
    106     if (mMinGuestRAM == -1)
    107     {
    108         /* We need some global defaults from the current VirtualBox
    109            installation */
    110         CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties();
    111         mMinGuestRAM = sp.GetMinGuestRAM();
    112         mMaxGuestRAM = sp.GetMaxGuestRAM();
    113         mMinGuestCPUCount = sp.GetMinGuestCPUCount();
    114         mMaxGuestCPUCount = sp.GetMaxGuestCPUCount();
    115     }
    116 }
    117 
    118 ////////////////////////////////////////////////////////////////////////////////
    11931// VBoxImportApplianceWzd
    12032
     
    13345    mFileSelector->setFileDialogTitle (tr ("Select an appliance to import"));
    13446    mFileSelector->setFileFilters (tr ("Open Virtualization Format (%1)").arg ("*.ovf"));
    135 //    mFileSelector->setPath ("/home/poetzsch/downloads/Appliances/Plan9.ovf");
    13647#ifdef Q_WS_MAC
    13748    /* Editable boxes are uncommon on the Mac */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r17051 r17053  
    746746void VBoxSelectorWnd::fileImportAppliance()
    747747{
    748     VBoxImportAppliance::import (this);
     748    VBoxImportApplianceWzd wzd (this);
     749
     750    wzd.exec();
    749751}
    750752
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