VirtualBox

Changeset 100169 in vbox


Ignore:
Timestamp:
Jun 13, 2023 3:14:29 PM (22 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157869
Message:

FE/Qt: bugref:9080. More work on the settings dialog.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r100155 r100169  
    2929/* Qt includes: */
    3030#include <QDir>
     31#include <QItemDelegate>
    3132#include <QFileInfo>
    3233#include <QGridLayout>
     
    4142#include "UIVisoContentBrowser.h"
    4243
     44
     45/*********************************************************************************************************************************
     46*   UIContentBrowserDelegate definition.                                                                                         *
     47*********************************************************************************************************************************/
     48/** A QItemDelegate child class to disable dashed lines drawn around selected cells in QTableViews */
     49class UIContentBrowserDelegate : public QItemDelegate
     50{
     51
     52    Q_OBJECT;
     53
     54public:
     55
     56    UIContentBrowserDelegate(QObject *pParent)
     57        : QItemDelegate(pParent){}
     58
     59protected:
     60
     61    virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {}
     62};
     63
     64
    4365/*********************************************************************************************************************************
    4466*   UIVisoContentTableView definition.                                                                                      *
     
    94116{
    95117    event->acceptProposedAction();
    96 
    97118}
    98119
     
    420441        m_pTableView->setAlternatingRowColors(true);
    421442        m_pTableView->setTabKeyNavigation(false);
     443        m_pTableView->setItemDelegate(new UIContentBrowserDelegate(this));
    422444        QHeaderView *pVerticalHeader = m_pTableView->verticalHeader();
    423445        if (pVerticalHeader)
     
    716738    if (selectedItems.empty())
    717739        return;
    718     /* This is not complete. we have to modify the entries in the m_entryMap as well: */
    719740    renameFileObject(selectedItems.at(0));
    720741}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r100163 r100169  
    8080    UIVisoSettingWidget(QWidget *pParent);
    8181    virtual void retranslateUi();
     82    void setSettings(const UIVisoCreatorWidget::Settings &settings);
     83    UIVisoCreatorWidget::Settings settings() const;
    8284
    8385private slots:
     
    209211{
    210212    emit sigClosed(false);
     213}
     214
     215
     216void UIVisoSettingWidget::setSettings(const UIVisoCreatorWidget::Settings &settings)
     217{
     218    if (m_pVisoNameLineEdit)
     219        m_pVisoNameLineEdit->setText(settings.m_strVisoName);
     220    if (m_pCustomOptionsLineEdit)
     221        m_pCustomOptionsLineEdit->setText(settings.m_customOptions.join(";"));
     222    if (m_pShowHiddenObjectsCheckBox)
     223        m_pShowHiddenObjectsCheckBox->setChecked(settings.m_fShowHiddenObjects);
     224}
     225
     226UIVisoCreatorWidget::Settings UIVisoSettingWidget::settings() const
     227{
     228    UIVisoCreatorWidget::Settings settings;
     229    if (m_pVisoNameLineEdit)
     230        settings.m_strVisoName = m_pVisoNameLineEdit->text();
     231    if (m_pCustomOptionsLineEdit)
     232        settings.m_customOptions = m_pCustomOptionsLineEdit->text().split(";");
     233    if (m_pShowHiddenObjectsCheckBox)
     234        settings.m_fShowHiddenObjects = m_pShowHiddenObjectsCheckBox->isChecked();
     235    return settings;
    211236}
    212237
     
    333358        m_pActionSettings->setChecked(false);
    334359    /* Update settings:*/
    335     if (fAccepted)
    336     {
     360    if (fAccepted && m_pSettingsWidget)
     361    {
     362        Settings newSettings = m_pSettingsWidget->settings();
     363        if (m_visoOptions.m_strVisoName != newSettings.m_strVisoName)
     364        {
     365            m_visoOptions.m_strVisoName = newSettings.m_strVisoName;
     366            emit sigVisoNameChanged(m_visoOptions.m_strVisoName);
     367        }
     368        if (m_visoOptions.m_customOptions != newSettings.m_customOptions)
     369            m_visoOptions.m_customOptions = newSettings.m_customOptions;
     370        if (m_visoOptions.m_fShowHiddenObjects != newSettings.m_fShowHiddenObjects)
     371            m_visoOptions.m_fShowHiddenObjects = newSettings.m_fShowHiddenObjects;
    337372    }
    338373}
     
    447482    m_pOverlayWidget->setGraphicsEffect(m_pOverlayBlurEffect);
    448483    m_pOverlayBlurEffect->setEnabled(false);
    449     m_pOverlayBlurEffect->setBlurRadius(6);
     484    m_pOverlayBlurEffect->setBlurRadius(4);
    450485
    451486    m_pSettingsWidget = new UIVisoSettingWidget(this);
    452     m_pSettingsWidget->setFixedWidth(300);
    453     m_pSettingsWidget->setFixedHeight(300);
    454487    AssertPtrReturnVoid(m_pSettingsWidget);
    455 
     488    m_pSettingsWidget->setMinimumWidth(300);
     489    m_pSettingsWidget->setMinimumHeight(300);
    456490    m_pStackedLayout->addWidget(m_pOverlayWidget);
    457491    m_pStackedLayout->addWidget(m_pBrowserContainerWidget);
     
    563597        /* Add to dummy QWidget to toolbar to center the action icons vertically: */
    564598        QWidget *topSpacerWidget = new QWidget(this);
     599        AssertPtrReturnVoid(topSpacerWidget);
    565600        topSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    566601        topSpacerWidget->setVisible(true);
    567602        QWidget *bottomSpacerWidget = new QWidget(this);
     603        AssertPtrReturnVoid(bottomSpacerWidget);
    568604        bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    569605        bottomSpacerWidget->setVisible(true);
     
    612648        if (m_pMainMenu)
    613649            m_pMainMenu->setEnabled(!m_fShowSettingsDialog);
     650        if (m_fShowSettingsDialog)
     651            m_pSettingsWidget->setSettings(m_visoOptions);
    614652    }
    615653}
     
    618656{
    619657    m_pVerticalToolBar = new QIToolBar;
    620     if (!m_pVerticalToolBar)
    621         return;
     658    AssertPtrReturnVoid(m_pVerticalToolBar);
    622659
    623660    m_pVerticalToolBar->setOrientation(Qt::Vertical);
     
    636673    UIVisoCreatorDialog *pVisoCreator = new UIVisoCreatorDialog(pActionPool, pDialogParent,
    637674                                                                strVisoSaveFolder, strMachineName);
    638 
    639     if (!pVisoCreator)
    640         return QUuid();
     675    AssertPtrReturn(pVisoCreator, QUuid());
     676
    641677    windowManager().registerNewParent(pVisoCreator, pDialogParent);
    642678    pVisoCreator->setCurrentPath(gEDataManager->visoCreatorRecentFolder());
     
    737773{
    738774    QWidget *pCentralWidget = new QWidget;
     775    AssertPtrReturnVoid(pCentralWidget);
    739776    setCentralWidget(pCentralWidget);
    740777    QVBoxLayout *pMainLayout = new QVBoxLayout;
     778    AssertPtrReturnVoid(pMainLayout);
    741779    pCentralWidget->setLayout(pMainLayout);
    742780
    743781
    744782    m_pVisoCreatorWidget = new UIVisoCreatorWidget(m_pActionPool, this, true /* show toolbar */, strMachineName);
    745     if (m_pVisoCreatorWidget && m_pVisoCreatorWidget->menu())
     783    AssertPtrReturnVoid(m_pVisoCreatorWidget);
     784    if (m_pVisoCreatorWidget->menu())
    746785    {
    747786        menuBar()->addMenu(m_pVisoCreatorWidget->menu());
     
    756795
    757796    m_pButtonBox = new QIDialogButtonBox;
    758     if (m_pButtonBox)
    759     {
    760         m_pButtonBox->setDoNotPickDefaultButton(true);
    761         m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    762         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape));
    763         pMainLayout->addWidget(m_pButtonBox);
    764 
    765         // connect(m_pButtonBox->button(QIDialogButtonBox::Help), &QPushButton::pressed,
    766         //         m_pButtonBox, &QIDialogButtonBox::sltHelpRequest);
    767 
    768         m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);
    769 
    770         uiCommon().setHelpKeyword(m_pButtonBox->button(QIDialogButtonBox::Help), "create-optical-disk-image");
    771     }
     797    AssertPtrReturnVoid(m_pButtonBox);
     798    m_pButtonBox->setDoNotPickDefaultButton(true);
     799    m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     800    m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape));
     801    pMainLayout->addWidget(m_pButtonBox);
     802
     803    connect(m_pButtonBox->button(QIDialogButtonBox::Help), &QPushButton::pressed,
     804            m_pButtonBox, &QIDialogButtonBox::sltHandleHelpRequest);
     805
     806    m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);
     807
     808    uiCommon().setHelpKeyword(m_pButtonBox->button(QIDialogButtonBox::Help), "create-optical-disk-image");
    772809
    773810    m_pStatusLabel = new QILabel;
    774811    m_pStatusBar = new QStatusBar(this);
    775     if (m_pButtonBox && m_pStatusLabel)
    776     {
    777         pMainLayout->addWidget(m_pStatusBar);
    778         m_pStatusBar->addPermanentWidget(m_pStatusLabel);
    779     }
     812    AssertPtrReturnVoid(m_pButtonBox);
     813    AssertPtrReturnVoid(m_pStatusLabel);
     814
     815    pMainLayout->addWidget(m_pStatusBar);
     816    m_pStatusBar->addPermanentWidget(m_pStatusLabel);
     817
    780818    retranslateUi();
    781819}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r100162 r100169  
    7474public:
    7575
     76    struct Settings
     77    {
     78        Settings()
     79            : m_strVisoName("ad-hoc-viso")
     80            , m_fShowHiddenObjects(true){}
     81        QString m_strVisoName;
     82        /** Additions viso options to be inserted to the viso file as separate lines. */
     83        QStringList m_customOptions;
     84        /* If host file browser shows hidden file objects. */
     85        bool m_fShowHiddenObjects;
     86    };
     87
    7688    UIVisoCreatorWidget(UIActionPool *pActionPool, QWidget *pParent,
    7789                        bool fShowToolBar, const QString& strMachineName = QString());
     
    109121private:
    110122
    111     struct VisoOptions
    112     {
    113         VisoOptions()
    114             :m_strVisoName("ad-hoc-viso"){}
    115         QString m_strVisoName;
    116         /** Additions viso options to be inserted to the viso file as separate lines. */
    117         QStringList m_customOptions;
    118     };
    119 
    120     struct BrowserOptions
    121     {
    122         BrowserOptions()
    123             :m_fShowHiddenObjects(true){}
    124         bool m_fShowHiddenObjects;
    125     };
    126 
    127123    void prepareWidgets();
    128124    void prepareConnections();
     
    156152    QIToolBar             *m_pToolBar;
    157153    QIToolBar             *m_pVerticalToolBar;
    158     VisoOptions            m_visoOptions;
    159     BrowserOptions         m_browserOptions;
     154    Settings            m_visoOptions;
    160155    QMenu                 *m_pMainMenu;
    161156    QPointer<UIActionPool> m_pActionPool;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp

    r100155 r100169  
    2929#include <QGridLayout>
    3030#include <QHeaderView>
     31#include <QItemDelegate>
    3132#include <QMimeData>
    3233#include <QTextEdit>
     
    3637/* GUI includes: */
    3738#include "UIVisoHostBrowser.h"
     39
     40
     41/*********************************************************************************************************************************
     42*   UIHostBrowserDelegate definition.                                                                                            *
     43*********************************************************************************************************************************/
     44/** A QItemDelegate child class to disable dashed lines drawn around selected cells in QTableViews */
     45class UIHostBrowserDelegate : public QItemDelegate
     46{
     47
     48    Q_OBJECT;
     49
     50public:
     51
     52    UIHostBrowserDelegate(QObject *pParent)
     53        : QItemDelegate(pParent){}
     54
     55protected:
     56
     57    virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {}
     58};
    3859
    3960/*********************************************************************************************************************************
     
    184205        m_pTableView->setAlternatingRowColors(true);
    185206        m_pTableView->setTabKeyNavigation(false);
     207        m_pTableView->setItemDelegate(new UIHostBrowserDelegate(this));
    186208        QHeaderView *pVerticalHeader = m_pTableView->verticalHeader();
    187209        if (pVerticalHeader)
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