VirtualBox

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

Last change on this file since 92733 was 92638, checked in by vboxsync, 3 years ago

FE/Qt: bugref:9371. More changes on file maanager code in order to use it as a machine tool.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: UIFileManagerDialog.cpp 92638 2021-11-30 07:20:00Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIFileManagerDialog class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-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 <QPushButton>
20#include <QVBoxLayout>
21
22/* GUI includes: */
23#include "UIDesktopWidgetWatchdog.h"
24#include "UIExtraDataManager.h"
25#include "UIIconPool.h"
26#include "UIFileManager.h"
27#include "UIFileManagerDialog.h"
28#include "UICommon.h"
29#ifdef VBOX_WS_MAC
30# include "VBoxUtils-darwin.h"
31#endif
32
33
34/*********************************************************************************************************************************
35* Class UIFileManagerDialogFactory implementation. *
36*********************************************************************************************************************************/
37
38UIFileManagerDialogFactory::UIFileManagerDialogFactory(UIActionPool *pActionPool, const CMachine &comMachine)
39 : m_pActionPool(pActionPool)
40 , m_comMachine(comMachine)
41{
42}
43
44
45UIFileManagerDialogFactory::UIFileManagerDialogFactory()
46 : m_pActionPool(0)
47 , m_comMachine(CMachine())
48{
49}
50
51void UIFileManagerDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
52{
53 pDialog = new UIFileManagerDialog(pCenterWidget, m_pActionPool, m_comMachine);
54}
55
56
57/*********************************************************************************************************************************
58* Class UIFileManagerDialog implementation. *
59*********************************************************************************************************************************/
60
61UIFileManagerDialog::UIFileManagerDialog(QWidget *pCenterWidget,
62 UIActionPool *pActionPool,
63 const CMachine &comMachine)
64 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
65 , m_pActionPool(pActionPool)
66 , m_comMachine(comMachine)
67{
68}
69
70UIFileManagerDialog::~UIFileManagerDialog()
71{
72 UIFileManager *pWidget = qobject_cast<UIFileManager*>(widget());
73 if (pWidget)
74 pWidget->setDialogBeingClosed(true);
75}
76
77void UIFileManagerDialog::retranslateUi()
78{
79 if (!m_comMachine.isNull())
80 setWindowTitle(UIFileManager::tr("%1 - File Manager").arg(m_comMachine.GetName()));
81 else
82 setWindowTitle(UIFileManager::tr("File Manager"));
83
84 /* Retranslate button box buttons: */
85 if (button(ButtonType_Close))
86 {
87 button(ButtonType_Close)->setText(UIFileManager::tr("Close"));
88 button(ButtonType_Close)->setStatusTip(UIFileManager::tr("Close dialog without saving"));
89 button(ButtonType_Close)->setShortcut(Qt::Key_Escape);
90 button(ButtonType_Close)->setToolTip(UIFileManager::tr("Reset Changes (%1)").arg(button(ButtonType_Close)->shortcut().toString()));
91 }
92
93 if (button(ButtonType_Help))
94 {
95 button(ButtonType_Help)->setText(UIFileManager::tr("Help"));
96 button(ButtonType_Help)->setStatusTip(UIFileManager::tr("Show dialog help"));
97 button(ButtonType_Help)->setShortcut(QKeySequence::HelpContents);
98 button(ButtonType_Help)->setToolTip(UIFileManager::tr("Show Help (%1)").arg(button(ButtonType_Help)->shortcut().toString()));
99 }
100}
101
102void UIFileManagerDialog::configure()
103{
104 /* Apply window icons: */
105 setWindowIcon(UIIconPool::iconSetFull(":/file_manager_32px.png", ":/file_manager_16px.png"));
106}
107
108void UIFileManagerDialog::configureCentralWidget()
109{
110 /* Create widget: */
111 UIFileManager *pWidget = new UIFileManager(EmbedTo_Dialog, m_pActionPool,
112 m_comMachine, this, true);
113
114 if (pWidget)
115 {
116 /* Configure widget: */
117 setWidget(pWidget);
118 setWidgetMenu(pWidget->menu());
119#ifdef VBOX_WS_MAC
120 setWidgetToolbar(pWidget->toolbar());
121#endif
122 connect(pWidget, &UIFileManager::sigSetCloseButtonShortCut,
123 this, &UIFileManagerDialog::sltSetCloseButtonShortCut);
124
125 /* Add into layout: */
126 centralWidget()->layout()->addWidget(pWidget);
127 }
128}
129
130void UIFileManagerDialog::finalize()
131{
132 /* Apply language settings: */
133 retranslateUi();
134 manageEscapeShortCut();
135}
136
137void UIFileManagerDialog::loadSettings()
138{
139 /* Load geometry from extradata: */
140 const QRect geo = gEDataManager->fileManagerDialogGeometry(this, centerWidget());
141 LogRel2(("GUI: UIFileManagerDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
142 geo.x(), geo.y(), geo.width(), geo.height()));
143 restoreGeometry(geo);
144}
145
146void UIFileManagerDialog::saveSettings()
147{
148 /* Save geometry to extradata: */
149 const QRect geo = currentGeometry();
150 LogRel2(("GUI: UIFileManagerDialog: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
151 geo.x(), geo.y(), geo.width(), geo.height()));
152 gEDataManager->setFileManagerDialogGeometry(geo, isCurrentlyMaximized());
153}
154
155bool UIFileManagerDialog::shouldBeMaximized() const
156{
157 return gEDataManager->fileManagerDialogShouldBeMaximized();
158}
159
160void UIFileManagerDialog::sltSetCloseButtonShortCut(QKeySequence shortcut)
161{
162 if (!closeEmitted() && button(ButtonType_Close))
163 button(ButtonType_Close)->setShortcut(shortcut);
164}
165
166void UIFileManagerDialog::manageEscapeShortCut()
167{
168 UIFileManager *pWidget = qobject_cast<UIFileManager*>(widget());
169 if (!pWidget)
170 return;
171 pWidget->manageEscapeShortCut();
172}
Note: See TracBrowser for help on using the repository browser.

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