1 | /* $Id: UIFileManagerOptionsPanel.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIVMLogViewer 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 <QHBoxLayout>
|
---|
30 | #include <QCheckBox>
|
---|
31 |
|
---|
32 | /* GUI includes: */
|
---|
33 | #include "QIToolButton.h"
|
---|
34 | #include "UIFileManager.h"
|
---|
35 | #include "UIFileManagerOptionsPanel.h"
|
---|
36 |
|
---|
37 | UIFileManagerOptionsPanel::UIFileManagerOptionsPanel(QWidget *pParent, UIFileManagerOptions *pFileManagerOptions)
|
---|
38 | : UIDialogPanel(pParent)
|
---|
39 | , m_pListDirectoriesOnTopCheckBox(0)
|
---|
40 | , m_pDeleteConfirmationCheckBox(0)
|
---|
41 | , m_pHumanReabableSizesCheckBox(0)
|
---|
42 | , m_pShowHiddenObjectsCheckBox(0)
|
---|
43 | , m_pFileManagerOptions(pFileManagerOptions)
|
---|
44 | {
|
---|
45 | prepare();
|
---|
46 | }
|
---|
47 |
|
---|
48 | QString UIFileManagerOptionsPanel::panelName() const
|
---|
49 | {
|
---|
50 | return "OptionsPanel";
|
---|
51 | }
|
---|
52 |
|
---|
53 | void UIFileManagerOptionsPanel::update()
|
---|
54 | {
|
---|
55 | if (!m_pFileManagerOptions)
|
---|
56 | return;
|
---|
57 |
|
---|
58 | if (m_pListDirectoriesOnTopCheckBox)
|
---|
59 | {
|
---|
60 | m_pListDirectoriesOnTopCheckBox->blockSignals(true);
|
---|
61 | m_pListDirectoriesOnTopCheckBox->setChecked(m_pFileManagerOptions->fListDirectoriesOnTop);
|
---|
62 | m_pListDirectoriesOnTopCheckBox->blockSignals(false);
|
---|
63 | }
|
---|
64 |
|
---|
65 | if (m_pDeleteConfirmationCheckBox)
|
---|
66 | {
|
---|
67 | m_pDeleteConfirmationCheckBox->blockSignals(true);
|
---|
68 | m_pDeleteConfirmationCheckBox->setChecked(m_pFileManagerOptions->fAskDeleteConfirmation);
|
---|
69 | m_pDeleteConfirmationCheckBox->blockSignals(false);
|
---|
70 | }
|
---|
71 |
|
---|
72 | if (m_pHumanReabableSizesCheckBox)
|
---|
73 | {
|
---|
74 | m_pHumanReabableSizesCheckBox->blockSignals(true);
|
---|
75 | m_pHumanReabableSizesCheckBox->setChecked(m_pFileManagerOptions->fShowHumanReadableSizes);
|
---|
76 | m_pHumanReabableSizesCheckBox->blockSignals(false);
|
---|
77 | }
|
---|
78 |
|
---|
79 | if (m_pShowHiddenObjectsCheckBox)
|
---|
80 | {
|
---|
81 | m_pShowHiddenObjectsCheckBox->blockSignals(true);
|
---|
82 | m_pShowHiddenObjectsCheckBox->setChecked(m_pFileManagerOptions->fShowHiddenObjects);
|
---|
83 | m_pShowHiddenObjectsCheckBox->blockSignals(false);
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | void UIFileManagerOptionsPanel::prepareWidgets()
|
---|
88 | {
|
---|
89 | if (!mainLayout())
|
---|
90 | return;
|
---|
91 |
|
---|
92 | m_pListDirectoriesOnTopCheckBox = new QCheckBox;
|
---|
93 | if (m_pListDirectoriesOnTopCheckBox)
|
---|
94 | mainLayout()->addWidget(m_pListDirectoriesOnTopCheckBox, 0, Qt::AlignLeft);
|
---|
95 |
|
---|
96 | m_pDeleteConfirmationCheckBox = new QCheckBox;
|
---|
97 | if (m_pDeleteConfirmationCheckBox)
|
---|
98 | mainLayout()->addWidget(m_pDeleteConfirmationCheckBox, 0, Qt::AlignLeft);
|
---|
99 |
|
---|
100 | m_pHumanReabableSizesCheckBox = new QCheckBox;
|
---|
101 | if (m_pHumanReabableSizesCheckBox)
|
---|
102 | mainLayout()->addWidget(m_pHumanReabableSizesCheckBox, 0, Qt::AlignLeft);
|
---|
103 |
|
---|
104 | m_pShowHiddenObjectsCheckBox = new QCheckBox;
|
---|
105 | if (m_pShowHiddenObjectsCheckBox)
|
---|
106 | mainLayout()->addWidget(m_pShowHiddenObjectsCheckBox, 0, Qt::AlignLeft);
|
---|
107 |
|
---|
108 | /* Set initial checkbox status wrt. options: */
|
---|
109 | if (m_pFileManagerOptions)
|
---|
110 | {
|
---|
111 | if (m_pListDirectoriesOnTopCheckBox)
|
---|
112 | m_pListDirectoriesOnTopCheckBox->setChecked(m_pFileManagerOptions->fListDirectoriesOnTop);
|
---|
113 | if (m_pDeleteConfirmationCheckBox)
|
---|
114 | m_pDeleteConfirmationCheckBox->setChecked(m_pFileManagerOptions->fAskDeleteConfirmation);
|
---|
115 | if (m_pHumanReabableSizesCheckBox)
|
---|
116 | m_pHumanReabableSizesCheckBox->setChecked(m_pFileManagerOptions->fShowHumanReadableSizes);
|
---|
117 | if (m_pShowHiddenObjectsCheckBox)
|
---|
118 | m_pShowHiddenObjectsCheckBox->setChecked(m_pFileManagerOptions->fShowHiddenObjects);
|
---|
119 |
|
---|
120 | }
|
---|
121 | retranslateUi();
|
---|
122 | mainLayout()->addStretch(2);
|
---|
123 | }
|
---|
124 |
|
---|
125 | void UIFileManagerOptionsPanel::sltListDirectoryCheckBoxToogled(bool bChecked)
|
---|
126 | {
|
---|
127 | if (!m_pFileManagerOptions)
|
---|
128 | return;
|
---|
129 | m_pFileManagerOptions->fListDirectoriesOnTop = bChecked;
|
---|
130 | emit sigOptionsChanged();
|
---|
131 | }
|
---|
132 |
|
---|
133 | void UIFileManagerOptionsPanel::sltDeleteConfirmationCheckBoxToogled(bool bChecked)
|
---|
134 | {
|
---|
135 | if (!m_pFileManagerOptions)
|
---|
136 | return;
|
---|
137 | m_pFileManagerOptions->fAskDeleteConfirmation = bChecked;
|
---|
138 | emit sigOptionsChanged();
|
---|
139 | }
|
---|
140 |
|
---|
141 | void UIFileManagerOptionsPanel::sltHumanReabableSizesCheckBoxToogled(bool bChecked)
|
---|
142 | {
|
---|
143 | if (!m_pFileManagerOptions)
|
---|
144 | return;
|
---|
145 | m_pFileManagerOptions->fShowHumanReadableSizes = bChecked;
|
---|
146 | emit sigOptionsChanged();
|
---|
147 | }
|
---|
148 |
|
---|
149 | void UIFileManagerOptionsPanel::sltShowHiddenObjectsCheckBoxToggled(bool bChecked)
|
---|
150 | {
|
---|
151 | if (!m_pFileManagerOptions)
|
---|
152 | return;
|
---|
153 | m_pFileManagerOptions->fShowHiddenObjects = bChecked;
|
---|
154 | emit sigOptionsChanged();
|
---|
155 | }
|
---|
156 |
|
---|
157 | void UIFileManagerOptionsPanel::prepareConnections()
|
---|
158 | {
|
---|
159 | if (m_pListDirectoriesOnTopCheckBox)
|
---|
160 | connect(m_pListDirectoriesOnTopCheckBox, &QCheckBox::toggled,
|
---|
161 | this, &UIFileManagerOptionsPanel::sltListDirectoryCheckBoxToogled);
|
---|
162 | if (m_pDeleteConfirmationCheckBox)
|
---|
163 | connect(m_pDeleteConfirmationCheckBox, &QCheckBox::toggled,
|
---|
164 | this, &UIFileManagerOptionsPanel::sltDeleteConfirmationCheckBoxToogled);
|
---|
165 | if (m_pHumanReabableSizesCheckBox)
|
---|
166 | connect(m_pHumanReabableSizesCheckBox, &QCheckBox::toggled,
|
---|
167 | this, &UIFileManagerOptionsPanel::sltHumanReabableSizesCheckBoxToogled);
|
---|
168 |
|
---|
169 | if (m_pShowHiddenObjectsCheckBox)
|
---|
170 | connect(m_pShowHiddenObjectsCheckBox, &QCheckBox::toggled,
|
---|
171 | this, &UIFileManagerOptionsPanel::sltShowHiddenObjectsCheckBoxToggled);
|
---|
172 | }
|
---|
173 |
|
---|
174 | void UIFileManagerOptionsPanel::retranslateUi()
|
---|
175 | {
|
---|
176 | UIDialogPanel::retranslateUi();
|
---|
177 | if (m_pListDirectoriesOnTopCheckBox)
|
---|
178 | {
|
---|
179 | m_pListDirectoriesOnTopCheckBox->setText(UIFileManager::tr("List directories on top"));
|
---|
180 | m_pListDirectoriesOnTopCheckBox->setToolTip(UIFileManager::tr("List directories before files"));
|
---|
181 | }
|
---|
182 |
|
---|
183 | if (m_pDeleteConfirmationCheckBox)
|
---|
184 | {
|
---|
185 | m_pDeleteConfirmationCheckBox->setText(UIFileManager::tr("Ask before delete"));
|
---|
186 | m_pDeleteConfirmationCheckBox->setToolTip(UIFileManager::tr("Show a confirmation dialog "
|
---|
187 | "before deleting files and directories"));
|
---|
188 | }
|
---|
189 |
|
---|
190 | if (m_pHumanReabableSizesCheckBox)
|
---|
191 | {
|
---|
192 | m_pHumanReabableSizesCheckBox->setText(UIFileManager::tr("Human readable sizes"));
|
---|
193 | m_pHumanReabableSizesCheckBox->setToolTip(UIFileManager::tr("Show file/directory sizes in human "
|
---|
194 | "readable format rather than in bytes"));
|
---|
195 | }
|
---|
196 |
|
---|
197 | if (m_pShowHiddenObjectsCheckBox)
|
---|
198 | {
|
---|
199 | m_pShowHiddenObjectsCheckBox->setText(UIFileManager::tr("Show hidden objects"));
|
---|
200 | m_pShowHiddenObjectsCheckBox->setToolTip(UIFileManager::tr("Show hidden files/directories"));
|
---|
201 | }
|
---|
202 | }
|
---|