VirtualBox

Changeset 72173 in vbox for trunk/src


Ignore:
Timestamp:
May 9, 2018 1:38:13 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122595
Message:

FE/Qt bugref:9072 Some small refactoring in logviewer filter panel.

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

Legend:

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

    r71463 r72173  
    11601160    QString strHomeFolder = fUseLastFolder && !strLastFolder.isEmpty() ? strLastFolder :
    11611161                            strDefaultFolder.isEmpty() ? vboxGlobal().homeFolder() : strDefaultFolder;
     1162
    11621163
    11631164    /* Prepare filters and backends: */
     
    46764677    return true;
    46774678}
    4678 
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp

    r72154 r72173  
    3232# include <QPlainTextEdit>
    3333# include <QTextCursor>
    34 # include <QToolButton>
    3534# include <QRadioButton>
    3635# include <QScrollArea>
     
    7978    virtual void        mousePressEvent(QMouseEvent * event) /* override */;
    8079    virtual void        mouseReleaseEvent(QMouseEvent *){}
    81     virtual void        paintEvent(QPaintEvent *event);
     80    virtual void        paintEvent(QPaintEvent *event) /* override */;
    8281
    8382private slots:
     
    9089private:
    9190
    92     void         createButtons();
    93     QToolButton *m_pRemoveTermButton;
    94     QToolButton *m_pClearAllButton;
    95     const int    m_iRemoveTermButtonSize;
    96     int          m_iTrailingSpaceCount;
     91    void          createButtons();
     92    QIToolButton *m_pRemoveTermButton;
     93    QIToolButton *m_pClearAllButton;
     94    const int     m_iRemoveTermButtonSize;
     95    int           m_iTrailingSpaceCount;
    9796};
    9897
     
    197196    if (!m_pRemoveTermButton)
    198197    {
    199         m_pRemoveTermButton = new QToolButton(this);
     198        m_pRemoveTermButton = new QIToolButton(this);
    200199        if (m_pRemoveTermButton)
    201200        {
    202201            m_pRemoveTermButton->setIcon(m_pRemoveTermButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
    203202            m_pRemoveTermButton->hide();
    204             connect(m_pRemoveTermButton, &QToolButton::clicked, this, &UIVMFilterLineEdit::sltRemoveFilterTerm);
     203            connect(m_pRemoveTermButton, &QIToolButton::clicked, this, &UIVMFilterLineEdit::sltRemoveFilterTerm);
    205204        }
    206205    }
     
    208207    if (!m_pClearAllButton)
    209208    {
    210         m_pClearAllButton = new QToolButton(this);
     209        m_pClearAllButton = new QIToolButton(this);
    211210        if (m_pClearAllButton)
    212211        {
    213212            m_pClearAllButton->setIcon(m_pClearAllButton->style()->standardIcon(QStyle::SP_LineEditClearButton));
    214             connect(m_pClearAllButton, &QToolButton::clicked, this, &UIVMFilterLineEdit::sltClearAll);
     213            connect(m_pClearAllButton, &QIToolButton::clicked, this, &UIVMFilterLineEdit::sltClearAll);
    215214        }
    216215    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r71924 r72173  
    554554        {
    555555            /* Configure widget: */
    556             m_pNameAndSystemEditor->nameEditor()->setValidator(new QRegExpValidator(QRegExp(".+"), this));
     556            //m_pNameAndSystemEditor->nameEditor()->setValidator(new QRegExpValidator(QRegExp(".+"), this));
    557557        }
    558558    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r72101 r72173  
    668668                   UIFilePathSelector *pFileChooser = new UIFilePathSelector(pParent);
    669669                   pFileChooser->setMode(UIFilePathSelector::Mode_File_Save);
    670                    pFileChooser->setResetEnabled(false);
     670                   pFileChooser->setResetEnabled(true);
    671671                   pEditor = pFileChooser;
    672672                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp

    r71924 r72173  
    3131# include "UIFilePathSelector.h"
    3232# include "UINameAndSystemEditor.h"
     33# include "UIVMNamePathSelector.h"
    3334
    3435/* COM includes: */
     
    5051    , m_fSupportsHWVirtEx(false)
    5152    , m_fSupportsLongMode(false)
    52     , m_pLabelName(0)
    5353    , m_pLabelFamily(0)
    5454    , m_pLabelType(0)
    5555    , m_pIconType(0)
    56     , m_pEditorName(0)
    57     , m_pEditorLocation(0)
     56    , m_pNamePathLabel(0)
     57    , m_pNamePathSelector(0)
    5858    , m_pComboFamily(0)
    5959    , m_pComboType(0)
     
    6565QString UINameAndSystemEditor::name() const
    6666{
    67     if (!m_fChooseLocation)
    68         return m_pEditorName->text();
    69     else
    70         return m_pEditorLocation->path();
     67    if (!m_pNamePathSelector)
     68        return QString();
     69    return m_pNamePathSelector->name();
     70}
     71
     72QString UINameAndSystemEditor::path() const
     73{
     74    if (!m_pNamePathSelector)
     75        return vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     76    return m_pNamePathSelector->path();
    7177}
    7278
    7379void UINameAndSystemEditor::setName(const QString &strName)
    7480{
    75     if (!m_fChooseLocation)
    76         m_pEditorName->setText(strName);
    77     else
    78         m_pEditorLocation->setPath(strName);
     81    if (!m_pNamePathSelector)
     82        return;
     83    m_pNamePathSelector->setName(strName);
    7984}
    8085
     
    112117void UINameAndSystemEditor::retranslateUi()
    113118{
    114     m_pLabelName->setText(tr("N&ame:"));
    115119    m_pLabelFamily->setText(tr("&Type:"));
    116120    m_pLabelType->setText(tr("&Version:"));
    117     if (!m_fChooseLocation)
    118         m_pEditorName->setWhatsThis(tr("Holds the name of the virtual machine."));
    119     else
    120         m_pEditorLocation->setWhatsThis(tr("Holds the location of the virtual machine."));
     121    m_pNamePathLabel->setText(tr("Path/Name:"));
     122
    121123    m_pComboFamily->setWhatsThis(tr("Selects the operating system family that "
    122124                                    "you plan to install into this virtual machine."));
     
    227229        pMainLayout->setContentsMargins(0, 0, 0, 0);
    228230
    229         /* Create VM name label: */
    230         m_pLabelName = new QLabel;
    231         if (m_pLabelName)
    232         {
    233             /* Configure VM name label: */
    234             m_pLabelName->setAlignment(Qt::AlignRight);
    235             m_pLabelName->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    236             /* Add VM name label into main-layout: */
    237             pMainLayout->addWidget(m_pLabelName, 0, 0);
    238         }
    239 
    240         if (!m_fChooseLocation)
    241         {
    242             /* Create VM name editor: */
    243             m_pEditorName = new QLineEdit;
    244             if (m_pEditorName)
    245             {
    246                 /* Configure VM name editor: */
    247                 m_pEditorName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    248                 m_pLabelName->setBuddy(m_pEditorName);
    249                 /* Add VM name editor into main-layout: */
    250                 pMainLayout->addWidget(m_pEditorName, 0, 1, 1, 2);
    251             }
    252         }
    253         else
    254         {
    255             /* Create VM location editor: */
    256             m_pEditorLocation = new UIFilePathSelector;
    257             if (m_pEditorLocation)
    258             {
    259                 /* Configure advanced VM name editor: */
    260                 m_pEditorLocation->setResetEnabled(false);
    261                 m_pEditorLocation->setMode(UIFilePathSelector::Mode_File_Save);
    262                 m_pEditorLocation->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    263                 m_pEditorLocation->setHomeDir(vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder());
    264                 m_pLabelName->setBuddy(m_pEditorLocation);
    265                 /* Add advanced VM name editor into main-layout: */
    266                 pMainLayout->addWidget(m_pEditorLocation, 0, 1, 1, 2);
    267             }
     231        m_pNamePathLabel = new QLabel;
     232        if (m_pNamePathLabel)
     233        {
     234            m_pNamePathLabel->setAlignment(Qt::AlignRight);
     235            m_pNamePathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     236            pMainLayout->addWidget(m_pNamePathLabel, 0, 0, 1, 1);
     237        }
     238        m_pNamePathSelector = new UIVMNamePathSelector;
     239        if (m_pNamePathSelector)
     240        {
     241            m_pNamePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     242            pMainLayout->addWidget(m_pNamePathSelector, 0, 1, 1, 2);
    268243        }
    269244
     
    325300                pLayoutIcon->addWidget(m_pIconType);
    326301            }
    327 
    328302            /* Add stretch to sub-layout: */
    329303            pLayoutIcon->addStretch();
     
    358332{
    359333    /* Prepare connections: */
    360     if (!m_fChooseLocation)
    361         connect(m_pEditorName, &QLineEdit::textChanged,
    362                 this, &UINameAndSystemEditor::sigNameChanged);
    363     else
    364         connect(m_pEditorLocation, &UIFilePathSelector::pathChanged,
    365                 this, &UINameAndSystemEditor::sigNameChanged);
     334    connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged,
     335            this, &UINameAndSystemEditor::sigNameChanged);
    366336    connect(m_pComboFamily, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    367337            this, &UINameAndSystemEditor::sltFamilyChanged);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r71924 r72173  
    3636class QString;
    3737class UIFilePathSelector;
     38class UIVMNamePathSelector;
    3839
    3940/** QWidget subclass providing complex editor for basic VM parameters. */
     
    5859    UINameAndSystemEditor(QWidget *pParent, bool fChooseLocation = false);
    5960
    60     /** Returns the VM name editor. */
    61     QLineEdit *nameEditor() const { return m_pEditorName; }
    62     /** Returns the VM location editor. */
    63     UIFilePathSelector *locationEditor() const { return m_pEditorLocation; }
    64 
    6561    /** Returns the VM name. */
    6662    QString name() const;
     63    /** Returns path string selected by the user. */
     64    QString path() const;
     65
    6766    /** Defines the VM @a strName. */
    6867    void setName(const QString &strName);
     
    8685    void sltTypeChanged(int iIndex);
    8786
    88 private:
     87 private:
    8988
    9089    /** @name Prepare cascade.
     
    113112    bool                    m_fSupportsLongMode;
    114113
    115     /** Holds the VM name label instance. */
    116     QLabel                 *m_pLabelName;
    117114    /** Holds the VM OS family label instance. */
    118115    QLabel                 *m_pLabelFamily;
     
    121118    /** Holds the VM OS type icon instance. */
    122119    QLabel                 *m_pIconType;
    123     /** Holds the VM name editor instance. */
    124     QLineEdit              *m_pEditorName;
    125     /** Holds the VM location editor instance. */
    126     UIFilePathSelector     *m_pEditorLocation;
     120
     121    QLabel                 *m_pNamePathLabel;
     122    UIVMNamePathSelector   *m_pNamePathSelector;
    127123    /** Holds the VM OS family combo instance. */
    128124    QComboBox              *m_pComboFamily;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.cpp

    r72136 r72173  
    2525
    2626/* GUI includes: */
     27# include "QIFileDialog.h"
    2728# include "QILineEdit.h"
    2829# include "QILabel.h"
     30# include "QIToolButton.h"
     31# include "UIIconPool.h"
    2932# include "UIVMNamePathSelector.h"
    3033# include "VBoxGlobal.h"
     
    3538#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3639
    37 
    38 
    3940UIVMNamePathSelector::UIVMNamePathSelector(QWidget *pParent /* = 0 */)
    4041    : QIWithRetranslateUI<QWidget>(pParent)
     
    4344    , m_pName(0)
    4445    , m_pSeparator(0)
     46    ,m_pFileDialogButton(0)
    4547{
    4648    prepareWidgets();
     49    retranslateUi();
    4750}
    4851
     
    5255    CVirtualBox vbox = vboxGlobal().virtualBox();
    5356    /* Get default machine folder: */
    54     /*const QString strDefaultMachineFolder = */return vbox.GetSystemProperties().GetDefaultMachineFolder();
     57    return vbox.GetSystemProperties().GetDefaultMachineFolder();
    5558
    5659}
     
    6568    m_pMainLayout->setSpacing(0);
    6669    setLayout(m_pMainLayout);
     70
     71    m_pFileDialogButton = new QIToolButton(this);
     72    if (m_pFileDialogButton)
     73    {
     74        m_pMainLayout->addWidget(m_pFileDialogButton);
     75        m_pFileDialogButton->setIcon(UIIconPool::iconSet(QString(":/sf_add_16px.png")));
     76        connect(m_pFileDialogButton, &QIToolButton::clicked, this, &UIVMNamePathSelector::sltOpenPathSelector);
     77    }
    6778
    6879    m_pPath = new QILineEdit;
     
    8495    {
    8596        m_pMainLayout->addWidget(m_pName);
     97        connect(m_pName, &QILineEdit::textChanged,
     98                this, &UIVMNamePathSelector::sigNameChanged);
     99
    86100    }
    87101
     
    121135void UIVMNamePathSelector::retranslateUi()
    122136{
     137    setToolTip(tr("The Virtual Machine files will be saved under ..."));
    123138}
     139
     140void UIVMNamePathSelector::sltOpenPathSelector()
     141{
     142
     143    QString strSelectedPath = QIFileDialog::getExistingDirectory(m_pPath->text(), this,
     144                                                                 QString("Select a parent folder for new Virtual Machine"));
     145    if (!strSelectedPath.isEmpty())
     146    {
     147        m_pPath->setText(strSelectedPath);
     148    }
     149}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.h

    r72136 r72173  
    2929class QILabel;
    3030class QILineEdit;
    31 
     31class QIToolButton;
    3232
    3333class SHARED_LIBRARY_STUFF UIVMNamePathSelector : public QIWithRetranslateUI<QWidget>
     
    3636
    3737signals:
     38
     39    void sigNameChanged(const QString &strName);
    3840
    3941public:
     
    5557private slots:
    5658
     59    void sltOpenPathSelector();
    5760
    5861private:
     
    6568    QILineEdit  *m_pName;
    6669    QILabel     *m_pSeparator;
     70    QIToolButton *m_pFileDialogButton;
     71
    6772};
    6873
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp

    r70805 r72173  
    2525
    2626/* Local includes: */
     27# include "QIRichTextLabel.h"
     28# include "UIEmptyFilePathSelector.h"
     29# include "UIFilePathSelector.h"
    2730# include "UIWizardImportAppPageBasic1.h"
    2831# include "UIWizardImportAppPageBasic2.h"
    2932# include "UIWizardImportApp.h"
    3033# include "VBoxGlobal.h"
    31 # include "UIEmptyFilePathSelector.h"
    32 # include "QIRichTextLabel.h"
     34
     35/* COM includes: */
     36# include "CSystemProperties.h"
    3337
    3438#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    5458        pMainLayout->addWidget(m_pLabel);
    5559        pMainLayout->addWidget(m_pFileSelector);
     60
     61
     62        m_pDefaultFolderLabel = new QIRichTextLabel(this);
     63        if (m_pDefaultFolderLabel)
     64        {
     65            pMainLayout->addWidget(m_pDefaultFolderLabel);
     66        }
     67
     68        m_pDestinationFolderSelector = new UIFilePathSelector(this);
     69        if (m_pDestinationFolderSelector)
     70        {
     71            m_pDestinationFolderSelector->setMode(UIFilePathSelector::Mode_Folder);
     72            pMainLayout->addWidget(m_pDestinationFolderSelector);
     73
     74            m_pDestinationFolderSelector->setPath(vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder());
     75            m_pDestinationFolderSelector->setResetEnabled(false);
     76        }
     77
    5678        pMainLayout->addStretch();
    5779    }
     
    7092                                            "saved in the Open Virtualization Format (OVF). "
    7193                                            "To continue, select the file to import below.</p>"));
     94    m_pDefaultFolderLabel->setText(UIWizardImportApp::tr("Select a destionation folder for appliance"));
    7295    m_pFileSelector->setChooseButtonToolTip(UIWizardImportApp::tr("Choose a virtual appliance file to import..."));
    7396    m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Please choose a virtual appliance file to import"));
     
    107130    return pImportApplianceWidget->isValid();
    108131}
    109 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h

    r69500 r72173  
    2424/* Forward declarations: */
    2525class UIEmptyFilePathSelector;
     26class UIFilePathSelector;
    2627class QIRichTextLabel;
    2728
     
    3637    /* Widgets: */
    3738    UIEmptyFilePathSelector *m_pFileSelector;
     39    QIRichTextLabel         *m_pDefaultFolderLabel;
     40    UIFilePathSelector      *m_pDestinationFolderSelector;
    3841};
    3942
     
    6568
    6669#endif /* __UIWizardImportAppPageBasic1_h__ */
    67 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r71924 r72173  
    217217bool UIWizardNewVMPage1::createMachineFolder()
    218218{
     219    if (!m_pNameAndSystemEditor)
     220        return false;
    219221    /* Cleanup previosly created folder if any: */
    220222    if (machineFolderCreated() && !cleanupMachineFolder())
     
    227229    CVirtualBox vbox = vboxGlobal().virtualBox();
    228230    /* Get default machine folder: */
    229     const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
     231    //const QString strMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
     232
    230233    /* Compose machine filename: */
    231234    const QString strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(),
    232235                                                                   m_strGroup,
    233236                                                                   QString(),
    234                                                                    strDefaultMachineFolder);
     237                                                                   m_pNameAndSystemEditor->path());
    235238    /* Compose machine folder/basename: */
    236239    const QFileInfo fileInfo(strMachineFilePath);
     
    315318
    316319    /* Translate widgets: */
    317     m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name for the new virtual machine "
     320    m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
    318321                                        "and select the type of operating system you intend to install on it. "
    319322                                        "The name you choose will be used throughout VirtualBox "
     
    340343    return createMachineFolder();
    341344}
    342 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r71027 r72173  
    5858    QString m_strMachineBaseName;
    5959
    60     /* Widgets: */
     60    /** Provides a path selector and a line edit field for path and name entry. */
    6161    UINameAndSystemEditor *m_pNameAndSystemEditor;
    6262
    63     /* Variables: */
     63    /** Variables: */
    6464    QString m_strGroup;
    6565    bool m_fSupportsHWVirtEx;
     
    107107
    108108#endif // __UIWizardNewVMPageBasic1_h__
    109 
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