2
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 2 or (at your option)
7
* version 3 of the License.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "ImportWizard.h"
19
#include "ImportWizardPageReview.h"
20
#include "ImportWizardPageSelect.h"
22
#include "core/Global.h"
23
#include "core/Group.h"
28
ImportWizard::ImportWizard(QWidget* parent)
30
, m_pageSelect(new ImportWizardPageSelect)
31
, m_pageReview(new ImportWizardPageReview)
33
setWizardStyle(MacStyle);
34
setOption(HaveHelpButton, false);
35
setOption(NoDefaultButton, false); // Needed for macOS
37
addPage(m_pageSelect.data());
38
addPage(m_pageReview.data());
40
setWindowTitle(tr("Import Wizard"));
42
Q_INIT_RESOURCE(wizard);
43
setPixmap(BackgroundPixmap, QPixmap(":/wizard/background-pixmap.png"));
45
// Fix MacStyle QWizard page frame too bright in dark mode (QTBUG-70346, QTBUG-71696)
46
QPalette defaultPalette;
47
auto windowColor = defaultPalette.color(QPalette::Window);
48
windowColor.setAlpha(153);
49
auto baseColor = defaultPalette.color(QPalette::Base);
50
baseColor.setAlpha(153);
52
auto* pageFrame = findChildren<QFrame*>()[0];
53
auto framePalette = pageFrame->palette();
54
framePalette.setBrush(QPalette::Window, windowColor.lighter(120));
55
framePalette.setBrush(QPalette::Base, baseColor.lighter(120));
56
pageFrame->setPalette(framePalette);
59
ImportWizard::~ImportWizard()
63
bool ImportWizard::validateCurrentPage()
65
bool ret = QWizard::validateCurrentPage();
66
if (ret && currentPage() == m_pageReview) {
67
m_db = m_pageReview->database();
72
QPair<QUuid, QUuid> ImportWizard::importInto()
74
auto list = field("ImportInto").toList();
75
if (list.size() >= 2) {
76
return qMakePair(QUuid(list[0].toString()), QUuid(list[1].toString()));
81
QSharedPointer<Database> ImportWizard::database()