VirtualBox

vbox的更動 69057 路徑 trunk/src/VBox


忽略:
時間撮記:
2017-10-12 上午09:43:58 (7 年 以前)
作者:
vboxsync
訊息:

FE/Qt: bugref:8900: A bit of refactoring; Also provide UITabBarItem items with their action references to let them translate their text when necessary.

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

圖例:

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

    r68418 r69057  
    13181318    m_pool[UIActionIndexST_M_Tools_T_Machine] = new UIActionToggleToolsMachine(this);
    13191319    m_pool[UIActionIndexST_M_Tools_M_Machine] = new UIActionMenuToolsMachine(this);
    1320     m_pool[UIActionIndexST_M_Tools_M_Machine_Details] = new UIActionSimpleToolsMachineDetails(this);
    1321     m_pool[UIActionIndexST_M_Tools_M_Machine_Snapshots] = new UIActionSimpleToolsMachineSnapshots(this);
     1320    m_pool[UIActionIndexST_M_Tools_M_Machine_S_Details] = new UIActionSimpleToolsMachineDetails(this);
     1321    m_pool[UIActionIndexST_M_Tools_M_Machine_S_Snapshots] = new UIActionSimpleToolsMachineSnapshots(this);
    13221322
    13231323    /* Global Tools actions: */
    13241324    m_pool[UIActionIndexST_M_Tools_T_Global] = new UIActionToggleToolsGlobal(this);
    13251325    m_pool[UIActionIndexST_M_Tools_M_Global] = new UIActionMenuToolsGlobal(this);
    1326     m_pool[UIActionIndexST_M_Tools_M_Global_VirtualMediaManager] = new UIActionSimpleToolsGlobalVirtualMediaManager(this);
    1327     m_pool[UIActionIndexST_M_Tools_M_Global_HostNetworkManager] = new UIActionSimpleToolsGlobalHostNetworkManager(this);
     1326    m_pool[UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager] = new UIActionSimpleToolsGlobalVirtualMediaManager(this);
     1327    m_pool[UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager] = new UIActionSimpleToolsGlobalHostNetworkManager(this);
    13281328
    13291329    /* Call to base-class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h

    r68200 r69057  
    9595    UIActionIndexST_M_Tools_T_Machine,
    9696    UIActionIndexST_M_Tools_M_Machine,
    97     UIActionIndexST_M_Tools_M_Machine_Details,
    98     UIActionIndexST_M_Tools_M_Machine_Snapshots,
     97    UIActionIndexST_M_Tools_M_Machine_S_Details,
     98    UIActionIndexST_M_Tools_M_Machine_S_Snapshots,
    9999
    100100    /* Global Tools actions: */
    101101    UIActionIndexST_M_Tools_T_Global,
    102102    UIActionIndexST_M_Tools_M_Global,
    103     UIActionIndexST_M_Tools_M_Global_VirtualMediaManager,
    104     UIActionIndexST_M_Tools_M_Global_HostNetworkManager,
     103    UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager,
     104    UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager,
    105105
    106106    /* Maximum index: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r68456 r69057  
    157157        /* Restore previously opened Machine tools at startup: */
    158158        QMap<ToolTypeMachine, QAction*> mapActionsMachine;
    159         mapActionsMachine[ToolTypeMachine_Details] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Details);
    160         mapActionsMachine[ToolTypeMachine_Snapshots] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Snapshots);
     159        mapActionsMachine[ToolTypeMachine_Details] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details);
     160        mapActionsMachine[ToolTypeMachine_Snapshots] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots);
    161161        for (int i = m_orderMachine.size() - 1; i >= 0; --i)
    162162            if (m_orderMachine.at(i) != ToolTypeMachine_Invalid)
     
    275275            /* Make sure Details or Snapshot pane is chosen if opened: */
    276276            if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
    277                 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Details)->trigger();
     277                actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details)->trigger();
    278278            else
    279279            if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
    280                 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Snapshots)->trigger();
     280                actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->trigger();
    281281        }
    282282
     
    21212121        /* We can restore previously opened Global tools right here: */
    21222122        QMap<ToolTypeGlobal, QAction*> mapActionsGlobal;
    2123         mapActionsGlobal[ToolTypeGlobal_VirtualMedia] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_VirtualMediaManager);
    2124         mapActionsGlobal[ToolTypeGlobal_HostNetwork] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_HostNetworkManager);
     2123        mapActionsGlobal[ToolTypeGlobal_VirtualMedia] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager);
     2124        mapActionsGlobal[ToolTypeGlobal_HostNetwork] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager);
    21252125        for (int i = m_orderGlobal.size() - 1; i >= 0; --i)
    21262126            if (m_orderGlobal.at(i) != ToolTypeGlobal_Invalid)
     
    23672367    /* Enable/disable tools actions: */
    23682368    actionPool()->action(UIActionIndexST_M_Tools_M_Machine)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine, items));
    2369     actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Details)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_Details, items));
    2370     actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Snapshots)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_Snapshots, items));
     2369    actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_S_Details, items));
     2370    actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_S_Snapshots, items));
    23712371}
    23722372
     
    24962496        }
    24972497        case UIActionIndexST_M_Tools_M_Machine:
    2498         case UIActionIndexST_M_Tools_M_Machine_Details:
    2499         case UIActionIndexST_M_Tools_M_Machine_Snapshots:
     2498        case UIActionIndexST_M_Tools_M_Machine_S_Details:
     2499        case UIActionIndexST_M_Tools_M_Machine_S_Snapshots:
    25002500        {
    25012501            return pItem->accessible();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPaneGlobal.cpp

    r68418 r69057  
    196196
    197197    /* Add tool descriptions: */
    198     QAction *pAction1 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_VirtualMediaManager);
     198    QAction *pAction1 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager);
    199199    m_pPaneDesktop->addToolDescription(pAction1,
    200200                                       tr("Tool to observe virtual storage media. "
     
    206206                                          "<u>location/name</u>, <u>description</u> and <u>size</u> (for dynamical storages "
    207207                                          "only)."));
    208     QAction *pAction2 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_HostNetworkManager);
     208    QAction *pAction2 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager);
    209209    m_pPaneDesktop->addToolDescription(pAction2,
    210210                                       tr("Tool to control host-only network interfaces. "
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPaneMachine.cpp

    r68418 r69057  
    253253    if (m_pItem && m_pItem->accessible())
    254254    {
    255         QAction *pAction1 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Details);
     255        QAction *pAction1 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Details);
    256256        m_pPaneDesktop->addToolDescription(pAction1,
    257257                                           tr("Tool to observe virtual machine (VM) details. "
    258258                                              "Reflects groups of <u>properties</u> for the currently chosen VM and allows "
    259259                                              "basic operations on certain properties (like the machine storage devices)."));
    260         QAction *pAction2 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Snapshots);
     260        QAction *pAction2 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots);
    261261        m_pPaneDesktop->addToolDescription(pAction2,
    262262                                           tr("Tool to control virtual machine (VM) snapshots. "
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.cpp

    r68304 r69057  
    105105    else
    106106    {
    107         idTab = m_pTabBarMachine->addTab(pAction->icon(), pAction->text().remove('&'));
     107        idTab = m_pTabBarMachine->addTab(pAction);
    108108        m_mapTabIdsMachine[enmType] = idTab;
    109109    }
     
    128128    else
    129129    {
    130         idTab = m_pTabBarGlobal->addTab(pAction->icon(), pAction->text().remove('&'));
     130        idTab = m_pTabBarGlobal->addTab(pAction);
    131131        m_mapTabIdsGlobal[enmType] = idTab;
    132132    }
     
    207207    {
    208208        /* Add 'Details' action: */
    209         pMenuMachine->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Details));
    210         connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Details), &UIAction::triggered,
     209        pMenuMachine->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Details));
     210        connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Details), &UIAction::triggered,
    211211                this, &UIToolsToolbar::sltHandleOpenToolMachine);
    212         m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Details)
     212        m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Details)
    213213            ->setProperty("ToolTypeMachine", QVariant::fromValue(ToolTypeMachine_Details));
    214214
    215215        /* Add 'Snapshots' action: */
    216         pMenuMachine->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Snapshots));
    217         connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Snapshots), &UIAction::triggered,
     216        pMenuMachine->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots));
     217        connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots), &UIAction::triggered,
    218218                this, &UIToolsToolbar::sltHandleOpenToolMachine);
    219         m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_Snapshots)
     219        m_pActionPool->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)
    220220            ->setProperty("ToolTypeMachine", QVariant::fromValue(ToolTypeMachine_Snapshots));
    221221    }
     
    231231    {
    232232        /* Add 'Virtual Media Manager' action: */
    233         pMenuGlobal->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_VirtualMediaManager));
    234         connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_VirtualMediaManager), &UIAction::triggered,
     233        pMenuGlobal->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager));
     234        connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager), &UIAction::triggered,
    235235                this, &UIToolsToolbar::sltHandleOpenToolGlobal);
    236         m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_VirtualMediaManager)
     236        m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager)
    237237            ->setProperty("ToolTypeGlobal", QVariant::fromValue(ToolTypeGlobal_VirtualMedia));
    238238
    239239        /* Add 'Host Network Manager' action: */
    240         pMenuGlobal->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_HostNetworkManager));
    241         connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_HostNetworkManager), &UIAction::triggered,
     240        pMenuGlobal->addAction(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager));
     241        connect(m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager), &UIAction::triggered,
    242242                this, &UIToolsToolbar::sltHandleOpenToolGlobal);
    243         m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_HostNetworkManager)
     243        m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager)
    244244            ->setProperty("ToolTypeGlobal", QVariant::fromValue(ToolTypeGlobal_HostNetwork));
    245245    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.cpp

    r68522 r69057  
    2121
    2222/* Qt includes: */
     23# include <QAction>
    2324# include <QApplication>
    2425# include <QDrag>
     
    4041
    4142/* GUI includes: */
     43# include "QIWithRetranslateUI.h"
    4244# include "UIIconPool.h"
    4345# include "UITabBar.h"
    4446
     47/* Other VBox includes: */
    4548# include "iprt/assert.h"
    4649
     
    6467
    6568/** Our own skinnable implementation of tabs for tab-bar. */
    66 class UITabBarItem : public QWidget
     69class UITabBarItem : public QIWithRetranslateUI<QWidget>
    6770{
    6871    Q_OBJECT;
     
    8790    static const QString MimeType;
    8891
    89     /** Creates tab-bar item on the basis of passed @a uuid, @a icon and @a strName. */
    90     UITabBarItem(const QUuid &uuid, const QIcon &icon = QIcon(), const QString &strName = QString());
     92    /** Creates tab-bar item on the basis of passed @a uuid and @a pAction. */
     93    UITabBarItem(const QUuid &uuid, const QAction *pAction);
    9194
    9295    /** Returns item ID. */
    9396    const QUuid uuid() const { return m_uuid; }
    94     /** Returns item icon. */
    95     const QIcon icon() const { return m_icon; }
    96     /** Returns item name. */
    97     const QString name() const { return m_strName; }
    9897
    9998    /** Defines the item @a enmPositionStyle. */
     
    104103
    105104protected:
     105
     106    /** Handles translation event. */
     107    virtual void retranslateUi() /* override */;
    106108
    107109    /** Handles paint @a pEvent. */
     
    130132
    131133    /** Holds the item ID. */
    132     const QUuid  m_uuid;
    133     /** Holds the item icon. */
    134     QIcon        m_icon;
    135     /** Holds the item name. */
    136     QString      m_strName;
     134    const QUuid    m_uuid;
     135    /** Holds the item action reference. */
     136    const QAction *m_pAction;
    137137
    138138    /** Holds the item position style. */
     
    170170const QString UITabBarItem::MimeType = QString("application/virtualbox;value=TabID");
    171171
    172 UITabBarItem::UITabBarItem(const QUuid &uuid, const QIcon &icon /* = QIcon() */, const QString &strName /* = QString() */)
     172UITabBarItem::UITabBarItem(const QUuid &uuid, const QAction *pAction)
    173173    : m_uuid(uuid)
    174     , m_icon(icon)
    175     , m_strName(strName)
     174    , m_pAction(pAction)
    176175    , m_enmPosition(PositionStyle_Single)
    177176    , m_fCurrent(false)
     
    213212    /* And call for repaint: */
    214213    update();
     214}
     215
     216void UITabBarItem::retranslateUi()
     217{
     218    /* Translate label: */
     219    m_pLabelName->setText(m_pAction->text().remove('&'));
    215220}
    216221
     
    547552    pDrag->setMimeData(pMimeData);
    548553    const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    549     pDrag->setPixmap(icon().pixmap(iMetric, iMetric));
     554    pDrag->setPixmap(m_pAction->icon().pixmap(iMetric, iMetric));
    550555    pDrag->exec();
    551556}
     
    618623            /* Configure label: */
    619624            m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    620             m_pLabelIcon->setPixmap(m_icon.pixmap(iMetric));
     625            m_pLabelIcon->setPixmap(m_pAction->icon().pixmap(iMetric));
    621626        }
    622627
     
    627632            /* Configure label: */
    628633            m_pLabelName->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    629             m_pLabelName->setText(m_strName);
    630634        }
    631635
     
    671675#endif /* !VBOX_WS_MAC */
    672676    }
     677
     678    /* Apply language settings: */
     679    retranslateUi();
    673680}
    674681
     
    690697}
    691698
    692 QUuid UITabBar::addTab(const QIcon &icon /* = QIcon() */, const QString &strName /* = QString() */)
     699QUuid UITabBar::addTab(const QAction *pAction)
    693700{
    694701    /* Generate unique ID: */
    695702    const QUuid uuid = QUuid::createUuid();
    696703    /* Create new tab item: */
    697     UITabBarItem *pItem = new UITabBarItem(uuid, icon, strName);
     704    UITabBarItem *pItem = new UITabBarItem(uuid, pAction);
    698705    AssertPtrReturn(pItem, QUuid());
    699706    {
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.h

    r68480 r69057  
    2626
    2727/* Forward declarations: */
     28class QAction;
    2829class QDragEnterEvent;
    2930class QDragLeaveEvent;
     
    5859    UITabBar(QWidget *pParent = 0);
    5960
    60     /** Adds new tab with passed @a icon and @a strName. @returns unique tab ID. */
    61     QUuid addTab(const QIcon &icon = QIcon(), const QString &strName = QString());
     61    /** Adds new tab for passed @a pAction. @returns unique tab ID. */
     62    QUuid addTab(const QAction *pAction);
    6263
    6364    /** Removes tab with passed @a uuid. */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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