Skip to content
API Documentation
BastionGuard™
PasswordImportDialog.hpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
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 <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#pragma once
22
23#include <gtkmm.h>
24#include <vector>
25#include <thread>
26#include <atomic>
27#include <utility>
28#include "PasswordImporter.hpp"
29#include "PasswordEntry.hpp"
30
32public:
33 explicit PasswordImportDialog(Gtk::Window& parent);
35
36 void present();
37 void hide();
38
39 using BulkItem = std::pair<PasswordEntry, std::string>;
40 sigc::signal<void(std::vector<BulkItem>)> signal_import_confirmed();
41
42private:
43 Gtk::Window& parent_;
44 Gtk::Dialog* dialog_ = nullptr;
45
46 Gtk::Box mainBox_;
47 Gtk::Label hintLabel_;
48 Gtk::Button chooseFileBtn_;
49 Gtk::Label fileLabel_;
50 Gtk::Label formatLabel_;
51 Gtk::Label countLabel_;
52 Gtk::ListBox previewList_;
53 Gtk::ScrolledWindow previewScrolled_;
54 Gtk::Box progressBox_;
55 Gtk::ProgressBar progressBar_;
56 Gtk::Label progressLabel_;
57 Gtk::Button importBtn_;
58
59 std::vector<ImportedCredential> parsed_;
60 std::vector<BulkItem> pendingItems_;
61
62 sigc::signal<void(std::vector<BulkItem>)> signalImportConfirmed_;
63
64 std::thread importThread_;
65 std::atomic<bool> importing_{ false };
66 std::atomic<int> progressDone_{ 0 };
67 std::atomic<int> progressTotal_{ 0 };
68 Glib::Dispatcher dispProgress_;
69 Glib::Dispatcher dispDone_;
70
71 void buildUi();
72 void styleImportButton();
73 void onChooseFile();
74 void loadFile(const std::string& path);
75 void populatePreview();
76 void onImportClicked();
77 void onProgressTick();
78 void onImportDone();
79};
std::pair< PasswordEntry, std::string > BulkItem
PasswordImportDialog(Gtk::Window &parent)
std::atomic< bool > importing_
void loadFile(const std::string &path)
std::atomic< int > progressDone_
sigc::signal< void(std::vector< BulkItem >)> signal_import_confirmed()
std::vector< ImportedCredential > parsed_
Gtk::ScrolledWindow previewScrolled_
sigc::signal< void(std::vector< BulkItem >)> signalImportConfirmed_
std::vector< BulkItem > pendingItems_
std::atomic< int > progressTotal_