2011-11-13 13:55:20 +00:00
|
|
|
/*
|
2021-10-10 11:49:25 +00:00
|
|
|
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
2011-11-13 13:55:20 +00:00
|
|
|
*
|
2018-02-04 12:18:59 +00: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 13:55:20 +00:00
|
|
|
*
|
2018-02-04 12:18:59 +00: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 13:55:20 +00:00
|
|
|
*
|
2018-02-04 12:18:59 +00: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 13:55:20 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-01-11 17:12:41 +00:00
|
|
|
#ifndef KEEPASSX_DATABASETABWIDGET_H
|
|
|
|
|
#define KEEPASSX_DATABASETABWIDGET_H
|
2011-11-13 13:55:20 +00:00
|
|
|
|
2018-11-23 23:57:41 +00:00
|
|
|
#include "DatabaseOpenDialog.h"
|
2019-01-20 14:50:20 +00:00
|
|
|
#include "gui/MessageWidget.h"
|
2011-11-13 13:55:20 +00:00
|
|
|
|
2019-01-20 14:50:20 +00:00
|
|
|
#include <QTabWidget>
|
2018-11-22 10:47:31 +00:00
|
|
|
|
|
|
|
|
class Database;
|
2011-12-27 14:49:06 +00:00
|
|
|
class DatabaseWidget;
|
2014-05-17 09:16:27 +00:00
|
|
|
class DatabaseWidgetStateSync;
|
2012-06-28 07:21:15 +00:00
|
|
|
class DatabaseOpenWidget;
|
2012-04-21 16:39:09 +00:00
|
|
|
|
2011-12-30 17:43:24 +00:00
|
|
|
class DatabaseTabWidget : public QTabWidget
|
2011-11-13 13:55:20 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2015-07-24 16:28:12 +00:00
|
|
|
explicit DatabaseTabWidget(QWidget* parent = nullptr);
|
2018-02-04 12:18:59 +00:00
|
|
|
~DatabaseTabWidget() override;
|
2018-11-22 10:47:31 +00:00
|
|
|
void mergeDatabase(const QString& filePath);
|
|
|
|
|
|
|
|
|
|
QString tabName(int index);
|
2011-12-29 19:03:20 +00:00
|
|
|
DatabaseWidget* currentDatabaseWidget();
|
2018-11-22 10:47:31 +00:00
|
|
|
DatabaseWidget* databaseWidgetFromIndex(int index) const;
|
2011-11-13 13:55:20 +00:00
|
|
|
|
2018-11-22 10:47:31 +00:00
|
|
|
bool isReadOnly(int index = -1) const;
|
|
|
|
|
bool canSave(int index = -1) const;
|
|
|
|
|
bool isModified(int index = -1) const;
|
|
|
|
|
bool hasLockableDatabases() const;
|
2012-05-27 21:01:14 +00:00
|
|
|
|
2017-03-10 14:58:42 +00:00
|
|
|
public slots:
|
2019-03-21 21:36:57 +00:00
|
|
|
void addDatabaseTab(const QString& filePath,
|
|
|
|
|
bool inBackground = false,
|
|
|
|
|
const QString& password = {},
|
|
|
|
|
const QString& keyfile = {});
|
2018-11-23 18:24:59 +00:00
|
|
|
void addDatabaseTab(DatabaseWidget* dbWidget, bool inBackground = false);
|
2018-11-22 10:47:31 +00:00
|
|
|
bool closeDatabaseTab(int index);
|
|
|
|
|
bool closeDatabaseTab(DatabaseWidget* dbWidget);
|
|
|
|
|
bool closeAllDatabaseTabs();
|
|
|
|
|
bool closeCurrentDatabaseTab();
|
|
|
|
|
bool closeDatabaseTabFromSender();
|
|
|
|
|
void updateTabName(int index = -1);
|
|
|
|
|
|
2019-02-21 05:51:23 +00:00
|
|
|
DatabaseWidget* newDatabase();
|
2011-11-13 13:55:20 +00:00
|
|
|
void openDatabase();
|
2016-11-08 03:37:42 +00:00
|
|
|
void mergeDatabase();
|
2018-11-22 10:47:31 +00:00
|
|
|
void importCsv();
|
2012-05-12 08:08:41 +00:00
|
|
|
void importKeePass1Database();
|
2019-05-19 21:49:48 +00:00
|
|
|
void importOpVaultDatabase();
|
2015-01-11 15:20:59 +00:00
|
|
|
bool saveDatabase(int index = -1);
|
|
|
|
|
bool saveDatabaseAs(int index = -1);
|
2020-05-09 03:48:03 +00:00
|
|
|
bool saveDatabaseBackup(int index = -1);
|
2015-07-14 20:14:34 +00:00
|
|
|
void exportToCsv();
|
2019-06-30 15:11:15 +00:00
|
|
|
void exportToHtml();
|
2018-11-22 10:47:31 +00:00
|
|
|
|
2020-03-06 03:59:07 +00:00
|
|
|
bool lockDatabases();
|
2012-04-11 18:35:52 +00:00
|
|
|
void closeDatabaseFromSender();
|
2018-11-23 23:57:41 +00:00
|
|
|
void unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent);
|
|
|
|
|
void unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent, const QString& filePath);
|
2018-11-22 10:47:31 +00:00
|
|
|
void relockPendingDatabase();
|
|
|
|
|
|
2020-07-01 23:16:40 +00:00
|
|
|
void showDatabaseSecurity();
|
|
|
|
|
void showDatabaseReports();
|
|
|
|
|
void showDatabaseSettings();
|
2021-10-10 11:49:25 +00:00
|
|
|
void performGlobalAutoType(const QString& search);
|
2019-10-28 08:52:03 +00:00
|
|
|
void performBrowserUnlock();
|
2011-11-13 13:55:20 +00:00
|
|
|
|
2017-03-10 14:58:42 +00:00
|
|
|
signals:
|
2019-02-21 05:51:23 +00:00
|
|
|
void databaseOpened(DatabaseWidget* dbWidget);
|
2018-11-22 10:47:31 +00:00
|
|
|
void databaseClosed(const QString& filePath);
|
2016-10-08 16:55:05 +00:00
|
|
|
void databaseUnlocked(DatabaseWidget* dbWidget);
|
2018-11-22 10:47:31 +00:00
|
|
|
void databaseLocked(DatabaseWidget* dbWidget);
|
2021-02-15 22:28:16 +00:00
|
|
|
void activeDatabaseChanged(DatabaseWidget* dbWidget);
|
2018-11-22 10:47:31 +00:00
|
|
|
void tabNameChanged();
|
2020-01-06 02:00:25 +00:00
|
|
|
void tabVisibilityChanged(bool tabsVisible);
|
2015-01-21 16:19:05 +00:00
|
|
|
void messageGlobal(const QString&, MessageWidget::MessageType type);
|
|
|
|
|
void messageDismissGlobal();
|
2019-12-13 20:28:45 +00:00
|
|
|
void databaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
|
2012-01-13 16:52:37 +00:00
|
|
|
|
2017-03-10 14:58:42 +00:00
|
|
|
private slots:
|
2012-04-20 09:29:31 +00:00
|
|
|
void toggleTabbar();
|
2021-02-15 22:28:16 +00:00
|
|
|
void emitActiveDatabaseChanged();
|
2018-11-22 10:47:31 +00:00
|
|
|
void emitDatabaseLockChanged();
|
2020-09-22 23:48:20 +00:00
|
|
|
void handleDatabaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
|
2021-10-10 14:36:19 +00:00
|
|
|
void handleExportError(const QString& reason);
|
2011-12-29 18:01:58 +00:00
|
|
|
|
2011-11-13 13:55:20 +00:00
|
|
|
private:
|
2018-11-22 10:47:31 +00:00
|
|
|
QSharedPointer<Database> execNewDatabaseWizard();
|
2012-05-27 21:01:14 +00:00
|
|
|
void updateLastDatabases(const QString& filename);
|
2019-06-30 19:04:43 +00:00
|
|
|
bool warnOnExport();
|
2020-09-22 23:48:20 +00:00
|
|
|
void unlockAnyDatabaseInDialog(DatabaseOpenDialog::Intent intent);
|
|
|
|
|
void displayUnlockDialog();
|
2011-11-13 13:55:20 +00:00
|
|
|
|
2018-02-04 12:18:59 +00:00
|
|
|
QPointer<DatabaseWidgetStateSync> m_dbWidgetStateSync;
|
2018-11-23 23:57:41 +00:00
|
|
|
QPointer<DatabaseWidget> m_dbWidgetPendingLock;
|
2019-12-16 21:49:58 +00:00
|
|
|
QPointer<DatabaseOpenDialog> m_databaseOpenDialog;
|
2011-11-13 13:55:20 +00:00
|
|
|
};
|
|
|
|
|
|
2012-01-11 17:12:41 +00:00
|
|
|
#endif // KEEPASSX_DATABASETABWIDGET_H
|