VirtualBox

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


Ignore:
Timestamp:
Aug 18, 2023 4:49:42 PM (16 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10496, bugref:6699. Toggle tool bar actions as tab widget's current index changes.

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

Legend:

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

    r98103 r100906  
    4242#endif
    4343
     44/* Other VBox includes: */
     45#include <iprt/assert.h>
     46
     47
     48
     49UIDialogPanelBase::UIDialogPanelBase(QWidget *pParent /* = 0 */)
     50    : QWidget(pParent)
     51    , m_pTabWidget(0)
     52{
     53    prepare();
     54}
     55
     56void UIDialogPanelBase::prepare()
     57{
     58    QHBoxLayout *pLayout = new QHBoxLayout(this);
     59    AssertReturnVoid(pLayout);
     60    pLayout->setContentsMargins(0, 0, 0, 0);
     61    m_pTabWidget = new QTabWidget();
     62    connect(m_pTabWidget, &QTabWidget::currentChanged, this, &UIDialogPanelBase::sigCurrentTabChanged);
     63    AssertReturnVoid(m_pTabWidget);
     64    pLayout->addWidget(m_pTabWidget);
     65}
     66
     67void UIDialogPanelBase::insertTab(int iIndex, QWidget *pPage, const QString &strLabel)
     68{
     69    if (m_pTabWidget)
     70        m_pTabWidget->insertTab(iIndex, pPage, strLabel);
     71}
     72
     73void UIDialogPanelBase::setTabText(int iIndex, const QString &strText)
     74{
     75    if (!m_pTabWidget || iIndex < 0 || iIndex >= m_pTabWidget->count())
     76        return;
     77    m_pTabWidget->setTabText(iIndex, strText);
     78}
     79
     80void UIDialogPanelBase::setCurrentIndex(int iIndex)
     81{
     82    if (!m_pTabWidget || iIndex >= m_pTabWidget->count() || iIndex < 0)
     83        return;
     84    m_pTabWidget->setCurrentIndex(iIndex);
     85}
    4486
    4587UIDialogPanel::UIDialogPanel(QWidget *pParent /* = 0 */)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.h

    r98103 r100906  
    4444
    4545/** QWidget extension acting as the base class for all the dialog panels like file manager, logviewer etc. */
     46class SHARED_LIBRARY_STUFF UIDialogPanelBase : public QWidget
     47{
     48    Q_OBJECT;
     49
     50signals:
     51
     52    void sigCurrentTabChanged(int iIndex);
     53
     54public:
     55
     56    UIDialogPanelBase(QWidget *pParent = 0);
     57    void setCurrentIndex(int iIndex);
     58
     59protected:
     60
     61    virtual void prepare();
     62    void insertTab(int iIndex, QWidget *pPage, const QString &strLabel);
     63    void setTabText(int iIndex, const QString &strText);
     64
     65private:
     66
     67    QTabWidget *m_pTabWidget;
     68};
     69
     70/** QWidget extension acting as the base class for all the dialog panels like file manager, logviewer etc. */
    4671class SHARED_LIBRARY_STUFF UIDialogPanel : public QIWithRetranslateUI<QWidget>
    4772{
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r100905 r100906  
    328328        connect(m_pPanel, &UIFileManagerPanel::sigFileOperationFail,
    329329                this, &UIFileManager::sltReceieveLogOutput);
     330        connect(m_pPanel, &UIFileManagerPanel::sigCurrentTabChanged,
     331                this, &UIFileManager::sltPanelCurrentTabChanged);
    330332    }
    331333
     
    411413            pAction->blockSignals(false);
    412414        }
     415        m_pPanel->blockSignals(true);
    413416        m_pPanel->setCurrentIndex(pSenderAction->data().toInt());
     417        m_pPanel->blockSignals(false);
    414418    }
    415419
     
    541545        m_pHostFileTable->optionsUpdated();
    542546    saveOptions();
     547}
     548
     549void UIFileManager::sltPanelCurrentTabChanged(int iIndex)
     550{
     551    if (!m_pPanel || !m_pPanel->isVisible())
     552        return;
     553
     554    for(QSet<QAction*>::iterator iter = m_panelActions.begin(); iter != m_panelActions.end(); ++iter)
     555    {
     556        QAction *pAction = *iter;
     557
     558        pAction->blockSignals(true);
     559        pAction->setChecked(false);
     560        pAction->blockSignals(false);
     561    }
     562
     563    switch (static_cast<UIFileManagerPanel::Page>(iIndex))
     564    {
     565        case UIFileManagerPanel::Page_Preferences:
     566            m_pActionPool->action(UIActionIndex_M_FileManager_T_Preferences)->setChecked(true);
     567            break;
     568        case UIFileManagerPanel::Page_Operations:
     569            m_pActionPool->action(UIActionIndex_M_FileManager_T_Operations)->setChecked(true);
     570            break;
     571        case UIFileManagerPanel::Page_Log:
     572            m_pActionPool->action(UIActionIndex_M_FileManager_T_Log)->setChecked(true);
     573            break;
     574        case UIFileManagerPanel::Page_Max:
     575        default:
     576            break;
     577    }
    543578}
    544579
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r100905 r100906  
    129129    void sltGuestFileTableStateChanged(bool fIsRunning);
    130130    void sltHandleOptionsUpdated();
     131    void sltPanelCurrentTabChanged(int iIndex);
    131132
    132133private:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.cpp

    r100905 r100906  
    369369
    370370UIFileManagerPanel::UIFileManagerPanel(QWidget *pParent, UIFileManagerOptions *pFileManagerOptions)
    371     : QIWithRetranslateUI<QWidget>(pParent)
    372     , m_pTabWidget(0)
     371    : QIWithRetranslateUI<UIDialogPanelBase>(pParent)
    373372    , m_pListDirectoriesOnTopCheckBox(0)
    374373    , m_pDeleteConfirmationCheckBox(0)
     
    389388void UIFileManagerPanel::prepare()
    390389{
    391     QHBoxLayout *pMainLayout = new QHBoxLayout(this);
    392     AssertReturnVoid(pMainLayout);
    393 
    394     m_pTabWidget = new QTabWidget;
    395     AssertReturnVoid(m_pTabWidget);
    396     pMainLayout->addWidget(m_pTabWidget);
    397390    preparePreferencesTab();
    398391    prepareLogTab();
     
    445438    pPreferencesLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 2, 0, 1, 2);
    446439
    447     m_pTabWidget->insertTab(Page_Preferences, pPreferencesTab, QString());
     440    insertTab(Page_Preferences, pPreferencesTab, QString());
    448441}
    449442
     
    458451    if (m_pLogTextEdit)
    459452        pLogLayout->addWidget(m_pLogTextEdit);
    460     m_pTabWidget->insertTab(Page_Log, pLogTab, QString());
     453    insertTab(Page_Log, pLogTab, QString());
    461454}
    462455
     
    486479    pOperationsTab->setLayout(m_pOperationsTabLayout);
    487480    m_pOperationsTabLayout->addStretch(4);
    488     m_pTabWidget->insertTab(Page_Operations, m_pScrollArea, QString());
     481    insertTab(Page_Operations, m_pScrollArea, QString());
    489482}
    490483
     
    548541        m_pShowHiddenObjectsCheckBox->setToolTip(QApplication::translate("UIFileManager", "Show hidden files/directories"));
    549542    }
    550     if (m_pTabWidget)
    551     {
    552         m_pTabWidget->setTabText(Page_Preferences, QApplication::translate("UIFileManager", "Preferences"));
    553         m_pTabWidget->setTabText(Page_Log, QApplication::translate("UIFileManager", "Log"));
    554         m_pTabWidget->setTabText(Page_Operations, QApplication::translate("UIFileManager", "Operations"));
    555     }
     543
     544    setTabText(Page_Preferences, QApplication::translate("UIFileManager", "Preferences"));
     545    setTabText(Page_Log, QApplication::translate("UIFileManager", "Log"));
     546    setTabText(Page_Operations, QApplication::translate("UIFileManager", "Operations"));
    556547}
    557548
     
    627618    connect(pOperationsWidget, &UIFileOperationProgressWidget::sigFocusOut,
    628619            this, &UIFileManagerPanel::sltHandleWidgetFocusOut);
    629 }
    630 
    631 void UIFileManagerPanel::setCurrentIndex(int iIndex)
    632 {
    633     if (!m_pTabWidget || iIndex >= m_pTabWidget->count() || iIndex < 0)
    634         return;
    635     m_pTabWidget->setCurrentIndex(iIndex);
    636620}
    637621
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.h

    r100905 r100906  
    3737
    3838/* GUI includes: */
     39#include "UIDialogPanel.h"
    3940#include "UIGuestControlDefs.h"
    4041#include "QIWithRetranslateUI.h"
     
    5253class QVBoxLayout;
    5354
    54 class UIFileManagerPanel : public QIWithRetranslateUI<QWidget>
     55class UIFileManagerPanel : public QIWithRetranslateUI<UIDialogPanelBase>
    5556{
    5657    Q_OBJECT;
     
    7071    void appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType);
    7172    void addNewProgress(const CProgress &comProgress, const QString &strSourceTableName);
    72     void setCurrentIndex(int iIndex);
     73
    7374    enum Page
    7475    {
    7576        Page_Preferences = 0,
     77        Page_Operations,
    7678        Page_Log,
    77         Page_Operations,
    7879        Page_Max
    7980    };
     
    107108private:
    108109
    109     void prepare();
     110    void prepare() override;
    110111    void preparePreferencesTab();
    111112    void prepareLogTab();
    112113    void prepareOperationsTab();
    113 
    114     QTabWidget   *m_pTabWidget;
    115114
    116115    /** @name Preferences tab
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