- Timestamp:
- Feb 16, 2009 6:04:09 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox.qrc
r16743 r16802 319 319 <file alias="monitor.png">images/monitor.png</file> 320 320 <file alias="monitor_glossy.png">images/monitor_glossy.png</file> 321 <file alias="arrow_right_10px.png">images/arrow_right_10px.png</file> 322 <file alias="arrow_left_10px.png">images/arrow_left_10px.png</file> 323 <file alias="arrow_up_10px.png">images/arrow_up_10px.png</file> 324 <file alias="arrow_down_10px.png">images/arrow_down_10px.png</file> 321 325 <file alias="name_16px.png">images/name_16px.png</file> 322 326 <file alias="os_type_16px.png">images/os_type_16px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/include/QIMessageBox.h
r14440 r16802 24 24 #define __QIMessageBox_h__ 25 25 26 /* VBox includes */ 26 27 #include "QIDialog.h" 27 28 … … 31 32 #include <QTextEdit> 32 33 34 /* VBox forwards */ 35 class QIArrowSplitter; 36 class QIDialogButtonBox; 33 37 class QILabel; 38 39 /* Qt forwards */ 40 class QCloseEvent; 34 41 class QLabel; 35 42 class QPushButton; 36 43 class QSpacerItem; 37 class QCloseEvent; 44 class QToolButton; 45 class QVBoxLayout; 38 46 39 class QIDialogButtonBox; 47 /** @class QIArrowSplitter 48 * 49 * The QIArrowSplitter class is a folding widget placeholder. 50 * It is declared here until moved into separate file in case 51 * of it will be used somewhere except problem-reporter dialog. 52 */ 53 class QIArrowSplitter : public QWidget 54 { 55 Q_OBJECT; 40 56 57 public: 58 59 QIArrowSplitter (QWidget *aParent = 0); 60 61 void addWidget (const QString &aName, QWidget *aWidget); 62 63 public slots: 64 65 void toggleWidget(); 66 67 private: 68 69 QVBoxLayout *mMainLayout; 70 QList <QToolButton*> mButtonsList; 71 QList <QWidget*> mWidgetsList; 72 }; 73 74 /** @class QIMessageBox 75 * 76 * The QIMessageBox class is a message box similar to QMessageBox. 77 * It partly implements the QMessageBox interface and adds some enhanced 78 * functionality. 79 */ 41 80 class QIMessageBox : public QIDialog 42 81 { 43 Q_OBJECT 82 Q_OBJECT; 44 83 45 84 public: … … 92 131 93 132 void closeEvent (QCloseEvent *e); 133 void showEvent (QShowEvent *e); 94 134 95 135 private slots: … … 109 149 QCheckBox *mFlagCB, *mFlagCB_Main, *mFlagCB_Details; 110 150 QWidget *mDetailsVBox; 151 QIArrowSplitter *mDetailsSplitter; 111 152 QTextEdit *mDetailsText; 112 153 QSpacerItem *mSpacer; 113 154 QIDialogButtonBox *mButtonBox; 114 155 bool mWasDone : 1; 156 bool mWasPolished : 1; 115 157 }; 116 158 -
trunk/src/VBox/Frontends/VirtualBox/src/QIMessageBox.cpp
r15887 r16802 21 21 */ 22 22 23 /* VBox includes */ 23 24 #include "VBoxDefs.h" 24 25 #include "VBoxGlobal.h" 25 26 26 #include "QIMessageBox.h" 27 27 #include "QILabel.h" … … 33 33 /* Qt includes */ 34 34 #include <QHBoxLayout> 35 #include <QLabel> 35 36 #include <QPushButton> 36 #include <QLabel> 37 #include <QToolButton> 38 39 /** @class QIArrowSplitter 40 * 41 * The QIArrowSplitter class is a folding widget placeholder. 42 */ 43 QIArrowSplitter::QIArrowSplitter (QWidget *aParent) 44 : QWidget (aParent) 45 , mMainLayout (new QVBoxLayout (this)) 46 { 47 VBoxGlobal::setLayoutMargin (mMainLayout, 0); 48 } 49 50 void QIArrowSplitter::addWidget (const QString &aName, QWidget *aWidget) 51 { 52 /* Creating arrow tool-button */ 53 QToolButton *arrowButton = new QToolButton(); 54 connect (arrowButton, SIGNAL (clicked (bool)), this, SLOT (toggleWidget())); 55 arrowButton->setIcon (VBoxGlobal::iconSet (":/arrow_right_10px.png")); 56 arrowButton->setFocusPolicy (Qt::StrongFocus); 57 arrowButton->setAutoRaise (true); 58 arrowButton->setFixedSize (14, 16); 59 mButtonsList.append (arrowButton); 60 61 /* Creating description label */ 62 QLabel *descriptionLabel = new QLabel (aName); 63 descriptionLabel->setBuddy (arrowButton); 64 65 mWidgetsList.append (aWidget); 66 67 QHBoxLayout *lineLayout = new QHBoxLayout(); 68 lineLayout->addWidget (arrowButton); 69 lineLayout->addWidget (descriptionLabel); 70 71 mMainLayout->insertWidget (0, aWidget); 72 mMainLayout->insertLayout (0, lineLayout); 73 } 74 75 void QIArrowSplitter::toggleWidget() 76 { 77 QToolButton *arrowButton = qobject_cast <QToolButton*> (sender()); 78 79 /* Toggle all or the specified arrow & related widget */ 80 foreach (QToolButton *itemButton, mButtonsList) 81 { 82 if ((itemButton == arrowButton) || (!arrowButton)) 83 { 84 QWidget *relatedWidget = mWidgetsList [mButtonsList.indexOf (itemButton)]; 85 Assert (relatedWidget); 86 relatedWidget->setVisible (!relatedWidget->isVisible()); 87 itemButton->setIcon (VBoxGlobal::iconSet (relatedWidget->isVisible() ? 88 ":/arrow_down_10px.png" : ":/arrow_right_10px.png")); 89 } 90 } 91 92 /* Update full layout system of message window */ 93 QList <QLayout*> layouts = findChildren <QLayout*> (); 94 foreach (QLayout *item, layouts) 95 { 96 item->update(); 97 item->activate(); 98 } 99 100 /* Update main layout of message window at last */ 101 window()->layout()->update(); 102 window()->layout()->activate(); 103 104 /* Now resize window to minimum possible size */ 105 window()->resize (window()->minimumSizeHint()); 106 qApp->processEvents(); 107 window()->setFixedSize (window()->size()); 108 } 37 109 38 110 /** @class QIMessageBox … … 51 123 : QIDialog (aParent) 52 124 , mWasDone (false) 125 , mWasPolished (false) 53 126 { 54 127 #ifdef Q_WS_MAC … … 99 172 hLayout->addLayout (messageVBoxLayout); 100 173 101 mTextLabel = new QILabel (aText , NULL);174 mTextLabel = new QILabel (aText); 102 175 mTextLabel->setAlignment (Qt::AlignLeft | Qt::AlignTop); 103 176 mTextLabel->setWordWrap (true); 104 QSizePolicy sp (QSizePolicy:: Minimum, QSizePolicy::Minimum);177 QSizePolicy sp (QSizePolicy::Preferred, QSizePolicy::Preferred); 105 178 sp.setHeightForWidth (true); 106 179 mTextLabel->setSizePolicy (sp); 107 mTextLabel->adjustSize();108 mTextLabel->setMinimumWidth (mTextLabel->sizeHint().width());109 180 messageVBoxLayout->addWidget (mTextLabel); 110 181 … … 116 187 layout->addWidget (mDetailsVBox); 117 188 118 QVBoxLayout* detailsVBoxLayout = new QVBoxLayout (mDetailsVBox);189 QVBoxLayout* detailsVBoxLayout = new QVBoxLayout (mDetailsVBox); 119 190 VBoxGlobal::setLayoutMargin (detailsVBoxLayout, 0); 120 191 detailsVBoxLayout->setSpacing (10); 192 193 mDetailsSplitter = new QIArrowSplitter(); 194 detailsVBoxLayout->addWidget (mDetailsSplitter); 121 195 122 196 mDetailsText = new QTextEdit(); … … 130 204 mDetailsText->setSizePolicy (QSizePolicy::Expanding, 131 205 QSizePolicy::MinimumExpanding); 132 detailsVBoxLayout->addWidget (mDetailsText);206 mDetailsSplitter->addWidget (tr ("&Details:"), mDetailsText); 133 207 134 208 mFlagCB_Details = new QCheckBox(); … … 157 231 /* this call is a must -- it initializes mFlagCB and mSpacer */ 158 232 setDetailsShown (false); 159 160 /* Set fixed size */161 setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);162 233 } 163 234 … … 379 450 } 380 451 452 void QIMessageBox::showEvent (QShowEvent *e) 453 { 454 if (!mWasPolished) 455 { 456 /* Polishing sub-widgets */ 457 resize (minimumSizeHint()); 458 qApp->processEvents(); 459 mTextLabel->setMinimumWidth (mTextLabel->width()); 460 mTextLabel->updateSizeHint(); 461 mDetailsSplitter->toggleWidget(); 462 mWasPolished = true; 463 } 464 465 QIDialog::showEvent (e); 466 } 467 381 468 void QIMessageBox::reject() 382 469 {
Note:
See TracChangeset
for help on using the changeset viewer.