VirtualBox

Changeset 27087 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 5, 2010 1:28:41 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58412
Message:

FE/Qt4: new core: make it possible to use this class in the old and new code at the same time

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

Legend:

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

    r27044 r27087  
    4545#ifdef VBOX_WITH_NEW_RUNTIME_CORE
    4646void VBoxVMInformationDlg::createInformationDlg(UIMachineWindow *pMachineWindow)
    47 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
    48 void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole)
    49 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    50 {
    51 #ifdef VBOX_WITH_NEW_RUNTIME_CORE
     47{
    5248    CMachine machine = pMachineWindow->machineLogic()->uisession()->session().GetMachine();
    53 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
    54     CMachine machine = aSession.GetMachine();
    55 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    5649    if (mSelfArray.find (machine.GetName()) == mSelfArray.end())
    5750    {
    5851        /* Creating new information dialog if there is no one existing */
    59 #ifdef VBOX_WITH_NEW_RUNTIME_CORE
    6052        VBoxVMInformationDlg *id = new VBoxVMInformationDlg(pMachineWindow, Qt::Window);
    6153        id->centerAccording (pMachineWindow->machineWindow());
    62 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
    63         VBoxVMInformationDlg *id = new VBoxVMInformationDlg (aConsole, aSession, Qt::Window);
    64         id->centerAccording (aConsole);
    65 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    6654        connect (vboxGlobal().mainWindow(), SIGNAL (closing()), id, SLOT (close()));
    6755        id->setAttribute (Qt::WA_DeleteOnClose);
     
    7664}
    7765
    78 #ifdef VBOX_WITH_NEW_RUNTIME_CORE
    7966VBoxVMInformationDlg::VBoxVMInformationDlg (UIMachineWindow *pMachineWindow, Qt::WindowFlags aFlags)
    8067# ifdef Q_WS_MAC
     
    8471# endif /* Q_WS_MAC */
    8572    , mSession (pMachineWindow->session())
    86 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
    87 VBoxVMInformationDlg::VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags)
    88 # ifdef Q_WS_MAC
    89     : QIWithRetranslateUI2 <QIMainDialog> (aConsole, aFlags)
    90 # else /* Q_WS_MAC */
    91     : QIWithRetranslateUI2 <QIMainDialog> (0, aFlags)
    92 # endif /* Q_WS_MAC */
    93 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    94 #ifndef VBOX_WITH_NEW_RUNTIME_CORE
    95     , mConsole (aConsole)
    96     , mSession (aSession)
    97 #endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
    9873    , mIsPolished (false)
    9974    , mStatTimer (new QTimer (this))
     
    127102
    128103    /* Setup handlers */
    129 #ifdef VBOX_WITH_NEW_RUNTIME_CORE
    130104    connect (pMachineWindow->uisession(), SIGNAL (sigMediumChange(const CMediumAttachment&)), this, SLOT (updateDetails()));
    131105    connect (pMachineWindow->uisession(), SIGNAL (sigSharedFolderChange()), this, SLOT (updateDetails()));
     
    133107     * more than one screens. */
    134108    connect (pMachineWindow->machineView(), SIGNAL (resizeHintDone()), this, SLOT (processStatistics()));
    135 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
     109    connect (mInfoStack, SIGNAL (currentChanged (int)), this, SLOT (onPageChanged (int)));
     110    connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails()));
     111    connect (mStatTimer, SIGNAL (timeout()), this, SLOT (processStatistics()));
     112
     113    /* Loading language constants */
     114    retranslateUi();
     115
     116    /* Details page update */
     117    updateDetails();
     118
     119    /* Statistics page update */
     120    processStatistics();
     121    mStatTimer->start (5000);
     122
     123    /* Preload dialog attributes for this vm */
     124    QString dlgsize = mSession.GetMachine().GetExtraData (VBoxDefs::GUI_InfoDlgState);
     125    if (dlgsize.isEmpty())
     126    {
     127        mWidth = 400;
     128        mHeight = 450;
     129        mMax = false;
     130    }
     131    else
     132    {
     133        QStringList list = dlgsize.split (',');
     134        mWidth = list [0].toInt(), mHeight = list [1].toInt();
     135        mMax = list [2] == "max";
     136    }
     137
     138    /* Make statistics page the default one */
     139    mInfoStack->setCurrentIndex (1);
     140}
     141#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
     142
     143void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole)
     144{
     145    CMachine machine = aSession.GetMachine();
     146    if (mSelfArray.find (machine.GetName()) == mSelfArray.end())
     147    {
     148        /* Creating new information dialog if there is no one existing */
     149        VBoxVMInformationDlg *id = new VBoxVMInformationDlg (aConsole, aSession, Qt::Window);
     150        id->centerAccording (aConsole);
     151        connect (vboxGlobal().mainWindow(), SIGNAL (closing()), id, SLOT (close()));
     152        id->setAttribute (Qt::WA_DeleteOnClose);
     153        mSelfArray [machine.GetName()] = id;
     154    }
     155
     156    VBoxVMInformationDlg *info = mSelfArray [machine.GetName()];
     157    info->show();
     158    info->raise();
     159    info->setWindowState (info->windowState() & ~Qt::WindowMinimized);
     160    info->activateWindow();
     161}
     162
     163VBoxVMInformationDlg::VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags)
     164# ifdef Q_WS_MAC
     165    : QIWithRetranslateUI2 <QIMainDialog> (aConsole, aFlags)
     166# else /* Q_WS_MAC */
     167    : QIWithRetranslateUI2 <QIMainDialog> (0, aFlags)
     168# endif /* Q_WS_MAC */
     169    , mConsole (aConsole)
     170    , mSession (aSession)
     171    , mIsPolished (false)
     172    , mStatTimer (new QTimer (this))
     173{
     174    /* Apply UI decorations */
     175    Ui::VBoxVMInformationDlg::setupUi (this);
     176
     177#ifdef Q_WS_MAC
     178    /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */
     179    setWindowIcon (QIcon());
     180#else
     181    /* Apply window icons */
     182    setWindowIcon (vboxGlobal().iconSetFull (QSize (32, 32), QSize (16, 16),
     183                                             ":/session_info_32px.png", ":/session_info_16px.png"));
     184#endif
     185
     186    /* Enable size grip without using a status bar. */
     187    setSizeGripEnabled (true);
     188
     189    /* Setup focus-proxy for pages */
     190    mPage1->setFocusProxy (mDetailsText);
     191    mPage2->setFocusProxy (mStatisticText);
     192
     193    /* Setup browsers */
     194    mDetailsText->viewport()->setAutoFillBackground (false);
     195    mStatisticText->viewport()->setAutoFillBackground (false);
     196
     197    /* Setup margins */
     198    mDetailsText->setViewportMargins (5, 5, 5, 5);
     199    mStatisticText->setViewportMargins (5, 5, 5, 5);
     200
     201    /* Setup handlers */
    136202    /* Setup handlers */
    137203    connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)), this, SLOT (updateDetails()));
    138204    connect (mConsole, SIGNAL (sharedFoldersChanged()), this, SLOT (updateDetails()));
    139205    connect (mConsole, SIGNAL (resizeHintDone()), this, SLOT (processStatistics()));
    140 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    141206    connect (mInfoStack, SIGNAL (currentChanged (int)), this, SLOT (onPageChanged (int)));
    142207    connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails()));
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.h

    r27044 r27087  
    4646#ifdef VBOX_WITH_NEW_RUNTIME_CORE
    4747    static void createInformationDlg(UIMachineWindow *pMachineWindow);
    48 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
     48#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    4949    static void createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole);
    50 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    5150
    5251protected:
     
    5453#ifdef VBOX_WITH_NEW_RUNTIME_CORE
    5554    VBoxVMInformationDlg (UIMachineWindow *pMachineWindow, Qt::WindowFlags aFlags);
    56 #else /* VBOX_WITH_NEW_RUNTIME_CORE */
     55#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    5756    VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags);
    58 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */
    5957   ~VBoxVMInformationDlg();
    6058
     
    8482    static InfoDlgMap  mSelfArray;
    8583
    86 #ifndef VBOX_WITH_NEW_RUNTIME_CORE
    8784    VBoxConsoleView   *mConsole;
    88 #endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
    8985    CSession           mSession;
    9086    bool               mIsPolished;
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