VirtualBox

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


Ignore:
Timestamp:
Aug 22, 2023 6:12:17 AM (16 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10496, bugref:9072. Refactoring bookmarks panel.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/logviewer
Files:
5 edited

Legend:

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

    r100915 r100933  
    4040#include "UIVMLogViewerWidget.h"
    4141
     42/* Other VBox includes: */
     43#include <iprt/assert.h>
    4244
    4345UIVMLogViewerBookmarksPanel::UIVMLogViewerBookmarksPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer)
     
    108110void UIVMLogViewerBookmarksPanel::prepareWidgets()
    109111{
    110     QHBoxLayout *pMainLayout = new QHBoxLayout(this);
    111 
     112    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     113    AssertReturnVoid(pMainLayout);
    112114    /* Create bookmark combo/button layout: */
    113115    QHBoxLayout *pComboButtonLayout = new QHBoxLayout;
    114     if (pComboButtonLayout)
    115     {
    116         pComboButtonLayout->setContentsMargins(0, 0, 0, 0);
     116    AssertReturnVoid(pComboButtonLayout);
     117
     118    pComboButtonLayout->setContentsMargins(0, 0, 0, 0);
    117119#ifdef VBOX_WS_MAC
    118         pComboButtonLayout->setSpacing(5);
     120    pComboButtonLayout->setSpacing(5);
    119121#else
    120         pComboButtonLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2);
     122    pComboButtonLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2);
    121123#endif
    122124
    123         /* Create bookmark combo-box: */
    124         m_pBookmarksComboBox = new QComboBox;
    125         if (m_pBookmarksComboBox)
    126         {
    127             m_pBookmarksComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
    128             /* Make sure we have 0th item in our combo-box. */
    129             m_pBookmarksComboBox->insertItem(0, "");
    130             pComboButtonLayout->addWidget(m_pBookmarksComboBox);
    131         }
    132 
    133         /* Create bookmark button layout 1: */
    134         QHBoxLayout *pButtonLayout1 = new QHBoxLayout;
    135         if (pButtonLayout1)
    136         {
    137             pButtonLayout1->setContentsMargins(0, 0, 0, 0);
    138             pButtonLayout1->setSpacing(0);
    139 
    140             /* Create goto selected bookmark button: */
    141             m_pGotoSelectedBookmark = new QIToolButton;
    142             if (m_pGotoSelectedBookmark)
    143             {
    144                 m_pGotoSelectedBookmark->setIcon(UIIconPool::iconSet(":/log_viewer_goto_selected_bookmark_16px.png"));
    145                 pButtonLayout1->addWidget(m_pGotoSelectedBookmark);
    146             }
    147 
    148             /* Create goto previous bookmark button: */
    149             m_pPreviousButton = new QIToolButton;
    150             if (m_pPreviousButton)
    151             {
    152                 m_pPreviousButton->setIcon(UIIconPool::iconSet(":/log_viewer_goto_previous_bookmark_16px.png"));
    153                 pButtonLayout1->addWidget(m_pPreviousButton);
    154             }
    155 
    156             /* Create goto next bookmark button: */
    157             m_pNextButton = new QIToolButton;
    158             if (m_pNextButton)
    159             {
    160                 m_pNextButton->setIcon(UIIconPool::iconSet(":/log_viewer_goto_next_bookmark_16px.png"));
    161                 pButtonLayout1->addWidget(m_pNextButton);
    162             }
    163 
    164             pComboButtonLayout->addLayout(pButtonLayout1);
    165         }
    166 
    167         /* Create bookmark button layout 2: */
    168         QHBoxLayout *pButtonLayout2 = new QHBoxLayout;
    169         if (pButtonLayout2)
    170         {
    171             pButtonLayout2->setContentsMargins(0, 0, 0, 0);
    172             pButtonLayout2->setSpacing(0);
    173 
    174             /* Create delete current bookmark button: */
    175             m_pDeleteCurrentButton = new QIToolButton;
    176             if (m_pDeleteCurrentButton)
    177             {
    178                 m_pDeleteCurrentButton->setIcon(UIIconPool::iconSet(":/log_viewer_delete_current_bookmark_16px.png"));
    179                 pButtonLayout2->addWidget(m_pDeleteCurrentButton);
    180             }
    181 
    182             /* Create delete all bookmarks button: */
    183             m_pDeleteAllButton = new QIToolButton;
    184             if (m_pDeleteAllButton)
    185             {
    186                 m_pDeleteAllButton->setIcon(UIIconPool::iconSet(":/log_viewer_delete_all_bookmarks_16px.png"));
    187                 pButtonLayout2->addWidget(m_pDeleteAllButton);
    188             }
    189 
    190             pComboButtonLayout->addLayout(pButtonLayout2);
    191         }
    192 
    193         pMainLayout->addLayout(pComboButtonLayout);
    194     }
     125    /* Create bookmark combo-box: */
     126    m_pBookmarksComboBox = new QComboBox;
     127    AssertReturnVoid(m_pBookmarksComboBox);
     128    m_pBookmarksComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
     129    /* Make sure we have 0th item in our combo-box. */
     130    m_pBookmarksComboBox->insertItem(0, "");
     131    pComboButtonLayout->addWidget(m_pBookmarksComboBox);
     132
     133    /* Create bookmark button layout 1: */
     134    QHBoxLayout *pButtonLayout1 = new QHBoxLayout;
     135    AssertReturnVoid(pButtonLayout1);
     136    pButtonLayout1->setContentsMargins(0, 0, 0, 0);
     137    pButtonLayout1->setSpacing(0);
     138
     139    /* Create goto selected bookmark button: */
     140    m_pGotoSelectedBookmark = new QIToolButton;
     141    AssertReturnVoid(m_pGotoSelectedBookmark);
     142    m_pGotoSelectedBookmark->setIcon(UIIconPool::iconSet(":/log_viewer_goto_selected_bookmark_16px.png"));
     143    pButtonLayout1->addWidget(m_pGotoSelectedBookmark);
     144
     145    /* Create goto previous bookmark button: */
     146    m_pPreviousButton = new QIToolButton;
     147    AssertReturnVoid(m_pPreviousButton);
     148    m_pPreviousButton->setIcon(UIIconPool::iconSet(":/log_viewer_goto_previous_bookmark_16px.png"));
     149    pButtonLayout1->addWidget(m_pPreviousButton);
     150
     151    /* Create goto next bookmark button: */
     152    m_pNextButton = new QIToolButton;
     153    AssertReturnVoid(m_pNextButton);
     154    m_pNextButton->setIcon(UIIconPool::iconSet(":/log_viewer_goto_next_bookmark_16px.png"));
     155    pButtonLayout1->addWidget(m_pNextButton);
     156
     157    pComboButtonLayout->addLayout(pButtonLayout1);
     158
     159    /* Create bookmark button layout 2: */
     160    QHBoxLayout *pButtonLayout2 = new QHBoxLayout;
     161    AssertReturnVoid(pButtonLayout2);
     162    pButtonLayout2->setContentsMargins(0, 0, 0, 0);
     163    pButtonLayout2->setSpacing(0);
     164
     165    /* Create delete current bookmark button: */
     166    m_pDeleteCurrentButton = new QIToolButton;
     167    AssertReturnVoid(m_pDeleteCurrentButton);
     168    m_pDeleteCurrentButton->setIcon(UIIconPool::iconSet(":/log_viewer_delete_current_bookmark_16px.png"));
     169    pButtonLayout2->addWidget(m_pDeleteCurrentButton);
     170
     171    /* Create delete all bookmarks button: */
     172    m_pDeleteAllButton = new QIToolButton;
     173    AssertReturnVoid(m_pDeleteAllButton);
     174    m_pDeleteAllButton->setIcon(UIIconPool::iconSet(":/log_viewer_delete_all_bookmarks_16px.png"));
     175    pButtonLayout2->addWidget(m_pDeleteAllButton);
     176    pComboButtonLayout->addLayout(pButtonLayout2);
     177
     178    pMainLayout->addLayout(pComboButtonLayout);
     179
     180    pMainLayout->addStretch(1);
    195181}
    196182
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.cpp

    r100926 r100933  
    3838#include "UIVMLogViewerSearchPanel.h"
    3939#include "UIVMLogViewerFilterPanel.h"
     40#include "UIVMLogViewerBookmarksPanel.h"
     41
    4042#ifdef VBOX_WS_MAC
    4143# include "VBoxUtils-darwin.h"
     
    4749    , m_pSearchWidget(0)
    4850    , m_pFilterWidget(0)
     51    , m_pBookmarksWidget(0)
    4952{
    5053    prepare();
     
    6871    connect(m_pFilterWidget, &UIVMLogViewerFilterPanel::sigFilterApplied,
    6972            this, &UIVMLogViewerPanelNew::sigFilterApplied);
     73
     74    /* Bookmark tab: */
     75    m_pBookmarksWidget = new UIVMLogViewerBookmarksPanel(0, m_pViewer);
     76    insertTab(Page_Bookmark, m_pBookmarksWidget);
     77
     78    connect(m_pBookmarksWidget, &UIVMLogViewerBookmarksPanel::sigDeleteBookmarkByIndex,
     79            this, &UIVMLogViewerPanelNew::sigDeleteBookmarkByIndex);
     80    connect(m_pBookmarksWidget, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks,
     81            this, &UIVMLogViewerPanelNew::sigDeleteAllBookmarks);
     82    connect(m_pBookmarksWidget, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
     83            this, &UIVMLogViewerPanelNew::sigBookmarkSelected);
    7084
    7185    retranslateUi();
     
    98112}
    99113
     114void UIVMLogViewerPanelNew::updateBookmarkList(const QVector<UIVMLogBookmark>& bookmarkList)
     115{
     116    if (m_pBookmarksWidget)
     117        m_pBookmarksWidget->updateBookmarkList(bookmarkList);
     118}
     119
     120void UIVMLogViewerPanelNew::disableEnableBookmarking(bool flag)
     121{
     122    if (m_pBookmarksWidget)
     123        m_pBookmarksWidget->disableEnableBookmarking(flag);
     124}
     125
    100126void UIVMLogViewerPanelNew::retranslateUi()
    101127{
    102128    setTabText(Page_Search, "Find");
    103129    setTabText(Page_Filter, "Filter");
     130    setTabText(Page_Bookmark, "Bookmarks");
    104131}
    105132
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.h

    r100921 r100933  
    3434/* GUI includes: */
    3535#include "UIDialogPanel.h"
     36#include "UIVMLogBookmark.h"
    3637
    3738/* Forward declarations: */
     
    4142class UIVMLogViewerSearchPanel;
    4243class UIVMLogViewerFilterPanel;
     44class UIVMLogViewerBookmarksPanel;
    4345
    4446class UIVMLogViewerPanelNew : public QIWithRetranslateUI<UIDialogPanelBase>
     
    5153    void sigSearchUpdated();
    5254    void sigFilterApplied();
     55    void sigDeleteBookmarkByIndex(int bookmarkIndex);
     56    void sigDeleteAllBookmarks();
     57    void sigBookmarkSelected(int index);
    5358
    5459public:
     
    6974    /** @} */
    7075
     76    /** @name Bookmark page pass through functions
     77      * @{ */
     78        void updateBookmarkList(const QVector<UIVMLogBookmark>& bookmarkList);
     79        void disableEnableBookmarking(bool flag);
     80    /** @} */
    7181
    7282    enum Page
     
    92102    UIVMLogViewerSearchPanel *m_pSearchWidget;
    93103    UIVMLogViewerFilterPanel *m_pFilterWidget;
     104    UIVMLogViewerBookmarksPanel *m_pBookmarksWidget;
    94105};
    95106
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r100921 r100933  
    212212    , m_fIsPolished(false)
    213213    , m_pTabWidget(0)
    214     , m_pBookmarksPanel(0)
    215214    , m_pOptionsPanel(0)
    216215    , m_pMainLayout(0)
     
    495494        return;
    496495    pLogPage->deleteBookmarkByIndex(index);
    497     if (m_pBookmarksPanel)
    498         m_pBookmarksPanel->updateBookmarkList(pLogPage->bookmarkList());
     496    if (m_pPanel)
     497        m_pPanel->updateBookmarkList(pLogPage->bookmarkList());
    499498}
    500499
     
    506505    pLogPage->deleteAllBookmarks();
    507506
    508     if (m_pBookmarksPanel)
    509         m_pBookmarksPanel->updateBookmarkList(pLogPage->bookmarkList());
     507    if (m_pPanel)
     508        m_pPanel->updateBookmarkList(pLogPage->bookmarkList());
    510509}
    511510
    512511void UIVMLogViewerWidget::sltUpdateBookmarkPanel()
    513512{
    514     if (!currentLogPage() || !m_pBookmarksPanel)
    515         return;
    516     m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkList());
     513    if (!currentLogPage() || !m_pPanel)
     514        return;
     515    m_pPanel->updateBookmarkList(currentLogPage()->bookmarkList());
    517516}
    518517
     
    555554
    556555    /* We keep a separate QVector<LogBookmark> for each log page: */
    557     if (m_pBookmarksPanel && currentLogPage())
    558         m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkList());
     556    if (m_pPanel && currentLogPage())
     557        m_pPanel->updateBookmarkList(currentLogPage()->bookmarkList());
    559558
    560559    m_pPreviousLogPage = currentLogPage();
     
    574573    /* Disable bookmark panel since bookmarks are stored as line numbers within
    575574       the original log text and does not mean much in a reduced/filtered one. */
    576     if (m_pBookmarksPanel)
    577         m_pBookmarksPanel->disableEnableBookmarking(!isFiltered);
     575    if (m_pPanel)
     576        m_pPanel->disableEnableBookmarking(!isFiltered);
    578577}
    579578
     
    768767
    769768    /* Create VM Log-Viewer bookmarks-panel: */
    770     m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(0, this);
    771     if (m_pBookmarksPanel)
    772     {
    773         /* Configure panel: */
    774         m_pBookmarksPanel->hide();
    775         connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmarkByIndex,
    776                 this, &UIVMLogViewerWidget::sltDeleteBookmarkByIndex);
    777         connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks,
    778                 this, &UIVMLogViewerWidget::sltDeleteAllBookmarks);
    779         connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
    780                 this, &UIVMLogViewerWidget::gotoBookmark);
    781         /* Add into layout: */
    782         m_pMainLayout->addWidget(m_pBookmarksPanel);
    783     }
     769    // m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(0, this);
     770    // if (m_pBookmarksPanel)
     771    // {
     772    //     /* Configure panel: */
     773    //     m_pBookmarksPanel->hide();
     774    //     connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmarkByIndex,
     775    //             this, &UIVMLogViewerWidget::sltDeleteBookmarkByIndex);
     776    //     connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks,
     777    //             this, &UIVMLogViewerWidget::sltDeleteAllBookmarks);
     778    //     connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
     779    //             this, &UIVMLogViewerWidget::gotoBookmark);
     780    //     /* Add into layout: */
     781    //     m_pMainLayout->addWidget(m_pBookmarksPanel);
     782    // }
    784783
    785784    /* Create VM Log-Viewer options-panel: */
     
    811810    connect(m_pPanel, &UIVMLogViewerPanelNew::sigFilterApplied,
    812811            this, &UIVMLogViewerWidget::sltFilterApplied);
     812    connect(m_pPanel, &UIVMLogViewerPanelNew::sigDeleteBookmarkByIndex,
     813            this, &UIVMLogViewerWidget::sltDeleteBookmarkByIndex);
     814    connect(m_pPanel, &UIVMLogViewerPanelNew::sigDeleteAllBookmarks,
     815            this, &UIVMLogViewerWidget::sltDeleteAllBookmarks);
     816    connect(m_pPanel, &UIVMLogViewerPanelNew::sigBookmarkSelected,
     817            this, &UIVMLogViewerWidget::gotoBookmark);
    813818
    814819    m_pMainLayout->addWidget(m_pPanel);
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r100921 r100933  
    227227    /** @name Panel instances and a QMap for mapping panel instances to related actions.
    228228      * @{ */
    229         UIVMLogViewerBookmarksPanel *m_pBookmarksPanel;
    230229        UIVMLogViewerOptionsPanel   *m_pOptionsPanel;
    231230        QList<UIDialogPanel*>          m_visiblePanelsList;
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