VirtualBox

儲存庫 vbox 的更動 42560


忽略:
時間撮記:
2012-8-2 下午10:16:05 (12 年 以前)
作者:
vboxsync
訊息:

FE/Qt: 6234: Support for VM groups: Fixing selector action states update.

位置:
trunk/src/VBox/Frontends/VirtualBox/src
檔案:
修改 3 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r42533 r42560  
    131131UIActionState::UIActionState(QObject *pParent, const QString &strIcon, const QString &strIconDis)
    132132    : UIAction(pParent, UIActionType_State)
     133    , m_iState(0)
    133134{
    134135    if (!strIcon.isNull())
     
    141142                             const QString &strNormalIconDis, const QString &strSmallIconDis)
    142143    : UIAction(pParent, UIActionType_State)
     144    , m_iState(0)
    143145{
    144146    setIcon(UIIconPool::iconSetFull(normalSize, smallSize, strNormalIcon, strSmallIcon, strNormalIconDis, strSmallIconDis));
     
    147149UIActionState::UIActionState(QObject *pParent, const QIcon& icon)
    148150    : UIAction(pParent, UIActionType_State)
     151    , m_iState(0)
    149152{
    150153    if (!icon.isNull())
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r42553 r42560  
    135135}
    136136
     137void UISelectorWindow::sltStateChanged(QString strId)
     138{
     139    /* Get current item: */
     140    UIVMItem *pItem = currentItem();
     141
     142    /* Make sure current item present: */
     143    if (!pItem)
     144        return;
     145
     146    /* If signal is for the current item: */
     147    if (pItem->id() == strId)
     148        updateActionsAppearance();
     149}
     150
    137151void UISelectorWindow::sltSnapshotChanged(QString strId)
    138152{
    139153    /* Get current item: */
    140     UIVMItem *pCurrentItem = currentItem();
     154    UIVMItem *pItem = currentItem();
    141155
    142156    /* Make sure current item present: */
    143     if (!pCurrentItem)
    144         return;
    145 
    146     /* If signal is for current item: */
    147     if (pCurrentItem->id() == strId)
    148         m_pVMDesktop->updateSnapshots(pCurrentItem, pCurrentItem->machine());
     157    if (!pItem)
     158        return;
     159
     160    /* If signal is for the current item: */
     161    if (pItem->id() == strId)
     162        m_pVMDesktop->updateSnapshots(pItem, pItem->machine());
    149163}
    150164
     
    734748}
    735749
    736 void UISelectorWindow::sltCurrentVMItemChanged(bool fRefreshDetails, bool fRefreshSnapshots, bool fRefreshDescription)
     750void UISelectorWindow::sltCurrentVMItemChanged(bool fRefreshDetails, bool fRefreshSnapshots, bool)
    737751{
    738752    /* Get current item: */
    739753    UIVMItem *pItem = currentItem();
    740     QList<UIVMItem*> items = currentItems();
    741754
    742755    /* Determine which menu to show: */
     
    758771    }
    759772
    760     /* Enable/disable group actions: */
    761     m_pActionGroupRenameDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_RenameDialog, items));
    762     m_pActionGroupRemoveDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_RemoveDialog, items));
    763     m_pActionGroupStartOrShow->setEnabled(isActionEnabled(UIActionIndexSelector_State_Group_StartOrShow, items));
    764     m_pActionGroupPauseAndResume->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Group_PauseAndResume, items));
    765     m_pActionGroupReset->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Reset, items));
    766     m_pActionGroupRefresh->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Refresh, items));
    767     m_pActionGroupLogDialog->setEnabled(isActionEnabled(UIActionIndex_Simple_LogDialog, items));
    768     m_pActionGroupShowInFileManager->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_ShowInFileManager, items));
    769     m_pActionGroupCreateShortcut->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_CreateShortcut, items));
    770 //    m_pActionGroupSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Sort, items));
    771 
    772     /* Enable/disable machine actions: */
    773     m_pActionMachineSettingsDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, items));
    774     m_pActionMachineCloneWizard->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, items));
    775     m_pActionMachineAddGroupDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_AddGroupDialog, items));
    776     m_pActionMachineRemoveDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, items));
    777     m_pActionMachineStartOrShow->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, items));
    778     m_pActionMachineDiscard->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Discard, items));
    779     m_pActionMachinePauseAndResume->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, items));
    780     m_pActionMachineReset->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, items));
    781     m_pActionMachineRefresh->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, items));
    782     m_pActionMachineLogDialog->setEnabled(isActionEnabled(UIActionIndex_Simple_LogDialog, items));
    783     m_pActionMachineShowInFileManager->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, items));
    784     m_pActionMachineCreateShortcut->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, items));
    785 //    m_pActionMachineSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, items));
    786 
    787     /* Enable/disable machine-close actions: */
    788     m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, items));
    789     m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, items));
     773    /* Update action appearance: */
     774    updateActionsAppearance();
    790775
    791776    /* If currently selected VM item is accessible: */
     
    798783            m_pContainer->setCurrentWidget(m_pDetails);
    799784
    800         KMachineState state = pItem->machineState();
    801 
    802         if (fRefreshDetails || fRefreshDescription)
     785        if (fRefreshDetails)
    803786            m_pDetails->setItems(currentItems());
    804787        if (fRefreshSnapshots)
    805788            m_pVMDesktop->updateSnapshots(pItem, pItem->machine());
    806 
    807         /* Update the Start button action appearance: */
    808         if (state == KMachineState_PoweredOff ||
    809             state == KMachineState_Saved ||
    810             state == KMachineState_Teleported ||
    811             state == KMachineState_Aborted)
    812         {
    813             m_pActionGroupStartOrShow->setState(1);
    814             m_pActionMachineStartOrShow->setState(1);
    815 #ifdef QT_MAC_USE_COCOA
    816             /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
    817                the necessary size of the toolbar is increased. Also for some languages
    818                the with doesn't match if the text increase. So manually adjust the size
    819                after changing the text. */
    820             mVMToolBar->updateLayout();
    821 #endif /* QT_MAC_USE_COCOA */
    822         }
    823         else
    824         {
    825             m_pActionGroupStartOrShow->setState(2);
    826             m_pActionMachineStartOrShow->setState(2);
    827 #ifdef QT_MAC_USE_COCOA
    828             /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
    829                the necessary size of the toolbar is increased. Also for some languages
    830                the with doesn't match if the text increase. So manually adjust the size
    831                after changing the text. */
    832             mVMToolBar->updateLayout();
    833 #endif /* QT_MAC_USE_COCOA */
    834         }
    835 
    836         /* Update the Pause/Resume action appearance: */
    837         if (state == KMachineState_Paused ||
    838             state == KMachineState_TeleportingPausedVM)
    839         {
    840             m_pActionGroupPauseAndResume->blockSignals(true);
    841             m_pActionGroupPauseAndResume->setChecked(true);
    842             m_pActionGroupPauseAndResume->blockSignals(false);
    843             m_pActionMachinePauseAndResume->blockSignals(true);
    844             m_pActionMachinePauseAndResume->setChecked(true);
    845             m_pActionMachinePauseAndResume->blockSignals(false);
    846         }
    847         else
    848         {
    849             m_pActionGroupPauseAndResume->blockSignals(true);
    850             m_pActionGroupPauseAndResume->setChecked(false);
    851             m_pActionGroupPauseAndResume->blockSignals(false);
    852             m_pActionMachinePauseAndResume->blockSignals(true);
    853             m_pActionMachinePauseAndResume->setChecked(false);
    854             m_pActionMachinePauseAndResume->blockSignals(false);
    855         }
    856         m_pActionGroupPauseAndResume->updateAppearance();
    857         m_pActionMachinePauseAndResume->updateAppearance();
    858     }
    859 
     789    }
    860790    /* If currently selected VM item is NOT accessible: */
    861791    else
    862792    {
    863         /* Show m_pVMDesktop: */
     793        /* Make sure valid widget raised: */
    864794        m_pContainer->setCurrentWidget(m_pVMDesktop);
    865795
     
    893823        /* Empty and disable other tabs: */
    894824        m_pVMDesktop->updateSnapshots(0, CMachine());
    895 
    896         /* Change the Start button text accordingly: */
    897         m_pActionGroupStartOrShow->setState(1);
    898         m_pActionMachineStartOrShow->setState(1);
    899825    }
    900826}
     
    14631389
    14641390    /* Global event handlers: */
     1391    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltStateChanged(QString)));
     1392    connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltStateChanged(QString)));
    14651393    connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltSnapshotChanged(QString)));
    14661394}
     
    15781506}
    15791507
     1508void UISelectorWindow::updateActionsAppearance()
     1509{
     1510    /* Get current item(s): */
     1511    UIVMItem *pItem = currentItem();
     1512    QList<UIVMItem*> items = currentItems();
     1513
     1514    /* Enable/disable group actions: */
     1515    m_pActionGroupRenameDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_RenameDialog, items));
     1516    m_pActionGroupRemoveDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_RemoveDialog, items));
     1517    m_pActionGroupStartOrShow->setEnabled(isActionEnabled(UIActionIndexSelector_State_Group_StartOrShow, items));
     1518    m_pActionGroupPauseAndResume->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Group_PauseAndResume, items));
     1519    m_pActionGroupReset->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Reset, items));
     1520    m_pActionGroupRefresh->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Refresh, items));
     1521    m_pActionGroupLogDialog->setEnabled(isActionEnabled(UIActionIndex_Simple_LogDialog, items));
     1522    m_pActionGroupShowInFileManager->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_ShowInFileManager, items));
     1523    m_pActionGroupCreateShortcut->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_CreateShortcut, items));
     1524//    m_pActionGroupSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Sort, items));
     1525
     1526    /* Enable/disable machine actions: */
     1527    m_pActionMachineSettingsDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, items));
     1528    m_pActionMachineCloneWizard->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, items));
     1529    m_pActionMachineAddGroupDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_AddGroupDialog, items));
     1530    m_pActionMachineRemoveDialog->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, items));
     1531    m_pActionMachineStartOrShow->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, items));
     1532    m_pActionMachineDiscard->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Discard, items));
     1533    m_pActionMachinePauseAndResume->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, items));
     1534    m_pActionMachineReset->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, items));
     1535    m_pActionMachineRefresh->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, items));
     1536    m_pActionMachineLogDialog->setEnabled(isActionEnabled(UIActionIndex_Simple_LogDialog, items));
     1537    m_pActionMachineShowInFileManager->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, items));
     1538    m_pActionMachineCreateShortcut->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, items));
     1539//    m_pActionMachineSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, items));
     1540
     1541    /* Enable/disable machine-close actions: */
     1542    m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, items));
     1543    m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, items));
     1544
     1545    /* If item present: */
     1546    if (pItem && pItem->accessible())
     1547    {
     1548        /* Get state: */
     1549        KMachineState state = pItem->machineState();
     1550
     1551        /* Update the Start button action appearance: */
     1552        if (state == KMachineState_PoweredOff ||
     1553            state == KMachineState_Saved ||
     1554            state == KMachineState_Teleported ||
     1555            state == KMachineState_Aborted)
     1556        {
     1557            m_pActionGroupStartOrShow->setState(1);
     1558            m_pActionMachineStartOrShow->setState(1);
     1559#ifdef QT_MAC_USE_COCOA
     1560            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
     1561               the necessary size of the toolbar is increased. Also for some languages
     1562               the with doesn't match if the text increase. So manually adjust the size
     1563               after changing the text. */
     1564            mVMToolBar->updateLayout();
     1565#endif /* QT_MAC_USE_COCOA */
     1566        }
     1567        else
     1568        {
     1569            m_pActionGroupStartOrShow->setState(2);
     1570            m_pActionMachineStartOrShow->setState(2);
     1571#ifdef QT_MAC_USE_COCOA
     1572            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
     1573               the necessary size of the toolbar is increased. Also for some languages
     1574               the with doesn't match if the text increase. So manually adjust the size
     1575               after changing the text. */
     1576            mVMToolBar->updateLayout();
     1577#endif /* QT_MAC_USE_COCOA */
     1578        }
     1579
     1580        /* Update the Pause/Resume action appearance: */
     1581        if (state == KMachineState_Paused ||
     1582            state == KMachineState_TeleportingPausedVM)
     1583        {
     1584            m_pActionGroupPauseAndResume->blockSignals(true);
     1585            m_pActionGroupPauseAndResume->setChecked(true);
     1586            m_pActionGroupPauseAndResume->blockSignals(false);
     1587            m_pActionMachinePauseAndResume->blockSignals(true);
     1588            m_pActionMachinePauseAndResume->setChecked(true);
     1589            m_pActionMachinePauseAndResume->blockSignals(false);
     1590        }
     1591        else
     1592        {
     1593            m_pActionGroupPauseAndResume->blockSignals(true);
     1594            m_pActionGroupPauseAndResume->setChecked(false);
     1595            m_pActionGroupPauseAndResume->blockSignals(false);
     1596            m_pActionMachinePauseAndResume->blockSignals(true);
     1597            m_pActionMachinePauseAndResume->setChecked(false);
     1598            m_pActionMachinePauseAndResume->blockSignals(false);
     1599        }
     1600        m_pActionGroupPauseAndResume->updateAppearance();
     1601        m_pActionMachinePauseAndResume->updateAppearance();
     1602    }
     1603    else
     1604    {
     1605        /* Update the Start button action appearance: */
     1606        m_pActionGroupStartOrShow->setState(1);
     1607        m_pActionMachineStartOrShow->setState(1);
     1608    }
     1609}
     1610
    15801611bool UISelectorWindow::isActionEnabled(int iActionIndex, const QList<UIVMItem*> &items)
    15811612{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r42553 r42560  
    6363private slots:
    6464
    65     /* Handler: Snapshot-view stuff: */
     65    /* Handlers: Global-event stuff: */
     66    void sltStateChanged(QString strId);
    6667    void sltSnapshotChanged(QString strId);
    6768
     
    136137    QList<UIVMItem*> currentItems() const;
    137138
     139    /* Helper: Action update stuff: */
     140    void updateActionsAppearance();
     141
    138142    /* Helpers: Action stuff: */
    139143    static bool isActionEnabled(int iActionIndex, const QList<UIVMItem*> &items);
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette