VirtualBox

Changeset 70519 in vbox for trunk/src


Ignore:
Timestamp:
Jan 10, 2018 2:27:17 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9072 Synchronize actions' checked state with panel hide event

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

Legend:

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

    r70500 r70519  
    120120    if (pFocus && pFocus->parent() == this)
    121121        focusNextPrevChild(true);
     122    if(m_pViewer)
     123        m_pViewer->hidePanel(this);
    122124
    123125    QWidget::hideEvent(pEvent);
    124     emit sigHide();
    125126}
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.h

    r70500 r70519  
    4040{
    4141    Q_OBJECT;
    42 
    43 signals:
    44 
    45     void sigHide();
    4642
    4743public:
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp

    r70500 r70519  
    336336    m_pNextPrevButtons->setToolTip(1, UIVMLogViewerWidget::tr("Search for the next occurrence of the string"));
    337337
    338     m_pCaseSensitiveCheckBox->setText(UIVMLogViewerWidget::tr("C&ase\nSensitive"));
     338    m_pCaseSensitiveCheckBox->setText(UIVMLogViewerWidget::tr("C&ase Sensitive"));
    339339    m_pCaseSensitiveCheckBox->setToolTip(UIVMLogViewerWidget::tr("Perform case sensitive search (when checked)"));
    340340
    341     m_pMatchWholeWordCheckBox->setText(UIVMLogViewerWidget::tr("Ma&tch\nWhole Word"));
     341    m_pMatchWholeWordCheckBox->setText(UIVMLogViewerWidget::tr("Ma&tch Whole Word"));
    342342    m_pMatchWholeWordCheckBox->setToolTip(UIVMLogViewerWidget::tr("Search matches only complete words when checked"));
    343343
    344     m_pHighlightAllCheckBox->setText(UIVMLogViewerWidget::tr("&Highlight\nAll"));
     344    m_pHighlightAllCheckBox->setText(UIVMLogViewerWidget::tr("&Highlight All"));
    345345    m_pHighlightAllCheckBox->setToolTip(UIVMLogViewerWidget::tr("All occurence of the search text are highlighted"));
    346346
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r70505 r70519  
    181181    QString m_logFileName;
    182182};
     183
    183184
    184185UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */, const CMachine &machine /* = CMachine() */)
     
    238239void UIVMLogViewerWidget::sltPanelActionTriggered(bool checked)
    239240{
    240     RT_NOREF(checked);
    241 
    242241    QAction *pSenderAction = qobject_cast<QAction*>(sender());
    243242    if(!pSenderAction)
    244243        return;
     244    UIVMLogViewerPanel* pPanel = 0;
    245245    /* Look for the sender() within the m_panelActionMap's values: */
    246     for(QMap<UIVMLogViewerPanel**, QAction**>::const_iterator iterator = m_panelActionMap.begin();
     246    for(QMap<UIVMLogViewerPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin();
    247247        iterator != m_panelActionMap.end(); ++iterator)
    248248    {
    249         if(iterator.value() == &pSenderAction)
    250             continue;
    251     }
     249        if(iterator.value() == pSenderAction)
     250            pPanel = iterator.key();
     251    }
     252    if(!pPanel)
     253        return;
     254    if(checked)
     255        showPanel(pPanel);
     256    else
     257        hidePanel(pPanel);
    252258}
    253259
     
    452458    m_pMainLayout = new QVBoxLayout(this);
    453459
     460    /* Prepare widgets: */
     461    prepareWidgets();
     462
     463
    454464    prepareActions();
    455465
     
    457467    prepareMenu();
    458468
    459     /* Prepare widgets: */
    460     prepareWidgets();
    461 
    462469    /* Reading log files: */
    463470    sltRefresh();
     
    465472    /* Loading language constants: */
    466473    retranslateUi();
     474
     475    m_panelActionMap.insert(m_pBookmarksPanel, m_pActionBookmark);
     476    m_panelActionMap.insert(m_pSearchPanel, m_pActionFind);
     477    m_panelActionMap.insert(m_pFilterPanel, m_pActionFilter);
    467478}
    468479
     
    515526    AssertPtrReturnVoid(m_pBookmarksPanel);
    516527    {
    517         //QMap<UIVMLogViewerPanel*&, QAction*&> m_panelActionMap;
    518         m_panelActionMap.insert(reinterpret_cast<UIVMLogViewerPanel**>(&m_pBookmarksPanel), &m_pActionBookmark);
    519         //connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigHide, this, &UIVMLogViewerWidget::sltHidePanel);
    520528        installEventFilter(m_pBookmarksPanel);
    521529        m_pBookmarksPanel->hide();
    522530        m_pMainLayout->insertWidget(4, m_pBookmarksPanel);
    523531    }
     532
    524533}
    525534
     
    532541        m_pActionFind->setShortcut(QKeySequence("Ctrl+F"));
    533542        m_pActionFind->setCheckable(true);
    534         connect(m_pActionFind, &QAction::triggered, this, &UIVMLogViewerWidget::sltShowHideSearchPanel);
     543        connect(m_pActionFind, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionTriggered);
    535544    }
    536545
     
    541550        m_pActionFilter->setShortcut(QKeySequence("Ctrl+T"));
    542551        m_pActionFilter->setCheckable(true);
    543         connect(m_pActionFilter, &QAction::triggered, this, &UIVMLogViewerWidget::sltShowHideFilterPanel);
     552        connect(m_pActionFilter, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionTriggered);
     553    }
     554    /* Create and configure 'Bookmark' action: */
     555    m_pActionBookmark = new QAction(this);
     556    AssertPtrReturnVoid(m_pActionBookmark);
     557    {
     558        /* tie Ctrl+D to save only if we show this in a dialog since Ctrl+D is
     559           already assigned to another action in the selector UI: */
     560        if (m_enmEmbedding == EmbedTo_Dialog)
     561            m_pActionBookmark->setShortcut(QKeySequence("Ctrl+D"));
     562        m_pActionBookmark->setCheckable(true);
     563        connect(m_pActionBookmark, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionTriggered);
    544564    }
    545565
     
    562582        connect(m_pActionSave, &QAction::triggered, this, &UIVMLogViewerWidget::sltSave);
    563583     }
    564 
    565     /* Create and configure 'Bookmark' action: */
    566     m_pActionBookmark = new QAction(this);
    567     AssertPtrReturnVoid(m_pActionBookmark);
    568     {
    569         /* tie Ctrl+D to save only if we show this in a dialog since Ctrl+D is
    570            already assigned to another action in the selector UI: */
    571         if (m_enmEmbedding == EmbedTo_Dialog)
    572             m_pActionBookmark->setShortcut(QKeySequence("Ctrl+D"));
    573         m_pActionBookmark->setCheckable(true);
    574         connect(m_pActionBookmark, &QAction::triggered, this, &UIVMLogViewerWidget::sltShowHideBookmarkPanel);
    575     }
    576584
    577585    /* Update action icons: */
     
    829837void UIVMLogViewerWidget::hidePanel(UIVMLogViewerPanel* panel)
    830838{
    831     if (!panel || panel->isHidden())
    832         return;
    833     panel->setVisible(false);
     839    if (panel && panel->isVisible())
     840        panel->setVisible(false);
     841    QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);
     842    if(iterator != m_panelActionMap.end())
     843    {
     844        if(iterator.value()->isChecked())
     845            iterator.value()->setChecked(false);
     846    }
    834847}
    835848
    836849void UIVMLogViewerWidget::showPanel(UIVMLogViewerPanel* panel)
    837850{
    838     if (!panel || panel->isVisible())
    839         return;
    840     panel->setVisible(true);
     851    if (panel && panel->isHidden())
     852        panel->setVisible(true);
     853    QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);
     854    if(iterator != m_panelActionMap.end())
     855    {
     856        if(!iterator.value()->isChecked())
     857            iterator.value()->setChecked(true);
     858    }
    841859}
    842860
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r70500 r70519  
    174174    UIVMLogViewerFilterPanel    *m_pFilterPanel;
    175175    UIVMLogViewerBookmarksPanel *m_pBookmarksPanel;
    176     QMap<UIVMLogViewerPanel**, QAction**> m_panelActionMap;
     176    QMap<UIVMLogViewerPanel*, QAction*> m_panelActionMap;
    177177
    178178    /** Holds the list of log file content. */
     
    207207    friend class UIVMLogViewerFilterPanel;
    208208    friend class UIVMLogViewerSearchPanel;
     209    friend class UIVMLogViewerPanel;
    209210};
    210211
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