- Timestamp:
- Jul 4, 2014 4:22:24 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r51770 r51873 268 268 src/extensions/QITableView.h \ 269 269 src/extensions/QIToolButton.h \ 270 src/extensions/QITextEdit.h \271 270 src/extensions/QITreeView.h \ 272 271 src/extensions/QITreeWidget.h \ … … 465 464 VirtualBox_QT_MOCSRCS = \ 466 465 src/UIVMLogViewer.cpp \ 466 src/extensions/QIArrowSplitter.cpp \ 467 467 src/extensions/QISplitter.cpp \ 468 468 src/extensions/QIAdvancedToolBar.cpp \ … … 535 535 src/extensions/QIStatusBar.cpp \ 536 536 src/extensions/QITableView.cpp \ 537 src/extensions/QITextEdit.cpp \538 537 src/extensions/QITreeView.cpp \ 539 538 src/extensions/QITreeWidget.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonPress.cpp
r44528 r51873 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QIArrowButtonPress class implementation 3 * VBox Qt GUI - QIArrowButtonPress class implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 16 */ 19 17 20 /* VBox includes */ 21 #include "QIArrowButtonPress.h" 22 #include "UIIconPool.h" 23 24 /* Qt includes */ 18 /* Qt includes: */ 25 19 #include <QKeyEvent> 26 20 21 /* GUI includes: */ 22 #include "QIArrowButtonPress.h" 27 23 28 /** @class QIArrowButtonPress 29 * 30 * The QIArrowButtonPress class is an arrow tool-button with text-label, 31 * used as back/next buttons in QIMessageBox class. 32 * 33 */ 34 35 QIArrowButtonPress::QIArrowButtonPress (QWidget *aParent) 36 : QIRichToolButton (aParent) 37 , mNext (true) 24 QIArrowButtonPress::QIArrowButtonPress(QIArrowButtonPress::ButtonType buttonType, 25 QWidget *pParent /* = 0 */) 26 : QIWithRetranslateUI<QIRichToolButton>(pParent) 27 , m_buttonType(buttonType) 38 28 { 39 updateIcon(); 29 /* Retranslate UI: */ 30 retranslateUi(); 40 31 } 41 32 42 QIArrowButtonPress::QIArrowButtonPress (bool aNext, const QString &aName, QWidget *aParent) 43 : QIRichToolButton (aName, aParent) 44 , mNext (aNext) 33 void QIArrowButtonPress::retranslateUi() 45 34 { 46 updateIcon(); 35 /* Retranslate: */ 36 switch (m_buttonType) 37 { 38 case ButtonType_Back: setText(QApplication::translate("QIArrowSplitter", "&Back")); break; 39 case ButtonType_Next: setText(QApplication::translate("QIArrowSplitter", "&Next")); break; 40 default: break; 41 } 47 42 } 48 43 49 void QIArrowButtonPress:: updateIcon()44 void QIArrowButtonPress::keyPressEvent(QKeyEvent *pEvent) 50 45 { 51 mButton->setIcon(UIIconPool::iconSet(mNext ? 52 ":/arrow_right_10px.png" : ":/arrow_left_10px.png")); 46 /* Handle different keys: */ 47 switch (pEvent->key()) 48 { 49 /* Animate-click for the Space key: */ 50 case Qt::Key_PageUp: if (m_buttonType == ButtonType_Next) return animateClick(); break; 51 case Qt::Key_PageDown: if (m_buttonType == ButtonType_Back) return animateClick(); break; 52 default: break; 53 } 54 /* Call to base-class: */ 55 QIWithRetranslateUI<QIRichToolButton>::keyPressEvent(pEvent); 53 56 } 54 57 55 bool QIArrowButtonPress::eventFilter (QObject *aObject, QEvent *aEvent)56 {57 /* Process only QIArrowButtonPress or children */58 if (!(aObject == this || children().contains (aObject)))59 return QIRichToolButton::eventFilter (aObject, aEvent);60 61 /* Process keyboard events */62 if (aEvent->type() == QEvent::KeyPress)63 {64 QKeyEvent *kEvent = static_cast <QKeyEvent*> (aEvent);65 if ((mNext && kEvent->key() == Qt::Key_PageUp) ||66 (!mNext && kEvent->key() == Qt::Key_PageDown))67 animateClick();68 }69 70 /* Default one handler */71 return QIRichToolButton::eventFilter (aObject, aEvent);72 }73 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonPress.h
r44528 r51873 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QIArrowButtonPress class declaration 2 * VBox Qt GUI - QIArrowButtonPress class declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2006-201 0Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ QIArrowButtonPress_h__20 #define __ QIArrowButtonPress_h__17 #ifndef ___QIArrowButtonPress_h___ 18 #define ___QIArrowButtonPress_h___ 21 19 22 /* VBox includes*/20 /* GUI includes: */ 23 21 #include "QIRichToolButton.h" 22 #include "QIWithRetranslateUI.h" 24 23 25 /* VBox forwards */ 26 class QIRichToolButton; 27 28 /** @class QIArrowButtonPress 29 * 30 * The QIArrowButtonPress class is an arrow tool-button with text-label, 31 * used as back/next buttons in QIMessageBox class. 32 * 33 */ 34 class QIArrowButtonPress : public QIRichToolButton 24 /** QIRichToolButton extension 25 * representing arrow tool-button with text-label, 26 * can be used as back/next buttons in various places. */ 27 class QIArrowButtonPress : public QIWithRetranslateUI<QIRichToolButton> 35 28 { 36 29 Q_OBJECT; … … 38 31 public: 39 32 40 QIArrowButtonPress (QWidget *aParent = 0);41 QIArrowButtonPress (bool aNext, const QString &aName, QWidget *aParent = 0);33 /** Button types. */ 34 enum ButtonType { ButtonType_Back, ButtonType_Next }; 42 35 43 void setNext (bool aNext) { mNext = aNext; } 36 /** Constructor, passes @a pParent to the QIRichToolButton constructor. 37 * @param buttonType is used to define which type of the button it is. */ 38 QIArrowButtonPress(ButtonType buttonType, QWidget *pParent = 0); 39 40 protected: 41 42 /** Retranslation routine. 43 * @todo Fix translation context. */ 44 virtual void retranslateUi(); 45 46 /** Key-press-event handler. */ 47 virtual void keyPressEvent(QKeyEvent *pEvent); 44 48 45 49 private: 46 50 47 void updateIcon(); 48 bool eventFilter (QObject *aObject, QEvent *aEvent); 49 50 bool mNext; 51 /** Holds the button-type. */ 52 ButtonType m_buttonType; 51 53 }; 52 54 53 #endif 54 55 #endif /* !___QIArrowButtonPress_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonSwitch.cpp
r51280 r51873 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QIArrowButtonSwitch class implementation 3 * VBox Qt GUI - QIArrowButtonSwitch class implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 16 */ 19 17 20 /* VBox includes */ 21 #include "QIArrowButtonSwitch.h" 22 #include "UIIconPool.h" 23 24 /* Qt includes */ 18 /* Qt includes: */ 25 19 #include <QKeyEvent> 26 20 21 /* GUI includes: */ 22 #include "QIArrowButtonSwitch.h" 27 23 28 /** @class QIArrowButtonSwitch 29 * 30 * The QIArrowButtonSwitch class is an arrow tool-button with text-label, 31 * used as collaps/expand switch in QIMessageBox class. 32 * 33 */ 34 35 QIArrowButtonSwitch::QIArrowButtonSwitch (QWidget *aParent) 36 : QIRichToolButton (aParent) 37 , mIsExpanded (false) 24 QIArrowButtonSwitch::QIArrowButtonSwitch(QWidget *pParent /* = 0 */) 25 : QIRichToolButton(pParent) 26 , m_buttonState(ButtonState_Collapsed) 38 27 { 39 init(); 28 /* Update icon: */ 29 updateIcon(); 40 30 } 41 31 42 QIArrowButtonSwitch::QIArrowButtonSwitch (const QString &aName, QWidget *aParent) 43 : QIRichToolButton (aName, aParent) 44 , mIsExpanded (false) 32 void QIArrowButtonSwitch::setIconForButtonState(QIArrowButtonSwitch::ButtonState buttonState, const QIcon &icon) 45 33 { 46 init(); 34 /* Assign icon: */ 35 m_icons[buttonState] = icon; 36 /* Update icon: */ 37 updateIcon(); 47 38 } 48 39 49 void QIArrowButtonSwitch:: buttonClicked()40 void QIArrowButtonSwitch::sltButtonClicked() 50 41 { 51 mIsExpanded = !mIsExpanded; 42 /* Toggle button-state: */ 43 m_buttonState = m_buttonState == ButtonState_Collapsed ? 44 ButtonState_Expanded : ButtonState_Collapsed; 45 /* Update icon: */ 52 46 updateIcon(); 53 QIRichToolButton::buttonClicked();54 47 } 55 48 56 void QIArrowButtonSwitch:: init()49 void QIArrowButtonSwitch::keyPressEvent(QKeyEvent *pEvent) 57 50 { 58 /* Restrict icon size: */ 59 mButton->setIconSize(QSize(10, 10)); 60 /* And update icon finally: */ 61 updateIcon(); 51 /* Handle different keys: */ 52 switch (pEvent->key()) 53 { 54 /* Animate-click for the Space key: */ 55 case Qt::Key_Minus: if (m_buttonState == ButtonState_Expanded) return animateClick(); break; 56 case Qt::Key_Plus: if (m_buttonState == ButtonState_Collapsed) return animateClick(); break; 57 default: break; 58 } 59 /* Call to base-class: */ 60 QIRichToolButton::keyPressEvent(pEvent); 62 61 } 63 62 64 63 void QIArrowButtonSwitch::updateIcon() 65 64 { 66 mButton->setIcon(UIIconPool::iconSet(mIsExpanded ? 67 ":/arrow_down_10px.png" : ":/arrow_right_10px.png")); 65 setIcon(m_icons.value(m_buttonState)); 68 66 } 69 67 70 bool QIArrowButtonSwitch::eventFilter (QObject *aObject, QEvent *aEvent)71 {72 /* Process only QIArrowButtonSwitch or children */73 if (!(aObject == this || children().contains (aObject)))74 return QIRichToolButton::eventFilter (aObject, aEvent);75 76 /* Process keyboard events */77 if (aEvent->type() == QEvent::KeyPress)78 {79 QKeyEvent *kEvent = static_cast <QKeyEvent*> (aEvent);80 if ((mIsExpanded && kEvent->key() == Qt::Key_Minus) ||81 (!mIsExpanded && kEvent->key() == Qt::Key_Plus))82 animateClick();83 }84 85 /* Default one handler */86 return QIRichToolButton::eventFilter (aObject, aEvent);87 }88 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonSwitch.h
r51280 r51873 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QIArrowButtonSwitch class declaration 2 * VBox Qt GUI - QIArrowButtonSwitch class declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2006-201 0Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ QIArrowButtonSwitch_h__20 #define __ QIArrowButtonSwitch_h__17 #ifndef ___QIArrowButtonSwitch_h___ 18 #define ___QIArrowButtonSwitch_h___ 21 19 22 /* VBox includes */ 20 /* Qt includes: */ 21 #include <QMap> 22 #include <QIcon> 23 24 /* GUI includes: */ 23 25 #include "QIRichToolButton.h" 24 26 25 /* VBox forwards */ 26 class QIRichToolButton; 27 28 29 /** @class QIArrowButtonSwitch 30 * 31 * The QIArrowButtonSwitch class is an arrow tool-button with text-label, 32 * used as collaps/expand switch in QIMessageBox class. 33 * 34 */ 27 /** QIRichToolButton extension 28 * representing arrow tool-button with text-label, 29 * can be used as collaps/expand switch in various places. */ 35 30 class QIArrowButtonSwitch : public QIRichToolButton 36 31 { … … 39 34 public: 40 35 41 QIArrowButtonSwitch (QWidget *aParent = 0);42 QIArrowButtonSwitch (const QString &aName, QWidget *aParent = 0);36 /** Button states. */ 37 enum ButtonState { ButtonState_Collapsed, ButtonState_Expanded }; 43 38 44 bool isExpanded() const { return mIsExpanded; } 39 /** Constructor, passes @a pParent to the QIRichToolButton constructor. */ 40 QIArrowButtonSwitch(QWidget *pParent = 0); 45 41 46 private slots: 42 /** Defines the @a icon for the @a buttonState. */ 43 void setIconForButtonState(ButtonState buttonState, const QIcon &icon); 47 44 48 void buttonClicked(); 45 /** Returns whether button-state is ButtonState_Expanded. */ 46 bool isExpanded() const { return m_buttonState == ButtonState_Expanded; } 47 48 protected slots: 49 50 /** Button-click handler. */ 51 virtual void sltButtonClicked(); 52 53 protected: 54 55 /** Key-press-event handler. */ 56 virtual void keyPressEvent(QKeyEvent *pEvent); 49 57 50 58 private: 51 59 52 /** Performs initialization. */ 53 void init(); 60 /** Updates icon according button-state. */ 54 61 void updateIcon(); 55 bool eventFilter (QObject *aObject, QEvent *aEvent);56 62 57 bool mIsExpanded; 63 /** Holds the button-state. */ 64 ButtonState m_buttonState; 65 /** Holds icons for button-states. */ 66 QMap<ButtonState, QIcon> m_icons; 58 67 }; 59 68 60 #endif 61 69 #endif /* !___QIArrowButtonSwitch_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowSplitter.cpp
r46831 r51873 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QIArrowSplitter class implementation 3 * VBox Qt GUI - QIArrowSplitter class implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 16 */ 19 17 20 /* VBox includes */ 18 /* Qt includes: */ 19 #include <QApplication> 20 #include <QDesktopWidget> 21 #include <QStyle> 22 #include <QHBoxLayout> 23 #include <QTextEdit> 24 25 /* GUI includes: */ 21 26 #include "QIArrowSplitter.h" 22 23 /* Qt includes */ 24 #include <QApplication> 25 #include <QHBoxLayout> 26 #include <QKeyEvent> 27 28 QIArrowSplitter::QIArrowSplitter (QWidget *aChild, QWidget *aParent) 29 : QWidget (aParent) 30 , mMainLayout (new QVBoxLayout (this)) 31 , mSwitchButton (new QIArrowButtonSwitch()) 32 , mBackButton (new QIArrowButtonPress (false, tr ("&Back"))) 33 , mNextButton (new QIArrowButtonPress (true, tr ("&Next"))) 34 , mChild (aChild) 35 { 36 /* Setup main-layout */ 37 mMainLayout->setContentsMargins(0, 0, 0, 0); 38 mMainLayout->setSpacing(3); 39 40 /* Setup buttons */ 41 mBackButton->setVisible (false); 42 mNextButton->setVisible (false); 43 44 /* Setup connections */ 45 connect (mSwitchButton, SIGNAL (clicked()), this, SLOT (toggleWidget())); 46 connect (mBackButton, SIGNAL (clicked()), this, SIGNAL (showBackDetails())); 47 connect (mNextButton, SIGNAL (clicked()), this, SIGNAL (showNextDetails())); 48 49 /* Setup button layout */ 50 QHBoxLayout *buttonLayout = new QHBoxLayout(); 51 buttonLayout->setContentsMargins(0, 0, 0, 0); 52 buttonLayout->setSpacing (0); 53 buttonLayout->addWidget (mSwitchButton); 54 buttonLayout->addStretch(); 55 buttonLayout->addWidget (mBackButton); 56 buttonLayout->addWidget (mNextButton); 57 58 /* Append layout with children */ 59 mMainLayout->addLayout (buttonLayout); 60 mMainLayout->addWidget (mChild); 61 62 /* Install event-filter */ 63 qApp->installEventFilter (this); 64 65 /* Hide child initially: */ 66 toggleWidget(); 67 } 68 69 void QIArrowSplitter::setMultiPaging (bool aMultiPage) 70 { 71 mBackButton->setVisible (aMultiPage); 72 mNextButton->setVisible (aMultiPage); 73 } 74 75 void QIArrowSplitter::setButtonEnabled (bool aNext, bool aEnabled) 76 { 77 aNext ? mNextButton->setEnabled (aEnabled) 78 : mBackButton->setEnabled (aEnabled); 79 } 80 81 void QIArrowSplitter::setName (const QString &aName) 82 { 83 mSwitchButton->setText (aName); 84 emit sigSizeChanged(); 27 #include "QIArrowButtonSwitch.h" 28 #include "QIArrowButtonPress.h" 29 #include "UIIconPool.h" 30 31 /* Other VBox includes: */ 32 #include "iprt/assert.h" 33 34 35 /** QTextEdit extension 36 * taking into account text-document size-hint. 37 * @note Used with QIMessageBox class only. 38 * @todo Should be moved/renamed accordingly. */ 39 class QIDetailsBrowser : public QTextEdit 40 { 41 Q_OBJECT; 42 43 public: 44 45 /** Constructor, passes @a pParent to the QTextEdit constructor. */ 46 QIDetailsBrowser(QWidget *pParent = 0); 47 48 /** Returns minimum size-hint. */ 49 QSize minimumSizeHint() const; 50 /** Returns size-hint. */ 51 QSize sizeHint() const; 52 53 /** Update scroll-bars. */ 54 void updateScrollBars(); 55 }; 56 57 QIDetailsBrowser::QIDetailsBrowser(QWidget *pParent /* = 0 */) 58 : QTextEdit(pParent) 59 { 60 /* Prepare: */ 61 setReadOnly(true); 62 } 63 64 QSize QIDetailsBrowser::minimumSizeHint() const 65 { 66 /* Get document size as the basis: */ 67 QSize documentSize = document()->size().toSize(); 68 /* But only document ideal-width can advice wise width: */ 69 const int iDocumentIdealWidth = document()->idealWidth(); 70 /* Moreover we should take document margins into account: */ 71 const int iDocumentMargin = document()->documentMargin(); 72 73 /* Compose minimum size-hint on the basis of values above: */ 74 documentSize.setWidth(iDocumentIdealWidth + iDocumentMargin); 75 documentSize.setHeight(documentSize.height() + iDocumentMargin); 76 77 /* Get 40% of the screen-area to limit the resulting hint: */ 78 const QSize screenGeometryDot4 = QApplication::desktop()->screenGeometry(this).size() * .4; 79 80 /* Calculate minimum size-hint which is document-size limited by screen-area: */ 81 QSize mSizeHint = documentSize.boundedTo(screenGeometryDot4); 82 83 /* If there is not enough of vertical space: */ 84 if (mSizeHint.height() < documentSize.height()) 85 { 86 /* We should also take into account vertical scroll-bar extent: */ 87 int iExtent = QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent); 88 mSizeHint.setWidth(mSizeHint.width() + iExtent); 89 } 90 91 /* Always bound cached hint by 40% of current screen-area: */ 92 return mSizeHint; 93 } 94 95 QSize QIDetailsBrowser::sizeHint() const 96 { 97 /* Return minimum size-hint: */ 98 return minimumSizeHint(); 99 } 100 101 void QIDetailsBrowser::updateScrollBars() 102 { 103 /* Some Qt issue prevents scroll-bars from update.. */ 104 Qt::ScrollBarPolicy horizontalPolicy = horizontalScrollBarPolicy(); 105 Qt::ScrollBarPolicy verticalPolicy = verticalScrollBarPolicy(); 106 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 107 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 108 setHorizontalScrollBarPolicy(horizontalPolicy); 109 setVerticalScrollBarPolicy(verticalPolicy); 110 } 111 112 113 QIArrowSplitter::QIArrowSplitter(QWidget *pParent /* = 0 */) 114 : QIWithRetranslateUI<QWidget>(pParent) 115 , m_pMainLayout(0) 116 , m_pSwitchButton(0) 117 , m_pBackButton(0) 118 , m_pNextButton(0) 119 , m_pDetailsBrowser(0) 120 , m_iDetailsIndex(-1) 121 { 122 /* Prepare: */ 123 prepare(); 85 124 } 86 125 87 126 QSize QIArrowSplitter::minimumSizeHint() const 88 127 { 89 /* Get size-hints: */ 90 QSize switchButtonHint = mSwitchButton->minimumSizeHint(); 91 QSize backButtonHint = mBackButton->minimumSizeHint(); 92 QSize nextButtonHint = mNextButton->minimumSizeHint(); 93 int iChildWidthHint = 0; 94 int iChildHeightHint = 0; 95 if (mChild) 96 { 97 QSize childHint = mChild->minimumSize(); 98 if (childHint.isNull()) 99 childHint = mChild->minimumSizeHint(); 100 iChildWidthHint = childHint.width(); 101 iChildHeightHint = childHint.height(); 102 } 128 /* Get minimum size-hints: */ 129 const QSize switchButtonHint = m_pSwitchButton->minimumSizeHint(); 130 const QSize backButtonHint = m_pBackButton->minimumSizeHint(); 131 const QSize nextButtonHint = m_pNextButton->minimumSizeHint(); 132 const QSize detailsBrowserHint = m_pDetailsBrowser->minimumSizeHint(); 103 133 104 134 /* Calculate width-hint: */ 105 135 int iWidthHint = 0; 106 136 iWidthHint += switchButtonHint.width(); 137 iWidthHint += 100 /* button spacing */; 107 138 iWidthHint += backButtonHint.width(); 108 139 iWidthHint += nextButtonHint.width(); 109 if (mChild) 110 iWidthHint = qMax(iWidthHint, iChildWidthHint); 140 iWidthHint = qMax(iWidthHint, detailsBrowserHint.width()); 111 141 112 142 /* Calculate height-hint: */ … … 115 145 iHeightHint = qMax(iHeightHint, backButtonHint.height()); 116 146 iHeightHint = qMax(iHeightHint, nextButtonHint.height()); 117 if (m Child && mChild->isVisible())118 iHeightHint += m MainLayout->spacing() + iChildHeightHint;147 if (m_pDetailsBrowser->isVisible()) 148 iHeightHint += m_pMainLayout->spacing() + detailsBrowserHint.height(); 119 149 120 150 /* Return result: */ … … 122 152 } 123 153 124 void QIArrowSplitter::toggleWidget() 125 { 126 mChild->setVisible (mSwitchButton->isExpanded()); 127 emit sigSizeChanged(); 128 } 129 130 bool QIArrowSplitter::eventFilter (QObject *aObject, QEvent *aEvent) 131 { 132 /* Process only parent window children */ 133 if (!(aObject == window() || window()->children().contains (aObject))) 134 return QWidget::eventFilter (aObject, aEvent); 135 136 /* Do not process QIArrowButtonSwitch & QIArrowButtonPress children */ 137 if (aObject == mSwitchButton || 138 aObject == mBackButton || 139 aObject == mNextButton || 140 mSwitchButton->children().contains (aObject) || 141 mBackButton->children().contains (aObject) || 142 mNextButton->children().contains (aObject)) 143 return QWidget::eventFilter (aObject, aEvent); 144 145 /* Process some keyboard events */ 146 if (aEvent->type() == QEvent::KeyPress) 154 void QIArrowSplitter::setName(const QString &strName) 155 { 156 /* Assign name for the switch-button: */ 157 m_pSwitchButton->setText(strName); 158 /* Update size-hints: */ 159 sltUpdateSizeHints(); 160 } 161 162 void QIArrowSplitter::setDetails(const QStringPairList &details) 163 { 164 /* Assign new details: */ 165 m_details = details; 166 /* Reset the details-list index: */ 167 m_iDetailsIndex = m_details.isEmpty() ? -1 : 0; 168 /* Update navigation-buttons visibility: */ 169 sltUpdateNavigationButtonsVisibility(); 170 /* Update details-browser visibility: */ 171 sltUpdateDetailsBrowserVisibility(); 172 /* Update details: */ 173 updateDetails(); 174 } 175 176 void QIArrowSplitter::sltUpdateSizeHints() 177 { 178 /* Let parent layout know our size-hint changed: */ 179 updateGeometry(); 180 /* Notify parent about our size-hint changed: */ 181 emit sigSizeHintChange(); 182 /* Update details-browser scroll-bars: */ 183 m_pDetailsBrowser->updateScrollBars(); 184 } 185 186 void QIArrowSplitter::sltUpdateNavigationButtonsVisibility() 187 { 188 /* Depending on switch-button state: */ 189 const bool fExpanded = m_pSwitchButton->isExpanded(); 190 /* Update back/next button visibility: */ 191 m_pBackButton->setVisible(m_details.size() > 1 && fExpanded); 192 m_pNextButton->setVisible(m_details.size() > 1 && fExpanded); 193 } 194 195 void QIArrowSplitter::sltUpdateDetailsBrowserVisibility() 196 { 197 /* Update details-browser visibility according switch-button state: */ 198 m_pDetailsBrowser->setVisible(m_details.size() > 0 && m_pSwitchButton->isExpanded()); 199 /* Update size-hints: */ 200 sltUpdateSizeHints(); 201 } 202 203 void QIArrowSplitter::sltSwitchDetailsPageBack() 204 { 205 /* Make sure details-page index feats the bounds: */ 206 AssertReturnVoid(m_iDetailsIndex > 0); 207 /* Decrease details-list index: */ 208 --m_iDetailsIndex; 209 /* Update details: */ 210 updateDetails(); 211 } 212 213 void QIArrowSplitter::sltSwitchDetailsPageNext() 214 { 215 /* Make sure details-page index feats the bounds: */ 216 AssertReturnVoid(m_iDetailsIndex < m_details.size() - 1); 217 /* Increase details-list index: */ 218 ++m_iDetailsIndex; 219 /* Update details: */ 220 updateDetails(); 221 } 222 223 void QIArrowSplitter::prepare() 224 { 225 /* Create main-layout: */ 226 m_pMainLayout = new QVBoxLayout(this); 227 AssertPtrReturnVoid(m_pMainLayout); 147 228 { 148 QKeyEvent *kEvent = static_cast <QKeyEvent*> (aEvent); 149 switch (kEvent->key()) 229 /* Configure main-layout: */ 230 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 231 m_pMainLayout->setSpacing(3); 232 /* Create button-layout: */ 233 QHBoxLayout *pButtonLayout = new QHBoxLayout; 234 AssertPtrReturnVoid(pButtonLayout); 150 235 { 151 case Qt::Key_Plus: 236 /* Configure button-layout: */ 237 pButtonLayout->setContentsMargins(0, 0, 0, 0); 238 pButtonLayout->setSpacing(0); 239 /* Create switch-button: */ 240 m_pSwitchButton = new QIArrowButtonSwitch; 241 AssertPtrReturnVoid(m_pSwitchButton); 152 242 { 153 if (!mSwitchButton->isExpanded()) 154 mSwitchButton->animateClick(); 155 break; 243 /* Configure switch-button: */ 244 m_pSwitchButton->setIconSize(QSize(10, 10)); 245 m_pSwitchButton->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Collapsed, 246 UIIconPool::iconSet(":/arrow_right_10px.png")); 247 m_pSwitchButton->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Expanded, 248 UIIconPool::iconSet(":/arrow_down_10px.png")); 249 connect(m_pSwitchButton, SIGNAL(sigClicked()), this, SLOT(sltUpdateNavigationButtonsVisibility())); 250 connect(m_pSwitchButton, SIGNAL(sigClicked()), this, SLOT(sltUpdateDetailsBrowserVisibility())); 251 /* Add switch-button into button-layout: */ 252 pButtonLayout->addWidget(m_pSwitchButton); 156 253 } 157 case Qt::Key_Minus: 254 /* Add stretch: */ 255 pButtonLayout->addStretch(); 256 /* Create back-button: */ 257 m_pBackButton = new QIArrowButtonPress(QIArrowButtonPress::ButtonType_Back); 258 AssertPtrReturnVoid(m_pBackButton); 158 259 { 159 if (mSwitchButton->isExpanded()) 160 mSwitchButton->animateClick(); 161 break; 260 /* Configure back-button: */ 261 m_pBackButton->setIconSize(QSize(10, 10)); 262 m_pBackButton->setIcon(UIIconPool::iconSet(":/arrow_left_10px.png")); 263 connect(m_pBackButton, SIGNAL(sigClicked()), this, SLOT(sltSwitchDetailsPageBack())); 264 /* Add back-button into button-layout: */ 265 pButtonLayout->addWidget(m_pBackButton); 162 266 } 163 case Qt::Key_PageUp: 267 /* Create next-button: */ 268 m_pNextButton = new QIArrowButtonPress(QIArrowButtonPress::ButtonType_Next); 269 AssertPtrReturnVoid(m_pNextButton); 164 270 { 165 if (mNextButton->isEnabled()) 166 mNextButton->animateClick(); 167 break; 271 /* Configure next-button: */ 272 m_pNextButton->setIconSize(QSize(10, 10)); 273 m_pNextButton->setIcon(UIIconPool::iconSet(":/arrow_right_10px.png")); 274 connect(m_pNextButton, SIGNAL(sigClicked()), this, SLOT(sltSwitchDetailsPageNext())); 275 /* Add next-button into button-layout: */ 276 pButtonLayout->addWidget(m_pNextButton); 168 277 } 169 case Qt::Key_PageDown: 170 { 171 if (mBackButton->isEnabled()) 172 mBackButton->animateClick(); 173 break; 174 } 278 /* Add button layout into main-layout: */ 279 m_pMainLayout->addLayout(pButtonLayout); 280 /* Update navigation-buttons visibility: */ 281 sltUpdateNavigationButtonsVisibility(); 282 } 283 /* Create details-browser: */ 284 m_pDetailsBrowser = new QIDetailsBrowser; 285 AssertPtrReturnVoid(m_pDetailsBrowser); 286 { 287 /* Add details-browser into main-layout: */ 288 m_pMainLayout->addWidget(m_pDetailsBrowser); 289 /* Update details-browser visibility: */ 290 sltUpdateDetailsBrowserVisibility(); 291 /* Update details: */ 292 updateDetails(); 175 293 } 176 294 } 177 295 178 /* Default one handler */ 179 return QWidget::eventFilter (aObject, aEvent); 180 } 181 296 /* Apply size-policy finally: */ 297 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); 298 } 299 300 void QIArrowSplitter::retranslateUi() 301 { 302 /* Update details: */ 303 updateDetails(); 304 } 305 306 void QIArrowSplitter::updateDetails() 307 { 308 /* If details are empty: */ 309 if (m_details.isEmpty()) 310 { 311 /* Make sure details-list index is invalid: */ 312 AssertReturnVoid(m_iDetailsIndex == -1); 313 314 /* Reset name: */ 315 setName(QString()); 316 } 317 /* If details are NOT empty: */ 318 else 319 { 320 /* Make sure details-list index feats the bounds: */ 321 AssertReturnVoid(m_iDetailsIndex >= 0 && m_iDetailsIndex < m_details.size()); 322 323 /* Single page: */ 324 if (m_details.size() == 1) 325 { 326 setName(QApplication::translate("QIMessageBox", "&Details")); 327 m_pBackButton->setEnabled(false); 328 m_pNextButton->setEnabled(false); 329 } 330 /* Multi-paging: */ 331 else if (m_details.size() > 1) 332 { 333 setName(QApplication::translate("QIMessageBox", "&Details (%1 of %2)").arg(m_iDetailsIndex + 1).arg(m_details.size())); 334 m_pBackButton->setEnabled(m_iDetailsIndex > 0); 335 m_pNextButton->setEnabled(m_iDetailsIndex < m_details.size() - 1); 336 } 337 338 /* Update details-browser: */ 339 const QString strFirstPart = m_details[m_iDetailsIndex].first; 340 const QString strSecondPart = m_details[m_iDetailsIndex].second; 341 if (strFirstPart.isEmpty()) 342 m_pDetailsBrowser->setText(strSecondPart); 343 else 344 m_pDetailsBrowser->setText(QString("%1<br>%2").arg(strFirstPart, strSecondPart)); 345 } 346 /* Update size-hints: */ 347 sltUpdateSizeHints(); 348 } 349 350 #include "QIArrowSplitter.moc" 351 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowSplitter.h
r45307 r51873 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QIArrowSplitter class declaration 2 * VBox Qt GUI - QIArrowSplitter class declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2006-201 2Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ QIArrowSplitter_h__20 #define __ QIArrowSplitter_h__17 #ifndef ___QIArrowSplitter_h___ 18 #define ___QIArrowSplitter_h___ 21 19 22 /* VBox includes */ 23 #include "QIArrowButtonPress.h" 24 #include "QIArrowButtonSwitch.h" 20 /* Qt includes: */ 21 #include <QWidget> 25 22 26 /* Qt includes */ 27 #include <QWidget> 28 #include <QHBoxLayout> 23 /* GUI includes: */ 24 #include "QIWithRetranslateUI.h" 29 25 30 /* VBox forwards */ 26 /* Forward declarations: */ 27 class QVBoxLayout; 28 class QIArrowButtonSwitch; 31 29 class QIArrowButtonPress; 32 class QI ArrowButtonSwitch;30 class QIDetailsBrowser; 33 31 34 /* Qt forwards */ 35 class QVBoxLayout; 32 /* Type definitions: */ 33 typedef QPair<QString, QString> QStringPair; 34 typedef QList<QStringPair> QStringPairList; 36 35 37 /** @class QIArrowSplitter 38 * 39 * The QIArrowSplitter class is a folding widget placeholder. 40 * 41 */ 42 class QIArrowSplitter : public QWidget 36 /** QWidget extension 37 * allowing to toggle visibility for any other child widget. */ 38 class QIArrowSplitter : public QIWithRetranslateUI<QWidget> 43 39 { 44 40 Q_OBJECT; 45 41 42 signals: 43 44 /** Notifies listeners about size-hint change: */ 45 void sigSizeHintChange(); 46 46 47 public: 47 48 48 QIArrowSplitter (QWidget *aChild, QWidget *aParent = 0); 49 /** Constructor, passes @a pParent to the QWidget constructor. */ 50 QIArrowSplitter(QWidget *pParent = 0); 49 51 50 void setMultiPaging (bool aMultiPage); 52 /** Returns minimum size-hint. */ 53 QSize minimumSizeHint() const; 51 54 52 void setButtonEnabled (bool aNext, bool aEnabled); 55 /** Defines the @a strName for the switch-button. */ 56 void setName(const QString &strName); 53 57 54 void setName (const QString &aName); 55 56 QSize minimumSizeHint() const; 58 /** Returns splitter details. */ 59 const QStringPairList& details() const { return m_details; } 60 /** Defines splitter @a details. */ 61 void setDetails(const QStringPairList &details); 57 62 58 63 public slots: 59 64 60 void toggleWidget(); 65 /** Updates size-hints. */ 66 void sltUpdateSizeHints(); 61 67 62 signals: 68 /** Updates navigation-buttons visibility. */ 69 void sltUpdateNavigationButtonsVisibility(); 70 /** Updates details-browser visibility. */ 71 void sltUpdateDetailsBrowserVisibility(); 63 72 64 void showBackDetails(); 65 void showNextDetails(); 66 void sigSizeChanged(); 73 /** Navigates through details-list backward. */ 74 void sltSwitchDetailsPageBack(); 75 /** Navigates through details-list forward. */ 76 void sltSwitchDetailsPageNext(); 67 77 68 78 private: 69 79 70 bool eventFilter (QObject *aObject, QEvent *aEvent); 80 /** Prepare routine. */ 81 void prepare(); 71 82 72 QVBoxLayout *mMainLayout; 73 QIArrowButtonSwitch *mSwitchButton; 74 QIArrowButtonPress *mBackButton; 75 QIArrowButtonPress *mNextButton; 76 QWidget *mChild; 83 /** Retranslation routine. 84 * @todo Fix translation context. */ 85 void retranslateUi(); 86 87 /** Updates details. */ 88 void updateDetails(); 89 90 /** Holds the main-layout. */ 91 QVBoxLayout *m_pMainLayout; 92 93 /** Holds the switch-button. */ 94 QIArrowButtonSwitch *m_pSwitchButton; 95 /** Holds the back-button. */ 96 QIArrowButtonPress *m_pBackButton; 97 /** Holds the next-button. */ 98 QIArrowButtonPress *m_pNextButton; 99 100 /** Holds the details-browser. */ 101 QIDetailsBrowser *m_pDetailsBrowser; 102 /** Holds details-list. */ 103 QStringPairList m_details; 104 /** Holds details-list index. */ 105 int m_iDetailsIndex; 77 106 }; 78 107 79 #endif 80 108 #endif /* !___QIArrowSplitter_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp
r50931 r51873 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QIMessageBox class implementation 3 * VBox Qt GUI - QIMessageBox class implementation. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 17 20 18 /* Qt includes: */ 19 #include <QVBoxLayout> 21 20 #include <QHBoxLayout> 22 #include <QVBoxLayout>23 21 #include <QClipboard> 24 22 #include <QLabel> 25 #include <QTextEdit>26 23 #include <QCheckBox> 27 24 #include <QPushButton> … … 30 27 /* GUI includes: */ 31 28 #include "QIMessageBox.h" 32 #include "UIIconPool.h"33 29 #include "QILabel.h" 34 30 #include "QIArrowSplitter.h" 35 31 #include "QIDialogButtonBox.h" 32 #include "UIIconPool.h" 36 33 37 34 /* Other VBox includes: */ 38 #include < VBox/sup.h>39 40 QIMessageBox::QIMessageBox(const QString &str Caption, const QString &strMessage, AlertIconType iconType,35 #include <iprt/assert.h> 36 37 QIMessageBox::QIMessageBox(const QString &strTitle, const QString &strMessage, AlertIconType iconType, 41 38 int iButton1 /* = 0*/, int iButton2 /* = 0*/, int iButton3 /* = 0*/, QWidget *pParent /* = 0*/) 42 39 : QIDialog(pParent) 40 , m_strTitle(strTitle) 41 , m_iconType(iconType) 42 , m_pLabelIcon(0) 43 , m_strMessage(strMessage) 44 , m_pLabelText(0) 45 , m_pFlagCheckBox(0) 46 , m_pDetailsContainer(0) 43 47 , m_iButton1(iButton1) 44 48 , m_iButton2(iButton2) 45 49 , m_iButton3(iButton3) 46 50 , m_iButtonEsc(0) 47 , m_iconType(iconType) 48 , m_strMessage(strMessage) 49 , m_iDetailsIndex(-1) 51 , m_pButton1(0) 52 , m_pButton2(0) 53 , m_pButton3(0) 54 , m_pButtonBox(0) 50 55 , m_fDone(false) 51 56 { 52 /* Set caption: */ 53 setWindowTitle(strCaption); 54 55 /* Prepare content: */ 56 prepareContent(); 57 } 58 59 QString QIMessageBox::detailsText() const 60 { 61 /* Return in html format: */ 62 return m_pDetailsTextView->toHtml(); 57 /* Prepare: */ 58 prepare(); 63 59 } 64 60 65 61 void QIMessageBox::setDetailsText(const QString &strText) 66 62 { 63 /* Make sure details-text is NOT empty: */ 64 AssertReturnVoid(!strText.isEmpty()); 65 67 66 /* Split details into paragraphs: */ 68 AssertMsg(!strText.isEmpty(), ("Details text should NOT be empty!"));69 67 QStringList paragraphs(strText.split("<!--EOP-->", QString::SkipEmptyParts)); 70 AssertMsg(paragraphs.size() != 0, ("There should be at least one paragraph.")); 71 /* Populate details list: */ 68 /* Make sure details-text has at least one paragraph: */ 69 AssertReturnVoid(!paragraphs.isEmpty()); 70 71 /* Enumerate all the paragraphs: */ 72 QStringPairList details; 72 73 foreach (const QString &strParagraph, paragraphs) 73 74 { 75 /* Split each paragraph into pairs: */ 74 76 QStringList parts(strParagraph.split("<!--EOM-->", QString::KeepEmptyParts)); 75 AssertMsg(parts.size() == 2, ("Each paragraph should consist of 2 parts.")); 76 m_details << QPair<QString, QString>(parts[0], parts[1]); 77 } 78 /* Update details container: */ 77 /* Make sure each paragraph consist of 2 parts: */ 78 AssertReturnVoid(parts.size() == 2); 79 /* Append each pair into details-list: */ 80 details << QStringPair(parts[0], parts[1]); 81 } 82 83 /* Pass details-list to details-container: */ 84 m_pDetailsContainer->setDetails(details); 85 /* Update details-container finally: */ 79 86 updateDetailsContainer(); 80 87 } … … 90 97 } 91 98 92 QString QIMessageBox::flagText() const 93 { 94 return m_pFlagCheckBox->text(); 95 } 96 97 void QIMessageBox::setFlagText(const QString &strText) 98 { 99 /* Set check-box text: */ 100 m_pFlagCheckBox->setText(strText); 101 /* And update check-box finally: */ 99 void QIMessageBox::setFlagText(const QString &strFlagText) 100 { 101 /* Pass text to flag check-box: */ 102 m_pFlagCheckBox->setText(strFlagText); 103 /* Update flag check-box finally: */ 102 104 updateCheckBox(); 103 }104 105 QString QIMessageBox::buttonText(int iButton) const106 {107 switch (iButton)108 {109 case 0: if (m_pButton1) return m_pButton1->text(); break;110 case 1: if (m_pButton2) return m_pButton2->text(); break;111 case 2: if (m_pButton3) return m_pButton3->text(); break;112 default: break;113 }114 return QString();115 105 } 116 106 … … 126 116 } 127 117 128 void QIMessageBox::reject() 129 { 130 if (m_iButtonEsc) 131 { 132 QDialog::reject(); 133 setResult(m_iButtonEsc & AlertButtonMask); 134 } 135 } 136 137 void QIMessageBox::copy() const 118 void QIMessageBox::sltUpdateSize() 119 { 120 /* Fix minimum possible size: */ 121 setFixedSize(minimumSizeHint()); 122 } 123 124 void QIMessageBox::sltCopy() const 138 125 { 139 126 /* Create the error string with all errors. First the html version. */ 140 127 QString strError = "<html><body><p>" + m_strMessage + "</p>"; 141 for (int i = 0; i < m_details.size(); ++i)142 strError += m_details.at(i).first + m_details.at(i).second + "<br>";128 foreach (const QStringPair &pair, m_pDetailsContainer->details()) 129 strError += pair.first + pair.second + "<br>"; 143 130 strError += "</body></html>"; 144 131 strError.remove(QRegExp("</+qt>")); 145 132 strError = strError.replace(QRegExp(" "), " "); 146 133 /* Create a new mime data object holding both the html and the plain text version. */ 147 QMimeData *pM d= new QMimeData();148 pM d->setHtml(strError);134 QMimeData *pMimeData = new QMimeData(); 135 pMimeData->setHtml(strError); 149 136 /* Replace all the html entities. */ 150 137 strError = strError.replace(QRegExp("<br>|</tr>"), "\n"); 151 138 strError = strError.replace(QRegExp("</p>"), "\n\n"); 152 139 strError = strError.remove(QRegExp("<[^>]*>")); 153 pM d->setText(strError);140 pMimeData->setText(strError); 154 141 /* Add the mime data to the global clipboard. */ 155 142 QClipboard *pClipboard = QApplication::clipboard(); 156 pClipboard->setMimeData(pMd); 157 } 158 159 void QIMessageBox::detailsBack() 160 { 161 /* Make sure details-page index feats the bounds: */ 162 if (m_iDetailsIndex <= 0) 163 return; 164 165 /* Advance the page index: */ 166 --m_iDetailsIndex; 167 /* Update details-page: */ 168 updateDetailsPage(); 169 } 170 171 void QIMessageBox::detailsNext() 172 { 173 /* Make sure details-page index feats the bounds: */ 174 if (m_iDetailsIndex >= m_details.size() - 1) 175 return; 176 177 /* Advance the page index: */ 178 ++m_iDetailsIndex; 179 /* Update details-page: */ 180 updateDetailsPage(); 181 } 182 183 void QIMessageBox::sltUpdateSize() 184 { 185 /* Reactivate all the layouts: */ 186 QList<QLayout*> layouts = findChildren<QLayout*>(); 187 foreach (QLayout *pLayout, layouts) 188 { 189 pLayout->update(); 190 pLayout->activate(); 191 } 192 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest); 193 /* And fix the size to the minimum possible: */ 194 setFixedSize(minimumSizeHint()); 195 } 196 197 void QIMessageBox::prepareContent() 198 { 143 pClipboard->setMimeData(pMimeData); 144 } 145 146 void QIMessageBox::reject() 147 { 148 if (m_iButtonEsc) 149 { 150 QDialog::reject(); 151 setResult(m_iButtonEsc & AlertButtonMask); 152 } 153 } 154 155 void QIMessageBox::prepare() 156 { 157 /* Set caption: */ 158 setWindowTitle(m_strTitle); 159 199 160 /* Create main-layout: */ 200 161 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 201 { 202 /* Configure layout: */ 162 AssertPtrReturnVoid(pMainLayout); 163 { 164 /* Configure main-layout: */ 203 165 #ifdef Q_WS_MAC 204 166 pMainLayout->setContentsMargins(40, 11, 40, 11); … … 210 172 /* Create top-layout: */ 211 173 QHBoxLayout *pTopLayout = new QHBoxLayout; 174 AssertPtrReturnVoid(pTopLayout); 212 175 { 213 /* Insert into parent layout: */ 214 pMainLayout->addLayout(pTopLayout); 215 /* Configure layout: */ 176 /* Configure top-layout: */ 216 177 pTopLayout->setContentsMargins(0, 0, 0, 0); 217 178 pTopLayout->setSpacing(10); 218 179 /* Create icon-label: */ 219 m_pIconLabel = new QLabel; 180 m_pLabelIcon = new QLabel; 181 AssertPtrReturnVoid(m_pLabelIcon); 220 182 { 221 /* Insert into parent layout: */222 pTopLayout->addWidget(m_pIconLabel);223 /* Configure label: */224 m_p IconLabel->setPixmap(standardPixmap(m_iconType, this));225 m_pIconLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop);226 m_pIconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);183 /* Configure icon-label: */ 184 m_pLabelIcon->setPixmap(standardPixmap(m_iconType, this)); 185 m_pLabelIcon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); 186 m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); 187 /* Add icon-label into top-layout: */ 188 pTopLayout->addWidget(m_pLabelIcon); 227 189 } 228 190 /* Create text-label: */ 229 m_pTextLabel = new QILabel(m_strMessage); 191 m_pLabelText = new QILabel(m_strMessage); 192 AssertPtrReturnVoid(m_pLabelText); 230 193 { 231 /* Insert into parent layout: */ 232 pTopLayout->addWidget(m_pTextLabel); 233 /* Configure label: */ 234 m_pTextLabel->setWordWrap(true); 235 m_pTextLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); 194 /* Configure text-label: */ 195 m_pLabelText->setWordWrap(true); 196 m_pLabelText->setAlignment(Qt::AlignLeft | Qt::AlignTop); 236 197 QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 237 198 sizePolicy.setHeightForWidth(true); 238 m_pTextLabel->setSizePolicy(sizePolicy); 199 m_pLabelText->setSizePolicy(sizePolicy); 200 /* Add text-label into top-layout: */ 201 pTopLayout->addWidget(m_pLabelText); 239 202 } 240 } 241 /* Create details text-view: */ 242 m_pDetailsTextView = new QTextEdit; 243 { 244 /* Configure text-view: */ 245 m_pDetailsTextView->setReadOnly(true); 246 m_pDetailsTextView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); 247 /* Calculate the minimum size dynamically, approx. for 40 chars, 4 lines & 2 <table> margins: */ 248 QFontMetrics fm = m_pDetailsTextView->fontMetrics(); 249 m_pDetailsTextView->setMinimumSize(fm.width ('m') * 40, fm.lineSpacing() * 4 + 4 * 2); 203 /* Add top-layout into main-layout: */ 204 pMainLayout->addLayout(pTopLayout); 250 205 } 251 206 /* Create details-container: */ 252 m_pDetailsContainer = new QIArrowSplitter(m_pDetailsTextView); 207 m_pDetailsContainer = new QIArrowSplitter; 208 AssertPtrReturnVoid(m_pDetailsContainer); 253 209 { 254 /* Insert into parent layout: */ 210 /* Configure container: */ 211 connect(m_pDetailsContainer, SIGNAL(sigSizeHintChange()), this, SLOT(sltUpdateSize())); 212 /* Add details-container into main-layout: */ 255 213 pMainLayout->addWidget(m_pDetailsContainer); 256 /* Configure container: */ 257 connect(m_pDetailsContainer, SIGNAL(showBackDetails()), this, SLOT(detailsBack())); 258 connect(m_pDetailsContainer, SIGNAL(showNextDetails()), this, SLOT(detailsNext())); 259 connect(m_pDetailsContainer, SIGNAL(sigSizeChanged()), this, SLOT(sltUpdateSize())); 260 /* And update container finally: */ 214 /* Update details-container finally: */ 261 215 updateDetailsContainer(); 262 216 } 263 /* Create detailscheck-box: */217 /* Create flag check-box: */ 264 218 m_pFlagCheckBox = new QCheckBox; 219 AssertPtrReturnVoid(m_pFlagCheckBox); 265 220 { 266 /* Insert into parent layout: */ 221 /* Configure flag check-box: */ 222 m_pFlagCheckBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 223 /* Add flag check-box into main-layout: */ 267 224 pMainLayout->addWidget(m_pFlagCheckBox, 0, Qt::AlignHCenter | Qt::AlignVCenter); 268 /* Configure check-box: */ 269 m_pFlagCheckBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 270 /* And update check-box finally: */ 225 /* Update flag check-box finally: */ 271 226 updateCheckBox(); 272 227 } 273 228 /* Create button-box: */ 274 229 m_pButtonBox = new QIDialogButtonBox; 230 AssertPtrReturnVoid(m_pButtonBox); 275 231 { 276 /* Insert into parent layout: */277 pMainLayout->addWidget(m_pButtonBox);278 232 /* Configure button-box: */ 279 233 m_pButtonBox->setCenterButtons(true); 280 234 m_pButton1 = createButton(m_iButton1); 281 235 if (m_pButton1) 282 connect(m_pButton1, SIGNAL(clicked()), SLOT( done1()));236 connect(m_pButton1, SIGNAL(clicked()), SLOT(sltDone1())); 283 237 m_pButton2 = createButton(m_iButton2); 284 238 if (m_pButton2) 285 connect(m_pButton2, SIGNAL(clicked()), SLOT( done2()));239 connect(m_pButton2, SIGNAL(clicked()), SLOT(sltDone2())); 286 240 m_pButton3 = createButton(m_iButton3); 287 241 if (m_pButton3) 288 connect(m_pButton3, SIGNAL(clicked()), SLOT( done3()));242 connect(m_pButton3, SIGNAL(clicked()), SLOT(sltDone3())); 289 243 /* If this is a critical message add a "Copy to clipboard" button: */ 290 244 if (m_iconType == AlertIconType_Critical) … … 292 246 QPushButton *pCopyButton = createButton(AlertButton_Copy); 293 247 pCopyButton->setToolTip(tr("Copy all errors to the clipboard")); 294 connect(pCopyButton, SIGNAL(clicked()), SLOT( copy()));248 connect(pCopyButton, SIGNAL(clicked()), SLOT(sltCopy())); 295 249 } 250 /* Add button-box into main-layout: */ 251 pMainLayout->addWidget(m_pButtonBox); 296 252 } 297 253 } … … 338 294 void QIMessageBox::polishEvent(QShowEvent *pPolishEvent) 339 295 { 340 /* Tune oursize: */341 m_p TextLabel->useSizeHintForWidth(m_pTextLabel->width());342 m_p TextLabel->updateGeometry();296 /* Tune text-label size: */ 297 m_pLabelText->useSizeHintForWidth(m_pLabelText->width()); 298 m_pLabelText->updateGeometry(); 343 299 344 300 /* Call to base-class: */ 345 301 QIDialog::polishEvent(pPolishEvent); 346 302 347 /* Make the size fixed: */348 s etFixedSize(size());303 /* Update size finally: */ 304 sltUpdateSize(); 349 305 } 350 306 … … 359 315 void QIMessageBox::updateDetailsContainer() 360 316 { 361 /* Do we have details to show? */ 362 m_pDetailsContainer->setVisible(!m_details.isEmpty()); 363 364 /* Reset the details page index: */ 365 m_iDetailsIndex = m_details.isEmpty() ? -1 : 0; 366 367 /* Do we have any details? */ 368 if (m_details.isEmpty()) 369 m_pDetailsContainer->setName(QString()); 370 else if (m_details.size() == 1) 371 m_pDetailsContainer->setName(tr("&Details")); 372 else 373 m_pDetailsContainer->setMultiPaging(true); 374 375 /* Do we have any details? */ 376 if (!m_details.isEmpty()) 377 updateDetailsPage(); 378 } 379 380 void QIMessageBox::updateDetailsPage() 381 { 382 /* Make sure details-page index feats the bounds: */ 383 if (m_iDetailsIndex < 0 || m_iDetailsIndex >= m_details.size()) 384 return; 385 386 /* Update message text-label: */ 387 m_pTextLabel->setText(m_strMessage + m_details[m_iDetailsIndex].first); 388 389 /* Update details text-view: */ 390 m_pDetailsTextView->setText(m_details[m_iDetailsIndex].second); 391 392 /* Update details-container: */ 393 if (m_details.size() > 1) 394 { 395 m_pDetailsContainer->setName(tr("&Details (%1 of %2)").arg(m_iDetailsIndex + 1).arg(m_details.size())); 396 m_pDetailsContainer->setButtonEnabled(true, m_iDetailsIndex < m_details.size() - 1); 397 m_pDetailsContainer->setButtonEnabled(false, m_iDetailsIndex > 0); 398 } 317 /* Details-container with details is always visible: */ 318 m_pDetailsContainer->setVisible(!m_pDetailsContainer->details().isEmpty()); 319 /* Update size: */ 320 sltUpdateSize(); 399 321 } 400 322 … … 403 325 /* Flag check-box with text is always visible: */ 404 326 m_pFlagCheckBox->setVisible(!m_pFlagCheckBox->text().isEmpty()); 327 /* Update size: */ 328 sltUpdateSize(); 405 329 } 406 330 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h
r45690 r51873 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QIMessageBox class declaration 2 * VBox Qt GUI - QIMessageBox class declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2006-201 3Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ QIMessageBox_h__20 #define __ QIMessageBox_h__17 #ifndef ___QIMessageBox_h___ 18 #define ___QIMessageBox_h___ 21 19 22 20 /* Qt includes: */ … … 27 25 28 26 /* Forward declarations: */ 29 class QShowEvent;30 class QCloseEvent;31 27 class QLabel; 32 class QTextEdit; 28 class QILabel; 29 class QPushButton; 33 30 class QCheckBox; 34 class QPushButton;35 class QILabel;36 31 class QIArrowSplitter; 37 32 class QIDialogButtonBox; 38 33 39 /* Button type enumerator:*/34 /** Button types. */ 40 35 enum AlertButton 41 36 { … … 49 44 }; 50 45 51 /* Button option enumerator:*/46 /** Button options. */ 52 47 enum AlertButtonOption 53 48 { … … 57 52 }; 58 53 59 /* Alert option enumerator:*/54 /** Alert options. */ 60 55 enum AlertOption 61 56 { … … 65 60 }; 66 61 67 /* Icon type enumerator:*/62 /** Icon types. */ 68 63 enum AlertIconType 69 64 { 70 AlertIconType_NoIcon = QMessageBox::NoIcon,71 AlertIconType_Information = QMessageBox::Information,72 AlertIconType_Warning = QMessageBox::Warning,73 AlertIconType_Critical = QMessageBox::Critical,74 AlertIconType_Question = QMessageBox::Question,65 AlertIconType_NoIcon = QMessageBox::NoIcon, 66 AlertIconType_Information = QMessageBox::Information, 67 AlertIconType_Warning = QMessageBox::Warning, 68 AlertIconType_Critical = QMessageBox::Critical, 69 AlertIconType_Question = QMessageBox::Question, 75 70 AlertIconType_GuruMeditation 76 71 }; 77 72 78 /* QIDialog extension representing GUI alerts: */ 73 /** QIDialog extension 74 * representing GUI alerts. */ 79 75 class QIMessageBox : public QIDialog 80 76 { … … 83 79 public: 84 80 85 /* Constructor: */ 86 QIMessageBox(const QString &strCaption, const QString &strMessage, AlertIconType iconType, 81 /** Constructor, passes @a pParent to the QIDialog constructor. 82 * @param strTitle defines title, 83 * @param strMessage defines message, 84 * @param iconType defines icon-type, 85 * @param iButton1 specifies integer-code for the 1st button, 86 * @param iButton2 specifies integer-code for the 2nd button, 87 * @param iButton3 specifies integer-code for the 3rd button. */ 88 QIMessageBox(const QString &strTitle, const QString &strMessage, AlertIconType iconType, 87 89 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, QWidget *pParent = 0); 88 90 89 /* API: Details stuff: */ 90 QString detailsText() const; 91 /** Defines details-text. */ 91 92 void setDetailsText(const QString &strText); 92 93 93 /* API: Flag stuff:*/94 /** Returns whether flag is checked. */ 94 95 bool flagChecked() const; 96 /** Defines whether flag is @a fChecked. */ 95 97 void setFlagChecked(bool fChecked); 96 QString flagText() const;97 void setFlagText(const QString &str Text);98 /** Defines @a strFlagText. */ 99 void setFlagText(const QString &strFlagText); 98 100 99 /* API: Button stuff: */ 100 QString buttonText(int iButton) const; 101 /** Defines @a iButton @a strText. */ 101 102 void setButtonText(int iButton, const QString &strText); 102 103 103 104 private slots: 104 105 105 /* Handler: Reject slot reimplementation: */106 void reject();106 /** Updates dialog size: */ 107 void sltUpdateSize(); 107 108 108 /* Handlers: Done slot variants for up to three buttons: */ 109 void done1() { m_fDone = true; done(m_iButton1 & AlertButtonMask); } 110 void done2() { m_fDone = true; done(m_iButton2 & AlertButtonMask); } 111 void done3() { m_fDone = true; done(m_iButton3 & AlertButtonMask); } 109 /** Copy details-text. */ 110 void sltCopy() const; 112 111 113 /* Handler: Copy button stuff:*/114 v oid copy() const;112 /** Closes dialog like user would press the Cancel button. */ 113 virtual void reject(); 115 114 116 /* Handlers: Details navigation stuff:*/117 void detailsBack();118 void detailsNext();119 120 /* Handler: Update stuff:*/121 void slt UpdateSize();115 /** Closes dialog like user would press the 1st button. */ 116 void sltDone1() { m_fDone = true; done(m_iButton1 & AlertButtonMask); } 117 /** Closes dialog like user would press the 2nd button. */ 118 void sltDone2() { m_fDone = true; done(m_iButton2 & AlertButtonMask); } 119 /** Closes dialog like user would press the 3rd button. */ 120 void sltDone3() { m_fDone = true; done(m_iButton3 & AlertButtonMask); } 122 121 123 122 private: 124 123 125 /* Helpers: Prepare stuff: */ 126 void prepareContent(); 124 /** Prepare routine. */ 125 void prepare(); 126 127 /** Push-button factory. */ 127 128 QPushButton* createButton(int iButton); 128 129 129 /* Handler: Event-processing stuff:*/130 /** Polish-event handler. */ 130 131 void polishEvent(QShowEvent *pPolishEvent); 132 /** Close-event handler. */ 131 133 void closeEvent(QCloseEvent *pCloseEvent); 132 134 133 /* Helpers: Update stuff:*/135 /** Visibility update routine for details-container. */ 134 136 void updateDetailsContainer(); 135 void updateDetailsPage();137 /** Visibility update routine for check-box. */ 136 138 void updateCheckBox(); 137 139 138 /* Static helper: Standard pixmap stuff:*/140 /** Generates standard pixmap for passed @a iconType using @a pWidget as hint. */ 139 141 static QPixmap standardPixmap(AlertIconType iconType, QWidget *pWidget = 0); 140 142 141 /* Variables: */ 142 int m_iButton1, m_iButton2, m_iButton3, m_iButtonEsc; 143 /** Holds the title. */ 144 QString m_strTitle; 145 146 /** Holds the icon-type. */ 143 147 AlertIconType m_iconType; 144 QLabel *m_pIconLabel; 145 QILabel *m_pTextLabel; 146 QPushButton *m_pButton1, *m_pButton2, *m_pButton3; 148 /** Holds the icon-label instance. */ 149 QLabel *m_pLabelIcon; 150 151 /** Holds the message. */ 152 QString m_strMessage; 153 /** Holds the message-label instance. */ 154 QILabel *m_pLabelText; 155 156 /** Holds the flag check-box instance. */ 147 157 QCheckBox *m_pFlagCheckBox; 158 159 /** Holds the flag details-container instance. */ 148 160 QIArrowSplitter *m_pDetailsContainer; 149 QTextEdit *m_pDetailsTextView; 161 162 /** Holds the integer-code for the 1st button. */ 163 int m_iButton1; 164 /** Holds the integer-code for the 2nd button. */ 165 int m_iButton2; 166 /** Holds the integer-code for the 3rd button. */ 167 int m_iButton3; 168 /** Holds the integer-code of the cancel-button. */ 169 int m_iButtonEsc; 170 /** Holds the 1st button instance. */ 171 QPushButton *m_pButton1; 172 /** Holds the 2nd button instance. */ 173 QPushButton *m_pButton2; 174 /** Holds the 3rd button instance. */ 175 QPushButton *m_pButton3; 176 /** Holds the button-box instance. */ 150 177 QIDialogButtonBox *m_pButtonBox; 151 QString m_strMessage; 152 QList<QPair<QString, QString> > m_details; 153 int m_iDetailsIndex; 178 179 /** Defines whether message was accepted. */ 154 180 bool m_fDone : 1; 155 181 }; 156 182 157 #endif 158 183 #endif /* !___QIMessageBox_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIRichToolButton.cpp
r51279 r51873 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QIRichToolButton class implementation 3 * VBox Qt GUI - QIRichToolButton class declaration. 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 16 */ 19 17 20 /* VBox includes */ 21 #include "QIRichToolButton.h" 22 23 /* Qt includes */ 24 #include <QApplication> 18 /* Qt includes: */ 19 #include <QHBoxLayout> 25 20 #include <QLabel> 26 #include <QHBoxLayout>27 #include <QToolButton>28 #include <QKeyEvent>29 21 #include <QStylePainter> 30 22 #include <QStyleOptionFocusRect> 23 #include <QKeyEvent> 31 24 32 QIRichToolButton::QIRichToolButton (QWidget *aParent) 33 : QWidget(aParent) 34 , mButton(new QIToolButton) 35 , mLabel(new QLabel) 25 /* GUI includes: */ 26 #include "QIRichToolButton.h" 27 #include "QIToolButton.h" 28 29 /* Other VBox includes: */ 30 #include "iprt/assert.h" 31 32 QIRichToolButton::QIRichToolButton(QWidget *pParent) 33 : QWidget(pParent) 34 , m_pButton(0) 35 , m_pLabel(0) 36 36 { 37 init(); 37 /* Prepare: */ 38 prepare(); 38 39 } 39 40 40 QIRichToolButton::QIRichToolButton (const QString &aName, QWidget *aParent) 41 : QWidget(aParent) 42 , mButton(new QIToolButton) 43 , mLabel(new QLabel(aName)) 41 void QIRichToolButton::setIconSize(const QSize &iconSize) 44 42 { 45 init();43 m_pButton->setIconSize(iconSize); 46 44 } 47 45 48 void QIRichToolButton:: init()46 void QIRichToolButton::setIcon(const QIcon &icon) 49 47 { 50 /* Setup itself */ 51 setFocusPolicy (Qt::StrongFocus); 52 53 /* Setup tool-button */ 54 mButton->removeBorder(); 55 mButton->setFocusPolicy (Qt::NoFocus); 56 connect (mButton, SIGNAL (clicked (bool)), this, SLOT (buttonClicked())); 57 58 /* Setup text-label */ 59 mLabel->setBuddy (mButton); 60 mLabel->setStyleSheet ("QLabel {padding: 2px 0px 2px 0px;}"); 61 62 /* Setup main-layout */ 63 QHBoxLayout *mainLayout = new QHBoxLayout (this); 64 mainLayout->setContentsMargins(0, 0, 0, 0); 65 mainLayout->setSpacing (0); 66 mainLayout->addWidget (mButton); 67 mainLayout->addWidget (mLabel); 68 69 /* Install event-filter */ 70 qApp->installEventFilter (this); 48 m_pButton->setIcon(icon); 71 49 } 72 50 73 bool QIRichToolButton::eventFilter (QObject *aObject, QEvent *aEvent)51 void QIRichToolButton::animateClick() 74 52 { 75 /* Process only QIRichToolButton or children */ 76 if (!(aObject == this || children().contains (aObject))) 77 return QWidget::eventFilter (aObject, aEvent); 53 m_pButton->animateClick(); 54 } 78 55 79 /* Process keyboard events */ 80 if (aEvent->type() == QEvent::KeyPress) 56 void QIRichToolButton::setText(const QString &strText) 57 { 58 m_pLabel->setText(strText); 59 } 60 61 void QIRichToolButton::paintEvent(QPaintEvent *pEvent) 62 { 63 /* Draw focus around whole button if focused: */ 64 if (hasFocus()) 81 65 { 82 QKeyEvent *kEvent = static_cast <QKeyEvent*> (aEvent); 83 if (kEvent->key() == Qt::Key_Space) 84 animateClick(); 66 QStylePainter painter(this); 67 QStyleOptionFocusRect option; 68 option.initFrom(this); 69 option.rect = geometry(); 70 painter.drawPrimitive(QStyle::PE_FrameFocusRect, option); 85 71 } 86 72 87 /* Process mouse events */ 88 if ((aEvent->type() == QEvent::MouseButtonPress || 89 aEvent->type() == QEvent::MouseButtonDblClick) 90 && aObject == mLabel) 91 { 92 /* Label click as toggle */ 93 animateClick(); 94 } 95 96 /* Default one handler */ 97 return QWidget::eventFilter (aObject, aEvent); 73 /* Call to base-class: */ 74 QWidget::paintEvent(pEvent); 98 75 } 99 76 100 void QIRichToolButton:: paintEvent (QPaintEvent *aEvent)77 void QIRichToolButton::keyPressEvent(QKeyEvent *pEvent) 101 78 { 102 /* Draw focus around mLabel if focused*/103 if (hasFocus())79 /* Handle different keys: */ 80 switch (pEvent->key()) 104 81 { 105 QStylePainter painter (this); 106 QStyleOptionFocusRect option; 107 option.initFrom (this); 108 option.rect = mLabel->frameGeometry(); 109 painter.drawPrimitive (QStyle::PE_FrameFocusRect, option); 82 /* Animate-click for the Space key: */ 83 case Qt::Key_Space: return animateClick(); 84 default: break; 110 85 } 111 QWidget::paintEvent (aEvent); 86 /* Call to base-class: */ 87 QWidget::keyPressEvent(pEvent); 112 88 } 113 89 90 void QIRichToolButton::mousePressEvent(QMouseEvent *pEvent) 91 { 92 /* Animate-click: */ 93 animateClick(); 94 } 95 96 void QIRichToolButton::prepare() 97 { 98 /* Enable string focus: */ 99 setFocusPolicy(Qt::StrongFocus); 100 101 /* Create main-layout: */ 102 QHBoxLayout *pMainLayout = new QHBoxLayout(this); 103 AssertPtrReturnVoid(pMainLayout); 104 { 105 /* Configure main-layout: */ 106 pMainLayout->setContentsMargins(0, 0, 0, 0); 107 pMainLayout->setSpacing(0); 108 /* Create tool-button: */ 109 m_pButton = new QIToolButton; 110 AssertPtrReturnVoid(m_pButton); 111 { 112 /* Configure tool-button: */ 113 m_pButton->removeBorder(); 114 m_pButton->setFocusPolicy(Qt::NoFocus); 115 connect(m_pButton, SIGNAL(clicked(bool)), this, SLOT(sltButtonClicked())); 116 connect(m_pButton, SIGNAL(clicked(bool)), this, SIGNAL(sigClicked())); 117 /* Add tool-button into main-layout: */ 118 pMainLayout->addWidget(m_pButton); 119 } 120 /* Create text-label: */ 121 m_pLabel = new QLabel; 122 AssertPtrReturnVoid(m_pLabel); 123 { 124 /* Configure text-label: */ 125 m_pLabel->setBuddy(m_pButton); 126 m_pLabel->setStyleSheet("QLabel {padding: 2px 0px 2px 0px;}"); 127 /* Add text-label into main-layout: */ 128 pMainLayout->addWidget(m_pLabel); 129 } 130 } 131 } 132 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIRichToolButton.h
r51279 r51873 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QIRichToolButton class declaration 2 * VBox Qt GUI - QIRichToolButton class declaration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2006-201 0Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ QIRichToolButton_h__20 #define __ QIRichToolButton_h__17 #ifndef ___QIRichToolButton_h___ 18 #define ___QIRichToolButton_h___ 21 19 22 20 /* Qt includes: */ 23 #include <QLabel>24 21 #include <QWidget> 25 22 26 /* GUI includes: */ 27 #include "QIToolButton.h" 23 /* Forward declarations: */ 24 class QIToolButton; 25 class QLabel; 28 26 29 /** @class QIRichToolButton 30 * 31 * The QIRichToolButton class is a tool-button with separate text-label. 32 * 33 */ 27 /** QWidget extension 28 * representing tool-button with separate text-label. */ 34 29 class QIRichToolButton : public QWidget 35 30 { 36 31 Q_OBJECT; 37 32 33 signals: 34 35 /** Notifies listeners about button click. */ 36 void sigClicked(); 37 38 38 public: 39 39 40 QIRichToolButton (QWidget *aParent = 0);41 QIRichToolButton (const QString &aName, QWidget *aParent = 0);40 /** Constructor, passes @a pParent to the QWidget constructor. */ 41 QIRichToolButton(QWidget *pParent = 0); 42 42 43 void animateClick() { mButton->animateClick(); } 44 void setText (const QString &aName) { mLabel->setText (aName); } 45 QString text() const { return mLabel->text(); } 43 /** Defines tool-button @a iconSize. */ 44 void setIconSize(const QSize &iconSize); 45 /** Defines tool-button @a icon. */ 46 void setIcon(const QIcon &icon); 47 /** Animates tool-button click: */ 48 void animateClick(); 46 49 47 signals: 48 49 void clicked(); 50 /** Defines text-label @a strText. */ 51 void setText(const QString &strText); 50 52 51 53 protected slots: 52 54 53 virtual void buttonClicked() { emit clicked(); } 55 /** Button-click handler. */ 56 virtual void sltButtonClicked() {} 54 57 55 58 protected: 56 59 57 void init(); 58 bool eventFilter (QObject *aObject, QEvent *aEvent); 59 void paintEvent (QPaintEvent *aEvent); 60 /** Paint-event handler. */ 61 virtual void paintEvent(QPaintEvent *pEvent); 62 /** Key-press-event handler. */ 63 virtual void keyPressEvent(QKeyEvent *pEvent); 64 /** Mouse-press-event handler. */ 65 virtual void mousePressEvent(QMouseEvent *pEvent); 60 66 61 QIToolButton *mButton; 62 QLabel *mLabel; 67 private: 68 69 /** Prepare routine. */ 70 void prepare(); 71 72 /** Holds the tool-button instance. */ 73 QIToolButton *m_pButton; 74 /** Holds the text-label instance. */ 75 QLabel *m_pLabel; 76 /** Holds the text for text-label instance. */ 77 QString m_strName; 63 78 }; 64 79 65 #endif 66 80 #endif /* !___QIRichToolButton_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp
r51280 r51873 60 60 m_pMACEditor->setMinimumWidthByText(QString().fill('0', 12)); 61 61 m_pMACButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png")); 62 m_pAdvancedArrow->setIconSize(QSize(10, 10)); 63 m_pAdvancedArrow->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Collapsed, 64 UIIconPool::iconSet(":/arrow_right_10px.png")); 65 m_pAdvancedArrow->setIconForButtonState(QIArrowButtonSwitch::ButtonState_Expanded, 66 UIIconPool::iconSet(":/arrow_down_10px.png")); 62 67 63 68 /* Setup connections: */ … … 66 71 connect(m_pAdapterNameCombo, SIGNAL(activated(int)), this, SLOT(sltHandleAlternativeNameChange())); 67 72 connect(m_pAdapterNameCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(sltHandleAlternativeNameChange())); 68 connect(m_pAdvancedArrow, SIGNAL( clicked()), this, SLOT(sltHandleAdvancedButtonStateChange()));73 connect(m_pAdvancedArrow, SIGNAL(sigClicked()), this, SLOT(sltHandleAdvancedButtonStateChange())); 69 74 connect(m_pMACButton, SIGNAL(clicked()), this, SLOT(sltGenerateMac())); 70 75 connect(m_pPortForwardingButton, SIGNAL(clicked()), this, SLOT(sltOpenPortForwardingDlg()));
Note:
See TracChangeset
for help on using the changeset viewer.