diff --git a/src/Editor/CExportGameDialog.cpp b/src/Editor/CExportGameDialog.cpp index f288ee8d..00d06b94 100644 --- a/src/Editor/CExportGameDialog.cpp +++ b/src/Editor/CExportGameDialog.cpp @@ -52,7 +52,7 @@ void CExportGameDialog::InitUI(QString ExportDir) CGameInfo GameInfo; GameInfo.LoadGameInfo(mGame); - ExportDir.replace('\\', '/'); + ExportDir.replace(QLatin1Char{'\\'}, QLatin1Char{'/'}); TString DefaultNameMapPath = CAssetNameMap::DefaultNameMapPath(mGame); if (!FileUtil::Exists(DefaultNameMapPath)) DefaultNameMapPath = ""; @@ -68,7 +68,7 @@ void CExportGameDialog::InitUI(QString ExportDir) mpUI->GameTitleLineEdit->setText( TO_QSTRING(mGameTitle) ); mpUI->GameIdLineEdit->setText( TO_QSTRING(mGameID) ); mpUI->BuildVersionLineEdit->setText(tr("%1 (%2)").arg(mBuildVer).arg(TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion)))); - mpUI->RegionLineEdit->setText(TEnumReflection::ConvertValueToString(mRegion)); + mpUI->RegionLineEdit->setText(QString::fromUtf8(TEnumReflection::ConvertValueToString(mRegion))); // Disc tree widget nod::IPartition *pPartition = mpDisc->getDataPartition(); diff --git a/src/Editor/CGeneratePropertyNamesDialog.cpp b/src/Editor/CGeneratePropertyNamesDialog.cpp index 381cf8b3..2468a824 100644 --- a/src/Editor/CGeneratePropertyNamesDialog.cpp +++ b/src/Editor/CGeneratePropertyNamesDialog.cpp @@ -219,7 +219,7 @@ void CGeneratePropertyNamesDialog::OnTreeItemDoubleClicked(QTreeWidgetItem* pIte const QString Text = pItem->text(0); - if (!Text.endsWith(".xml")) + if (!Text.endsWith(QStringLiteral(".xml"))) return; const TString TStrText = TO_TSTRING(Text); diff --git a/src/Editor/CMakeLists.txt b/src/Editor/CMakeLists.txt index 7e659376..714c8279 100644 --- a/src/Editor/CMakeLists.txt +++ b/src/Editor/CMakeLists.txt @@ -121,6 +121,14 @@ target_compile_definitions( "APP_VERSION=\"${PROJECT_VERSION}\"" "APP_FULL_NAME=\"${PWE_APP_NAME} ${PWE_WC_DESCRIBE}\"" UNICODE + + # Ensures conversions to internal strings and Qt strings are explicit + QT_NO_CAST_FROM_ASCII + QT_NO_CAST_FROM_BYTEARRAY + QT_NO_CAST_TO_ASCII + + # Disable deprecated Qt snprintf functions + QT_NO_QSNPRINTF ) gather_include_directories(pwe_editor_include_directories pwe_editor) diff --git a/src/Editor/CProjectSettingsDialog.cpp b/src/Editor/CProjectSettingsDialog.cpp index aec7ed88..2ca9fcc3 100644 --- a/src/Editor/CProjectSettingsDialog.cpp +++ b/src/Editor/CProjectSettingsDialog.cpp @@ -105,7 +105,7 @@ void CProjectSettingsDialog::SetupPackagesList() QString PackageName = TO_QSTRING(pPackage->Name()); if (pPackage->NeedsRecook()) - PackageName += '*'; + PackageName += QLatin1Char{'*'}; mpUI->PackagesList->addItem(PackageName); } } diff --git a/src/Editor/CTweakEditor.cpp b/src/Editor/CTweakEditor.cpp index e67db4d8..081fc8c9 100644 --- a/src/Editor/CTweakEditor.cpp +++ b/src/Editor/CTweakEditor.cpp @@ -2,6 +2,8 @@ #include "ui_CTweakEditor.h" #include "Editor/Undo/IUndoCommand.h" +#include + /** Internal undo command for changing tabs */ class CSetTweakIndexCommand : public IUndoCommand { @@ -10,7 +12,7 @@ class CSetTweakIndexCommand : public IUndoCommand public: CSetTweakIndexCommand(CTweakEditor* pEditor, int OldIndex, int NewIndex) - : IUndoCommand("Change Tab") + : IUndoCommand(QCoreApplication::translate("CSetTweakIndexCommand", "Change Tab")) , mpEditor(pEditor) , mOldIndex(OldIndex) , mNewIndex(NewIndex) diff --git a/src/Editor/MacOSExtras.mm b/src/Editor/MacOSExtras.mm index 470eb890..d4a929ba 100644 --- a/src/Editor/MacOSExtras.mm +++ b/src/Editor/MacOSExtras.mm @@ -20,7 +20,7 @@ QString MacOSPathToDolphinBinary() /* Filter to accumulate relative coordinates of middle and right mouse drags for camera control. */ bool MouseDragCocoaEventFilter::nativeEventFilter(const QByteArray& eventType, void* message, long*) { - if (eventType == "mac_generic_NSEvent") + if (eventType == QByteArrayLiteral("mac_generic_NSEvent")) { NSEvent* event = static_cast(message); NSEventType evType = event.type; diff --git a/src/Editor/ModelEditor/CModelEditorWindow.cpp b/src/Editor/ModelEditor/CModelEditorWindow.cpp index 3feb1b81..6484a44d 100644 --- a/src/Editor/ModelEditor/CModelEditorWindow.cpp +++ b/src/Editor/ModelEditor/CModelEditorWindow.cpp @@ -754,7 +754,7 @@ void CModelEditorWindow::Import() SetActiveModel(pModel); SET_WINDOWTITLE_APPVARS(tr("%APP_FULL_NAME% - Model Editor: Untitled")); - mOutputFilename = ""; + mOutputFilename.clear(); gpResourceStore->DestroyUnreferencedResources(); } @@ -785,7 +785,7 @@ void CModelEditorWindow::ConvertToDDS() void CModelEditorWindow::ConvertToTXTR() { - QString Input = QFileDialog::getOpenFileName(this, "DirectDraw Surface (*.dds)", "", "*.dds"); + QString Input = QFileDialog::getOpenFileName(this, tr("DirectDraw Surface (*.dds)"), QString(), QStringLiteral("*.dds")); if (Input.isEmpty()) return; TString TexFilename = TO_TSTRING(Input); diff --git a/src/Editor/NDolphinIntegration.cpp b/src/Editor/NDolphinIntegration.cpp index dc14bd59..186a2126 100644 --- a/src/Editor/NDolphinIntegration.cpp +++ b/src/Editor/NDolphinIntegration.cpp @@ -3,6 +3,7 @@ #include "Editor/UICommon.h" #include "Editor/SDolHeader.h" +#include #include #include #include @@ -109,8 +110,8 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget, // Check if quickplay is already running if (gpDolphinProcess && gpDolphinProcess->state() != QProcess::NotRunning) { - if (UICommon::YesNoQuestion(pParentWidget, "Quickplay", - "Quickplay is already running. Close the existing session and relaunch?")) + if (UICommon::YesNoQuestion(pParentWidget, QCoreApplication::translate("LaunchQuickplay", "Quickplay"), + QCoreApplication::translate("LaunchQuickplay", "Quickplay is already running. Close the existing session and relaunch?"))) { KillQuickplay(); } @@ -146,8 +147,8 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget, // Check if the user has any dirty packages if (gpEdApp->HasAnyDirtyPackages()) { - if (UICommon::YesNoQuestion(pParentWidget, "Uncooked Changes", - "You have uncooked changes. Cook before starting quickplay?")) + if (UICommon::YesNoQuestion(pParentWidget, QCoreApplication::translate("LaunchQuickplay", "Uncooked Changes"), + QCoreApplication::translate("LaunchQuickplay", "You have uncooked changes. Cook before starting quickplay?"))) { gpEdApp->CookAllDirtyPackages(); } @@ -299,23 +300,23 @@ bool SetDolphinPath(QWidget* pParentWidget, const QString& kDolphinPath, bool bS { if (!bSilent) { - UICommon::ErrorMsg(pParentWidget, "The selected file is not a Dolphin executable!"); + UICommon::ErrorMsg(pParentWidget, QCoreApplication::translate("SetDolphinPath", "The selected file is not a Dolphin executable!")); } return false; } // Try to obtain the version from Dolphin QProcess DolphinProcess; - DolphinProcess.start(kDolphinPath, QStringList() << "--version"); + DolphinProcess.start(kDolphinPath, QStringList() << QStringLiteral("--version")); DolphinProcess.waitForFinished(); - QString VersionString = DolphinProcess.readLine().trimmed(); + QString VersionString = QString::fromUtf8(DolphinProcess.readLine().trimmed()); // Make sure we have a valid string if (VersionString.isNull()) { if (!bSilent) { - UICommon::ErrorMsg(pParentWidget, "Unable to validate version string, the selected file is likely not a Dolphin executable"); + UICommon::ErrorMsg(pParentWidget, QCoreApplication::translate("SetDolphinPath", "Unable to validate version string, the selected file is likely not a Dolphin executable")); } return false; } @@ -323,12 +324,12 @@ bool SetDolphinPath(QWidget* pParentWidget, const QString& kDolphinPath, bool bS // Dolphin's version string is broken into two parts, the first part is the name the second is the version // Dolphin unfortunately collide's with KDE Plasma's file manager which also happens to be named "Dolphin" // Fortunately the latter uses a lowercase name so we can differentiate. - QStringList VersionParts = VersionString.split(' '); - if (VersionParts.count() < 2 || (VersionParts[0] != "Dolphin" && VersionParts[0] != "PrimeHack")) + QStringList VersionParts = VersionString.split(QLatin1Char{' '}); + if (VersionParts.count() < 2 || (VersionParts[0] != QStringLiteral("Dolphin") && VersionParts[0] != QStringLiteral("PrimeHack"))) { if (!bSilent) { - UICommon::ErrorMsg(pParentWidget, "The selected file is not a Dolphin executable!"); + UICommon::ErrorMsg(pParentWidget, QCoreApplication::translate("SetDolphinPath", "The selected file is not a Dolphin executable!")); } return false; } @@ -374,13 +375,13 @@ QString GetDolphinPath() QString AskForDolphinPath(QWidget* pParentWidget) { #if defined(Q_OS_WIN) - QString Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", "*.exe"); + QString Path = UICommon::OpenFileDialog(pParentWidget, QCoreApplication::translate("AskForDolphinPath", "Open Dolphin"), QStringLiteral("*.exe")); #elif defined(Q_OS_MACOS) - QString Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", "*.app"); - if (Path.endsWith(".app")) - Path += "/Contents/MacOS/Dolphin"; + QString Path = UICommon::OpenFileDialog(pParentWidget, QCoreApplication::translate("AskForDolphinPath", "Open Dolphin"), QStringLiteral("*.app")); + if (Path.endsWith(QStringLiteral(".app"))) + Path += QStringLiteral("/Contents/MacOS/Dolphin"); #else - QString Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", {}); + QString Path = UICommon::OpenFileDialog(pParentWidget, QCoreApplication::translate("AskForDolphinPath", "Open Dolphin"), {}); #endif return Path; } diff --git a/src/Editor/PropertyEdit/CPropertyModel.cpp b/src/Editor/PropertyEdit/CPropertyModel.cpp index 465ba107..fb17d9c8 100644 --- a/src/Editor/PropertyEdit/CPropertyModel.cpp +++ b/src/Editor/PropertyEdit/CPropertyModel.cpp @@ -407,7 +407,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const // Add name IProperty *pProp = PropertyForIndex(rkIndex, false); const QString DisplayText = data(rkIndex, Qt::DisplayRole).toString(); - const QString TypeName = pProp->HashableTypeName(); + const QString TypeName = QString::fromUtf8(pProp->HashableTypeName()); QString Text = tr("%1 (%2)").arg(DisplayText).arg(TypeName); // Add uncooked notification diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.cpp b/src/Editor/ResourceBrowser/CResourceBrowser.cpp index 6190be21..6006b0c9 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.cpp +++ b/src/Editor/ResourceBrowser/CResourceBrowser.cpp @@ -96,7 +96,7 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent) mpFilterAllBox = new QCheckBox(this); mpFilterAllBox->setChecked(true); mpFilterAllBox->setFont(AllBoxFont); - mpFilterAllBox->setText("All"); + mpFilterAllBox->setText(tr("All")); mpFilterBoxesLayout->addWidget(mpFilterAllBox); CreateFilterCheckboxes(); @@ -675,7 +675,7 @@ bool CResourceBrowser::Delete(QList Resources, QListIsSafeToDelete()) { - ErrorPaths += TO_QSTRING(Directories[DirIdx]->FullPath()) + '\n'; + ErrorPaths += TO_QSTRING(Directories[DirIdx]->FullPath()) + QLatin1Char{'\n'}; Directories.removeAt(DirIdx); DirIdx--; } @@ -685,7 +685,7 @@ bool CResourceBrowser::Delete(QList Resources, QListIsLoaded() && Resources[ResIdx]->Resource()->IsReferenced()) { - ErrorPaths += TO_QSTRING(Resources[ResIdx]->CookedAssetPath(true)) + '\n'; + ErrorPaths += TO_QSTRING(Resources[ResIdx]->CookedAssetPath(true)) + QLatin1Char{'\n'}; Resources.removeAt(ResIdx); ResIdx--; } @@ -986,7 +986,7 @@ void CResourceBrowser::ImportAssetNameMap() void CResourceBrowser::ExportAssetNames() { const QString OutFile = UICommon::SaveFileDialog(this, tr("Export asset name map"), QStringLiteral("*.xml"), - gResourcesWritable ? *(gDataDir + "resources/gameinfo/") : ""); + gResourcesWritable ? TO_QSTRING(gDataDir + "resources/gameinfo/") : QString()); if (OutFile.isEmpty()) return; diff --git a/src/Editor/ResourceBrowser/CResourceDelegate.cpp b/src/Editor/ResourceBrowser/CResourceDelegate.cpp index d11b5a05..96a27574 100644 --- a/src/Editor/ResourceBrowser/CResourceDelegate.cpp +++ b/src/Editor/ResourceBrowser/CResourceDelegate.cpp @@ -99,10 +99,10 @@ void CResourceBrowserDelegate::paint(QPainter *pPainter, const QStyleOptionViewI // Draw resource info string if (pEntry) { - QString ResInfo = TO_QSTRING( pEntry->TypeInfo()->TypeName() ); + QString ResInfo = TO_QSTRING(pEntry->TypeInfo()->TypeName()); if (mDisplayAssetIDs) - ResInfo.prepend( TO_QSTRING(pEntry->ID().ToString()) + " | " ); + ResInfo.prepend(TO_QSTRING(pEntry->ID().ToString()) + QStringLiteral(" | ")); QString ElidedResInfo = FontInfo.InfoFontMetrics.elidedText(ResInfo, Qt::ElideRight, GeomInfo.InfoStringRect.width()); diff --git a/src/Editor/StringEditor/CStringEditor.cpp b/src/Editor/StringEditor/CStringEditor.cpp index 3ffb6412..539cd236 100644 --- a/src/Editor/StringEditor/CStringEditor.cpp +++ b/src/Editor/StringEditor/CStringEditor.cpp @@ -5,6 +5,7 @@ #include "Editor/UICommon.h" #include "Editor/Undo/TSerializeUndoCommand.h" +#include #include #include @@ -18,7 +19,8 @@ class CSetStringIndexCommand : public IUndoCommand int mOldIndex, mNewIndex; public: CSetStringIndexCommand(CStringEditor* pEditor, int OldIndex, int NewIndex) - : IUndoCommand("Select String"), mpEditor(pEditor), mOldIndex(OldIndex), mNewIndex(NewIndex) + : IUndoCommand(QCoreApplication::translate("CSetStringIndexCommand", "Select String")) + , mpEditor(pEditor), mOldIndex(OldIndex), mNewIndex(NewIndex) {} void undo() override { mpEditor->SetActiveString(mOldIndex); } @@ -32,7 +34,8 @@ class CSetLanguageCommand : public IUndoCommand ELanguage mOldLanguage, mNewLanguage; public: CSetLanguageCommand(CStringEditor* pEditor, ELanguage OldLanguage, ELanguage NewLanguage) - : IUndoCommand("Select Language"), mpEditor(pEditor), mOldLanguage(OldLanguage), mNewLanguage(NewLanguage) + : IUndoCommand(QCoreApplication::translate("CSetLanguageCommand", "Select Language")) + , mpEditor(pEditor), mOldLanguage(OldLanguage), mNewLanguage(NewLanguage) {} void undo() override { mpEditor->SetActiveLanguage(mOldLanguage); } @@ -111,7 +114,7 @@ void CStringEditor::InitUI() { const ELanguage Language = mpStringTable->LanguageByIndex(LanguageIdx); const char* pkLanguageName = TEnumReflection::ConvertValueToString(Language); - mpUI->EditLanguageTabBar->addTab(pkLanguageName); + mpUI->EditLanguageTabBar->addTab(QString::fromUtf8(pkLanguageName)); } // Connect signals & slots diff --git a/src/Editor/UICommon.cpp b/src/Editor/UICommon.cpp index 5fb0abe6..03733ae4 100644 --- a/src/Editor/UICommon.cpp +++ b/src/Editor/UICommon.cpp @@ -1,4 +1,5 @@ #include "UICommon.h" +#include #include #include @@ -31,8 +32,8 @@ void OpenContainingFolder(QWidget* parent, const QString& pathIn) } if (explorer.isEmpty()) { - QMessageBox::warning(parent, "Launching Windows Explorer Failed", - "Could not find explorer.exe in path to launch Windows Explorer."); + QMessageBox::warning(parent, QCoreApplication::translate("OpenContainingFoleder", "Launching Windows Explorer Failed"), + QCoreApplication::translate("OpenContainingFolder", "Could not find explorer.exe in path to launch Windows Explorer.")); return; } QStringList param; @@ -60,7 +61,7 @@ void OpenContainingFolder(QWidget* parent, const QString& pathIn) bool OpenInExternalApplication(const QString& rkPath) { - return QDesktopServices::openUrl( QString("file:///") + QDir::toNativeSeparators(rkPath) ); + return QDesktopServices::openUrl(QStringLiteral("file:///") + QDir::toNativeSeparators(rkPath)); } } diff --git a/src/Editor/UICommon.h b/src/Editor/UICommon.h index 606e984d..e788ce88 100644 --- a/src/Editor/UICommon.h +++ b/src/Editor/UICommon.h @@ -3,6 +3,7 @@ #include "CEditorApplication.h" #include +#include #include #include #include @@ -15,9 +16,9 @@ #define UI_APPVAR_VERSION "%APP_VERSION%" #define REPLACE_APPVARS(InQString) \ - InQString.replace(UI_APPVAR_NAME, APP_NAME); \ - InQString.replace(UI_APPVAR_FULLNAME, APP_FULL_NAME); \ - InQString.replace(UI_APPVAR_VERSION, APP_VERSION); + InQString.replace(QStringLiteral(UI_APPVAR_NAME), QStringLiteral(APP_NAME)); \ + InQString.replace(QStringLiteral(UI_APPVAR_FULLNAME), QStringLiteral(APP_FULL_NAME)); \ + InQString.replace(QStringLiteral(UI_APPVAR_VERSION), QStringLiteral(APP_VERSION)); #define SET_WINDOWTITLE_APPVARS(InString) \ { \ @@ -100,7 +101,7 @@ inline T16String ToT16String(const QString& rkStr) #define POP_TICKS_ENABLED \ gpEdApp->SetEditorTicksEnabled(TicksEnabled); -inline QString OpenFileDialog(QWidget *pParent, const QString& rkCaption, const QString& rkFilter, const QString& rkStartingDir = "") +inline QString OpenFileDialog(QWidget* pParent, const QString& rkCaption, const QString& rkFilter, const QString& rkStartingDir = {}) { PUSH_TICKS_ENABLED; QString Result = QFileDialog::getOpenFileName(pParent, rkCaption, rkStartingDir, rkFilter); @@ -108,7 +109,7 @@ inline QString OpenFileDialog(QWidget *pParent, const QString& rkCaption, const return Result; } -inline QStringList OpenFilesDialog(QWidget *pParent, const QString& rkCaption, const QString& rkFilter, const QString& rkStartingDir = "") +inline QStringList OpenFilesDialog(QWidget* pParent, const QString& rkCaption, const QString& rkFilter, const QString& rkStartingDir = {}) { PUSH_TICKS_ENABLED; QStringList Result = QFileDialog::getOpenFileNames(pParent, rkCaption, rkStartingDir, rkFilter); @@ -116,7 +117,7 @@ inline QStringList OpenFilesDialog(QWidget *pParent, const QString& rkCaption, c return Result; } -inline QString SaveFileDialog(QWidget *pParent, const QString& rkCaption, const QString& rkFilter, const QString& rkStartingDir = "") +inline QString SaveFileDialog(QWidget* pParent, const QString& rkCaption, const QString& rkFilter, const QString& rkStartingDir = {}) { PUSH_TICKS_ENABLED; QString Result = QFileDialog::getSaveFileName(pParent, rkCaption, rkStartingDir, rkFilter); @@ -124,7 +125,7 @@ inline QString SaveFileDialog(QWidget *pParent, const QString& rkCaption, const return Result; } -inline QString OpenDirDialog(QWidget *pParent, const QString& rkCaption, const QString& rkStartingDir = "") +inline QString OpenDirDialog(QWidget* pParent, const QString& rkCaption, const QString& rkStartingDir = {}) { PUSH_TICKS_ENABLED; QString Result = QFileDialog::getExistingDirectory(pParent, rkCaption, rkStartingDir); @@ -133,17 +134,17 @@ inline QString OpenDirDialog(QWidget *pParent, const QString& rkCaption, const Q } // QMessageBox wrappers -inline void InfoMsg(QWidget *pParent, QString InfoBoxTitle, QString InfoText) +inline void InfoMsg(QWidget *pParent, const QString& InfoBoxTitle, const QString& InfoText) { QMessageBox::information(pParent, InfoBoxTitle, InfoText); } -inline void ErrorMsg(QWidget *pParent, QString ErrorText) +inline void ErrorMsg(QWidget *pParent, const QString& ErrorText) { - QMessageBox::warning(pParent, "Error", ErrorText); + QMessageBox::warning(pParent, QCoreApplication::translate("ErrorMsg", "Error"), ErrorText); } -inline bool YesNoQuestion(QWidget *pParent, QString InfoBoxTitle, QString Question) +inline bool YesNoQuestion(QWidget *pParent, const QString& InfoBoxTitle, const QString& Question) { QMessageBox::StandardButton Button = QMessageBox::question(pParent, InfoBoxTitle, Question, QMessageBox::Yes | QMessageBox::No); return Button == QMessageBox::Yes; @@ -152,7 +153,7 @@ inline bool YesNoQuestion(QWidget *pParent, QString InfoBoxTitle, QString Questi inline bool OpenProject() { QWidget* pMainWindow = (QWidget*) gpEdApp->WorldEditor(); - QString ProjPath = UICommon::OpenFileDialog(pMainWindow, "Open Project", "Game Project (*.prj)"); + QString ProjPath = UICommon::OpenFileDialog(pMainWindow, QCoreApplication::translate("OpenProject", "Open Project"), QStringLiteral("Game Project (*.prj)")); return ProjPath.isEmpty() ? false : gpEdApp->OpenProject(ProjPath); } diff --git a/src/Editor/Widgets/CResourceSelector.cpp b/src/Editor/Widgets/CResourceSelector.cpp index a3849f35..43dd1e7f 100644 --- a/src/Editor/Widgets/CResourceSelector.cpp +++ b/src/Editor/Widgets/CResourceSelector.cpp @@ -96,8 +96,8 @@ void CResourceSelector::UpdateUI() bool HasResource = mpResEntry != nullptr; // Update main UI - mpResNameButton->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + "." + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : ""); - mpResNameButton->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : ""); + mpResNameButton->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + QLatin1Char{'.'} + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : QString()); + mpResNameButton->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : QString()); mpClearButton->setEnabled(HasResource); // Update context menu @@ -259,7 +259,7 @@ void CResourceSelector::CopyName() void CResourceSelector::CopyPath() { - QString Text = (mpResEntry ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : ""); + QString Text = (mpResEntry ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : QString()); gpEdApp->clipboard()->setText(Text); } diff --git a/src/Editor/Widgets/CSoftValidatorLineEdit.h b/src/Editor/Widgets/CSoftValidatorLineEdit.h index 7a7fd02a..c98440ab 100644 --- a/src/Editor/Widgets/CSoftValidatorLineEdit.h +++ b/src/Editor/Widgets/CSoftValidatorLineEdit.h @@ -40,18 +40,18 @@ protected slots: if ( mpSoftValidator->validate(Text, DummyPos) == QValidator::Acceptable ) { NewValidity = true; - setStyleSheet("border: 1px solid green"); + setStyleSheet(QStringLiteral("border: 1px solid green")); } else { NewValidity = false; - setStyleSheet("border: 1px solid red"); + setStyleSheet(QStringLiteral("border: 1px solid red")); } } else { NewValidity = true; - setStyleSheet(""); + setStyleSheet(QString()); } if (NewValidity != mInputIsValid) diff --git a/src/Editor/Widgets/TEnumComboBox.h b/src/Editor/Widgets/TEnumComboBox.h index 0a112b9a..52792e8c 100644 --- a/src/Editor/Widgets/TEnumComboBox.h +++ b/src/Editor/Widgets/TEnumComboBox.h @@ -23,7 +23,7 @@ public: { if (It.Value() != TEnumReflection::ErrorValue()) { - addItem(It.Name()); + addItem(QString::fromUtf8(It.Name())); mValueList.push_back(It.Value()); } } diff --git a/src/Editor/Widgets/WDraggableSpinBox.cpp b/src/Editor/Widgets/WDraggableSpinBox.cpp index 210f1e6d..7473e4fd 100644 --- a/src/Editor/Widgets/WDraggableSpinBox.cpp +++ b/src/Editor/Widgets/WDraggableSpinBox.cpp @@ -98,7 +98,7 @@ bool WDraggableSpinBox::eventFilter(QObject *, QEvent *pEvent) QString WDraggableSpinBox::textFromValue(double Val) const { QString Str = QString::number(Val, 'f', decimals()); - int DecIndex = Str.indexOf('.'); + int DecIndex = Str.indexOf(QLatin1Char{'.'}); int NumDecs; if (DecIndex == -1) @@ -111,23 +111,23 @@ QString WDraggableSpinBox::textFromValue(double Val) const int Size = Str.size() + mMinDecimals + 1; Str.reserve(Size); - Str += '.'; + Str += QLatin1Char{'.'}; for (int iDec = 0; iDec < mMinDecimals; iDec++) - Str += '0'; + Str += QLatin1Char{'0'}; } else if ((NumDecs > mMinDecimals) && mTrimTrailingZeroes) { while (NumDecs > mMinDecimals) { - if (Str.endsWith('0')) + if (Str.endsWith(QLatin1Char{'0'})) { Str.chop(1); NumDecs--; } - else if (Str.endsWith('.')) + else if (Str.endsWith(QLatin1Char{'.'})) { Str.chop(1); break; diff --git a/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp b/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp index 8ef1b62a..5ce11133 100644 --- a/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp +++ b/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp @@ -35,8 +35,8 @@ void CCollisionRenderSettingsDialog::SetupWidgets() EGame Game = mpEditor->CurrentGame(); // Set widgets to match current render setting values - mpUi->HideMaskLineEdit->setText( "0x" + QString::number(rSettings.HideMask, 16).toUpper() ); - mpUi->HighlightMaskLineEdit->setText( "0x" + QString::number(rSettings.HighlightMask, 16).toUpper() ); + mpUi->HideMaskLineEdit->setText(QStringLiteral("0x") + QString::number(rSettings.HideMask, 16).toUpper()); + mpUi->HighlightMaskLineEdit->setText(QStringLiteral("0x") + QString::number(rSettings.HighlightMask, 16).toUpper()); mpUi->WireframeCheckBox->setChecked(rSettings.DrawWireframe); mpUi->SurfaceTypeCheckBox->setChecked(rSettings.TintWithSurfaceColor); mpUi->StandableTrisCheckBox->setChecked(rSettings.TintUnwalkableTris); diff --git a/src/Editor/WorldEditor/CTemplateEditDialog.cpp b/src/Editor/WorldEditor/CTemplateEditDialog.cpp index f82d5aaa..60361fb6 100644 --- a/src/Editor/WorldEditor/CTemplateEditDialog.cpp +++ b/src/Editor/WorldEditor/CTemplateEditDialog.cpp @@ -174,7 +174,7 @@ void CTemplateEditDialog::RefreshTypeNameOverride() } else { - mpValidator->SetTypeNameOverride(""); + mpValidator->SetTypeNameOverride(QString()); } } diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 169ff8d7..c8a4b129 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -741,7 +741,7 @@ void CWorldEditor::UpdateOpenRecentActions() // Remove projects that don't exist anymore for (const QString& rkProj : RecentProjectsList) { - if (!FileUtil::Exists( TO_TSTRING(rkProj) ) || rkProj.contains('\\') ) + if (!FileUtil::Exists(TO_TSTRING(rkProj)) || rkProj.contains(QLatin1Char{'\\'})) RecentProjectsList.removeAll(rkProj); } @@ -771,14 +771,14 @@ void CWorldEditor::UpdateWindowTitle() if (pProj) { - WindowTitle += " - " + TO_QSTRING( pProj->Name() ); + WindowTitle += QStringLiteral(" - ") + TO_QSTRING(pProj->Name()); if (mpWorld) { - WindowTitle += " - " + TO_QSTRING(mpWorld->InGameName()); + WindowTitle += QStringLiteral(" - ") + TO_QSTRING(mpWorld->InGameName()); if (mpArea && CurrentGame() < EGame::DKCReturns) - WindowTitle += " - " + TO_QSTRING( mpWorld->AreaInGameName(mpArea->WorldIndex()) ); + WindowTitle += QStringLiteral(" - ") + TO_QSTRING(mpWorld->AreaInGameName(mpArea->WorldIndex())); } } diff --git a/src/Editor/WorldEditor/CWorldTreeModel.cpp b/src/Editor/WorldEditor/CWorldTreeModel.cpp index b77b98d6..73c2904e 100644 --- a/src/Editor/WorldEditor/CWorldTreeModel.cpp +++ b/src/Editor/WorldEditor/CWorldTreeModel.cpp @@ -316,7 +316,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj) // Add remaining worlds to FrontEnd world mWorldList.prepend(SWorldInfo()); pInfo = &mWorldList.front(); - pInfo->WorldName = "FrontEnd"; + pInfo->WorldName = QStringLiteral("FrontEnd"); for (TResourceIterator It; It; ++It) { diff --git a/src/Editor/WorldEditor/WEditorProperties.cpp b/src/Editor/WorldEditor/WEditorProperties.cpp index a5e30f32..394e4c69 100644 --- a/src/Editor/WorldEditor/WEditorProperties.cpp +++ b/src/Editor/WorldEditor/WEditorProperties.cpp @@ -119,7 +119,7 @@ void WEditorProperties::OnSelectionModified() } else { - mpInstanceInfoLabel->setText(QString("[%1 objects selected]").arg(pSelection->Size())); + mpInstanceInfoLabel->setText(tr("[%1 objects selected]").arg(pSelection->Size())); mpInstanceNameLineEdit->clear(); } diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index e3f91e73..b36de3a5 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -95,7 +96,7 @@ public: QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); CEditorApplication App(argc, argv); App.setApplicationName(QStringLiteral("PrimeWorldEditor")); - App.setApplicationVersion( APP_VERSION ); + App.setApplicationVersion(QStringLiteral(APP_VERSION)); App.setOrganizationName(QStringLiteral("AxioDL")); App.setWindowIcon(QIcon(QStringLiteral(":/icons/win/AppIcon.ico"))); @@ -116,7 +117,7 @@ public: // Init log bool Initialized = NLog::InitLog(LocateLogPath()); if (!Initialized) - UICommon::ErrorMsg(nullptr, "Couldn't open log file. Logging will not work for this session."); + UICommon::ErrorMsg(nullptr, QCoreApplication::translate("Main", "Couldn't open log file. Logging will not work for this session.")); qInstallMessageHandler(QtLogRedirect); // Locate data directory and check write permissions @@ -129,8 +130,8 @@ public: if (!gpEditorStore->DatabasePathExists()) { - UICommon::ErrorMsg(nullptr, "Unable to locate PWE resources directory; " - "PWE's executable must remain as deployed."); + UICommon::ErrorMsg(nullptr, QCoreApplication::translate("Main", "Unable to locate PWE resources directory; " + "PWE's executable must remain as deployed.")); return 1; }