VirtualBox

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

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

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UITools.cpp 82968 2020-02-04 10:35:17Z 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
91UIToolsItem *UITools::currentItem() const
92{
93 return m_pToolsModel->currentItem();
94}
95
96void UITools::prepare()
97{
98 /* Prepare palette: */
99 preparePalette();
100 /* Prepare layout: */
101 prepareLayout();
102 /* Prepare model: */
103 prepareModel();
104 /* Prepare view: */
105 prepareView();
106 /* Prepare connections: */
107 prepareConnections();
108
109 /* Load settings: */
110 loadSettings();
111}
112
113void UITools::preparePalette()
114{
115 /* Setup palette: */
116 setAutoFillBackground(true);
117 QPalette pal = palette();
118 QColor bodyColor = pal.color(QPalette::Active, QPalette::Midlight).darker(110);
119 pal.setColor(QPalette::Window, bodyColor);
120 setPalette(pal);
121}
122
123void UITools::prepareLayout()
124{
125 /* Setup own layout rules: */
126 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
127
128 /* Create main-layout: */
129 m_pMainLayout = new QVBoxLayout(this);
130 if (m_pMainLayout)
131 {
132 /* Configure main-layout: */
133 m_pMainLayout->setContentsMargins(1, 1, 1, 1);
134 m_pMainLayout->setSpacing(0);
135 }
136}
137
138void UITools::prepareModel()
139{
140 /* Create Tools-model: */
141 m_pToolsModel = new UIToolsModel(this);
142}
143
144void UITools::prepareView()
145{
146 /* Setup Tools-view: */
147 m_pToolsView = new UIToolsView(this);
148 if (m_pToolsView)
149 {
150 /* Configure Tools-view. */
151 m_pToolsView->setScene(m_pToolsModel->scene());
152 m_pToolsView->show();
153 setFocusProxy(m_pToolsView);
154
155 /* Add into layout: */
156 m_pMainLayout->addWidget(m_pToolsView);
157 }
158}
159
160void UITools::prepareConnections()
161{
162 /* Setup Tools-model connections: */
163 connect(m_pToolsModel, &UIToolsModel::sigItemMinimumWidthHintChanged,
164 m_pToolsView, &UIToolsView::sltMinimumWidthHintChanged);
165 connect(m_pToolsModel, &UIToolsModel::sigItemMinimumHeightHintChanged,
166 m_pToolsView, &UIToolsView::sltMinimumHeightHintChanged);
167 connect(m_pToolsModel, &UIToolsModel::sigFocusChanged,
168 m_pToolsView, &UIToolsView::sltFocusChanged);
169
170 /* Setup Tools-view connections: */
171 connect(m_pToolsView, &UIToolsView::sigResized,
172 m_pToolsModel, &UIToolsModel::sltHandleViewResized);
173}
174
175void UITools::loadSettings()
176{
177 /* Init model: */
178 m_pToolsModel->init();
179}
180
181void UITools::saveSettings()
182{
183 /* Deinit model: */
184 m_pToolsModel->deinit();
185}
186
187void UITools::cleanup()
188{
189 /* Save settings: */
190 saveSettings();
191}
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