VirtualBox

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

Last change on this file since 83023 was 83023, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9653: VirtualBox Manager: Details pane: A possibility to hide unwanted tools.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: UITools.cpp 83023 2020-02-07 17:06:29Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UITools class implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2020 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 "UITools.h"
23#include "UIToolsModel.h"
24#include "UIToolsView.h"
25#include "UIVirtualBoxManagerWidget.h"
26#include "UICommon.h"
27
28
29UITools::UITools(UIVirtualBoxManagerWidget *pParent)
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 prepare();
38}
39
40UITools::~UITools()
41{
42 /* Cleanup: */
43 cleanup();
44}
45
46UIActionPool *UITools::actionPool() const
47{
48 return managerWidget()->actionPool();
49}
50
51void UITools::setToolsClass(UIToolClass enmClass)
52{
53 m_pToolsModel->setToolsClass(enmClass);
54}
55
56UIToolClass UITools::toolsClass() const
57{
58 return m_pToolsModel->toolsClass();
59}
60
61void UITools::setToolsType(UIToolType enmType)
62{
63 m_pToolsModel->setToolsType(enmType);
64}
65
66UIToolType UITools::toolsType() const
67{
68 return m_pToolsModel->toolsType();
69}
70
71UIToolType UITools::lastSelectedToolGlobal() const
72{
73 return m_pToolsModel->lastSelectedToolGlobal();
74}
75
76UIToolType UITools::lastSelectedToolMachine() const
77{
78 return m_pToolsModel->lastSelectedToolMachine();
79}
80
81void UITools::setToolsEnabled(UIToolClass enmClass, bool fEnabled)
82{
83 m_pToolsModel->setToolsEnabled(enmClass, fEnabled);
84}
85
86bool UITools::areToolsEnabled(UIToolClass enmClass) const
87{
88 return m_pToolsModel->areToolsEnabled(enmClass);
89}
90
91void UITools::setRestrictedToolTypes(const QList<UIToolType> &types)
92{
93 m_pToolsModel->setRestrictedToolTypes(types);
94}
95
96QList<UIToolType> UITools::restrictedToolTypes() const
97{
98 return m_pToolsModel->restrictedToolTypes();
99}
100
101UIToolsItem *UITools::currentItem() const
102{
103 return m_pToolsModel->currentItem();
104}
105
106void UITools::prepare()
107{
108 /* Prepare palette: */
109 preparePalette();
110 /* Prepare layout: */
111 prepareLayout();
112 /* Prepare model: */
113 prepareModel();
114 /* Prepare view: */
115 prepareView();
116 /* Prepare connections: */
117 prepareConnections();
118
119 /* Load settings: */
120 loadSettings();
121}
122
123void UITools::preparePalette()
124{
125 /* Setup palette: */
126 setAutoFillBackground(true);
127 QPalette pal = palette();
128 QColor bodyColor = pal.color(QPalette::Active, QPalette::Midlight).darker(110);
129 pal.setColor(QPalette::Window, bodyColor);
130 setPalette(pal);
131}
132
133void UITools::prepareLayout()
134{
135 /* Setup own layout rules: */
136 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
137
138 /* Create main-layout: */
139 m_pMainLayout = new QVBoxLayout(this);
140 if (m_pMainLayout)
141 {
142 /* Configure main-layout: */
143 m_pMainLayout->setContentsMargins(1, 1, 1, 1);
144 m_pMainLayout->setSpacing(0);
145 }
146}
147
148void UITools::prepareModel()
149{
150 /* Create Tools-model: */
151 m_pToolsModel = new UIToolsModel(this);
152}
153
154void UITools::prepareView()
155{
156 /* Setup Tools-view: */
157 m_pToolsView = new UIToolsView(this);
158 if (m_pToolsView)
159 {
160 /* Configure Tools-view. */
161 m_pToolsView->setScene(m_pToolsModel->scene());
162 m_pToolsView->show();
163 setFocusProxy(m_pToolsView);
164
165 /* Add into layout: */
166 m_pMainLayout->addWidget(m_pToolsView);
167 }
168}
169
170void UITools::prepareConnections()
171{
172 /* Setup Tools-model connections: */
173 connect(m_pToolsModel, &UIToolsModel::sigItemMinimumWidthHintChanged,
174 m_pToolsView, &UIToolsView::sltMinimumWidthHintChanged);
175 connect(m_pToolsModel, &UIToolsModel::sigItemMinimumHeightHintChanged,
176 m_pToolsView, &UIToolsView::sltMinimumHeightHintChanged);
177 connect(m_pToolsModel, &UIToolsModel::sigFocusChanged,
178 m_pToolsView, &UIToolsView::sltFocusChanged);
179
180 /* Setup Tools-view connections: */
181 connect(m_pToolsView, &UIToolsView::sigResized,
182 m_pToolsModel, &UIToolsModel::sltHandleViewResized);
183}
184
185void UITools::loadSettings()
186{
187 /* Init model: */
188 m_pToolsModel->init();
189}
190
191void UITools::saveSettings()
192{
193 /* Deinit model: */
194 m_pToolsModel->deinit();
195}
196
197void UITools::cleanup()
198{
199 /* Save settings: */
200 saveSettings();
201}
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