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/parsingexception.h>
|
||||
|
||||
#include <qtutilities/misc/compat.h>
|
||||
#include <qtutilities/misc/dialogutils.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)
|
||||
{
|
||||
// get rid of file:// prefix
|
||||
QStringRef actualFilePath(&filePath);
|
||||
auto actualFilePath = makeStringView(filePath);
|
||||
if (filePath.startsWith(QLatin1String("file:"))) {
|
||||
actualFilePath = filePath.midRef(5);
|
||||
actualFilePath = midRef(filePath, 5);
|
||||
}
|
||||
while (actualFilePath.startsWith(QLatin1String("//"))) {
|
||||
actualFilePath = actualFilePath.mid(1);
|
||||
|
@ -483,11 +484,19 @@ void Controller::setUseNativeFileDialog(bool useNativeFileDialog)
|
|||
|
||||
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());
|
||||
#endif
|
||||
if (filter == previousFilter) {
|
||||
return;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
m_entryFilterModel.setFilterRegularExpression(filter);
|
||||
#else
|
||||
m_entryFilterModel.setFilterRegExp(filter);
|
||||
#endif
|
||||
emit entryFilterChanged(filter);
|
||||
if (previousFilter.isEmpty() != filter.isEmpty()) {
|
||||
emit hasEntryFilterChanged(!filter.isEmpty());
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
QUndoStack *undoStack();
|
||||
QString undoText() const;
|
||||
QString redoText() const;
|
||||
Io::PasswordFileSaveFlags prepareSaving();
|
||||
|
||||
public Q_SLOTS:
|
||||
void init();
|
||||
|
@ -101,7 +102,6 @@ public Q_SLOTS:
|
|||
void handleFileSelectionCanceled();
|
||||
void undo();
|
||||
void redo();
|
||||
Io::PasswordFileSaveFlags prepareSaving();
|
||||
QString computeFileSummary();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -296,12 +296,20 @@ inline QModelIndex Controller::filterEntryIndex(const QModelIndex &entryIndex) c
|
|||
|
||||
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();
|
||||
#endif
|
||||
}
|
||||
|
||||
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();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool Controller::filterAsDialog() const
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <QtQml>
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QDebug>
|
||||
|
@ -53,7 +52,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
|||
|
||||
// init application
|
||||
SET_QT_APPLICATION_INFO;
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||
QApplication application(argc, argv);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue