2011-11-13 08:55:20 -05:00
|
|
|
/*
|
2021-10-10 07:49:25 -04:00
|
|
|
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
2011-11-13 08:55:20 -05:00
|
|
|
*
|
2018-02-04 07:18:59 -05:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
2011-11-13 08:55:20 -05:00
|
|
|
*
|
2018-02-04 07:18:59 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2011-11-13 08:55:20 -05:00
|
|
|
*
|
2018-02-04 07:18:59 -05:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-11-13 08:55:20 -05:00
|
|
|
*/
|
|
|
|
|
2012-01-11 12:12:41 -05:00
|
|
|
#ifndef KEEPASSX_DATABASETABWIDGET_H
|
|
|
|
#define KEEPASSX_DATABASETABWIDGET_H
|
2011-11-13 08:55:20 -05:00
|
|
|
|
2018-11-23 18:57:41 -05:00
|
|
|
#include "DatabaseOpenDialog.h"
|
2019-01-20 09:50:20 -05:00
|
|
|
#include "gui/MessageWidget.h"
|
2011-11-13 08:55:20 -05:00
|
|
|
|
2019-01-20 09:50:20 -05:00
|
|
|
#include <QTabWidget>
|
2022-06-27 23:21:40 -04:00
|
|
|
#include <QTimer>
|
2018-11-22 05:47:31 -05:00
|
|
|
|
|
|
|
class Database;
|
2011-12-27 09:49:06 -05:00
|
|
|
class DatabaseWidget;
|
2014-05-17 05:16:27 -04:00
|
|
|
class DatabaseWidgetStateSync;
|
2012-06-28 03:21:15 -04:00
|
|
|
class DatabaseOpenWidget;
|
2012-04-21 12:39:09 -04:00
|
|
|
|
2011-12-30 12:43:24 -05:00
|
|
|
class DatabaseTabWidget : public QTabWidget
|
2011-11-13 08:55:20 -05:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-07-24 12:28:12 -04:00
|
|
|
explicit DatabaseTabWidget(QWidget* parent = nullptr);
|
2018-02-04 07:18:59 -05:00
|
|
|
~DatabaseTabWidget() override;
|
2018-11-22 05:47:31 -05:00
|
|
|
void mergeDatabase(const QString& filePath);
|
|
|
|
|
|
|
|
QString tabName(int index);
|
2011-12-29 14:03:20 -05:00
|
|
|
DatabaseWidget* currentDatabaseWidget();
|
2018-11-22 05:47:31 -05:00
|
|
|
DatabaseWidget* databaseWidgetFromIndex(int index) const;
|
2011-11-13 08:55:20 -05:00
|
|
|
|
2018-11-22 05:47:31 -05:00
|
|
|
bool canSave(int index = -1) const;
|
|
|
|
bool isModified(int index = -1) const;
|
|
|
|
bool hasLockableDatabases() const;
|
2012-05-27 17:01:14 -04:00
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
public slots:
|
2021-07-02 05:33:12 -04:00
|
|
|
void lockAndSwitchToFirstUnlockedDatabase(int index = -1);
|
2019-03-21 17:36:57 -04:00
|
|
|
void addDatabaseTab(const QString& filePath,
|
|
|
|
bool inBackground = false,
|
|
|
|
const QString& password = {},
|
|
|
|
const QString& keyfile = {});
|
2018-11-23 13:24:59 -05:00
|
|
|
void addDatabaseTab(DatabaseWidget* dbWidget, bool inBackground = false);
|
2018-11-22 05:47:31 -05:00
|
|
|
bool closeDatabaseTab(int index);
|
|
|
|
bool closeDatabaseTab(DatabaseWidget* dbWidget);
|
|
|
|
bool closeAllDatabaseTabs();
|
|
|
|
bool closeCurrentDatabaseTab();
|
|
|
|
bool closeDatabaseTabFromSender();
|
|
|
|
void updateTabName(int index = -1);
|
|
|
|
|
2019-02-21 00:51:23 -05:00
|
|
|
DatabaseWidget* newDatabase();
|
2011-11-13 08:55:20 -05:00
|
|
|
void openDatabase();
|
2016-11-07 22:37:42 -05:00
|
|
|
void mergeDatabase();
|
2018-11-22 05:47:31 -05:00
|
|
|
void importCsv();
|
2012-05-12 04:08:41 -04:00
|
|
|
void importKeePass1Database();
|
2019-05-19 17:49:48 -04:00
|
|
|
void importOpVaultDatabase();
|
2015-01-11 10:20:59 -05:00
|
|
|
bool saveDatabase(int index = -1);
|
|
|
|
bool saveDatabaseAs(int index = -1);
|
2020-05-08 23:48:03 -04:00
|
|
|
bool saveDatabaseBackup(int index = -1);
|
2015-07-14 16:14:34 -04:00
|
|
|
void exportToCsv();
|
2019-06-30 11:11:15 -04:00
|
|
|
void exportToHtml();
|
2022-10-02 23:04:21 -04:00
|
|
|
void exportToXML();
|
2018-11-22 05:47:31 -05:00
|
|
|
|
2020-03-05 22:59:07 -05:00
|
|
|
bool lockDatabases();
|
2022-06-27 23:21:40 -04:00
|
|
|
void lockDatabasesDelayed();
|
2012-04-11 14:35:52 -04:00
|
|
|
void closeDatabaseFromSender();
|
2018-11-23 18:57:41 -05:00
|
|
|
void unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent);
|
|
|
|
void unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent, const QString& filePath);
|
2022-05-07 03:38:10 -04:00
|
|
|
void unlockAnyDatabaseInDialog(DatabaseOpenDialog::Intent intent);
|
2018-11-22 05:47:31 -05:00
|
|
|
void relockPendingDatabase();
|
|
|
|
|
2020-07-01 19:16:40 -04:00
|
|
|
void showDatabaseSecurity();
|
|
|
|
void showDatabaseReports();
|
|
|
|
void showDatabaseSettings();
|
2021-10-10 07:49:25 -04:00
|
|
|
void performGlobalAutoType(const QString& search);
|
2019-10-28 04:52:03 -04:00
|
|
|
void performBrowserUnlock();
|
2011-11-13 08:55:20 -05:00
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
signals:
|
2019-02-21 00:51:23 -05:00
|
|
|
void databaseOpened(DatabaseWidget* dbWidget);
|
2018-11-22 05:47:31 -05:00
|
|
|
void databaseClosed(const QString& filePath);
|
2016-10-08 12:55:05 -04:00
|
|
|
void databaseUnlocked(DatabaseWidget* dbWidget);
|
2018-11-22 05:47:31 -05:00
|
|
|
void databaseLocked(DatabaseWidget* dbWidget);
|
2021-02-15 17:28:16 -05:00
|
|
|
void activeDatabaseChanged(DatabaseWidget* dbWidget);
|
2018-11-22 05:47:31 -05:00
|
|
|
void tabNameChanged();
|
2020-01-05 21:00:25 -05:00
|
|
|
void tabVisibilityChanged(bool tabsVisible);
|
2015-01-21 11:19:05 -05:00
|
|
|
void messageGlobal(const QString&, MessageWidget::MessageType type);
|
|
|
|
void messageDismissGlobal();
|
2019-12-13 15:28:45 -05:00
|
|
|
void databaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
|
2012-01-13 11:52:37 -05:00
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
private slots:
|
2012-04-20 05:29:31 -04:00
|
|
|
void toggleTabbar();
|
2021-02-15 17:28:16 -05:00
|
|
|
void emitActiveDatabaseChanged();
|
2018-11-22 05:47:31 -05:00
|
|
|
void emitDatabaseLockChanged();
|
2020-09-22 19:48:20 -04:00
|
|
|
void handleDatabaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
|
2021-10-10 10:36:19 -04:00
|
|
|
void handleExportError(const QString& reason);
|
2023-01-29 09:24:10 -05:00
|
|
|
void updateLastDatabases();
|
2011-12-29 13:01:58 -05:00
|
|
|
|
2011-11-13 08:55:20 -05:00
|
|
|
private:
|
2018-11-22 05:47:31 -05:00
|
|
|
QSharedPointer<Database> execNewDatabaseWizard();
|
2012-05-27 17:01:14 -04:00
|
|
|
void updateLastDatabases(const QString& filename);
|
2019-06-30 15:04:43 -04:00
|
|
|
bool warnOnExport();
|
2020-09-22 19:48:20 -04:00
|
|
|
void displayUnlockDialog();
|
2011-11-13 08:55:20 -05:00
|
|
|
|
2018-02-04 07:18:59 -05:00
|
|
|
QPointer<DatabaseWidgetStateSync> m_dbWidgetStateSync;
|
2018-11-23 18:57:41 -05:00
|
|
|
QPointer<DatabaseWidget> m_dbWidgetPendingLock;
|
2019-12-16 16:49:58 -05:00
|
|
|
QPointer<DatabaseOpenDialog> m_databaseOpenDialog;
|
2022-06-27 23:21:40 -04:00
|
|
|
QTimer m_lockDelayTimer;
|
2011-11-13 08:55:20 -05:00
|
|
|
};
|
|
|
|
|
2012-01-11 12:12:41 -05:00
|
|
|
#endif // KEEPASSX_DATABASETABWIDGET_H
|