VirtualBox

Changeset 72410 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 1, 2018 12:48:18 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt bugref:9183 Initial size and position settings for UIMediumselector

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

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

    r72409 r72410  
    3030# include "QITabWidget.h"
    3131# include "VBoxGlobal.h"
     32# include "UIDesktopWidgetWatchdog.h"
    3233# include "UIExtraDataManager.h"
    3334# include "UIMediumSelector.h"
     
    6364    , m_pAttachedSubTreeRoot(0)
    6465    , m_pNotAttachedSubTreeRoot(0)
     66    , m_pParent(pParent)
    6567{
    6668    configure();
     
    8991    if (m_pActionAdd)
    9092    {
    91         m_pActionAdd->setText(QApplication::translate("UIMediumManager", "&Add..."));
     93        m_pActionAdd->setText(QApplication::translate("UIMediumManager", "&Add from file..."));
    9294        m_pActionAdd->setToolTip(QApplication::translate("UIMediumManager", "Add Disk Image File"));
    9395        m_pActionAdd->setStatusTip(QApplication::translate("UIMediumManager", "Add disk image file"));
     
    102104    if (m_pButtonBox)
    103105        m_pButtonBox->button(QDialogButtonBox::Ok)->setText("Add Selected");
     106
     107    if (m_pTreeWidget)
     108    {
     109        m_pTreeWidget->headerItem()->setText(0, QApplication::translate("UIMediumManager","Name"));
     110    }
    104111}
    105112
     
    108115    /* Apply window icons: */
    109116    setWindowIcon(UIIconPool::iconSetFull(":/diskimage_32px.png", ":/diskimage_16px.png"));
     117
     118
    110119    prepareActions();
    111120    prepareWidgets();
    112121    prepareConnections();
     122
    113123}
    114124
     
    166176    if (m_pActionRefresh)
    167177        connect(m_pActionRefresh, &QAction::triggered, this, &UIMediumSelector::sltHandleRefresh);
     178
     179    if (m_pTreeWidget)
     180        connect(m_pTreeWidget, &QITreeWidget::itemSelectionChanged, this, &UIMediumSelector::sltHandleItemSelectionChanged);
     181
     182    if (m_pButtonBox)
     183    {
     184        connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMediumSelector::close);
     185        connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMediumSelector::accept);
     186    }
    168187}
    169188
     
    244263    {
    245264        m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
    246         //connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, this, &UIMediumSelector::sltHandleCurrentItemChanged);
    247         connect(m_pTreeWidget, &QITreeWidget::itemSelectionChanged, this, &UIMediumSelector::sltHandleItemSelectionChanged);
    248265        m_pMainLayout->addWidget(m_pTreeWidget);
    249     }
    250 
    251         m_pButtonBox = new QIDialogButtonBox;
     266
     267    }
     268
     269    m_pButtonBox = new QIDialogButtonBox;
    252270    if (m_pButtonBox)
    253271    {
     
    255273        m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    256274        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    257         // connect(m_pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);
    258         connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMediumSelector::close);
    259         connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMediumSelector::accept);
    260275
    261276        /* Add button-box into main layout: */
     
    338353    /* Apply language settings: */
    339354    retranslateUi();
     355}
     356
     357void UIMediumSelector::showEvent(QShowEvent *pEvent)
     358{
     359
     360    /* Try to determine the initial size: */
     361    QSize proposedSize;
     362    int iHostScreen = 0;
     363    if (m_pParent)
     364        iHostScreen = gpDesktop->screenNumber(m_pParent);
     365    else
     366        iHostScreen = gpDesktop->screenNumber(this);
     367    if (iHostScreen >= 0 && iHostScreen < gpDesktop->screenCount())
     368    {
     369        /* On the basis of current host-screen geometry if possible: */
     370        const QRect screenGeometry = gpDesktop->screenGeometry(iHostScreen);
     371        if (screenGeometry.isValid())
     372            proposedSize = screenGeometry.size() * 7 / 15;
     373    }
     374    /* Fallback to default size if we failed: */
     375    if (proposedSize.isNull())
     376        proposedSize = QSize(800, 600);
     377    /* Resize to initial size: */
     378    resize(proposedSize);
     379
     380    if (m_pParent)
     381        VBoxGlobal::centerWidget(this, m_pParent, false);
     382
    340383}
    341384
     
    396439        m_pTreeWidget->expandItem(m_pNotAttachedSubTreeRoot);
    397440
    398     // QItemSelectionModel *selectionModel = m_pTreeWidget->selectionModel();
    399     // selectionModel->clearSelection();
    400 
    401     // /* Remember current medium-items: */
    402     // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_HardDisk))
    403     //     m_strCurrentIdHD = pMediumItem->id();
    404     // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_DVD))
    405     //     m_strCurrentIdCD = pMediumItem->id();
    406     // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_Floppy))
    407     //     m_strCurrentIdFD = pMediumItem->id();
    408 
    409     // /* Clear tree-widgets: */
    410     // QITreeWidget *pTreeWidgetHD = treeWidget(UIMediumType_HardDisk);
    411     // if (pTreeWidgetHD)
    412     // {
    413     //     setCurrentItem(pTreeWidgetHD, 0);
    414     //     pTreeWidgetHD->clear();
    415     // }
    416     // QITreeWidget *pTreeWidgetCD = treeWidget(UIMediumType_DVD);
    417     // if (pTreeWidgetCD)
    418     // {
    419     //     setCurrentItem(pTreeWidgetCD, 0);
    420     //     pTreeWidgetCD->clear();
    421     // }
    422     // QITreeWidget *pTreeWidgetFD = treeWidget(UIMediumType_Floppy);
    423     // if (pTreeWidgetFD)
    424     // {
    425     //     setCurrentItem(pTreeWidgetFD, 0);
    426     //     pTreeWidgetFD->clear();
    427     // }
    428 
    429     // /* Create medium-items (do not change current one): */
    430     // m_fPreventChangeCurrentItem = true;
    431 
    432     // m_fPreventChangeCurrentItem = false;
    433 
    434     // /* Select first item as current one if nothing selected: */
    435     // if (pTreeWidgetHD && !mediumItem(UIMediumType_HardDisk))
    436     //     if (QTreeWidgetItem *pItem = pTreeWidgetHD->topLevelItem(0))
    437     //         setCurrentItem(pTreeWidgetHD, pItem);
    438     // if (pTreeWidgetCD && !mediumItem(UIMediumType_DVD))
    439     //     if (QTreeWidgetItem *pItem = pTreeWidgetCD->topLevelItem(0))
    440     //         setCurrentItem(pTreeWidgetCD, pItem);
    441     // if (pTreeWidgetFD && !mediumItem(UIMediumType_Floppy))
    442     //     if (QTreeWidgetItem *pItem = pTreeWidgetFD->topLevelItem(0))
    443     //         setCurrentItem(pTreeWidgetFD, pItem);
    444 
    445 
    446 }
     441}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

    r72406 r72410  
    3737
    3838
    39 /** QIDialog extension providing GUI with the dialog to select an existing media. */
     39/** QIDialog extension providing GUI with a dialog to select an existing medium. */
    4040class SHARED_LIBRARY_STUFF UIMediumSelector : public QIWithRetranslateUI<QIDialog>
    4141{
     
    5050    QStringList selectedMediumIds() const;
    5151
     52protected:
     53
     54    void showEvent(QShowEvent *pEvent);
     55
    5256private slots:
    5357
    5458    void sltAddMedium();
    55     //void sltHandleCurrentItemChanged();
    5659    void sltHandleItemSelectionChanged();
    5760    void sltHandleMediumEnumerationStart();
     
    97100    /** All the known media that are not attached to any vm are added under the following top level tree item */
    98101    QITreeWidgetItem  *m_pNotAttachedSubTreeRoot;
     102    QWidget           *m_pParent;
    99103};
    100104
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