VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.cpp@ 88805

Last change on this file since 88805 was 88805, checked in by vboxsync, 4 years ago

FE/Qt: bugref:10003: Reworking Chooser, Details and Tools panes backgrounds to have native colors.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: UITools.cpp 88805 2021-04-30 13:29:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UITools class implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2021 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QVBoxLayout>
20
21/* GUI includes: */
22#include "UICommon.h"
23#include "UITools.h"
24#include "UIToolsModel.h"
25#include "UIToolsView.h"
26#include "UIVirtualBoxManagerWidget.h"
27
28
29UITools::UITools(UIVirtualBoxManagerWidget *pParent /* = 0 */)
30 : QWidget(pParent, Qt::Popup)
31 , m_pManagerWidget(pParent)
32 , m_pMainLayout(0)
33 , m_pToolsModel(0)
34 , m_pToolsView(0)
35{
36 prepare();
37}
38
39UIActionPool *UITools::actionPool() const
40{
41 return managerWidget()->actionPool();
42}
43
44void UITools::setToolsClass(UIToolClass enmClass)
45{
46 m_pToolsModel->setToolsClass(enmClass);
47}
48
49UIToolClass UITools::toolsClass() const
50{
51 return m_pToolsModel->toolsClass();
52}
53
54void UITools::setToolsType(UIToolType enmType)
55{
56 m_pToolsModel->setToolsType(enmType);
57}
58
59UIToolType UITools::toolsType() const
60{
61 return m_pToolsModel->toolsType();
62}
63
64UIToolType UITools::lastSelectedToolGlobal() const
65{
66 return m_pToolsModel->lastSelectedToolGlobal();
67}
68
69UIToolType UITools::lastSelectedToolMachine() const
70{
71 return m_pToolsModel->lastSelectedToolMachine();
72}
73
74void UITools::setToolClassEnabled(UIToolClass enmClass, bool fEnabled)
75{
76 m_pToolsModel->setToolClassEnabled(enmClass, fEnabled);
77}
78
79bool UITools::toolClassEnabled(UIToolClass enmClass) const
80{
81 return m_pToolsModel->toolClassEnabled(enmClass);
82}
83
84void UITools::setRestrictedToolTypes(const QList<UIToolType> &types)
85{
86 m_pToolsModel->setRestrictedToolTypes(types);
87}
88
89QList<UIToolType> UITools::restrictedToolTypes() const
90{
91 return m_pToolsModel->restrictedToolTypes();
92}
93
94UIToolsItem *UITools::currentItem() const
95{
96 return m_pToolsModel->currentItem();
97}
98
99void UITools::prepare()
100{
101 /* Prepare everything: */
102 prepareContents();
103 prepareConnections();
104
105 /* Init model finally: */
106 initModel();
107}
108
109void UITools::prepareContents()
110{
111 /* Setup own layout rules: */
112 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
113
114 /* Prepare main-layout: */
115 m_pMainLayout = new QVBoxLayout(this);
116 if (m_pMainLayout)
117 {
118 m_pMainLayout->setContentsMargins(1, 1, 1, 1);
119 m_pMainLayout->setSpacing(0);
120
121 /* Prepare model: */
122 prepareModel();
123 }
124}
125
126void UITools::prepareModel()
127{
128 /* Prepare model: */
129 m_pToolsModel = new UIToolsModel(this);
130 if (m_pToolsModel)
131 prepareView();
132}
133
134void UITools::prepareView()
135{
136 AssertPtrReturnVoid(m_pToolsModel);
137 AssertPtrReturnVoid(m_pMainLayout);
138
139 /* Prepare view: */
140 m_pToolsView = new UIToolsView(this);
141 if (m_pToolsView)
142 {
143 m_pToolsView->setScene(m_pToolsModel->scene());
144 m_pToolsView->show();
145 setFocusProxy(m_pToolsView);
146
147 /* Add into layout: */
148 m_pMainLayout->addWidget(m_pToolsView);
149 }
150}
151
152void UITools::prepareConnections()
153{
154 /* Model connections: */
155 connect(m_pToolsModel, &UIToolsModel::sigItemMinimumWidthHintChanged,
156 m_pToolsView, &UIToolsView::sltMinimumWidthHintChanged);
157 connect(m_pToolsModel, &UIToolsModel::sigItemMinimumHeightHintChanged,
158 m_pToolsView, &UIToolsView::sltMinimumHeightHintChanged);
159 connect(m_pToolsModel, &UIToolsModel::sigFocusChanged,
160 m_pToolsView, &UIToolsView::sltFocusChanged);
161
162 /* View connections: */
163 connect(m_pToolsView, &UIToolsView::sigResized,
164 m_pToolsModel, &UIToolsModel::sltHandleViewResized);
165}
166
167void UITools::initModel()
168{
169 m_pToolsModel->init();
170}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette