Changeset 71513 in vbox
- Timestamp:
- Mar 26, 2018 2:11:28 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
-
UIPopupPaneButtonPane.cpp (modified) (5 diffs)
-
UIPopupPaneButtonPane.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneButtonPane.cpp
r69500 r71513 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 # include <QApplication> 23 23 # include <QHBoxLayout> 24 # include <QKeyEvent> 24 25 # include <QVBoxLayout> 25 # include <QKeyEvent>26 26 27 27 /* GUI includes: */ 28 # include "QIMessageBox.h" 29 # include "QIToolButton.h" 30 # include "UIIconPool.h" 28 31 # include "UIPopupPaneButtonPane.h" 29 # include "UIIconPool.h"30 # include "QIToolButton.h"31 # include "QIMessageBox.h"32 32 33 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 51 51 /* Assign new button-descriptions: */ 52 52 m_buttonDescriptions = buttonDescriptions; 53 53 54 /* Recreate buttons: */ 54 55 cleanupButtons(); … … 80 81 void UIPopupPaneButtonPane::prepareLayouts() 81 82 { 82 /* Create layouts: */ 83 m_pButtonLayout = new QHBoxLayout; 84 m_pButtonLayout->setContentsMargins(0, 0, 0, 0); 85 m_pButtonLayout->setSpacing(0); 83 /* Create main-layout: */ 86 84 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 87 pMainLayout->setContentsMargins(0, 0, 0, 0); 88 pMainLayout->setSpacing(0); 89 pMainLayout->addLayout(m_pButtonLayout); 90 pMainLayout->addStretch(); 85 if (pMainLayout) 86 { 87 /* Configure layout: */ 88 pMainLayout->setSpacing(0); 89 pMainLayout->setContentsMargins(0, 0, 0, 0); 90 91 /* Create button-layout: */ 92 m_pButtonLayout = new QHBoxLayout; 93 if (m_pButtonLayout) 94 { 95 /* Configure layout: */ 96 m_pButtonLayout->setSpacing(0); 97 m_pButtonLayout->setContentsMargins(0, 0, 0, 0); 98 99 /* Add into layout: */ 100 pMainLayout->addLayout(m_pButtonLayout); 101 } 102 103 /* Add stretch: */ 104 pMainLayout->addStretch(); 105 } 91 106 } 92 107 … … 153 168 154 169 /* static */ 155 QIToolButton *UIPopupPaneButtonPane::addButton(int iButtonID, const QString &strToolTip)170 QIToolButton *UIPopupPaneButtonPane::addButton(int iButtonID, const QString &strToolTip) 156 171 { 157 172 /* Create button: */ 158 173 QIToolButton *pButton = new QIToolButton; 159 pButton->removeBorder(); 160 pButton->setToolTip(strToolTip.isEmpty() ? defaultToolTip(iButtonID) : strToolTip); 161 pButton->setIcon(defaultIcon(iButtonID)); 162 163 /* Sign the 'default' button: */ 164 if (iButtonID & AlertButtonOption_Default) 165 pButton->setProperty("default", true); 166 /* Sign the 'escape' button: */ 167 if (iButtonID & AlertButtonOption_Escape) 168 pButton->setProperty("escape", true); 174 if (pButton) 175 { 176 /* Configure button: */ 177 pButton->removeBorder(); 178 pButton->setToolTip(strToolTip.isEmpty() ? defaultToolTip(iButtonID) : strToolTip); 179 pButton->setIcon(defaultIcon(iButtonID)); 180 181 /* Sign the 'default' button: */ 182 if (iButtonID & AlertButtonOption_Default) 183 pButton->setProperty("default", true); 184 /* Sign the 'escape' button: */ 185 if (iButtonID & AlertButtonOption_Escape) 186 pButton->setProperty("escape", true); 187 } 169 188 170 189 /* Return button: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneButtonPane.h
r69500 r71513 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIPopupPaneButtonPane_h__19 #define __ UIPopupPaneButtonPane_h__18 #ifndef ___UIPopupPaneButtonPane_h___ 19 #define ___UIPopupPaneButtonPane_h___ 20 20 21 21 /* Qt includes: */ … … 25 25 /* Forward declarations: */ 26 26 class QHBoxLayout; 27 class QIcon; 27 28 class QKeyEvent; 29 class QString; 28 30 class QIToolButton; 29 31 30 /* Popup-pane button-pane prototype class:*/32 /** QWidget extension providing GUI with popup-pane button-pane prototype class. */ 31 33 class UIPopupPaneButtonPane : public QWidget 32 34 { … … 35 37 signals: 36 38 37 /* Notifier: Button stuff:*/39 /** Notifies about button with @a iButtonID being clicked. */ 38 40 void sigButtonClicked(int iButtonID); 39 41 40 42 public: 41 43 42 /* Constructor:*/44 /** Constructs popup-button pane passing @a pParent to the base-class. */ 43 45 UIPopupPaneButtonPane(QWidget *pParent = 0); 44 46 45 /* API: Button stuff:*/47 /** Defines @a buttonDescriptions. */ 46 48 void setButtons(const QMap<int, QString> &buttonDescriptions); 49 /** Returns default button. */ 47 50 int defaultButton() const { return m_iDefaultButton; } 51 /** Returns escape button. */ 48 52 int escapeButton() const { return m_iEscapeButton; } 49 53 50 54 private slots: 51 55 52 /* Handler: Button stuff:*/56 /** Handles button click. */ 53 57 void sltButtonClicked(); 54 58 55 59 private: 56 60 57 /* Helpers: Prepare/cleanup stuff:*/61 /** Prepares all. */ 58 62 void prepare(); 63 /** Prepares layouts. */ 59 64 void prepareLayouts(); 65 /** Prepares buttons. */ 60 66 void prepareButtons(); 67 /** Cleanups buttons. */ 61 68 void cleanupButtons(); 62 69 63 /* Handler: Event stuff:*/64 v oid keyPressEvent(QKeyEvent *pEvent);70 /** Handles key-press @a pEvent. */ 71 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 65 72 66 /* Static helpers: Button stuff: */ 67 static QIToolButton* addButton(int iButtonID, const QString &strToolTip); 73 /** Adds button with @a iButtonID and @a strToolTip. */ 74 static QIToolButton *addButton(int iButtonID, const QString &strToolTip); 75 /** Returns default tool-tip for button @a iButtonID. */ 68 76 static QString defaultToolTip(int iButtonID); 77 /** Returns default icon for button @a iButtonID. */ 69 78 static QIcon defaultIcon(int iButtonID); 70 79 71 /* Variables: Widget stuff:*/80 /** Holds the button layout. */ 72 81 QHBoxLayout *m_pButtonLayout; 73 QMap<int, QString> m_buttonDescriptions; 82 83 /** Holds the button descriptions. */ 84 QMap<int, QString> m_buttonDescriptions; 85 /** Holds the button instances. */ 74 86 QMap<int, QIToolButton*> m_buttons; 87 88 /** Holds default button. */ 75 89 int m_iDefaultButton; 90 /** Holds escape button. */ 76 91 int m_iEscapeButton; 77 92 }; 78 93 79 #endif /* __UIPopupPaneButtonPane_h__ */ 94 #endif /* !___UIPopupPaneButtonPane_h___ */ 95
Note:
See TracChangeset
for help on using the changeset viewer.

