VirtualBox

Changeset 93414 in vbox for trunk


Ignore:
Timestamp:
Jan 24, 2022 3:27:29 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: UI to toggle UINotificationCenter alignment; Based on extra-data support implemented in r149507.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.cpp

    r93413 r93414  
    1919#include <QApplication>
    2020#include <QHBoxLayout>
     21#include <QMenu>
    2122#include <QPainter>
    2223#include <QPaintEvent>
     
    421422}
    422423
     424void UINotificationCenter::sltHandleOpenButtonContextMenuRequested(const QPoint &)
     425{
     426    /* Create menu: */
     427    QMenu menu(m_pButtonOpen);
     428
     429    /* Create action: */
     430    QAction action(  m_enmAlignment == Qt::AlignTop
     431                   ? tr("Align Bottom")
     432                   : tr("Align Top"),
     433                   m_pButtonOpen);
     434    menu.addAction(&action);
     435
     436    /* Execute menu, check if any (single) action is clicked: */
     437    QAction *pAction = menu.exec(m_pButtonOpen->mapToGlobal(QPoint(m_pButtonOpen->width(), 0)));
     438    if (pAction)
     439    {
     440        const Qt::Alignment enmAlignment = m_enmAlignment == Qt::AlignTop
     441                                         ? Qt::AlignBottom
     442                                         : Qt::AlignTop;
     443        gEDataManager->setNotificationCenterAlignment(enmAlignment);
     444    }
     445}
     446
    423447void UINotificationCenter::sltHandleOpenTimerTimeout()
    424448{
     
    576600                m_pButtonOpen->setIcon(UIIconPool::iconSet(":/notification_center_16px.png"));
    577601                m_pButtonOpen->setCheckable(true);
     602                m_pButtonOpen->setContextMenuPolicy(Qt::CustomContextMenu);
    578603                connect(m_pButtonOpen, &QIToolButton::toggled,
    579604                        this, &UINotificationCenter::sltHandleOpenButtonToggled);
     605                connect(m_pButtonOpen, &QIToolButton::customContextMenuRequested,
     606                        this, &UINotificationCenter::sltHandleOpenButtonContextMenuRequested);
    580607                m_pLayoutButtons->addWidget(m_pButtonOpen);
    581608            }
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h

    r93408 r93414  
    115115    /** Removes finished notifications. */
    116116    void sltHandleRemoveFinishedButtonClicked();
     117
     118    /** Invokes open button context menu at specified @a position. */
     119    void sltHandleOpenButtonContextMenuRequested(const QPoint &position);
    117120
    118121    /** Handles open-timer timeout. */
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