keepassxc

Форк
0
/
ImportWizard.cpp 
84 строки · 2.5 Кб
1
/*
2
 *  Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
3
 *
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.
8
 *
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.
13
 *
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/>.
16
 */
17

18
#include "ImportWizard.h"
19
#include "ImportWizardPageReview.h"
20
#include "ImportWizardPageSelect.h"
21

22
#include "core/Global.h"
23
#include "core/Group.h"
24

25
#include <QFrame>
26
#include <QPalette>
27

28
ImportWizard::ImportWizard(QWidget* parent)
29
    : QWizard(parent)
30
    , m_pageSelect(new ImportWizardPageSelect)
31
    , m_pageReview(new ImportWizardPageReview)
32
{
33
    setWizardStyle(MacStyle);
34
    setOption(HaveHelpButton, false);
35
    setOption(NoDefaultButton, false); // Needed for macOS
36

37
    addPage(m_pageSelect.data());
38
    addPage(m_pageReview.data());
39

40
    setWindowTitle(tr("Import Wizard"));
41

42
    Q_INIT_RESOURCE(wizard);
43
    setPixmap(BackgroundPixmap, QPixmap(":/wizard/background-pixmap.png"));
44

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);
51

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);
57
}
58

59
ImportWizard::~ImportWizard()
60
{
61
}
62

63
bool ImportWizard::validateCurrentPage()
64
{
65
    bool ret = QWizard::validateCurrentPage();
66
    if (ret && currentPage() == m_pageReview) {
67
        m_db = m_pageReview->database();
68
    }
69
    return ret;
70
}
71

72
QPair<QUuid, QUuid> ImportWizard::importInto()
73
{
74
    auto list = field("ImportInto").toList();
75
    if (list.size() >= 2) {
76
        return qMakePair(QUuid(list[0].toString()), QUuid(list[1].toString()));
77
    }
78
    return {};
79
}
80

81
QSharedPointer<Database> ImportWizard::database()
82
{
83
    return m_db;
84
}
85

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.