VirtualBox

Changeset 42722 in vbox


Ignore:
Timestamp:
Aug 9, 2012 6:26:14 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79931
Message:

FE/Qt: 6234: Support for VM groups: Save machine groups on each change (in parallel thread); Some rework to details-view update procedures making it a little bit faster.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
14 edited

Legend:

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

    r42631 r42722  
    859859        }
    860860    }
     861}
     862
     863void UISelectorWindow::sltGroupSavingUpdate()
     864{
     865    updateActionsAppearance();
    861866}
    862867
     
    13461351    connect(m_pChooser, SIGNAL(sigSelectionChanged()), this, SLOT(sltCurrentVMItemChanged()), Qt::QueuedConnection);
    13471352    connect(m_pChooser, SIGNAL(sigSlidingStarted()), m_pDetails, SIGNAL(sigSlidingStarted()));
     1353    connect(m_pChooser, SIGNAL(sigGroupSavingStarted()), this, SLOT(sltGroupSavingUpdate()));
     1354    connect(m_pChooser, SIGNAL(sigGroupSavingFinished()), this, SLOT(sltGroupSavingUpdate()));
    13481355
    13491356    /* Tool-bar connections: */
     
    16081615        case UIActionIndexSelector_Simple_Machine_SettingsDialog:
    16091616        {
    1610             /* Check that there is only one item, its accessible
     1617            /* Check that we are not saving groups,
     1618             * there is only one item, its accessible
    16111619             * and machine is not in 'stuck' state. */
    1612             return items.size() == 1 &&
     1620            return !m_pChooser->isGroupSavingInProgress() &&
     1621                   items.size() == 1 &&
    16131622                   pItem->accessible() &&
    16141623                   pItem->machineState() != KMachineState_Stuck;
     
    16331642        case UIActionIndexSelector_Simple_Group_RemoveDialog:
    16341643        {
     1644            /* Make sure we are not saving groups: */
     1645            if (m_pChooser->isGroupSavingInProgress())
     1646                return false;
     1647
    16351648            /* Group can be always removed/renamed: */
    16361649            return true;
     
    16381651        case UIActionIndexSelector_Simple_Machine_RemoveDialog:
    16391652        {
     1653            /* Make sure we are not saving groups: */
     1654            if (m_pChooser->isGroupSavingInProgress())
     1655                return false;
     1656
    16401657            /* Check that all machines are NOT accessible
    16411658             * or session states of all machines are unlocked. */
     
    16471664            /* Make sure all items are accessible: */
    16481665            if (!isItemsAccessible(items))
     1666                return false;
     1667
     1668            /* Make sure we are not saving groups: */
     1669            if (m_pChooser->isGroupSavingInProgress())
    16491670                return false;
    16501671
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r42631 r42722  
    105105    void sltOpenUrls(QList<QUrl> list = QList<QUrl>());
    106106
     107    /* Handlers: Group saving stuff: */
     108    void sltGroupSavingUpdate();
     109
    107110private:
    108111
     
    139142
    140143    /* Helpers: Action stuff: */
    141     static bool isActionEnabled(int iActionIndex, const QList<UIVMItem*> &items);
     144    bool isActionEnabled(int iActionIndex, const QList<UIVMItem*> &items);
    142145    static bool isItemsAccessible(const QList<UIVMItem*> &items);
    143146    static bool isItemsInaccessible(const QList<UIVMItem*> &items);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.cpp

    r42547 r42722  
    5858    prepareConnections();
    5959
    60     /* Load model: */
    61     m_pChooserModel->load();
     60    /* Prepare model: */
     61    m_pChooserModel->prepare();
    6262
    6363    /* Load last selected item: */
     
    7070    vboxGlobal().virtualBox().SetExtraData(GUI_LastItemSelected, m_pChooserModel->currentItemDefinition());
    7171
    72     /* Save model: */
    73     m_pChooserModel->save();
     72    /* Cleanup model: */
     73    m_pChooserModel->cleanup();
    7474}
    7575
     
    106106}
    107107
     108bool UIGChooser::isGroupSavingInProgress() const
     109{
     110    return m_pChooserModel->isGroupSavingInProgress();
     111}
     112
    108113void UIGChooser::prepareConnections()
    109114{
     
    113118    connect(m_pChooserModel, SIGNAL(sigSelectionChanged()), this, SIGNAL(sigSelectionChanged()));
    114119    connect(m_pChooserModel, SIGNAL(sigSlidingStarted()), this, SIGNAL(sigSlidingStarted()));
     120    connect(m_pChooserModel, SIGNAL(sigGroupSavingStarted()), this, SIGNAL(sigGroupSavingStarted()));
     121    connect(m_pChooserModel, SIGNAL(sigGroupSavingFinished()), this, SIGNAL(sigGroupSavingFinished()));
    115122
    116123    /* Chooser-view connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.h

    r42547 r42722  
    4646    void sigSlidingStarted();
    4747
     48    /* Notifiers: Group saving stuff: */
     49    void sigGroupSavingStarted();
     50    void sigGroupSavingFinished();
     51
    4852public:
    4953
     
    6165    void setStatusBar(QStatusBar *pStatusBar);
    6266
     67    /* API: Group saving stuff: */
     68    bool isGroupSavingInProgress() const;
     69
    6370private:
    6471
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp

    r42710 r42722  
    219219        return;
    220220
     221    /* Set new name / update model: */
    221222    m_strName = strNewName;
     223    model()->saveGroupSettings();
    222224}
    223225
     
    466468        return;
    467469
     470    /* Not while saving groups: */
     471    if (model()->isGroupSavingInProgress())
     472        return;
     473
    468474    /* Unlock name-editor: */
    469475    m_pNameEditor->show();
     
    834840bool UIGChooserItemGroup::isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const
    835841{
     842    /* No drops while saving groups: */
     843    if (model()->isGroupSavingInProgress())
     844        return false;
    836845    /* Get mime: */
    837846    const QMimeData *pMimeData = pEvent->mimeData();
     
    927936                }
    928937
    929                 /* Update scene: */
     938                /* Update model: */
    930939                pModel->updateGroupTree();
    931940                pModel->updateNavigation();
     
    933942                pModel->setCurrentItem(pNewGroupItem->parentItem()->toGroupItem()->opened() ?
    934943                                       pNewGroupItem : pNewGroupItem->parentItem());
     944                pModel->saveGroupSettings();
    935945                break;
    936946            }
     
    978988                }
    979989
    980                 /* Update scene: */
     990                /* Update model: */
    981991                pModel->updateGroupTree();
    982992                pModel->updateNavigation();
     
    984994                pModel->setCurrentItem(pNewMachineItem->parentItem()->toGroupItem()->opened() ?
    985995                                       pNewMachineItem : pNewMachineItem->parentItem());
     996                pModel->saveGroupSettings();
    986997                break;
    987998            }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp

    r42710 r42722  
    403403bool UIGChooserItemMachine::isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const
    404404{
     405    /* No drops while saving groups: */
     406    if (model()->isGroupSavingInProgress())
     407        return false;
    405408    /* Get mime: */
    406409    const QMimeData *pMimeData = pEvent->mimeData();
     
    463466                delete this;
    464467
    465                 /* Update scene: */
     468                /* Update model: */
    466469                pModel->updateGroupTree();
    467470                pModel->updateNavigation();
    468471                pModel->updateLayout();
    469472                pModel->setCurrentItem(pNewGroupItem);
     473                pModel->saveGroupSettings();
    470474                break;
    471475            }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r42678 r42722  
    4545#include "CMachine.h"
    4646#include "CVirtualBox.h"
     47
     48/* Type defs: */
     49typedef QSet<QString> UIStringSet;
    4750
    4851UIGChooserModel::UIGChooserModel(QObject *pParent)
     
    8891 }
    8992
    90 void UIGChooserModel::load()
     93void UIGChooserModel::prepare()
    9194{
    9295    /* Prepare group-tree: */
     
    9497}
    9598
    96 void UIGChooserModel::save()
     99void UIGChooserModel::cleanup()
    97100{
    98101    /* Cleanup group-tree: */
     
    496499}
    497500
     501void UIGChooserModel::saveGroupSettings()
     502{
     503    emit sigStartGroupSaving();
     504}
     505
     506bool UIGChooserModel::isGroupSavingInProgress() const
     507{
     508    return UIGroupsSavingThread::instance();
     509}
     510
    498511void UIGChooserModel::sltMachineStateChanged(QString strId, KMachineState)
    499512{
     
    650663    else
    651664        unsetCurrentItem();
     665    saveGroupSettings();
    652666}
    653667
     
    750764    updateLayout();
    751765    setCurrentItem(pNewGroupItem);
     766    saveGroupSettings();
    752767}
    753768
     
    844859    if (singleGroupSelected())
    845860        sortItems(selectionList().first());
     861}
     862
     863void UIGChooserModel::sltGroupSavingStart()
     864{
     865    saveGroupTree();
     866}
     867
     868void UIGChooserModel::sltGroupSavingComplete()
     869{
     870    makeSureGroupSavingIsFinished();
     871    emit sigGroupSavingFinished();
    846872}
    847873
     
    930956    connect(gActionPool->action(UIActionIndexSelector_Simple_Group_Sort), SIGNAL(triggered()),
    931957            this, SLOT(sltSortGroup()));
     958
     959    connect(this, SIGNAL(sigStartGroupSaving()), this, SLOT(sltGroupSavingStart()), Qt::QueuedConnection);
    932960}
    933961
     
    954982void UIGChooserModel::cleanupGroupTree()
    955983{
    956     /* Save group tree: */
    957     saveGroupTree();
    958     /* Save order: */
     984    makeSureGroupSavingIsFinished();
    959985    saveGroupsOrder();
    960986}
     
    11131139        }
    11141140        /* Update group definitions: */
    1115         m_groups[machine.GetId()] = UIStringSet::fromList(groups.toList());
     1141        m_groups[machine.GetId()] = groups.toList();
    11161142    }
    11171143    /* Inaccessible machine: */
     
    12951321void UIGChooserModel::saveGroupTree()
    12961322{
    1297     /* Prepare machine map: */
     1323    /* Make sure there is no group saving activity: */
     1324    if (UIGroupsSavingThread::instance())
     1325        return;
     1326
     1327    /* Prepare full group map: */
    12981328    QMap<QString, QStringList> groups;
    1299     /* Iterate over all the items: */
    13001329    gatherGroupTree(groups, mainRoot());
    1301     /* Saving groups: */
    1302     foreach (const QString &strId, groups.keys())
    1303     {
    1304         /* Get new group list: */
    1305         const QStringList &newGroupList = groups.value(strId);
    1306         /* Get old group set: */
    1307         AssertMsg(m_groups.contains(strId), ("Invalid group set!"));
    1308         const UIStringSet &oldGroupSet = m_groups.value(strId);
    1309         /* Get new group set: */
    1310         const UIStringSet &newGroupSet = UIStringSet::fromList(newGroupList);
    1311         /* Is group set changed? */
    1312         if (oldGroupSet != newGroupSet)
    1313         {
    1314             /* Open session to save machine settings: */
    1315             CSession session = vboxGlobal().openSession(strId);
    1316             if (session.isNull())
    1317                 return;
    1318             /* Get machine: */
    1319             CMachine machine = session.GetMachine();
    1320             /* Save groups: */
    1321 //            printf(" Saving groups for machine {%s}: {%s}\n",
    1322 //                   machine.GetName().toAscii().constData(),
    1323 //                   newGroupList.join(",").toAscii().constData());
    1324             machine.SetGroups(newGroupList.toVector());
    1325             machine.SaveSettings();
    1326             if (!machine.isOk())
    1327                 msgCenter().cannotSaveMachineSettings(machine);
    1328             /* Close the session: */
    1329             session.UnlockMachine();
    1330         }
    1331     }
     1330
     1331    /* Save information in other thread: */
     1332    UIGroupsSavingThread::prepare();
     1333    emit sigGroupSavingStarted();
     1334    UIGroupsSavingThread::instance()->configure(this, m_groups, groups);
     1335    UIGroupsSavingThread::instance()->start();
     1336    m_groups = groups;
    13321337}
    13331338
     
    17431748}
    17441749
     1750void UIGChooserModel::makeSureGroupSavingIsFinished()
     1751{
     1752    /* Nothing to do if thread is null: */
     1753    if (!UIGroupsSavingThread::instance())
     1754        return;
     1755
     1756    /* Cleanup thread otherwise: */
     1757    UIGroupsSavingThread::cleanup();
     1758}
     1759
     1760/* static */
     1761UIGroupsSavingThread* UIGroupsSavingThread::m_spInstance = 0;
     1762
     1763/* static */
     1764UIGroupsSavingThread* UIGroupsSavingThread::instance()
     1765{
     1766    return m_spInstance;
     1767}
     1768
     1769/* static */
     1770void UIGroupsSavingThread::prepare()
     1771{
     1772    /* Make sure instance not prepared: */
     1773    if (m_spInstance)
     1774        return;
     1775
     1776    /* Crate instance: */
     1777    new UIGroupsSavingThread;
     1778}
     1779
     1780/* static */
     1781void UIGroupsSavingThread::cleanup()
     1782{
     1783    /* Make sure instance prepared: */
     1784    if (!m_spInstance)
     1785        return;
     1786
     1787    /* Crate instance: */
     1788    delete m_spInstance;
     1789}
     1790
     1791void UIGroupsSavingThread::configure(QObject *pParent,
     1792                                     const QMap<QString, QStringList> &oldLists,
     1793                                     const QMap<QString, QStringList> &newLists)
     1794{
     1795    m_oldLists = oldLists;
     1796    m_newLists = newLists;
     1797    connect(this, SIGNAL(sigComplete()), pParent, SLOT(sltGroupSavingComplete()));
     1798}
     1799
     1800UIGroupsSavingThread::UIGroupsSavingThread()
     1801{
     1802    /* Assign instance: */
     1803    m_spInstance = this;
     1804}
     1805
     1806UIGroupsSavingThread::~UIGroupsSavingThread()
     1807{
     1808    /* Wait: */
     1809    wait();
     1810
     1811    /* Erase instance: */
     1812    m_spInstance = 0;
     1813}
     1814
     1815void UIGroupsSavingThread::run()
     1816{
     1817    /* COM prepare: */
     1818    COMBase::InitializeCOM(false);
     1819
     1820    /* For every particular machine ID: */
     1821    foreach (const QString &strId, m_newLists.keys())
     1822    {
     1823        /* Get new group list/set: */
     1824        const QStringList &newGroupList = m_newLists.value(strId);
     1825        const UIStringSet &newGroupSet = UIStringSet::fromList(newGroupList);
     1826        /* Get old group list/set: */
     1827        const QStringList &oldGroupList = m_oldLists.value(strId);
     1828        const UIStringSet &oldGroupSet = UIStringSet::fromList(oldGroupList);
     1829        /* Is group set changed? */
     1830        if (newGroupSet != oldGroupSet)
     1831        {
     1832            /* Open session to save machine settings: */
     1833            CSession session = vboxGlobal().openSession(strId);
     1834            AssertMsg(!session.isNull(), ("Can't open session!"));
     1835            /* Get machine: */
     1836            CMachine machine = session.GetMachine();
     1837            AssertMsg(!machine.isNull(), ("Can't get machine!"));
     1838            /* Save settings: */
     1839            machine.SetGroups(newGroupList.toVector());
     1840            machine.SaveSettings();
     1841            AssertMsg(machine.isOk(), ("Unable to save machine settings!"));
     1842            //msgCenter().cannotSaveMachineSettings(machine);
     1843            /* Close the session: */
     1844            session.UnlockMachine();
     1845        }
     1846    }
     1847
     1848    /* Notify listeners about completeness: */
     1849    emit sigComplete();
     1850
     1851    /* COM cleanup: */
     1852    COMBase::CleanupCOM();
     1853}
     1854
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r42637 r42722  
    2525#include <QTransform>
    2626#include <QMap>
    27 #include <QSet>
     27#include <QThread>
    2828
    2929/* GUI includes: */
     
    4545class UIGChooserHandlerKeyboard;
    4646
    47 /* Type defs: */
    48 typedef QSet<QString> UIStringSet;
    49 
    5047/* Context-menu type: */
    5148enum UIGraphicsSelectorContextMenuType
     
    7572    void sigSlidingStarted();
    7673
     74    /* Notifiers: Group saving stuff: */
     75    void sigStartGroupSaving();
     76    void sigGroupSavingStarted();
     77    void sigGroupSavingFinished();
     78
    7779public:
    7880
     
    8183    ~UIGChooserModel();
    8284
    83     /* API: Load/save stuff: */
    84     void load();
    85     void save();
     85    /* API: Prepare/cleanup stuff: */
     86    void prepare();
     87    void cleanup();
    8688
    8789    /* API: Scene getter: */
     
    140142    QString uniqueGroupName(UIGChooserItem *pRoot);
    141143
     144    /* API: Group saving stuff: */
     145    void saveGroupSettings();
     146    bool isGroupSavingInProgress() const;
     147
    142148private slots:
    143149
     
    183189    void sltSortParentGroup();
    184190    void sltSortGroup();
     191
     192    /* Handlers: Group saving stuff: */
     193    void sltGroupSavingStart();
     194    void sltGroupSavingComplete();
    185195
    186196private:
     
    271281    void sortItems(UIGChooserItem *pParent, bool fRecursively = false);
    272282
     283    /* Helper: Group saving stuff: */
     284    void makeSureGroupSavingIsFinished();
     285
    273286    /* Variables: */
    274287    QGraphicsScene *m_pScene;
     
    280293    QPointer<UIGChooserItem> m_pAfterSlidingFocus;
    281294
    282     QMap<QString, UIStringSet> m_groups;
     295    QMap<QString, QStringList> m_groups;
    283296    QList<UIGChooserItem*> m_navigationList;
    284297    QList<UIGChooserItem*> m_selectionList;
     
    293306};
    294307
     308/* Allows to save group settings asynchronously: */
     309class UIGroupsSavingThread : public QThread
     310{
     311    Q_OBJECT;
     312
     313signals:
     314
     315    /* Notifier: Complete stuff: */
     316    void sigComplete();
     317
     318public:
     319
     320    /* Singleton stuff: */
     321    static UIGroupsSavingThread* instance();
     322    static void prepare();
     323    static void cleanup();
     324
     325    /* API: Configuring stuff: */
     326    void configure(QObject *pParent,
     327                   const QMap<QString, QStringList> &oldLists,
     328                   const QMap<QString, QStringList> &newLists);
     329
     330private:
     331
     332    /* Constructor/destructor: */
     333    UIGroupsSavingThread();
     334    ~UIGroupsSavingThread();
     335
     336    /* Worker thread stuff: */
     337    void run();
     338
     339    /* Variables: */
     340    static UIGroupsSavingThread *m_spInstance;
     341    QMap<QString, QStringList> m_oldLists;
     342    QMap<QString, QStringList> m_newLists;
     343};
     344
    295345#endif /* __UIGChooserModel_h__ */
    296346
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r42689 r42722  
    1919
    2020/* Qt includes: */
     21#include <QApplication>
    2122#include <QPainter>
    2223#include <QStyleOptionGraphicsItem>
     
    3233#include "UIGDetailsModel.h"
    3334#include "UIGraphicsRotatorButton.h"
    34 #include "VBoxGlobal.h"
    35 #include "UIVirtualBoxEventHandler.h"
    3635#include "UIIconPool.h"
    3736#include "UIConverter.h"
     
    127126}
    128127
     128void UIGDetailsElement::updateHoverAccessibility()
     129{
     130    /* Check if name-hovering should be available: */
     131    m_fNameHoveringAccessible = machine().isNull() || !machine().GetAccessible() ? false :
     132                                machine().GetState() != KMachineState_Stuck;
     133}
     134
    129135void UIGDetailsElement::sltElementToggleStart()
    130136{
     
    153159    model()->updateLayout();
    154160    update();
    155 }
    156 
    157 void UIGDetailsElement::sltMachineStateChange(QString strId)
    158 {
    159     /* Is this our VM changed? */
    160     if (machine().GetId() == strId)
    161         updateHoverAccessibility();
    162 
    163     /* Finally, update appearance: */
    164     sltShouldWeUpdateAppearance(strId);
    165 }
    166 
    167 void UIGDetailsElement::sltShouldWeUpdateAppearance(QString strId)
    168 {
    169     if (machine().GetId() == strId)
    170         sltUpdateAppearance();
    171161}
    172162
     
    321311}
    322312
     313UITextTable UIGDetailsElement::text() const
     314{
     315    return m_text;
     316}
     317
    323318void UIGDetailsElement::setText(const UITextTable &text)
    324319{
     
    390385    m_pHighlightMachine->start();
    391386
    392     connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString)));
    393     connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltShouldWeUpdateAppearance(QString)));
    394     connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltShouldWeUpdateAppearance(QString)));
    395     connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltShouldWeUpdateAppearance(QString)));
    396     connect(&vboxGlobal(), SIGNAL(mediumEnumStarted()), this, SLOT(sltUpdateAppearance()));
    397     connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltUpdateAppearance()));
    398387    connect(this, SIGNAL(sigToggleElement(DetailsElementType, bool)), model(), SLOT(sltToggleElements(DetailsElementType, bool)));
    399388    connect(this, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),
     
    735724}
    736725
    737 void UIGDetailsElement::updateHoverAccessibility()
    738 {
    739     /* Check if name-hovering should be available: */
    740     m_fNameHoveringAccessible = machine().isNull() || !machine().GetAccessible() ? false :
    741                                 machine().GetState() != KMachineState_Stuck;
    742 }
    743 
    744726void UIGDetailsElement::updateNameHoverRepresentation(QGraphicsSceneHoverEvent *pEvent)
    745727{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r42689 r42722  
    8383    virtual int minimumHeightHint() const;
    8484
    85 public slots:
    86 
    8785    /* API: Update stuff: */
    88     virtual void sltUpdateAppearance() = 0;
     86    void updateHoverAccessibility();
     87    virtual void updateAppearance() = 0;
    8988
    9089protected:
     
    122121
    123122    /* API: Text stuff: */
     123    UITextTable text() const;
    124124    void setText(const UITextTable &text);
    125125
     
    144144    void sltElementToggleStart();
    145145    void sltElementToggleFinish(bool fToggled);
    146 
    147     /* Handlers: Global event stuff: */
    148     void sltMachineStateChange(QString strId);
    149     void sltShouldWeUpdateAppearance(QString strId);
    150146
    151147private:
     
    181177    /* Helpers: Mouse stuff: */
    182178    void updateButtonVisibility();
    183     void updateHoverAccessibility();
    184179    void updateNameHoverRepresentation(QGraphicsSceneHoverEvent *pEvent);
    185180
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r42686 r42722  
    6363}
    6464
    65 void UIGDetailsElementInterface::sltUpdateAppearance()
     65void UIGDetailsElementInterface::updateAppearance()
    6666{
    6767    if (!m_pThread)
     
    7474}
    7575
    76 void UIGDetailsElementInterface::sltUpdateAppearanceFinished(const UITextTable &text)
    77 {
    78     setText(text);
     76void UIGDetailsElementInterface::sltUpdateAppearanceFinished(const UITextTable &newText)
     77{
     78    if (text() != newText)
     79    {
     80        setText(newText);
     81        model()->updateLayout();
     82        update();
     83    }
    7984    cleanupThread();
    80     model()->updateLayout();
    81     update();
    8285}
    8386
     
    167170}
    168171
    169 void UIGDetailsElementPreview::sltUpdateAppearance()
    170 {
    171     m_pPreview->setMachine(machine());
    172 }
    173 
    174172int UIGDetailsElementPreview::minimumWidthHint() const
    175173{
     
    221219    /* Return result: */
    222220    return iProposedHeight;
     221}
     222
     223void UIGDetailsElementPreview::updateAppearance()
     224{
     225    m_pPreview->setMachine(machine());
    223226}
    224227
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.h

    r42529 r42722  
    7070    ~UIGDetailsElementInterface();
    7171
    72 protected slots:
    73 
    74     /* Handlers: Update stuff: */
    75     void sltUpdateAppearance();
    76     virtual void sltUpdateAppearanceFinished(const UITextTable &text);
    77 
    7872protected:
    7973
    8074    /* Helpers: Update stuff: */
     75    void updateAppearance();
    8176    virtual UIGDetailsUpdateThread* createUpdateThread() = 0;
     77
     78private slots:
     79
     80    /* Handler: Update stuff: */
     81    virtual void sltUpdateAppearanceFinished(const UITextTable &newText);
    8282
    8383private:
     
    133133    /* Constructor: */
    134134    UIGDetailsElementPreview(UIGDetailsSet *pParent, bool fOpened);
    135 
    136 private slots:
    137 
    138     /* Handlers: Update stuff: */
    139     void sltUpdateAppearance();
    140135
    141136private:
     
    145140    int minimumHeightHint(bool fClosed) const;
    146141
     142    /* Helpers: Update stuff: */
     143    void updateAppearance();
     144
    147145    /* Helpers: Layout stuff: */
    148146    void updateLayout();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp

    r42678 r42722  
    2424#include "UIVMItem.h"
    2525#include "UIConverter.h"
     26#include "UIVirtualBoxEventHandler.h"
     27#include "VBoxGlobal.h"
    2628
    2729/* COM includes: */
     
    4345    connect(this, SIGNAL(sigElementPrepared(QString)), this, SLOT(sltNextStep(QString)), Qt::QueuedConnection);
    4446    connect(this, SIGNAL(sigSetPrepared()), this, SLOT(sltSetPrepared()), Qt::QueuedConnection);
     47    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString)));
     48    connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltMachineAttributesChange(QString)));
     49    connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltMachineAttributesChange(QString)));
     50    connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltMachineAttributesChange(QString)));
     51    connect(&vboxGlobal(), SIGNAL(mediumEnumStarted()), this, SLOT(sltUpdateAppearance()));
     52    connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltUpdateAppearance()));
    4553}
    4654
     
    97105    /* Notify parent group: */
    98106    emit sigSetCreationDone();
     107}
     108
     109void UIGDetailsSet::sltMachineStateChange(QString strId)
     110{
     111    /* Is this our VM changed? */
     112    if (machine().GetId() != strId)
     113        return;
     114
     115    /* Update hover accessibility: */
     116    foreach (UIGDetailsItem *pItem, items())
     117        pItem->toElement()->updateHoverAccessibility();
     118
     119    /* Update appearance: */
     120    foreach (UIGDetailsItem *pItem, items())
     121        pItem->toElement()->updateAppearance();
     122}
     123
     124void UIGDetailsSet::sltMachineAttributesChange(QString strId)
     125{
     126    /* Is this our VM changed? */
     127    if (machine().GetId() != strId)
     128        return;
     129
     130    /* Update appearance: */
     131    foreach (UIGDetailsItem *pItem, items())
     132        pItem->toElement()->updateAppearance();
     133}
     134
     135void UIGDetailsSet::sltUpdateAppearance()
     136{
     137    /* Update appearance: */
     138    foreach (UIGDetailsItem *pItem, items())
     139        pItem->toElement()->updateAppearance();
    99140}
    100141
     
    456497
    457498        /* Check if element is present already: */
     499        bool fJustCreated = false;
    458500        UIGDetailsElement *pElement = element(elementType);
    459501        /* Create if necessary: */
    460502        if (!pElement)
     503        {
    461504            pElement = createElement(elementType, fOpen);
     505            fJustCreated = true;
     506        }
    462507        /* Prepare element: */
    463508        if (fVisible && !pElement->isVisible())
     
    465510        else if (!fVisible && pElement->isVisible())
    466511            pElement->hide();
    467         pElement->sltUpdateAppearance();
    468         /* Update layout: */
    469         model()->updateLayout();
     512        if (pElement->isVisible())
     513            pElement->updateAppearance();
     514        if (fJustCreated)
     515            model()->updateLayout();
    470516        /* Mark element prepared: */
    471517        emit sigElementPrepared(strSetId);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h

    r42608 r42722  
    6868    void sltSetPrepared();
    6969
     70    /* Handlers: Global event stuff: */
     71    void sltMachineStateChange(QString strId);
     72    void sltMachineAttributesChange(QString strId);
     73
     74    /* Handler: Update stuff: */
     75    void sltUpdateAppearance();
     76
    7077private:
    7178
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