mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-03-11 08:54:48 +00:00
This patch removes redundant lock widget members of the DatabaseWidget and consolidates all unlocking functionality into a single DatabaseOpenWidget (with the exception of KeePass1OpenWidget). Distinction between different unlock actions is now done via a dedicated Intent enum class instead of using individual widgets. Further, the DatabaseUnlockDialog has been generalized so that it is usable for unlock intents other than just Auto-Type and is now also used for merging databases which is less confusing to the user. The KeePassXC main window is no longer a parent of the DatabaseUnlockDialog and has the Qt::ForeignWindow flag set, which should cause fewer issues with Auto-Type trying to type into KeePassXC after unlock instead of the intended target window. In addition, its instance has been moved into the DatabaseTabWidget class so that it is no longer bound to individual DatabaseWidgets, potentially allowing for database selection during Auto-Type. The actual selection has not yet been implemented, but Auto-Type has been adjusted to use the currently selected tab instead of the first one as an intermediary improvement.
102 lines
3.3 KiB
C++
102 lines
3.3 KiB
C++
/*
|
|
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
|
|
*
|
|
* 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.
|
|
*
|
|
* 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.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef KEEPASSX_DATABASETABWIDGET_H
|
|
#define KEEPASSX_DATABASETABWIDGET_H
|
|
|
|
#include "gui/MessageWidget.h"
|
|
#include "DatabaseOpenDialog.h"
|
|
|
|
#include <QTabWidget>
|
|
#include <QPointer>
|
|
|
|
class Database;
|
|
class DatabaseWidget;
|
|
class DatabaseWidgetStateSync;
|
|
class DatabaseOpenWidget;
|
|
|
|
class DatabaseTabWidget : public QTabWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DatabaseTabWidget(QWidget* parent = nullptr);
|
|
~DatabaseTabWidget() override;
|
|
void mergeDatabase(const QString& filePath);
|
|
|
|
QString tabName(int index);
|
|
DatabaseWidget* currentDatabaseWidget();
|
|
DatabaseWidget* databaseWidgetFromIndex(int index) const;
|
|
|
|
bool isReadOnly(int index = -1) const;
|
|
bool canSave(int index = -1) const;
|
|
bool isModified(int index = -1) const;
|
|
bool hasLockableDatabases() const;
|
|
|
|
public slots:
|
|
void addDatabaseTab(const QString& filePath, bool inBackground = false, const QString& password = {});
|
|
void addDatabaseTab(DatabaseWidget* dbWidget, bool inBackground = false);
|
|
bool closeDatabaseTab(int index);
|
|
bool closeDatabaseTab(DatabaseWidget* dbWidget);
|
|
bool closeAllDatabaseTabs();
|
|
bool closeCurrentDatabaseTab();
|
|
bool closeDatabaseTabFromSender();
|
|
void updateTabName(int index = -1);
|
|
|
|
void newDatabase();
|
|
void openDatabase();
|
|
void mergeDatabase();
|
|
void importCsv();
|
|
void importKeePass1Database();
|
|
bool saveDatabase(int index = -1);
|
|
bool saveDatabaseAs(int index = -1);
|
|
void exportToCsv();
|
|
|
|
void lockDatabases();
|
|
void closeDatabaseFromSender();
|
|
void unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent);
|
|
void unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent, const QString& filePath);
|
|
void relockPendingDatabase();
|
|
|
|
void changeMasterKey();
|
|
void changeDatabaseSettings();
|
|
void performGlobalAutoType();
|
|
|
|
signals:
|
|
void databaseClosed(const QString& filePath);
|
|
void databaseUnlocked(DatabaseWidget* dbWidget);
|
|
void databaseLocked(DatabaseWidget* dbWidget);
|
|
void activateDatabaseChanged(DatabaseWidget* dbWidget);
|
|
void tabNameChanged();
|
|
void messageGlobal(const QString&, MessageWidget::MessageType type);
|
|
void messageDismissGlobal();
|
|
|
|
private slots:
|
|
void toggleTabbar();
|
|
void emitActivateDatabaseChanged();
|
|
void emitDatabaseLockChanged();
|
|
|
|
private:
|
|
QSharedPointer<Database> execNewDatabaseWizard();
|
|
void updateLastDatabases(const QString& filename);
|
|
|
|
QPointer<DatabaseWidgetStateSync> m_dbWidgetStateSync;
|
|
QPointer<DatabaseWidget> m_dbWidgetPendingLock;
|
|
QScopedPointer<DatabaseOpenDialog> m_databaseOpenDialog;
|
|
};
|
|
|
|
#endif // KEEPASSX_DATABASETABWIDGET_H
|