Changeset 100952 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 23, 2023 8:41:01 AM (20 months ago)
- svn:sync-xref-src-repo-rev:
- 158890
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.cpp
r100951 r100952 44 44 /* Other VBox includes: */ 45 45 #include <iprt/assert.h> 46 47 48 46 49 47 UIDialogPanelBase::UIDialogPanelBase(QWidget *pParent /* = 0 */) … … 118 116 return m_pTabWidget->currentIndex(); 119 117 } 120 121 UIDialogPanel::UIDialogPanel(QWidget *pParent /* = 0 */)122 : QIWithRetranslateUI<QWidget>(pParent)123 , m_pMainLayout(0)124 , m_pCloseButton(0)125 {126 prepare();127 }128 129 void UIDialogPanel::setCloseButtonShortCut(QKeySequence shortCut)130 {131 if (!m_pCloseButton)132 return;133 m_pCloseButton->setShortcut(shortCut);134 }135 136 QHBoxLayout* UIDialogPanel::mainLayout()137 {138 return m_pMainLayout;139 }140 141 void UIDialogPanel::prepare()142 {143 prepareWidgets();144 prepareConnections();145 retranslateUi();146 }147 148 void UIDialogPanel::prepareWidgets()149 {150 m_pMainLayout = new QHBoxLayout(this);151 if (m_pMainLayout)152 {153 #ifdef VBOX_WS_MAC154 m_pMainLayout->setContentsMargins(5 /* since there is always a button */, 0, 10 /* standard */, 0);155 m_pMainLayout->setSpacing(10);156 #else157 m_pMainLayout->setContentsMargins(qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2, 0,158 qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 2,159 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) / 2);160 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));161 #endif162 }163 m_pCloseButton = new QIToolButton;164 if (m_pCloseButton)165 {166 m_pCloseButton->setIcon(UIIconPool::iconSet(":/close_16px.png"));167 m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft);168 }169 }170 171 void UIDialogPanel::prepareConnections()172 {173 if (m_pCloseButton)174 connect(m_pCloseButton, &QIToolButton::clicked, this, &UIDialogPanel::hide);175 }176 177 void UIDialogPanel::retranslateUi()178 {179 if (m_pCloseButton)180 m_pCloseButton->setToolTip(tr("Close the pane"));181 }182 183 void UIDialogPanel::showEvent(QShowEvent *pEvent)184 {185 QWidget::showEvent(pEvent);186 }187 188 void UIDialogPanel::hideEvent(QHideEvent *pEvent)189 {190 /* Get focused widget: */191 QWidget *pFocus = QApplication::focusWidget();192 /* If focus-widget is valid and child-widget of search-panel,193 * focus next child-widget in line: */194 if (pFocus && pFocus->parent() == this)195 focusNextPrevChild(true);196 emit sigHidePanel(this);197 198 QWidget::hideEvent(pEvent);199 }200 201 void UIDialogPanel::addVerticalSeparator()202 {203 QFrame *pSeparator = new QFrame();204 if (!pSeparator)205 return;206 pSeparator->setFrameShape(QFrame::VLine);207 pSeparator->setFrameShadow(QFrame::Sunken);208 mainLayout()->addWidget(pSeparator);209 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.h
r100951 r100952 70 70 }; 71 71 72 /** QWidget extension acting as the base class for all the dialog panels like file manager, logviewer etc. */73 class SHARED_LIBRARY_STUFF UIDialogPanel : public QIWithRetranslateUI<QWidget>74 {75 Q_OBJECT;76 77 public:78 79 UIDialogPanel(QWidget *pParent = 0);80 void setCloseButtonShortCut(QKeySequence shortCut);81 virtual QString panelName() const = 0;82 83 signals:84 85 void sigHidePanel(UIDialogPanel *pPanel);86 void sigShowPanel(UIDialogPanel *pPanel);87 88 protected:89 90 virtual void prepare();91 virtual void prepareWidgets();92 virtual void prepareConnections();93 94 /* Access functions for children classes. */95 QHBoxLayout* mainLayout();96 97 /** Handles the translation event. */98 void retranslateUi() RT_OVERRIDE;99 100 /** Handles the Qt show @a pEvent. */101 void showEvent(QShowEvent *pEvent) RT_OVERRIDE;102 /** Handles the Qt hide @a pEvent. */103 void hideEvent(QHideEvent *pEvent) RT_OVERRIDE;104 void addVerticalSeparator();105 106 private:107 108 QHBoxLayout *m_pMainLayout;109 QIToolButton *m_pCloseButton;110 };111 112 72 #endif /* !FEQT_INCLUDED_SRC_globals_UIDialogPanel_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r100951 r100952 1106 1106 void UIVMLogViewerWidget::manageEscapeShortCut() 1107 1107 { 1108 / * if there is no visible panels give the escape shortcut to parent dialog: */1109 if (m_visiblePanelsList.isEmpty())1110 {1111 emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape));1112 return;1113 }1114 / * Take the escape shortcut from the dialog: */1115 emit sigSetCloseButtonShortCut(QKeySequence());1116 / * Just loop thru the visible panel list and set the esc key to the1117 panel which made visible latest */1118 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)1119 {1120 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());1121 }1122 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));1108 // /* if there is no visible panels give the escape shortcut to parent dialog: */ 1109 // if (m_visiblePanelsList.isEmpty()) 1110 // { 1111 // emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 1112 // return; 1113 // } 1114 // /* Take the escape shortcut from the dialog: */ 1115 // emit sigSetCloseButtonShortCut(QKeySequence()); 1116 // /* Just loop thru the visible panel list and set the esc key to the 1117 // panel which made visible latest */ 1118 // for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i) 1119 // { 1120 // m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 1121 // } 1122 // m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 1123 1123 } 1124 1124
Note:
See TracChangeset
for help on using the changeset viewer.