summaryrefslogtreecommitdiffstats
path: root/src/designer/src/lib/shared/qtresourceeditordialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/designer/src/lib/shared/qtresourceeditordialog.cpp')
-rw-r--r--src/designer/src/lib/shared/qtresourceeditordialog.cpp357
1 files changed, 188 insertions, 169 deletions
diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp
index a1c15e708..589363e54 100644
--- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp
+++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Designer of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qtresourceeditordialog_p.h"
#include "ui_qtresourceeditordialog.h"
@@ -36,6 +11,7 @@
#include <QtDesigner/abstractsettings.h>
#include <QtDesigner/abstractformeditor.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
#include <QtCore/qcoreapplication.h>
@@ -49,15 +25,17 @@
QT_BEGIN_NAMESPACE
-static const char *rccRootTag = "RCC";
-static const char *rccTag = "qresource";
-static const char *rccFileTag = "file";
-static const char *rccAliasAttribute = "alias";
-static const char *rccPrefixAttribute = "prefix";
-static const char *rccLangAttribute = "lang";
-static const char *SplitterPosition = "SplitterPosition";
-static const char *Geometry = "Geometry";
-static const char *QrcDialogC = "QrcDialog";
+using namespace Qt::StringLiterals;
+
+static constexpr auto rccRootTag = "RCC"_L1;
+static constexpr auto rccTag = "qresource"_L1;
+static constexpr auto rccFileTag = "file"_L1;
+static constexpr auto rccAliasAttribute = "alias"_L1;
+static constexpr auto rccPrefixAttribute = "prefix"_L1;
+static constexpr auto rccLangAttribute = "lang"_L1;
+static constexpr auto SplitterPosition = "SplitterPosition"_L1;
+static constexpr auto ResourceEditorGeometry = "Geometry"_L1;
+static constexpr auto QrcDialogC = "QrcDialog"_L1;
static QString msgOverwrite(const QString &fname)
{
@@ -69,48 +47,71 @@ static QString msgTagMismatch(const QString &got, const QString &expected)
return QCoreApplication::translate("QtResourceEditorDialog", "The file does not appear to be a resource file; element '%1' was found where '%2' was expected.").arg(got, expected);
}
-namespace {
+namespace qdesigner_internal {
// below 3 data classes should be derived from QSharedData and made implicit shared class
-struct QtResourceFileData {
+struct QtResourceFileData
+{
QString path;
QString alias;
- bool operator==(const QtResourceFileData &other) const
- { return path == other.path && alias == other.alias; }
+
+ friend bool comparesEqual(const QtResourceFileData &lhs,
+ const QtResourceFileData &rhs) noexcept
+ {
+ return lhs.path == rhs.path && lhs.alias == rhs.alias;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(QtResourceFileData)
};
-struct QtResourcePrefixData {
+struct QtResourcePrefixData
+{
QString prefix;
QString language;
QList<QtResourceFileData> resourceFileList;
- bool operator==(const QtResourcePrefixData &other) const
+
+ friend bool comparesEqual(const QtResourcePrefixData &lhs,
+ const QtResourcePrefixData &rhs) noexcept
{
- return prefix == other.prefix && language == other.language
- && resourceFileList == other.resourceFileList;
+ return lhs.prefix == rhs.prefix && lhs.language == rhs.language
+ && lhs.resourceFileList == rhs.resourceFileList;
}
+ Q_DECLARE_EQUALITY_COMPARABLE(QtResourcePrefixData)
};
-struct QtQrcFileData {
+struct QtQrcFileData
+{
QString qrcPath;
QList<QtResourcePrefixData> resourceList;
- bool operator==(const QtQrcFileData &other) const
- { return qrcPath == other.qrcPath && resourceList == other.resourceList; }
+
+ friend bool comparesEqual(const QtQrcFileData &lhs,
+ const QtQrcFileData &rhs) noexcept
+ {
+ return lhs.qrcPath == rhs.qrcPath && lhs.resourceList == rhs.resourceList;
+ }
+ Q_DECLARE_EQUALITY_COMPARABLE(QtQrcFileData)
};
-bool loadResourceFileData(const QDomElement &fileElem, QtResourceFileData *fileData, QString *errorMessage)
+} // namespace qdesigner_internal
+
+using QtResourcePrefixData = qdesigner_internal::QtResourcePrefixData;
+using QtResourceFileData = qdesigner_internal::QtResourceFileData;
+using QtQrcFileData = qdesigner_internal::QtQrcFileData;
+
+static bool loadResourceFileData(const QDomElement &fileElem, QtResourceFileData *fileData,
+ QString *errorMessage)
{
if (!fileData)
return false;
- if (fileElem.tagName() != QLatin1String(rccFileTag)) {
- *errorMessage = msgTagMismatch(fileElem.tagName(), QLatin1String(rccFileTag));
+ if (fileElem.tagName() != rccFileTag) {
+ *errorMessage = msgTagMismatch(fileElem.tagName(), rccFileTag);
return false;
}
QtResourceFileData &data = *fileData;
data.path = fileElem.text();
- data.alias = fileElem.attribute(QLatin1String(rccAliasAttribute));
+ data.alias = fileElem.attribute(rccAliasAttribute);
return true;
}
@@ -120,15 +121,15 @@ static bool loadResourcePrefixData(const QDomElement &prefixElem, QtResourcePref
if (!prefixData)
return false;
- if (prefixElem.tagName() != QLatin1String(rccTag)) {
- *errorMessage = msgTagMismatch(prefixElem.tagName(), QLatin1String(rccTag));
+ if (prefixElem.tagName() != rccTag) {
+ *errorMessage = msgTagMismatch(prefixElem.tagName(), rccTag);
return false;
}
QtResourcePrefixData &data = *prefixData;
- data.prefix = prefixElem.attribute(QLatin1String(rccPrefixAttribute));
- data.language = prefixElem.attribute(QLatin1String(rccLangAttribute));
+ data.prefix = prefixElem.attribute(rccPrefixAttribute);
+ data.language = prefixElem.attribute(rccLangAttribute);
QDomElement fileElem = prefixElem.firstChildElement();
while (!fileElem.isNull()) {
QtResourceFileData fileData;
@@ -148,8 +149,8 @@ static bool loadQrcFileData(const QDomDocument &doc, const QString &path, QtQrcF
QtQrcFileData &data = *qrcFileData;
QDomElement docElem = doc.documentElement();
- if (docElem.tagName() != QLatin1String(rccRootTag)) {
- *errorMessage = msgTagMismatch(docElem.tagName(), QLatin1String(rccRootTag));
+ if (docElem.tagName() != rccRootTag) {
+ *errorMessage = msgTagMismatch(docElem.tagName(), rccRootTag);
return false;
}
@@ -167,11 +168,11 @@ static bool loadQrcFileData(const QDomDocument &doc, const QString &path, QtQrcF
return true;
}
-QDomElement saveResourceFileData(QDomDocument &doc, const QtResourceFileData &fileData)
+static QDomElement saveResourceFileData(QDomDocument &doc, const QtResourceFileData &fileData)
{
- QDomElement fileElem = doc.createElement(QLatin1String(rccFileTag));
+ QDomElement fileElem = doc.createElement(rccFileTag);
if (!fileData.alias.isEmpty())
- fileElem.setAttribute(QLatin1String(rccAliasAttribute), fileData.alias);
+ fileElem.setAttribute(rccAliasAttribute, fileData.alias);
QDomText textElem = doc.createTextNode(fileData.path);
fileElem.appendChild(textElem);
@@ -179,13 +180,13 @@ QDomElement saveResourceFileData(QDomDocument &doc, const QtResourceFileData &fi
return fileElem;
}
-QDomElement saveResourcePrefixData(QDomDocument &doc, const QtResourcePrefixData &prefixData)
+static QDomElement saveResourcePrefixData(QDomDocument &doc, const QtResourcePrefixData &prefixData)
{
- QDomElement prefixElem = doc.createElement(QLatin1String(rccTag));
+ QDomElement prefixElem = doc.createElement(rccTag);
if (!prefixData.prefix.isEmpty())
- prefixElem.setAttribute(QLatin1String(rccPrefixAttribute), prefixData.prefix);
+ prefixElem.setAttribute(rccPrefixAttribute, prefixData.prefix);
if (!prefixData.language.isEmpty())
- prefixElem.setAttribute(QLatin1String(rccLangAttribute), prefixData.language);
+ prefixElem.setAttribute(rccLangAttribute, prefixData.language);
for (const QtResourceFileData &rfd : prefixData.resourceFileList) {
QDomElement fileElem = saveResourceFileData(doc, rfd);
@@ -195,10 +196,10 @@ QDomElement saveResourcePrefixData(QDomDocument &doc, const QtResourcePrefixData
return prefixElem;
}
-QDomDocument saveQrcFileData(const QtQrcFileData &qrcFileData)
+static QDomDocument saveQrcFileData(const QtQrcFileData &qrcFileData)
{
QDomDocument doc;
- QDomElement docElem = doc.createElement(QLatin1String(rccRootTag));
+ QDomElement docElem = doc.createElement(rccRootTag);
for (const QtResourcePrefixData &prefixData : qrcFileData.resourceList) {
QDomElement prefixElem = saveResourcePrefixData(doc, prefixData);
@@ -208,6 +209,9 @@ QDomDocument saveQrcFileData(const QtQrcFileData &qrcFileData)
return doc;
}
+
+namespace qdesigner_internal {
+
// --------------- QtResourceFile
class QtResourceFile {
public:
@@ -334,9 +338,9 @@ private:
QList<QtQrcFile *> m_qrcFiles;
QMap<QString, QtQrcFile *> m_pathToQrc;
- QMap<QtQrcFile *, bool> m_qrcFileToExists;
- QMap<QtResourcePrefix *, QtQrcFile *> m_prefixToQrc;
- QMap<QtResourceFile *, QtResourcePrefix *> m_fileToPrefix;
+ QHash<QtQrcFile *, bool> m_qrcFileToExists;
+ QHash<QtResourcePrefix *, QtQrcFile *> m_prefixToQrc;
+ QHash<QtResourceFile *, QtResourcePrefix *> m_fileToPrefix;
QMap<QString, QList<QtResourceFile *> > m_fullPathToResourceFiles;
QMap<QString, QIcon> m_fullPathToIcon;
QMap<QString, bool> m_fullPathToExists;
@@ -784,9 +788,12 @@ void QtQrcManager::removeResourceFile(QtResourceFile *resourceFile)
delete resourceFile;
}
+} // namespace qdesigner_internal
-
-}
+using QtResourceFile = qdesigner_internal::QtResourceFile;
+using QtResourcePrefix = qdesigner_internal::QtResourcePrefix;
+using QtQrcFile = qdesigner_internal::QtQrcFile;
+using QtQrcManager = qdesigner_internal::QtQrcManager;
// ----------------- QtResourceEditorDialogPrivate
class QtResourceEditorDialogPrivate
@@ -859,16 +866,16 @@ public:
QtQrcManager *m_qrcManager = nullptr;
QList<QtQrcFileData> m_initialState;
- QMap<QtQrcFile *, QListWidgetItem *> m_qrcFileToItem;
- QMap<QListWidgetItem *, QtQrcFile *> m_itemToQrcFile;
- QMap<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToPrefixItem;
- QMap<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToLanguageItem;
- QMap<QStandardItem *, QtResourcePrefix *> m_prefixItemToResourcePrefix;
- QMap<QStandardItem *, QtResourcePrefix *> m_languageItemToResourcePrefix;
- QMap<QtResourceFile *, QStandardItem *> m_resourceFileToPathItem;
- QMap<QtResourceFile *, QStandardItem *> m_resourceFileToAliasItem;
- QMap<QStandardItem *, QtResourceFile *> m_pathItemToResourceFile;
- QMap<QStandardItem *, QtResourceFile *> m_aliasItemToResourceFile;
+ QHash<QtQrcFile *, QListWidgetItem *> m_qrcFileToItem;
+ QHash<QListWidgetItem *, QtQrcFile *> m_itemToQrcFile;
+ QHash<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToPrefixItem;
+ QHash<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToLanguageItem;
+ QHash<QStandardItem *, QtResourcePrefix *> m_prefixItemToResourcePrefix;
+ QHash<QStandardItem *, QtResourcePrefix *> m_languageItemToResourcePrefix;
+ QHash<QtResourceFile *, QStandardItem *> m_resourceFileToPathItem;
+ QHash<QtResourceFile *, QStandardItem *> m_resourceFileToAliasItem;
+ QHash<QStandardItem *, QtResourceFile *> m_pathItemToResourceFile;
+ QHash<QStandardItem *, QtResourceFile *> m_aliasItemToResourceFile;
bool m_ignoreCurrentChanged = false;
bool m_firstQrcFileDialog = true;
@@ -1186,7 +1193,7 @@ void QtResourceEditorDialogPrivate::slotCurrentQrcFileChanged(QListWidgetItem *i
return;
if (m_currentQrcFile) {
- QMap<QtResourcePrefix *, QStandardItem *> currentPrefixList = m_resourcePrefixToPrefixItem;
+ QHash<QtResourcePrefix *, QStandardItem *> currentPrefixList = m_resourcePrefixToPrefixItem;
for (auto it = currentPrefixList.cbegin(), end = currentPrefixList.cend(); it != end; ++it) {
QtResourcePrefix *resourcePrefix = it.key();
const auto currentResourceFiles = resourcePrefix->resourceFiles();
@@ -1312,8 +1319,6 @@ void QtResourceEditorDialogPrivate::slotTreeViewItemChanged(QStandardItem *item)
QString QtResourceEditorDialogPrivate::getSaveFileNameWithExtension(QWidget *parent,
const QString &title, QString dir, const QString &filter, const QString &extension) const
{
- const QChar dot = QLatin1Char('.');
-
QString saveFile;
while (true) {
saveFile = m_dlgGui->getSaveFileName(parent, title, dir, filter, nullptr, QFileDialog::DontConfirmOverwrite);
@@ -1321,10 +1326,8 @@ QString QtResourceEditorDialogPrivate::getSaveFileNameWithExtension(QWidget *par
return saveFile;
const QFileInfo fInfo(saveFile);
- if (fInfo.suffix().isEmpty() && !fInfo.fileName().endsWith(dot)) {
- saveFile += dot;
- saveFile += extension;
- }
+ if (fInfo.suffix().isEmpty() && !fInfo.fileName().endsWith(u'.'))
+ saveFile += u'.' + extension;
const QFileInfo fi(saveFile);
if (!fi.exists())
@@ -1352,7 +1355,7 @@ void QtResourceEditorDialogPrivate::slotNewQrcFile()
QCoreApplication::translate("QtResourceEditorDialog", "New Resource File"),
m_firstQrcFileDialog ? qrcStartDirectory() : QString(),
QCoreApplication::translate("QtResourceEditorDialog", "Resource files (*.qrc)"),
- QStringLiteral("qrc"));
+ u"qrc"_s);
if (qrcPath.isEmpty())
return;
@@ -1543,7 +1546,7 @@ void QtResourceEditorDialogPrivate::slotAddFiles()
QtResourceFile *nextResourceFile = m_qrcManager->nextResourceFile(currentResourceFile);
if (!currentResourceFile) {
const auto resourceFiles = currentResourcePrefix->resourceFiles();
- if (resourceFiles.count() > 0)
+ if (!resourceFiles.isEmpty())
nextResourceFile = resourceFiles.first();
}
@@ -1552,7 +1555,7 @@ void QtResourceEditorDialogPrivate::slotAddFiles()
const QDir dir(fi.absolutePath());
for (QString resourcePath : resourcePaths) {
QString relativePath = dir.relativeFilePath(resourcePath);
- if (relativePath.startsWith(QStringLiteral(".."))) {
+ if (relativePath.startsWith(".."_L1)) {
QMessageBox msgBox(QMessageBox::Warning,
QCoreApplication::translate("QtResourceEditorDialog", "Incorrect Path"),
outOfPathWarning(relativePath), QMessageBox::Cancel);
@@ -1667,7 +1670,7 @@ void QtResourceEditorDialogPrivate::slotClonePrefix()
QDir dir(fi.dir());
QString oldSuffix = fi.completeSuffix();
if (!oldSuffix.isEmpty())
- oldSuffix = QLatin1Char('.') + oldSuffix;
+ oldSuffix = u'.' + oldSuffix;
const QString newBaseName = fi.baseName() + suffix + oldSuffix;
const QString newPath = QDir::cleanPath(dir.filePath(newBaseName));
m_qrcManager->insertResourceFile(newResourcePrefix, newPath,
@@ -1765,7 +1768,7 @@ QString QtResourceEditorDialogPrivate::browseForNewLocation(const QString &resou
QCoreApplication::translate("QtResourceEditorDialog", "Copy As"),
initialPath);
QString relativePath = rootDir.relativeFilePath(newPath);
- if (relativePath.startsWith(QStringLiteral(".."))) {
+ if (relativePath.startsWith(".."_L1)) {
if (warning(QCoreApplication::translate("QtResourceEditorDialog", "Copy As"),
QCoreApplication::translate("QtResourceEditorDialog", "<p>The selected file:</p>"
"<p>%1</p><p>is outside of the current resource file's directory:</p><p>%2</p>"
@@ -1827,16 +1830,15 @@ bool QtResourceEditorDialogPrivate::loadQrcFile(const QString &path, QtQrcFileDa
file.close();
QDomDocument doc;
- int errLine, errCol;
- if (!doc.setContent(dataArray, errorMessage, &errLine, &errCol)) {
+ if (QDomDocument::ParseResult result = doc.setContent(dataArray)) {
+ return loadQrcFileData(doc, path, qrcFileData, errorMessage);
+ } else {
*errorMessage =
QCoreApplication::translate("QtResourceEditorDialog",
"A parse error occurred at line %1, column %2 of %3:\n%4")
- .arg(errLine).arg(errCol).arg(path, *errorMessage);
+ .arg(result.errorLine).arg(result.errorColumn).arg(path, result.errorMessage);
return false;
}
-
- return loadQrcFileData(doc, path, qrcFileData, errorMessage);
}
bool QtResourceEditorDialogPrivate::saveQrcFile(const QtQrcFileData &qrcFileData)
@@ -1881,41 +1883,42 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor
d_ptr->m_dlgGui = dlgGui;
d_ptr->m_core = core;
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Edit Resources"));
- connect(d_ptr->m_qrcManager, SIGNAL(qrcFileInserted(QtQrcFile*)),
- this, SLOT(slotQrcFileInserted(QtQrcFile*)));
- connect(d_ptr->m_qrcManager, SIGNAL(qrcFileMoved(QtQrcFile*,QtQrcFile*)),
- this, SLOT(slotQrcFileMoved(QtQrcFile*)));
- connect(d_ptr->m_qrcManager, SIGNAL(qrcFileRemoved(QtQrcFile*)),
- this, SLOT(slotQrcFileRemoved(QtQrcFile*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixInserted(QtResourcePrefix*)),
- this, SLOT(slotResourcePrefixInserted(QtResourcePrefix*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixMoved(QtResourcePrefix*,QtResourcePrefix*)),
- this, SLOT(slotResourcePrefixMoved(QtResourcePrefix*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixChanged(QtResourcePrefix*,QString)),
- this, SLOT(slotResourcePrefixChanged(QtResourcePrefix*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourceLanguageChanged(QtResourcePrefix*,QString)),
- this, SLOT(slotResourceLanguageChanged(QtResourcePrefix*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixRemoved(QtResourcePrefix*)),
- this, SLOT(slotResourcePrefixRemoved(QtResourcePrefix*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourceFileInserted(QtResourceFile*)),
- this, SLOT(slotResourceFileInserted(QtResourceFile*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourceFileMoved(QtResourceFile*,QtResourceFile*)),
- this, SLOT(slotResourceFileMoved(QtResourceFile*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourceAliasChanged(QtResourceFile*,QString)),
- this, SLOT(slotResourceAliasChanged(QtResourceFile*)));
- connect(d_ptr->m_qrcManager, SIGNAL(resourceFileRemoved(QtResourceFile*)),
- this, SLOT(slotResourceFileRemoved(QtResourceFile*)));
-
- QIcon upIcon = qdesigner_internal::createIconSet(QString::fromUtf8("up.png"));
- QIcon downIcon = qdesigner_internal::createIconSet(QString::fromUtf8("down.png"));
- QIcon minusIcon = qdesigner_internal::createIconSet(QString::fromUtf8("minus-16.png"));
- QIcon newIcon = qdesigner_internal::createIconSet(QString::fromUtf8("filenew-16.png"));
- QIcon openIcon = qdesigner_internal::createIconSet(QString::fromUtf8("fileopen-16.png"));
- QIcon removeIcon = qdesigner_internal::createIconSet(QString::fromUtf8("editdelete-16.png"));
- QIcon addPrefixIcon = qdesigner_internal::createIconSet(QString::fromUtf8("prefix-add.png"));
+ connect(d_ptr->m_qrcManager, &QtQrcManager::qrcFileInserted,
+ this, [this](QtQrcFile *file) { d_ptr->slotQrcFileInserted(file); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::qrcFileMoved,
+ this, [this](QtQrcFile *file) { d_ptr->slotQrcFileMoved(file); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::qrcFileRemoved,
+ this, [this](QtQrcFile *file) { d_ptr->slotQrcFileRemoved(file); });
+
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixInserted,
+ this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixInserted(prefix); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixMoved,
+ this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixMoved(prefix); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixChanged,
+ this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixChanged(prefix); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourceLanguageChanged,
+ this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourceLanguageChanged(prefix); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixRemoved,
+ this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixRemoved(prefix); });
+
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourceFileInserted,
+ this, [this](QtResourceFile *file) { d_ptr->slotResourceFileInserted(file); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourceFileMoved,
+ this, [this](QtResourceFile *file) { d_ptr->slotResourceFileMoved(file); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourceAliasChanged,
+ this, [this](QtResourceFile *file) { d_ptr->slotResourceAliasChanged(file); });
+ connect(d_ptr->m_qrcManager, &QtQrcManager::resourceFileRemoved,
+ this, [this](QtResourceFile *file) { d_ptr->slotResourceFileRemoved(file); });
+
+ QIcon upIcon = qdesigner_internal::createIconSet("up.png"_L1);
+ QIcon downIcon = qdesigner_internal::createIconSet("down.png"_L1);
+ QIcon minusIcon = qdesigner_internal::createIconSet("minus-16.png"_L1);
+ QIcon newIcon = qdesigner_internal::createIconSet("filenew-16.png"_L1);
+ QIcon openIcon = qdesigner_internal::createIconSet("fileopen-16.png"_L1);
+ QIcon removeIcon = qdesigner_internal::createIconSet("editdelete-16.png"_L1);
+ QIcon addPrefixIcon = qdesigner_internal::createIconSet("prefix-add.png"_L1);
d_ptr->m_newQrcFileAction = new QAction(newIcon, tr("New..."), this);
d_ptr->m_newQrcFileAction->setToolTip(tr("New Resource File"));
@@ -1944,27 +1947,41 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor
d_ptr->m_ui.addResourceButton->setDefaultAction(d_ptr->m_addResourceFileAction);
d_ptr->m_ui.removeResourceButton->setDefaultAction(d_ptr->m_removeAction);
- connect(d_ptr->m_newQrcFileAction, SIGNAL(triggered()), this, SLOT(slotNewQrcFile()));
- connect(d_ptr->m_importQrcFileAction, SIGNAL(triggered()), this, SLOT(slotImportQrcFile()));
- connect(d_ptr->m_removeQrcFileAction, SIGNAL(triggered()), this, SLOT(slotRemoveQrcFile()));
- connect(d_ptr->m_moveUpQrcFileAction, SIGNAL(triggered()), this, SLOT(slotMoveUpQrcFile()));
- connect(d_ptr->m_moveDownQrcFileAction, SIGNAL(triggered()), this, SLOT(slotMoveDownQrcFile()));
-
- connect(d_ptr->m_newPrefixAction, SIGNAL(triggered()), this, SLOT(slotNewPrefix()));
- connect(d_ptr->m_addResourceFileAction, SIGNAL(triggered()), this, SLOT(slotAddFiles()));
- connect(d_ptr->m_changePrefixAction, SIGNAL(triggered()), this, SLOT(slotChangePrefix()));
- connect(d_ptr->m_changeLanguageAction, SIGNAL(triggered()), this, SLOT(slotChangeLanguage()));
- connect(d_ptr->m_changeAliasAction, SIGNAL(triggered()), this, SLOT(slotChangeAlias()));
- connect(d_ptr->m_clonePrefixAction, SIGNAL(triggered()), this, SLOT(slotClonePrefix()));
- connect(d_ptr->m_removeAction, SIGNAL(triggered()), this, SLOT(slotRemove()));
- connect(d_ptr->m_moveUpAction, SIGNAL(triggered()), this, SLOT(slotMoveUp()));
- connect(d_ptr->m_moveDownAction, SIGNAL(triggered()), this, SLOT(slotMoveDown()));
+ connect(d_ptr->m_newQrcFileAction, &QAction::triggered,
+ this, [this] { d_ptr->slotNewQrcFile(); });
+ connect(d_ptr->m_importQrcFileAction, &QAction::triggered,
+ this, [this] { d_ptr->slotImportQrcFile(); });
+ connect(d_ptr->m_removeQrcFileAction, &QAction::triggered,
+ this, [this] { d_ptr->slotRemoveQrcFile(); });
+ connect(d_ptr->m_moveUpQrcFileAction, &QAction::triggered,
+ this, [this] { d_ptr->slotMoveUpQrcFile(); });
+ connect(d_ptr->m_moveDownQrcFileAction, &QAction::triggered,
+ this, [this] { d_ptr->slotMoveDownQrcFile(); });
+
+ connect(d_ptr->m_newPrefixAction, &QAction::triggered,
+ this, [this] { d_ptr->slotNewPrefix(); });
+ connect(d_ptr->m_addResourceFileAction, &QAction::triggered,
+ this, [this] { d_ptr->slotAddFiles(); });
+ connect(d_ptr->m_changePrefixAction, &QAction::triggered,
+ this, [this] { d_ptr->slotChangePrefix(); });
+ connect(d_ptr->m_changeLanguageAction, &QAction::triggered,
+ this, [this] { d_ptr->slotChangeLanguage(); });
+ connect(d_ptr->m_changeAliasAction, &QAction::triggered,
+ this, [this] { d_ptr->slotChangeAlias(); });
+ connect(d_ptr->m_clonePrefixAction, &QAction::triggered,
+ this, [this] { d_ptr->slotClonePrefix(); });
+ connect(d_ptr->m_removeAction, &QAction::triggered,
+ this, [this] { d_ptr->slotRemove(); });
+ connect(d_ptr->m_moveUpAction, &QAction::triggered,
+ this, [this] { d_ptr->slotMoveUp(); });
+ connect(d_ptr->m_moveDownAction, &QAction::triggered,
+ this, [this] { d_ptr->slotMoveDown(); });
d_ptr->m_ui.qrcFileList->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(d_ptr->m_ui.qrcFileList, SIGNAL(customContextMenuRequested(QPoint)),
- this, SLOT(slotListWidgetContextMenuRequested(QPoint)));
- connect(d_ptr->m_ui.qrcFileList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
- this, SLOT(slotCurrentQrcFileChanged(QListWidgetItem*)));
+ connect(d_ptr->m_ui.qrcFileList, &QListWidget::customContextMenuRequested,
+ this, [this](const QPoint &point) { d_ptr->slotListWidgetContextMenuRequested(point); });
+ connect(d_ptr->m_ui.qrcFileList, &QListWidget::currentItemChanged,
+ this, [this](QListWidgetItem *item) { d_ptr->slotCurrentQrcFileChanged(item); });
d_ptr->m_treeModel = new QStandardItemModel(this);
d_ptr->m_treeModel->setColumnCount(2);
@@ -1977,12 +1994,12 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor
d_ptr->m_ui.resourceTreeView, &QTreeView::resizeColumnToContents);
d_ptr->m_ui.resourceTreeView->setTextElideMode(Qt::ElideLeft);
- connect(d_ptr->m_ui.resourceTreeView, SIGNAL(customContextMenuRequested(QPoint)),
- this, SLOT(slotTreeViewContextMenuRequested(QPoint)));
- connect(d_ptr->m_treeModel, SIGNAL(itemChanged(QStandardItem*)),
- this, SLOT(slotTreeViewItemChanged(QStandardItem*)));
- connect(d_ptr->m_treeSelection, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- this, SLOT(slotCurrentTreeViewItemChanged(QModelIndex)));
+ connect(d_ptr->m_ui.resourceTreeView, &QTreeView::customContextMenuRequested,
+ this, [this](const QPoint &point) { d_ptr->slotTreeViewContextMenuRequested(point); });
+ connect(d_ptr->m_treeModel, &QStandardItemModel::itemChanged,
+ this, [this](QStandardItem *item) { d_ptr->slotTreeViewItemChanged(item); });
+ connect(d_ptr->m_treeSelection, &QItemSelectionModel::currentChanged,
+ this, [this](const QModelIndex &index) { d_ptr->slotCurrentTreeViewItemChanged(index); });
d_ptr->m_ui.resourceTreeView->setColumnWidth(0, 200);
@@ -1992,11 +2009,11 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor
d_ptr->m_moveDownQrcFileAction->setEnabled(false);
QDesignerSettingsInterface *settings = core->settingsManager();
- settings->beginGroup(QLatin1String(QrcDialogC));
+ settings->beginGroup(QrcDialogC);
- d_ptr->m_ui.splitter->restoreState(settings->value(QLatin1String(SplitterPosition)).toByteArray());
- const QVariant geometry = settings->value(QLatin1String(Geometry));
- if (geometry.type() == QVariant::ByteArray) // Used to be a QRect up until 5.4.0, QTBUG-43374
+ d_ptr->m_ui.splitter->restoreState(settings->value(SplitterPosition).toByteArray());
+ const QVariant geometry = settings->value(ResourceEditorGeometry);
+ if (geometry.metaType().id() == QMetaType::QByteArray) // Used to be a QRect up until 5.4.0, QTBUG-43374
restoreGeometry(geometry.toByteArray());
settings->endGroup();
@@ -2005,11 +2022,13 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor
QtResourceEditorDialog::~QtResourceEditorDialog()
{
QDesignerSettingsInterface *settings = d_ptr->m_core->settingsManager();
- settings->beginGroup(QLatin1String(QrcDialogC));
+ settings->beginGroup(QrcDialogC);
- settings->setValue(QLatin1String(SplitterPosition), d_ptr->m_ui.splitter->saveState());
- settings->setValue(QLatin1String(Geometry), saveGeometry());
+ settings->setValue(SplitterPosition, d_ptr->m_ui.splitter->saveState());
+ settings->setValue(ResourceEditorGeometry, saveGeometry());
settings->endGroup();
+
+ disconnect(d_ptr->m_qrcManager, nullptr, this, nullptr);
}
QtResourceModel *QtResourceEditorDialog::model() const
@@ -2050,13 +2069,13 @@ QString QtResourceEditorDialog::selectedResource() const
if (!currentResourcePrefix)
return QString();
- const QChar slash(QLatin1Char('/'));
+ const QChar slash(u'/');
QString resource = currentResourcePrefix->prefix();
if (!resource.startsWith(slash))
resource.prepend(slash);
if (!resource.endsWith(slash))
resource.append(slash);
- resource.prepend(QLatin1Char(':'));
+ resource.prepend(u':');
QtResourceFile *currentResourceFile = d_ptr->getCurrentResourceFile();
if (!currentResourceFile)
@@ -2066,15 +2085,15 @@ QString QtResourceEditorDialog::selectedResource() const
if (!currentResourceFile->alias().isEmpty())
resourceEnding = currentResourceFile->alias();
- const QString dotSlash(QStringLiteral("./"));
- const QString dotDotSlash(QStringLiteral("../"));
+ const auto dotSlash = "./"_L1;
+ const auto dotDotSlash = "../"_L1;
while (true) {
if (resourceEnding.startsWith(slash))
resourceEnding = resourceEnding.mid(1);
else if (resourceEnding.startsWith(dotSlash))
- resourceEnding = resourceEnding.mid(dotSlash.count());
+ resourceEnding = resourceEnding.mid(dotSlash.size());
else if (resourceEnding.startsWith(dotDotSlash))
- resourceEnding = resourceEnding.mid(dotDotSlash.count());
+ resourceEnding = resourceEnding.mid(dotDotSlash.size());
else
break;
}