Changeset 68354 in vbox for trunk/src/VBox
- Timestamp:
- Aug 9, 2017 2:50:26 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIDesktopPane.cpp
r68353 r68354 26 26 # include <QLabel> 27 27 # include <QPainter> 28 # include <QScrollArea> 29 # include <QScrollBar> 28 30 # include <QStackedWidget> 29 31 # include <QStyle> … … 48 50 class QPaintEvent; 49 51 class QResizeEvent; 52 class QScrollArea; 50 53 class QString; 51 54 class QUuid; … … 54 57 55 58 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 59 60 61 /** QScrollArea extension to wrap a tools pane. */ 62 class UIToolScrollArea : public QScrollArea 63 { 64 Q_OBJECT; 65 66 public: 67 68 /** Constructs scroll-area passing @a pParent to the base-class. */ 69 UIToolScrollArea(QWidget *pParent = 0); 70 71 protected: 72 73 /** Holds the minimum widget size. */ 74 virtual QSize minimumSizeHint() const /* override */; 75 }; 56 76 57 77 … … 202 222 QAction *m_pRefreshAction; 203 223 224 /** Holds the tools pane scroll-area instance. */ 225 UIToolScrollArea *m_pScrollArea; 204 226 /** Holds the tools pane instance. */ 205 QWidget *m_pToolsPane;227 QWidget *m_pToolsPane; 206 228 /** Holds the tools pane widget layout instance. */ 207 QVBoxLayout *m_pLayoutWidget;229 QVBoxLayout *m_pLayoutWidget; 208 230 /** Holds the tools pane text label instance. */ 209 QLabel *m_pLabelToolsPaneText;231 QLabel *m_pLabelToolsPaneText; 210 232 /** Holds the tools pane icon label instance. */ 211 QLabel *m_pLabelToolsPaneIcon;233 QLabel *m_pLabelToolsPaneIcon; 212 234 }; 235 236 237 /********************************************************************************************************************************* 238 * Class UIToolScrollArea implementation. * 239 *********************************************************************************************************************************/ 240 241 UIToolScrollArea::UIToolScrollArea(QWidget *pParent /* = 0 */) 242 : QScrollArea(pParent) 243 { 244 } 245 246 QSize UIToolScrollArea::minimumSizeHint() const 247 { 248 // WORKAROUND: 249 // The idea is simple, hold the minimum size hint to 250 // avoid horizontal scroll-bar, but allow vertical one. 251 return widget() 252 ? QSize( widget()->minimumSizeHint().width() 253 + verticalScrollBar()->height(), 254 200 /* what about something more dynamical? */) 255 : QScrollArea::minimumSizeHint(); 256 } 213 257 214 258 … … 510 554 m_pLabelDescription->setAttribute(Qt::WA_TransparentForMouseEvents); 511 555 m_pLabelDescription->setWordWrap(true); 512 m_pLabelDescription->setMinimumWidth( 400);556 m_pLabelDescription->setMinimumWidth(315); 513 557 m_pLabelDescription->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); 514 558 m_pLabelDescription->setText(m_strDescription); … … 542 586 , m_pErrBox(0), m_pErrLabel(0), m_pErrText(0) 543 587 , m_pRefreshButton(0), m_pRefreshAction(pRefreshAction) 544 , m_p ToolsPane(0), m_pLayoutWidget(0), m_pLabelToolsPaneText(0), m_pLabelToolsPaneIcon(0)588 , m_pScrollArea(0), m_pToolsPane(0), m_pLayoutWidget(0), m_pLabelToolsPaneText(0), m_pLabelToolsPaneIcon(0) 545 589 { 546 590 /* Translate finally: */ … … 693 737 { 694 738 /* Do nothing if already exists: */ 695 if (m_p ToolsPane)739 if (m_pScrollArea) 696 740 return; 697 741 698 /* Create tool pane: */ 699 m_pToolsPane = new QWidget; 700 AssertPtrReturnVoid(m_pToolsPane); 701 { 702 /* Create main layout: */ 703 QVBoxLayout *pMainLayout = new QVBoxLayout(m_pToolsPane); 704 AssertPtrReturnVoid(pMainLayout); 742 /* Create scroll-area: */ 743 m_pScrollArea = new UIToolScrollArea; 744 AssertPtrReturnVoid(m_pScrollArea); 745 { 746 /* Configure scroll-area: */ 747 m_pScrollArea->setFrameShape(QFrame::NoFrame); 748 m_pScrollArea->setWidgetResizable(true); 749 750 /* Create tool pane: */ 751 m_pToolsPane = new QWidget; 752 AssertPtrReturnVoid(m_pToolsPane); 705 753 { 706 /* Create welcomelayout: */707 Q HBoxLayout *pLayoutWelcome = new QHBoxLayout;708 AssertPtrReturnVoid(p LayoutWelcome);754 /* Create main layout: */ 755 QVBoxLayout *pMainLayout = new QVBoxLayout(m_pToolsPane); 756 AssertPtrReturnVoid(pMainLayout); 709 757 { 710 /* Invent pixel metric: */ 711 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 712 713 /* Configure layout: */ 714 pLayoutWelcome->setContentsMargins(iMetric, 0, 0, 0); 715 pLayoutWelcome->setSpacing(10); 716 717 /* Create welcome text label: */ 718 m_pLabelToolsPaneText = new UILabel; 719 AssertPtrReturnVoid(m_pLabelToolsPaneText); 758 /* Create welcome layout: */ 759 QHBoxLayout *pLayoutWelcome = new QHBoxLayout; 760 AssertPtrReturnVoid(pLayoutWelcome); 720 761 { 721 /* Configure label: */ 722 m_pLabelToolsPaneText->setWordWrap(true); 723 m_pLabelToolsPaneText->setMinimumWidth(200); 724 m_pLabelToolsPaneText->setAlignment(Qt::AlignLeading | Qt::AlignTop); 725 m_pLabelToolsPaneText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); 762 /* Invent pixel metric: */ 763 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 764 765 /* Configure layout: */ 766 pLayoutWelcome->setContentsMargins(iMetric, 0, 0, 0); 767 pLayoutWelcome->setSpacing(10); 768 769 /* Create welcome text label: */ 770 m_pLabelToolsPaneText = new UILabel; 771 AssertPtrReturnVoid(m_pLabelToolsPaneText); 772 { 773 /* Configure label: */ 774 m_pLabelToolsPaneText->setWordWrap(true); 775 m_pLabelToolsPaneText->setMinimumWidth(160); 776 m_pLabelToolsPaneText->setAlignment(Qt::AlignLeading | Qt::AlignTop); 777 m_pLabelToolsPaneText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); 778 779 /* Add into layout: */ 780 pLayoutWelcome->addWidget(m_pLabelToolsPaneText); 781 } 782 783 /* Create welcome picture label: */ 784 m_pLabelToolsPaneIcon = new QLabel; 785 AssertPtrReturnVoid(m_pLabelToolsPaneIcon); 786 { 787 /* Configure label: */ 788 m_pLabelToolsPaneIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 789 790 /* Add into layout: */ 791 pLayoutWelcome->addWidget(m_pLabelToolsPaneIcon); 792 pLayoutWelcome->setAlignment(m_pLabelToolsPaneIcon, Qt::AlignHCenter | Qt::AlignTop); 793 } 726 794 727 795 /* Add into layout: */ 728 p LayoutWelcome->addWidget(m_pLabelToolsPaneText);796 pMainLayout->addLayout(pLayoutWelcome); 729 797 } 730 798 731 /* Create w elcome picture label: */732 m_pLa belToolsPaneIcon = new QLabel;733 AssertPtrReturnVoid(m_pLa belToolsPaneIcon);799 /* Create widget layout: */ 800 m_pLayoutWidget = new QVBoxLayout; 801 AssertPtrReturnVoid(m_pLayoutWidget); 734 802 { 735 /* Configure label: */736 m_pLabelToolsPaneIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);737 738 803 /* Add into layout: */ 739 pLayoutWelcome->addWidget(m_pLabelToolsPaneIcon); 740 pLayoutWelcome->setAlignment(m_pLabelToolsPaneIcon, Qt::AlignHCenter | Qt::AlignTop); 804 pMainLayout->addLayout(m_pLayoutWidget); 741 805 } 742 806 743 /* Add into layout: */744 pMainLayout->add Layout(pLayoutWelcome);807 /* Add stretch: */ 808 pMainLayout->addStretch(); 745 809 } 746 810 747 /* Create widget layout: */ 748 m_pLayoutWidget = new QVBoxLayout; 749 AssertPtrReturnVoid(m_pLayoutWidget); 750 { 751 /* Add into layout: */ 752 pMainLayout->addLayout(m_pLayoutWidget); 753 } 754 755 /* Add stretch: */ 756 pMainLayout->addStretch(); 811 /* Add into the scroll-area: */ 812 m_pScrollArea->setWidget(m_pToolsPane); 757 813 } 758 814 759 815 /* Add into the stack: */ 760 addWidget(m_p ToolsPane);816 addWidget(m_pScrollArea); 761 817 } 762 818 }
Note:
See TracChangeset
for help on using the changeset viewer.