VirtualBox

Ignore:
Timestamp:
May 30, 2008 11:57:42 AM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4: Created QIMainDialog which could be used as a QMainWindow, but has the
exec semantic of QDialog also. Additionally there is a new function
'setFileForProxyIcon' which enables the proxy icon usage on Mac OS X.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk

    r9234 r9245  
    444444        include/QIListView.h \
    445445        include/QITreeWidget.h \
     446        include/QIMainDialog.h \
    446447        include/VBoxGlobalSettings.h \
    447448        include/VBoxUtils.h \
     
    528529        src/QIListView.cpp \
    529530        src/QITreeWidget.cpp \
     531        src/QIMainDialog.cpp \
    530532        src/QILineEdit.cpp \
    531533        src/VBoxDefs.cpp \
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h

    r9214 r9245  
    2525
    2626#include "VBoxDiskImageManagerDlg.gen.h"
     27#include "QIMainDialog.h"
    2728#include "QIWithRetranslateUI.h"
    2829#include "COMDefs.h"
     
    3031#include "VBoxMediaComboBox.h"
    3132
    32 /* Qt includes */
    33 #include <QPointer>
    34 
    3533class DiskImageItem;
    3634class VBoxToolBar;
    3735class InfoPaneLabel;
    3836
    39 class VBoxDiskImageManagerDlg : public QIWithRetranslateUI2<QMainWindow>,
     37class VBoxDiskImageManagerDlg : public QIWithRetranslateUI2<QIMainDialog>,
    4038                                public Ui::VBoxDiskImageManagerDlg
    4139{
     
    4846public:
    4947
    50     enum ResultCode { Rejected,
    51                       Accepted };
    52 
    5348    VBoxDiskImageManagerDlg (QWidget *aParent = NULL, Qt::WindowFlags aFlags = Qt::Dialog);
    5449
     
    5651
    5752    static void showModeless (bool aRefresh = true);
    58     int exec();
    59     int result() const;
    6053
    6154    QUuid selectedUuid() const;
     
    6962
    7063    void refreshAll();
    71     virtual void setVisible (bool aVisible);
    7264
    7365protected:
     
    10193    void processDoubleClick (QTreeWidgetItem *aItem, int aColumn);
    10294    void processRightClick (const QPoint &aPos, QTreeWidgetItem *aItem, int aColumn);
    103 
    104     void accept();
    105     void reject();
    106     void done (int aRescode);
    107 
    108     void setResult (int aRescode);
    10995
    11096private:
     
    152138    /* Window status */
    153139    bool mDoSelect;
    154     int mRescode;
    155140    static VBoxDiskImageManagerDlg *mModelessDialog;
    156     QPointer<QEventLoop> mEventLoop;
    157141
    158142    /* Type if we are in the select modus */
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxUtils.h

    r8733 r9245  
    269269}
    270270
     271/* Proxy icon creation */
     272QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
     273
    271274/* Special routines for the dock handling */
    272275CGImageRef darwinCreateDockBadge (const char *aSource);
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp

    r9214 r9245  
    25332533    dlg.setup (VBoxDefs::FD, true, &id);
    25342534
    2535     if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted)
     2535    if (dlg.exec() == QDialog::Accepted)
    25362536    {
    25372537        CFloppyDrive drv = csession.GetMachine().GetFloppyDrive();
     
    25772577    dlg.setup (VBoxDefs::CD, true, &id);
    25782578
    2579     if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted)
     2579    if (dlg.exec() == QDialog::Accepted)
    25802580    {
    25812581        CDVDDrive drv = csession.GetMachine().GetDVDDrive();
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp

    r9217 r9245  
    209209
    210210VBoxDiskImageManagerDlg::VBoxDiskImageManagerDlg (QWidget *aParent /* = NULL */,  Qt::WindowFlags aFlags /* = 0 */)
    211     : QIWithRetranslateUI2<QMainWindow> (aParent, aFlags)
    212     , mRescode (Rejected)
     211    : QIWithRetranslateUI2<QIMainDialog> (aParent, aFlags)
    213212    , mType (VBoxDefs::InvalidType)
    214213{
     
    523522}
    524523
    525 int VBoxDiskImageManagerDlg::exec()
    526 {
    527     AssertMsg (!mEventLoop, ("exec is called recursively!\n"));
    528 
    529     /* Reset the result code */
    530     setResult (Rejected);
    531     bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
    532     setAttribute(Qt::WA_DeleteOnClose, false);
    533     /* Create a local event loop */
    534     mEventLoop = new QEventLoop();
    535     /* Show the window */
    536     show();
    537     /* A guard to ourself for the case we destroy ourself. */
    538     QPointer<VBoxDiskImageManagerDlg> guard = this;
    539     /* Start the event loop. This blocks. */
    540     mEventLoop->exec();
    541     /* Delete the event loop */
    542     delete mEventLoop;
    543     /* Are we valid anymore? */
    544     if (guard.isNull())
    545         return Rejected;
    546      int res = result();
    547      if (deleteOnClose)
    548          delete this;
    549     /* Return the final result */
    550     return res;
    551 }
    552 
    553524QUuid VBoxDiskImageManagerDlg::selectedUuid() const
    554525{
     
    796767    /* Start enumerating media */
    797768    vboxGlobal().startEnumeratingMedia();
    798 }
    799 
    800 void VBoxDiskImageManagerDlg::setVisible (bool aVisible)
    801 {
    802     QMainWindow::setVisible (aVisible);
    803     /* Exit from the event loop if there is any and we are changing our state
    804      * from visible to invisible. */
    805     if(mEventLoop && !aVisible)
    806         mEventLoop->exit();
    807769}
    808770
     
    14071369}
    14081370
    1409 void VBoxDiskImageManagerDlg::accept()
    1410 {
    1411     done (Accepted);
    1412 }
    1413 
    1414 void VBoxDiskImageManagerDlg::reject()
    1415 {
    1416     done (Rejected);
    1417 }
    1418 
    1419 void VBoxDiskImageManagerDlg::done (int aResult)
    1420 {
    1421     /* Set the final result */
    1422     setResult (aResult);
    1423     /* Hide this window */
    1424     hide();
    1425     /* And close the window */
    1426     close();
    1427 }
    1428 
    1429 int VBoxDiskImageManagerDlg::result() const
    1430 {
    1431     return mRescode;
    1432 }
    1433 
    1434 void VBoxDiskImageManagerDlg::setResult (int aRescode)
    1435 {
    1436     mRescode = aRescode;
    1437 }
    1438 
    14391371QTreeWidget* VBoxDiskImageManagerDlg::treeWidget (VBoxDefs::DiskType aType) const
    14401372{
     
    15521484        return;
    15531485    }
     1486
     1487    /* Set the file for the proxy icon */
     1488    setFileForProxyIcon (item->path());
    15541489
    15551490    /* Ensures current item visible every time we are switching page */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxNewVMWzd.cpp

    r9214 r9245  
    197197    VBoxDiskImageManagerDlg dlg (this);
    198198    dlg.setup (VBoxDefs::HD, true);
    199     QUuid newId = dlg.exec() == VBoxDiskImageManagerDlg::Accepted ?
     199    QUuid newId = dlg.exec() == QDialog::Accepted ?
    200200        dlg.selectedUuid() : mMediaCombo->getId();
    201201
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp

    r9214 r9245  
    246246        mRbFdType->isChecked() ? VBoxDefs::FD : VBoxDefs::InvalidType;
    247247    vdm.setup (type, true, &machineId);
    248     if (vdm.exec() == VBoxDiskImageManagerDlg::Accepted)
     248    if (vdm.exec() == QDialog::Accepted)
    249249    {
    250250        mCbImage->setCurrentItem (vdm.selectedUuid());
  • trunk/src/VBox/Frontends/VirtualBox4/src/darwin/VBoxUtils-darwin.cpp

    r8733 r9245  
    3232#include <QPixmap>
    3333#include <QPainter>
     34#include <QApplication>
    3435
    3536/**
     
    9596    Assert (!qpm.isNull());
    9697    return ::darwinToCGImageRef (&qpm);
     98}
     99
     100/* Proxy icon creation */
     101QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText)
     102{
     103    QFontMetrics fm (qApp->font());
     104    QRect tbRect = fm.boundingRect (aText);
     105    const int h = qMax (aPixmap.height(), tbRect.height());
     106    const int m = 2;
     107    QPixmap dragPixmap (aPixmap.width() + tbRect.width() + m, h);
     108    dragPixmap.fill (Qt::transparent);
     109    QPainter painter (&dragPixmap);
     110    painter.drawPixmap (0, qAbs (h - aPixmap.height()) / 2.0, aPixmap);
     111    painter.drawText (aPixmap.width() + m, qAbs (h - aPixmap.height()) / 2.0 + aPixmap.height(), aText);
     112    painter.end();
     113    return dragPixmap;
    97114}
    98115
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