Adapt C++ code of Qt Quick GUI to Qt 6
This commit is contained in:
parent
16b1051c68
commit
eb6fc17f6b
|
@ -4,6 +4,7 @@
|
||||||
#include <passwordfile/io/cryptoexception.h>
|
#include <passwordfile/io/cryptoexception.h>
|
||||||
#include <passwordfile/io/parsingexception.h>
|
#include <passwordfile/io/parsingexception.h>
|
||||||
|
|
||||||
|
#include <qtutilities/misc/compat.h>
|
||||||
#include <qtutilities/misc/dialogutils.h>
|
#include <qtutilities/misc/dialogutils.h>
|
||||||
|
|
||||||
#include <c++utilities/io/nativefilestream.h>
|
#include <c++utilities/io/nativefilestream.h>
|
||||||
|
@ -73,9 +74,9 @@ Controller::Controller(QSettings &settings, const QString &filePath, QObject *pa
|
||||||
void Controller::setFilePath(const QString &filePath)
|
void Controller::setFilePath(const QString &filePath)
|
||||||
{
|
{
|
||||||
// get rid of file:// prefix
|
// get rid of file:// prefix
|
||||||
QStringRef actualFilePath(&filePath);
|
auto actualFilePath = makeStringView(filePath);
|
||||||
if (filePath.startsWith(QLatin1String("file:"))) {
|
if (filePath.startsWith(QLatin1String("file:"))) {
|
||||||
actualFilePath = filePath.midRef(5);
|
actualFilePath = midRef(filePath, 5);
|
||||||
}
|
}
|
||||||
while (actualFilePath.startsWith(QLatin1String("//"))) {
|
while (actualFilePath.startsWith(QLatin1String("//"))) {
|
||||||
actualFilePath = actualFilePath.mid(1);
|
actualFilePath = actualFilePath.mid(1);
|
||||||
|
@ -483,11 +484,19 @@ void Controller::setUseNativeFileDialog(bool useNativeFileDialog)
|
||||||
|
|
||||||
void Controller::setEntryFilter(const QString &filter)
|
void Controller::setEntryFilter(const QString &filter)
|
||||||
{
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
const auto previousFilter(m_entryFilterModel.filterRegularExpression().pattern());
|
||||||
|
#else
|
||||||
const auto previousFilter(m_entryFilterModel.filterRegExp().pattern());
|
const auto previousFilter(m_entryFilterModel.filterRegExp().pattern());
|
||||||
|
#endif
|
||||||
if (filter == previousFilter) {
|
if (filter == previousFilter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
m_entryFilterModel.setFilterRegularExpression(filter);
|
||||||
|
#else
|
||||||
m_entryFilterModel.setFilterRegExp(filter);
|
m_entryFilterModel.setFilterRegExp(filter);
|
||||||
|
#endif
|
||||||
emit entryFilterChanged(filter);
|
emit entryFilterChanged(filter);
|
||||||
if (previousFilter.isEmpty() != filter.isEmpty()) {
|
if (previousFilter.isEmpty() != filter.isEmpty()) {
|
||||||
emit hasEntryFilterChanged(!filter.isEmpty());
|
emit hasEntryFilterChanged(!filter.isEmpty());
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
QUndoStack *undoStack();
|
QUndoStack *undoStack();
|
||||||
QString undoText() const;
|
QString undoText() const;
|
||||||
QString redoText() const;
|
QString redoText() const;
|
||||||
|
Io::PasswordFileSaveFlags prepareSaving();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void init();
|
void init();
|
||||||
|
@ -101,7 +102,6 @@ public Q_SLOTS:
|
||||||
void handleFileSelectionCanceled();
|
void handleFileSelectionCanceled();
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
Io::PasswordFileSaveFlags prepareSaving();
|
|
||||||
QString computeFileSummary();
|
QString computeFileSummary();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -296,12 +296,20 @@ inline QModelIndex Controller::filterEntryIndex(const QModelIndex &entryIndex) c
|
||||||
|
|
||||||
inline QString Controller::entryFilter() const
|
inline QString Controller::entryFilter() const
|
||||||
{
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
return m_entryFilterModel.filterRegularExpression().pattern();
|
||||||
|
#else
|
||||||
return m_entryFilterModel.filterRegExp().pattern();
|
return m_entryFilterModel.filterRegExp().pattern();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Controller::hasEntryFilter() const
|
inline bool Controller::hasEntryFilter() const
|
||||||
{
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
return !m_entryFilterModel.filterRegularExpression().pattern().isEmpty();
|
||||||
|
#else
|
||||||
return !m_entryFilterModel.filterRegExp().isEmpty();
|
return !m_entryFilterModel.filterRegExp().isEmpty();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Controller::filterAsDialog() const
|
inline bool Controller::filterAsDialog() const
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -53,7 +52,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
|
|
||||||
// init application
|
// init application
|
||||||
SET_QT_APPLICATION_INFO;
|
SET_QT_APPLICATION_INFO;
|
||||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
||||||
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue