VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerDialog.cpp@ 100887

Last change on this file since 100887 was 98103, checked in by vboxsync, 2 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: 6.4 KB
Line 
1/* $Id: UIFileManagerDialog.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIFileManagerDialog class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QPushButton>
30#include <QVBoxLayout>
31
32/* GUI includes: */
33#include "UIDesktopWidgetWatchdog.h"
34#include "UIExtraDataManager.h"
35#include "UIIconPool.h"
36#include "UIFileManager.h"
37#include "UIFileManagerDialog.h"
38#include "UICommon.h"
39#ifdef VBOX_WS_MAC
40# include "VBoxUtils-darwin.h"
41#endif
42
43/* COM includes: */
44#include "COMEnums.h"
45#include "CMachine.h"
46
47/*********************************************************************************************************************************
48* Class UIFileManagerDialogFactory implementation. *
49*********************************************************************************************************************************/
50
51UIFileManagerDialogFactory::UIFileManagerDialogFactory(UIActionPool *pActionPool, const QUuid &uMachineId, const QString &strMachineName)
52 : m_pActionPool(pActionPool)
53 , m_uMachineId(uMachineId)
54 , m_strMachineName(strMachineName)
55{
56}
57
58
59UIFileManagerDialogFactory::UIFileManagerDialogFactory()
60 : m_pActionPool(0)
61 , m_uMachineId(QUuid())
62{
63}
64
65void UIFileManagerDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
66{
67 pDialog = new UIFileManagerDialog(pCenterWidget, m_pActionPool, m_uMachineId, m_strMachineName);
68}
69
70
71/*********************************************************************************************************************************
72* Class UIFileManagerDialog implementation. *
73*********************************************************************************************************************************/
74
75UIFileManagerDialog::UIFileManagerDialog(QWidget *pCenterWidget,
76 UIActionPool *pActionPool,
77 const QUuid &uMachineId,
78 const QString &strMachineName)
79 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
80 , m_pActionPool(pActionPool)
81 , m_uMachineId(uMachineId)
82 , m_strMachineName(strMachineName)
83{
84}
85
86UIFileManagerDialog::~UIFileManagerDialog()
87{
88}
89
90void UIFileManagerDialog::retranslateUi()
91{
92 if (!m_strMachineName.isEmpty())
93 setWindowTitle(UIFileManager::tr("%1 - File Manager").arg(m_strMachineName));
94 else
95 setWindowTitle(UIFileManager::tr("File Manager"));
96
97 /* Retranslate button box buttons: */
98 if (button(ButtonType_Close))
99 {
100 button(ButtonType_Close)->setText(UIFileManager::tr("Close"));
101 button(ButtonType_Close)->setStatusTip(UIFileManager::tr("Close dialog without saving"));
102 button(ButtonType_Close)->setShortcut(Qt::Key_Escape);
103 button(ButtonType_Close)->setToolTip(UIFileManager::tr("Reset Changes (%1)").arg(button(ButtonType_Close)->shortcut().toString()));
104 }
105
106 if (button(ButtonType_Help))
107 {
108 button(ButtonType_Help)->setText(UIFileManager::tr("Help"));
109 button(ButtonType_Help)->setStatusTip(UIFileManager::tr("Show dialog help"));
110 button(ButtonType_Help)->setShortcut(QKeySequence::HelpContents);
111 button(ButtonType_Help)->setToolTip(UIFileManager::tr("Show Help (%1)").arg(button(ButtonType_Help)->shortcut().toString()));
112 }
113}
114
115void UIFileManagerDialog::configure()
116{
117 /* Apply window icons: */
118 setWindowIcon(UIIconPool::iconSetFull(":/file_manager_32px.png", ":/file_manager_16px.png"));
119}
120
121void UIFileManagerDialog::configureCentralWidget()
122{
123 CMachine comMachine;
124 CVirtualBox vbox = uiCommon().virtualBox();
125 if (!vbox.isNull() && !m_uMachineId.isNull())
126 comMachine = vbox.FindMachine(m_uMachineId.toString());
127 /* Create widget: */
128 UIFileManager *pWidget = new UIFileManager(EmbedTo_Dialog, m_pActionPool,
129 comMachine, this, true);
130
131 if (pWidget)
132 {
133 /* Configure widget: */
134 setWidget(pWidget);
135 setWidgetMenu(pWidget->menu());
136#ifdef VBOX_WS_MAC
137 setWidgetToolbar(pWidget->toolbar());
138#endif
139 connect(pWidget, &UIFileManager::sigSetCloseButtonShortCut,
140 this, &UIFileManagerDialog::sltSetCloseButtonShortCut);
141
142 /* Add into layout: */
143 centralWidget()->layout()->addWidget(pWidget);
144 }
145}
146
147void UIFileManagerDialog::finalize()
148{
149 /* Apply language settings: */
150 retranslateUi();
151 manageEscapeShortCut();
152}
153
154void UIFileManagerDialog::loadSettings()
155{
156 /* Load geometry from extradata: */
157 const QRect geo = gEDataManager->fileManagerDialogGeometry(this, centerWidget());
158 LogRel2(("GUI: UIFileManagerDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
159 geo.x(), geo.y(), geo.width(), geo.height()));
160 restoreGeometry(geo);
161}
162
163void UIFileManagerDialog::saveSettings()
164{
165 /* Save geometry to extradata: */
166 const QRect geo = currentGeometry();
167 LogRel2(("GUI: UIFileManagerDialog: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
168 geo.x(), geo.y(), geo.width(), geo.height()));
169 gEDataManager->setFileManagerDialogGeometry(geo, isCurrentlyMaximized());
170}
171
172bool UIFileManagerDialog::shouldBeMaximized() const
173{
174 return gEDataManager->fileManagerDialogShouldBeMaximized();
175}
176
177void UIFileManagerDialog::sltSetCloseButtonShortCut(QKeySequence shortcut)
178{
179 if (!closeEmitted() && button(ButtonType_Close))
180 button(ButtonType_Close)->setShortcut(shortcut);
181}
182
183void UIFileManagerDialog::manageEscapeShortCut()
184{
185 UIFileManager *pWidget = qobject_cast<UIFileManager*>(widget());
186 if (!pWidget)
187 return;
188 pWidget->manageEscapeShortCut();
189}
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