2018-05-20 01:54:08 +02:00
|
|
|
#ifndef QT_QUICK_GUI_CONTROLLER_H
|
|
|
|
#define QT_QUICK_GUI_CONTROLLER_H
|
|
|
|
|
|
|
|
#include "../model/entryfiltermodel.h"
|
|
|
|
#include "../model/entrymodel.h"
|
|
|
|
#include "../model/fieldmodel.h"
|
|
|
|
|
|
|
|
#include <passwordfile/io/passwordfile.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
2018-06-11 23:21:15 +02:00
|
|
|
#include <QPersistentModelIndex>
|
2018-05-20 01:54:08 +02:00
|
|
|
|
2018-06-16 15:07:46 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QSettings)
|
|
|
|
|
2018-12-01 02:22:26 +01:00
|
|
|
#if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_ENABLE_UNDO_SUPPORT_FOR_QUICK_GUI)
|
2018-12-03 00:29:54 +01:00
|
|
|
#include "../gui/stacksupport.h"
|
2018-11-22 22:05:49 +01:00
|
|
|
#endif
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
namespace QtGui {
|
|
|
|
|
|
|
|
class Controller : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString filePath READ filePath WRITE setFilePath NOTIFY filePathChanged)
|
2018-06-14 23:19:28 +02:00
|
|
|
Q_PROPERTY(QString fileName READ fileName NOTIFY filePathChanged)
|
2018-09-10 19:54:49 +02:00
|
|
|
Q_PROPERTY(QString password READ password WRITE setPassword RESET clearPassword NOTIFY passwordChanged)
|
2018-05-20 01:54:08 +02:00
|
|
|
Q_PROPERTY(QString windowTitle READ windowTitle NOTIFY windowTitleChanged)
|
|
|
|
Q_PROPERTY(bool fileOpen READ isFileOpen NOTIFY fileOpenChanged)
|
2018-09-10 19:53:14 +02:00
|
|
|
Q_PROPERTY(bool passwordSet READ isPasswordSet NOTIFY passwordChanged)
|
2018-05-20 01:54:08 +02:00
|
|
|
Q_PROPERTY(EntryModel *entryModel READ entryModel NOTIFY entryModelChanged)
|
|
|
|
Q_PROPERTY(EntryFilterModel *entryFilterModel READ entryFilterModel NOTIFY entryFilterModelChanged)
|
|
|
|
Q_PROPERTY(FieldModel *fieldModel READ fieldModel NOTIFY fieldModelChanged)
|
2019-06-24 18:51:47 +02:00
|
|
|
//Q_PROPERTY(Io::AccountEntry *currentAccount READ currentAccount WRITE setCurrentAccount NOTIFY currentAccountChanged)
|
2018-05-20 01:54:08 +02:00
|
|
|
Q_PROPERTY(QModelIndex currentAccountIndex READ currentAccountIndex WRITE setCurrentAccountIndex NOTIFY currentAccountChanged)
|
|
|
|
Q_PROPERTY(QString currentAccountName READ currentAccountName NOTIFY currentAccountChanged)
|
2018-09-10 22:46:04 +02:00
|
|
|
Q_PROPERTY(bool hasCurrentAccount READ hasCurrentAccount NOTIFY currentAccountChanged)
|
2019-06-24 18:51:47 +02:00
|
|
|
//Q_PROPERTY(QList<QPersistentModelIndex> cutEntries READ cutEntries WRITE setCutEntries NOTIFY cutEntriesChanged)
|
2018-06-11 23:21:15 +02:00
|
|
|
Q_PROPERTY(bool canPaste READ canPaste NOTIFY cutEntriesChanged)
|
2018-09-16 19:16:12 +02:00
|
|
|
Q_PROPERTY(QStringList recentFiles READ recentFiles RESET clearRecentFiles NOTIFY recentFilesChanged)
|
2018-09-04 00:52:43 +02:00
|
|
|
Q_PROPERTY(bool useNativeFileDialog READ useNativeFileDialog WRITE setUseNativeFileDialog NOTIFY useNativeFileDialogChanged)
|
|
|
|
Q_PROPERTY(bool supportsNativeFileDialog READ supportsNativeFileDialog NOTIFY supportsNativeFileDialogChanged)
|
2018-09-16 21:37:30 +02:00
|
|
|
Q_PROPERTY(QString entryFilter READ entryFilter WRITE setEntryFilter NOTIFY entryFilterChanged)
|
|
|
|
Q_PROPERTY(bool hasEntryFilter READ hasEntryFilter NOTIFY hasEntryFilterChanged)
|
2018-11-20 00:45:05 +01:00
|
|
|
Q_PROPERTY(bool filterAsDialog READ filterAsDialog NOTIFY filterAsDialogChanged)
|
2018-11-22 22:05:49 +01:00
|
|
|
Q_PROPERTY(QUndoStack *undoStack READ undoStack NOTIFY undoStackChanged)
|
|
|
|
Q_PROPERTY(QString undoText READ undoText NOTIFY undoTextChanged)
|
|
|
|
Q_PROPERTY(QString redoText READ redoText NOTIFY redoTextChanged)
|
2024-03-31 22:53:32 +02:00
|
|
|
Q_PROPERTY(bool darkModeEnabled READ isDarkModeEnabled WRITE setDarkModeEnabled NOTIFY darkModeEnabledChanged)
|
2018-05-20 01:54:08 +02:00
|
|
|
|
|
|
|
public:
|
2018-06-16 15:07:46 +02:00
|
|
|
explicit Controller(QSettings &settings, const QString &filePath = QString(), QObject *parent = nullptr);
|
2018-05-20 01:54:08 +02:00
|
|
|
|
|
|
|
const QString &filePath() const;
|
2018-06-14 23:19:28 +02:00
|
|
|
const QString &fileName() const;
|
2018-05-20 01:54:08 +02:00
|
|
|
void setFilePath(const QString &filePath);
|
|
|
|
const QString &password() const;
|
|
|
|
void setPassword(const QString &password);
|
2018-09-10 19:54:49 +02:00
|
|
|
Q_INVOKABLE void clearPassword();
|
2018-05-20 01:54:08 +02:00
|
|
|
const QString &windowTitle() const;
|
|
|
|
bool isFileOpen() const;
|
2018-09-10 19:53:14 +02:00
|
|
|
bool isPasswordSet() const;
|
2018-05-20 01:54:08 +02:00
|
|
|
EntryModel *entryModel();
|
|
|
|
EntryFilterModel *entryFilterModel();
|
|
|
|
FieldModel *fieldModel();
|
2018-09-10 22:46:04 +02:00
|
|
|
Io::AccountEntry *currentAccount();
|
|
|
|
void setCurrentAccount(Io::AccountEntry *entry);
|
2018-05-20 01:54:08 +02:00
|
|
|
QModelIndex currentAccountIndex() const;
|
2018-09-16 21:37:30 +02:00
|
|
|
void setCurrentAccountIndex(const QModelIndex &accountIndexMaybeFromFilterModel);
|
2018-09-10 22:46:04 +02:00
|
|
|
bool hasCurrentAccount() const;
|
2018-06-11 23:21:15 +02:00
|
|
|
const QList<QPersistentModelIndex> &cutEntries() const;
|
|
|
|
void setCutEntries(const QList<QPersistentModelIndex> &cutEntries);
|
2018-05-20 01:54:08 +02:00
|
|
|
QString currentAccountName() const;
|
2018-09-16 21:37:30 +02:00
|
|
|
Q_INVOKABLE void cutEntry(const QModelIndex &entryIndexMaybeFromFilterModel);
|
2018-06-12 22:20:43 +02:00
|
|
|
Q_INVOKABLE QStringList pasteEntries(const QModelIndex &destinationParent, int row = -1);
|
2018-06-16 15:37:55 +02:00
|
|
|
Q_INVOKABLE bool copyToClipboard(const QString &text) const;
|
2018-06-11 23:21:15 +02:00
|
|
|
bool canPaste() const;
|
2018-06-16 15:07:46 +02:00
|
|
|
const QStringList &recentFiles() const;
|
2018-09-16 19:16:12 +02:00
|
|
|
Q_INVOKABLE void clearRecentFiles();
|
2018-09-04 00:52:43 +02:00
|
|
|
bool useNativeFileDialog() const;
|
|
|
|
void setUseNativeFileDialog(bool useNativeFileDialog);
|
|
|
|
bool supportsNativeFileDialog() const;
|
2018-09-16 21:37:30 +02:00
|
|
|
Q_INVOKABLE QModelIndex filterEntryIndex(const QModelIndex &entryIndex) const;
|
|
|
|
QString entryFilter() const;
|
|
|
|
void setEntryFilter(const QString &filter);
|
|
|
|
bool hasEntryFilter() const;
|
2018-11-20 00:45:05 +01:00
|
|
|
bool filterAsDialog() const;
|
2018-11-22 22:05:49 +01:00
|
|
|
QUndoStack *undoStack();
|
|
|
|
QString undoText() const;
|
|
|
|
QString redoText() const;
|
2022-01-29 19:45:14 +01:00
|
|
|
Io::PasswordFileSaveFlags prepareSaving();
|
2024-03-31 22:53:32 +02:00
|
|
|
bool isDarkModeEnabled() const;
|
|
|
|
void setDarkModeEnabled(bool darkModeEnabled);
|
2018-05-20 01:54:08 +02:00
|
|
|
|
2020-03-08 14:09:56 +01:00
|
|
|
public Q_SLOTS:
|
2018-06-16 15:15:25 +02:00
|
|
|
void init();
|
2019-06-24 18:51:47 +02:00
|
|
|
void load();
|
|
|
|
void create();
|
2018-05-20 01:54:08 +02:00
|
|
|
void close();
|
2019-06-24 18:51:47 +02:00
|
|
|
void clear();
|
2018-05-20 01:54:08 +02:00
|
|
|
void save();
|
2019-06-24 18:51:47 +02:00
|
|
|
bool showNativeFileDialog(bool existing, bool createNew);
|
|
|
|
void handleFileSelectionAccepted(const QString &filePath, const QString &nativeUrl, bool existing, bool createNew);
|
2018-09-04 00:52:43 +02:00
|
|
|
#if defined(Q_OS_ANDROID) && defined(CPP_UTILITIES_USE_NATIVE_FILE_BUFFER)
|
2019-06-24 18:51:47 +02:00
|
|
|
void handleFileSelectionAcceptedDescriptor(const QString &nativeUrl, const QString &fileName, int fileDescriptor, bool existing, bool createNew);
|
2018-09-04 00:52:43 +02:00
|
|
|
#endif
|
|
|
|
void handleFileSelectionCanceled();
|
2018-11-22 22:05:49 +01:00
|
|
|
void undo();
|
|
|
|
void redo();
|
2018-12-21 01:14:41 +01:00
|
|
|
QString computeFileSummary();
|
2018-05-20 01:54:08 +02:00
|
|
|
|
2020-03-09 18:46:47 +01:00
|
|
|
Q_SIGNALS:
|
2018-05-20 01:54:08 +02:00
|
|
|
void filePathChanged(const QString &newFilePath);
|
|
|
|
void passwordChanged(const QString &newPassword);
|
|
|
|
void passwordRequired(const QString &filePath);
|
|
|
|
void windowTitleChanged(const QString &windowTitle);
|
|
|
|
void fileOpenChanged(bool fileOpen);
|
2019-06-24 18:51:47 +02:00
|
|
|
void fileError(const QString &errorMessage, const QString &retryAction);
|
2018-06-12 22:02:37 +02:00
|
|
|
void fileSaved();
|
2018-05-20 01:54:08 +02:00
|
|
|
void entryModelChanged();
|
|
|
|
void entryFilterModelChanged();
|
|
|
|
void fieldModelChanged();
|
|
|
|
void currentAccountChanged();
|
2018-06-11 23:21:15 +02:00
|
|
|
void cutEntriesChanged(const QList<QPersistentModelIndex> &cutEntries);
|
2018-06-16 15:07:46 +02:00
|
|
|
void recentFilesChanged(const QStringList &recentFiles);
|
2018-09-04 00:52:43 +02:00
|
|
|
void newNotification(const QString &message);
|
|
|
|
void useNativeFileDialogChanged(bool useNativeFileDialog);
|
|
|
|
void supportsNativeFileDialogChanged();
|
2018-09-10 22:46:04 +02:00
|
|
|
void entryAboutToBeRemoved(const QModelIndex &removedIndex);
|
2018-09-16 21:37:30 +02:00
|
|
|
void entryFilterChanged(const QString &newFilter);
|
|
|
|
void hasEntryFilterChanged(bool hasEntryFilter);
|
2018-11-20 00:45:05 +01:00
|
|
|
void filterAsDialogChanged(bool filterAsDialog);
|
2018-11-22 22:05:49 +01:00
|
|
|
void undoStackChanged(QUndoStack *undoStack);
|
|
|
|
void undoTextChanged(const QString &undoText);
|
|
|
|
void redoTextChanged(const QString &redoText);
|
2023-02-18 19:00:05 +01:00
|
|
|
void settingsError(const QString &errorMessage);
|
2024-03-31 22:53:32 +02:00
|
|
|
void darkModeEnabledChanged(bool darkModeEnabled);
|
2018-09-10 22:46:04 +02:00
|
|
|
|
2020-03-08 14:09:56 +01:00
|
|
|
private Q_SLOTS:
|
2018-09-10 22:46:04 +02:00
|
|
|
void handleEntriesRemoved(const QModelIndex &parentIndex, int first, int last);
|
2018-09-16 19:16:12 +02:00
|
|
|
void handleRecentFilesChanged();
|
2018-05-20 01:54:08 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void resetFileStatus();
|
|
|
|
void updateWindowTitle();
|
|
|
|
void setFileOpen(bool fileOpen);
|
2019-03-13 19:09:31 +01:00
|
|
|
void emitFileError(const QString &when);
|
2018-09-16 21:37:30 +02:00
|
|
|
QModelIndex ensureSourceEntryIndex(const QModelIndex &entryIndexMaybeFromFilterModel) const;
|
2018-05-20 01:54:08 +02:00
|
|
|
|
2018-06-16 15:07:46 +02:00
|
|
|
QSettings &m_settings;
|
2018-05-20 01:54:08 +02:00
|
|
|
QString m_filePath;
|
2018-06-14 23:19:28 +02:00
|
|
|
QString m_fileName;
|
2018-05-20 01:54:08 +02:00
|
|
|
QString m_password;
|
|
|
|
QString m_windowTitle;
|
|
|
|
Io::PasswordFile m_file;
|
2018-11-22 22:05:49 +01:00
|
|
|
#ifdef PASSWORD_MANAGER_UNDO_SUPPORT
|
|
|
|
QUndoStack m_undoStack;
|
|
|
|
#endif
|
2018-05-20 01:54:08 +02:00
|
|
|
EntryModel m_entryModel;
|
|
|
|
EntryFilterModel m_entryFilterModel;
|
|
|
|
FieldModel m_fieldModel;
|
2018-06-11 23:21:15 +02:00
|
|
|
QList<QPersistentModelIndex> m_cutEntries;
|
2018-06-16 15:07:46 +02:00
|
|
|
QStringList m_recentFiles;
|
2018-09-04 00:52:43 +02:00
|
|
|
QString m_nativeUrl;
|
2018-05-20 01:54:08 +02:00
|
|
|
bool m_fileOpen;
|
|
|
|
bool m_fileModified;
|
2018-09-04 00:52:43 +02:00
|
|
|
bool m_useNativeFileDialog;
|
2018-11-20 00:45:05 +01:00
|
|
|
bool m_filterAsDialog;
|
2024-03-31 22:53:32 +02:00
|
|
|
bool m_darkModeEnabled;
|
2018-05-20 01:54:08 +02:00
|
|
|
};
|
|
|
|
|
2018-09-16 21:37:30 +02:00
|
|
|
inline QModelIndex Controller::ensureSourceEntryIndex(const QModelIndex &entryIndexMaybeFromFilterModel) const
|
|
|
|
{
|
|
|
|
return entryIndexMaybeFromFilterModel.model() == &m_entryFilterModel ? m_entryFilterModel.mapToSource(entryIndexMaybeFromFilterModel)
|
|
|
|
: entryIndexMaybeFromFilterModel;
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
inline const QString &Controller::filePath() const
|
|
|
|
{
|
|
|
|
return m_filePath;
|
|
|
|
}
|
|
|
|
|
2018-06-14 23:19:28 +02:00
|
|
|
inline const QString &Controller::fileName() const
|
|
|
|
{
|
|
|
|
return m_fileName;
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
inline const QString &Controller::password() const
|
|
|
|
{
|
|
|
|
return m_password;
|
|
|
|
}
|
|
|
|
|
2018-09-10 19:54:49 +02:00
|
|
|
inline void Controller::clearPassword()
|
|
|
|
{
|
2018-09-10 20:04:14 +02:00
|
|
|
setPassword(QString());
|
2018-09-10 19:54:49 +02:00
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
inline const QString &Controller::windowTitle() const
|
|
|
|
{
|
|
|
|
return m_windowTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Controller::isFileOpen() const
|
|
|
|
{
|
|
|
|
return m_fileOpen;
|
|
|
|
}
|
|
|
|
|
2018-09-10 19:53:14 +02:00
|
|
|
inline bool Controller::isPasswordSet() const
|
|
|
|
{
|
|
|
|
return !m_password.isEmpty();
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
inline EntryModel *Controller::entryModel()
|
|
|
|
{
|
|
|
|
return &m_entryModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline EntryFilterModel *Controller::entryFilterModel()
|
|
|
|
{
|
|
|
|
return &m_entryFilterModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline FieldModel *Controller::fieldModel()
|
|
|
|
{
|
|
|
|
return &m_fieldModel;
|
|
|
|
}
|
|
|
|
|
2018-09-10 22:46:04 +02:00
|
|
|
inline Io::AccountEntry *Controller::currentAccount()
|
|
|
|
{
|
|
|
|
return m_fieldModel.accountEntry();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Controller::setCurrentAccount(Io::AccountEntry *entry)
|
|
|
|
{
|
|
|
|
m_fieldModel.setAccountEntry(entry);
|
|
|
|
emit currentAccountChanged();
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
inline QModelIndex Controller::currentAccountIndex() const
|
|
|
|
{
|
|
|
|
return m_fieldModel.accountEntry() ? m_entryModel.index(const_cast<Io::AccountEntry *>(m_fieldModel.accountEntry())) : QModelIndex();
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:37:30 +02:00
|
|
|
inline void Controller::setCurrentAccountIndex(const QModelIndex &accountIndexMaybeFromFilterModel)
|
2018-05-20 01:54:08 +02:00
|
|
|
{
|
2018-09-16 21:37:30 +02:00
|
|
|
const auto accountIndex = ensureSourceEntryIndex(accountIndexMaybeFromFilterModel);
|
2018-05-20 01:54:08 +02:00
|
|
|
m_fieldModel.setAccountEntry(m_entryModel.isNode(accountIndex) ? nullptr : static_cast<Io::AccountEntry *>(m_entryModel.entry(accountIndex)));
|
|
|
|
emit currentAccountChanged();
|
|
|
|
}
|
|
|
|
|
2018-09-10 22:46:04 +02:00
|
|
|
inline bool Controller::hasCurrentAccount() const
|
|
|
|
{
|
|
|
|
return m_fieldModel.accountEntry() != nullptr;
|
|
|
|
}
|
|
|
|
|
2018-06-11 23:21:15 +02:00
|
|
|
inline const QList<QPersistentModelIndex> &Controller::cutEntries() const
|
|
|
|
{
|
|
|
|
return m_cutEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Controller::setCutEntries(const QList<QPersistentModelIndex> &cutEntries)
|
|
|
|
{
|
|
|
|
cutEntriesChanged(m_cutEntries = cutEntries);
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
inline QString Controller::currentAccountName() const
|
|
|
|
{
|
|
|
|
return m_fieldModel.accountEntry() ? QString::fromStdString(m_fieldModel.accountEntry()->label()) : QStringLiteral("?");
|
|
|
|
}
|
|
|
|
|
2018-06-11 23:21:15 +02:00
|
|
|
inline void Controller::cutEntry(const QModelIndex &entryIndex)
|
|
|
|
{
|
2018-09-16 21:37:30 +02:00
|
|
|
cutEntriesChanged(m_cutEntries << QPersistentModelIndex(ensureSourceEntryIndex(entryIndex)));
|
2018-06-11 23:21:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Controller::canPaste() const
|
|
|
|
{
|
|
|
|
return !m_cutEntries.isEmpty();
|
|
|
|
}
|
|
|
|
|
2018-06-16 15:07:46 +02:00
|
|
|
inline const QStringList &Controller::recentFiles() const
|
|
|
|
{
|
|
|
|
return m_recentFiles;
|
|
|
|
}
|
|
|
|
|
2018-09-04 00:52:43 +02:00
|
|
|
inline bool Controller::useNativeFileDialog() const
|
|
|
|
{
|
|
|
|
return m_useNativeFileDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Controller::supportsNativeFileDialog() const
|
|
|
|
{
|
|
|
|
#if defined(Q_OS_ANDROID) && defined(CPP_UTILITIES_USE_NATIVE_FILE_BUFFER)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:37:30 +02:00
|
|
|
inline QModelIndex Controller::filterEntryIndex(const QModelIndex &entryIndex) const
|
|
|
|
{
|
|
|
|
return m_entryFilterModel.mapFromSource(entryIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QString Controller::entryFilter() const
|
|
|
|
{
|
2022-01-29 19:45:14 +01:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
|
|
|
return m_entryFilterModel.filterRegularExpression().pattern();
|
|
|
|
#else
|
2018-09-16 21:37:30 +02:00
|
|
|
return m_entryFilterModel.filterRegExp().pattern();
|
2022-01-29 19:45:14 +01:00
|
|
|
#endif
|
2018-09-16 21:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Controller::hasEntryFilter() const
|
|
|
|
{
|
2022-01-29 19:45:14 +01:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
|
|
|
return !m_entryFilterModel.filterRegularExpression().pattern().isEmpty();
|
|
|
|
#else
|
2018-09-16 21:37:30 +02:00
|
|
|
return !m_entryFilterModel.filterRegExp().isEmpty();
|
2022-01-29 19:45:14 +01:00
|
|
|
#endif
|
2018-09-16 21:37:30 +02:00
|
|
|
}
|
|
|
|
|
2018-11-20 00:45:05 +01:00
|
|
|
inline bool Controller::filterAsDialog() const
|
|
|
|
{
|
|
|
|
return m_filterAsDialog;
|
|
|
|
}
|
|
|
|
|
2018-11-22 22:05:49 +01:00
|
|
|
inline QUndoStack *Controller::undoStack()
|
|
|
|
{
|
|
|
|
#ifdef PASSWORD_MANAGER_UNDO_SUPPORT
|
|
|
|
return &m_undoStack;
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QString Controller::undoText() const
|
|
|
|
{
|
|
|
|
#ifdef PASSWORD_MANAGER_UNDO_SUPPORT
|
|
|
|
return m_undoStack.undoText();
|
|
|
|
#else
|
|
|
|
return QString();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QString Controller::redoText() const
|
|
|
|
{
|
|
|
|
#ifdef PASSWORD_MANAGER_UNDO_SUPPORT
|
|
|
|
return m_undoStack.redoText();
|
|
|
|
#else
|
|
|
|
return QString();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2024-03-31 22:53:32 +02:00
|
|
|
inline bool Controller::isDarkModeEnabled() const
|
|
|
|
{
|
|
|
|
return m_darkModeEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Controller::setDarkModeEnabled(bool darkModeEnabled)
|
|
|
|
{
|
|
|
|
if (darkModeEnabled != m_darkModeEnabled) {
|
|
|
|
emit darkModeEnabledChanged(m_darkModeEnabled = darkModeEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-22 22:05:49 +01:00
|
|
|
inline void Controller::undo()
|
|
|
|
{
|
|
|
|
#ifdef PASSWORD_MANAGER_UNDO_SUPPORT
|
|
|
|
return m_undoStack.undo();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Controller::redo()
|
|
|
|
{
|
|
|
|
#ifdef PASSWORD_MANAGER_UNDO_SUPPORT
|
|
|
|
return m_undoStack.redo();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-12-21 01:14:41 +01:00
|
|
|
inline QString Controller::computeFileSummary()
|
|
|
|
{
|
|
|
|
return QString::fromStdString(m_file.summary(prepareSaving()));
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:54:08 +02:00
|
|
|
} // namespace QtGui
|
|
|
|
|
|
|
|
#endif // QT_QUICK_GUI_CONTROLLER_H
|