Editor: Disable implicit Qt string conversions

Requires that our format conversions be explicit.
This commit is contained in:
Lioncache
2025-12-01 15:10:38 -05:00
parent 5fc6b50923
commit 2419b11b45
24 changed files with 91 additions and 74 deletions

View File

@@ -52,7 +52,7 @@ void CExportGameDialog::InitUI(QString ExportDir)
CGameInfo GameInfo; CGameInfo GameInfo;
GameInfo.LoadGameInfo(mGame); GameInfo.LoadGameInfo(mGame);
ExportDir.replace('\\', '/'); ExportDir.replace(QLatin1Char{'\\'}, QLatin1Char{'/'});
TString DefaultNameMapPath = CAssetNameMap::DefaultNameMapPath(mGame); TString DefaultNameMapPath = CAssetNameMap::DefaultNameMapPath(mGame);
if (!FileUtil::Exists(DefaultNameMapPath)) DefaultNameMapPath = ""; if (!FileUtil::Exists(DefaultNameMapPath)) DefaultNameMapPath = "";
@@ -68,7 +68,7 @@ void CExportGameDialog::InitUI(QString ExportDir)
mpUI->GameTitleLineEdit->setText( TO_QSTRING(mGameTitle) ); mpUI->GameTitleLineEdit->setText( TO_QSTRING(mGameTitle) );
mpUI->GameIdLineEdit->setText( TO_QSTRING(mGameID) ); mpUI->GameIdLineEdit->setText( TO_QSTRING(mGameID) );
mpUI->BuildVersionLineEdit->setText(tr("%1 (%2)").arg(mBuildVer).arg(TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion)))); mpUI->BuildVersionLineEdit->setText(tr("%1 (%2)").arg(mBuildVer).arg(TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion))));
mpUI->RegionLineEdit->setText(TEnumReflection<ERegion>::ConvertValueToString(mRegion)); mpUI->RegionLineEdit->setText(QString::fromUtf8(TEnumReflection<ERegion>::ConvertValueToString(mRegion)));
// Disc tree widget // Disc tree widget
nod::IPartition *pPartition = mpDisc->getDataPartition(); nod::IPartition *pPartition = mpDisc->getDataPartition();

View File

@@ -219,7 +219,7 @@ void CGeneratePropertyNamesDialog::OnTreeItemDoubleClicked(QTreeWidgetItem* pIte
const QString Text = pItem->text(0); const QString Text = pItem->text(0);
if (!Text.endsWith(".xml")) if (!Text.endsWith(QStringLiteral(".xml")))
return; return;
const TString TStrText = TO_TSTRING(Text); const TString TStrText = TO_TSTRING(Text);

View File

@@ -121,6 +121,14 @@ target_compile_definitions(
"APP_VERSION=\"${PROJECT_VERSION}\"" "APP_VERSION=\"${PROJECT_VERSION}\""
"APP_FULL_NAME=\"${PWE_APP_NAME} ${PWE_WC_DESCRIBE}\"" "APP_FULL_NAME=\"${PWE_APP_NAME} ${PWE_WC_DESCRIBE}\""
UNICODE 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) gather_include_directories(pwe_editor_include_directories pwe_editor)

View File

@@ -105,7 +105,7 @@ void CProjectSettingsDialog::SetupPackagesList()
QString PackageName = TO_QSTRING(pPackage->Name()); QString PackageName = TO_QSTRING(pPackage->Name());
if (pPackage->NeedsRecook()) if (pPackage->NeedsRecook())
PackageName += '*'; PackageName += QLatin1Char{'*'};
mpUI->PackagesList->addItem(PackageName); mpUI->PackagesList->addItem(PackageName);
} }
} }

View File

@@ -2,6 +2,8 @@
#include "ui_CTweakEditor.h" #include "ui_CTweakEditor.h"
#include "Editor/Undo/IUndoCommand.h" #include "Editor/Undo/IUndoCommand.h"
#include <QCoreApplication>
/** Internal undo command for changing tabs */ /** Internal undo command for changing tabs */
class CSetTweakIndexCommand : public IUndoCommand class CSetTweakIndexCommand : public IUndoCommand
{ {
@@ -10,7 +12,7 @@ class CSetTweakIndexCommand : public IUndoCommand
public: public:
CSetTweakIndexCommand(CTweakEditor* pEditor, int OldIndex, int NewIndex) CSetTweakIndexCommand(CTweakEditor* pEditor, int OldIndex, int NewIndex)
: IUndoCommand("Change Tab") : IUndoCommand(QCoreApplication::translate("CSetTweakIndexCommand", "Change Tab"))
, mpEditor(pEditor) , mpEditor(pEditor)
, mOldIndex(OldIndex) , mOldIndex(OldIndex)
, mNewIndex(NewIndex) , mNewIndex(NewIndex)

View File

@@ -20,7 +20,7 @@ QString MacOSPathToDolphinBinary()
/* Filter to accumulate relative coordinates of middle and right mouse drags for camera control. */ /* Filter to accumulate relative coordinates of middle and right mouse drags for camera control. */
bool MouseDragCocoaEventFilter::nativeEventFilter(const QByteArray& eventType, void* message, long*) bool MouseDragCocoaEventFilter::nativeEventFilter(const QByteArray& eventType, void* message, long*)
{ {
if (eventType == "mac_generic_NSEvent") if (eventType == QByteArrayLiteral("mac_generic_NSEvent"))
{ {
NSEvent* event = static_cast<NSEvent*>(message); NSEvent* event = static_cast<NSEvent*>(message);
NSEventType evType = event.type; NSEventType evType = event.type;

View File

@@ -754,7 +754,7 @@ void CModelEditorWindow::Import()
SetActiveModel(pModel); SetActiveModel(pModel);
SET_WINDOWTITLE_APPVARS(tr("%APP_FULL_NAME% - Model Editor: Untitled")); SET_WINDOWTITLE_APPVARS(tr("%APP_FULL_NAME% - Model Editor: Untitled"));
mOutputFilename = ""; mOutputFilename.clear();
gpResourceStore->DestroyUnreferencedResources(); gpResourceStore->DestroyUnreferencedResources();
} }
@@ -785,7 +785,7 @@ void CModelEditorWindow::ConvertToDDS()
void CModelEditorWindow::ConvertToTXTR() 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; if (Input.isEmpty()) return;
TString TexFilename = TO_TSTRING(Input); TString TexFilename = TO_TSTRING(Input);

View File

@@ -3,6 +3,7 @@
#include "Editor/UICommon.h" #include "Editor/UICommon.h"
#include "Editor/SDolHeader.h" #include "Editor/SDolHeader.h"
#include <QCoreApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QObject> #include <QObject>
#include <QOverload> #include <QOverload>
@@ -109,8 +110,8 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget,
// Check if quickplay is already running // Check if quickplay is already running
if (gpDolphinProcess && gpDolphinProcess->state() != QProcess::NotRunning) if (gpDolphinProcess && gpDolphinProcess->state() != QProcess::NotRunning)
{ {
if (UICommon::YesNoQuestion(pParentWidget, "Quickplay", if (UICommon::YesNoQuestion(pParentWidget, QCoreApplication::translate("LaunchQuickplay", "Quickplay"),
"Quickplay is already running. Close the existing session and relaunch?")) QCoreApplication::translate("LaunchQuickplay", "Quickplay is already running. Close the existing session and relaunch?")))
{ {
KillQuickplay(); KillQuickplay();
} }
@@ -146,8 +147,8 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget,
// Check if the user has any dirty packages // Check if the user has any dirty packages
if (gpEdApp->HasAnyDirtyPackages()) if (gpEdApp->HasAnyDirtyPackages())
{ {
if (UICommon::YesNoQuestion(pParentWidget, "Uncooked Changes", if (UICommon::YesNoQuestion(pParentWidget, QCoreApplication::translate("LaunchQuickplay", "Uncooked Changes"),
"You have uncooked changes. Cook before starting quickplay?")) QCoreApplication::translate("LaunchQuickplay", "You have uncooked changes. Cook before starting quickplay?")))
{ {
gpEdApp->CookAllDirtyPackages(); gpEdApp->CookAllDirtyPackages();
} }
@@ -299,23 +300,23 @@ bool SetDolphinPath(QWidget* pParentWidget, const QString& kDolphinPath, bool bS
{ {
if (!bSilent) 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; return false;
} }
// Try to obtain the version from Dolphin // Try to obtain the version from Dolphin
QProcess DolphinProcess; QProcess DolphinProcess;
DolphinProcess.start(kDolphinPath, QStringList() << "--version"); DolphinProcess.start(kDolphinPath, QStringList() << QStringLiteral("--version"));
DolphinProcess.waitForFinished(); DolphinProcess.waitForFinished();
QString VersionString = DolphinProcess.readLine().trimmed(); QString VersionString = QString::fromUtf8(DolphinProcess.readLine().trimmed());
// Make sure we have a valid string // Make sure we have a valid string
if (VersionString.isNull()) if (VersionString.isNull())
{ {
if (!bSilent) 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; 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'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" // 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. // Fortunately the latter uses a lowercase name so we can differentiate.
QStringList VersionParts = VersionString.split(' '); QStringList VersionParts = VersionString.split(QLatin1Char{' '});
if (VersionParts.count() < 2 || (VersionParts[0] != "Dolphin" && VersionParts[0] != "PrimeHack")) if (VersionParts.count() < 2 || (VersionParts[0] != QStringLiteral("Dolphin") && VersionParts[0] != QStringLiteral("PrimeHack")))
{ {
if (!bSilent) 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; return false;
} }
@@ -374,13 +375,13 @@ QString GetDolphinPath()
QString AskForDolphinPath(QWidget* pParentWidget) { QString AskForDolphinPath(QWidget* pParentWidget) {
#if defined(Q_OS_WIN) #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) #elif defined(Q_OS_MACOS)
QString Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", "*.app"); QString Path = UICommon::OpenFileDialog(pParentWidget, QCoreApplication::translate("AskForDolphinPath", "Open Dolphin"), QStringLiteral("*.app"));
if (Path.endsWith(".app")) if (Path.endsWith(QStringLiteral(".app")))
Path += "/Contents/MacOS/Dolphin"; Path += QStringLiteral("/Contents/MacOS/Dolphin");
#else #else
QString Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", {}); QString Path = UICommon::OpenFileDialog(pParentWidget, QCoreApplication::translate("AskForDolphinPath", "Open Dolphin"), {});
#endif #endif
return Path; return Path;
} }

View File

@@ -407,7 +407,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
// Add name // Add name
IProperty *pProp = PropertyForIndex(rkIndex, false); IProperty *pProp = PropertyForIndex(rkIndex, false);
const QString DisplayText = data(rkIndex, Qt::DisplayRole).toString(); const QString DisplayText = data(rkIndex, Qt::DisplayRole).toString();
const QString TypeName = pProp->HashableTypeName(); const QString TypeName = QString::fromUtf8(pProp->HashableTypeName());
QString Text = tr("<b>%1</b> <i>(%2)</i>").arg(DisplayText).arg(TypeName); QString Text = tr("<b>%1</b> <i>(%2)</i>").arg(DisplayText).arg(TypeName);
// Add uncooked notification // Add uncooked notification

View File

@@ -96,7 +96,7 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent)
mpFilterAllBox = new QCheckBox(this); mpFilterAllBox = new QCheckBox(this);
mpFilterAllBox->setChecked(true); mpFilterAllBox->setChecked(true);
mpFilterAllBox->setFont(AllBoxFont); mpFilterAllBox->setFont(AllBoxFont);
mpFilterAllBox->setText("All"); mpFilterAllBox->setText(tr("All"));
mpFilterBoxesLayout->addWidget(mpFilterAllBox); mpFilterBoxesLayout->addWidget(mpFilterAllBox);
CreateFilterCheckboxes(); CreateFilterCheckboxes();
@@ -675,7 +675,7 @@ bool CResourceBrowser::Delete(QList<CResourceEntry*> Resources, QList<CVirtualDi
{ {
if (!Directories[DirIdx]->IsSafeToDelete()) if (!Directories[DirIdx]->IsSafeToDelete())
{ {
ErrorPaths += TO_QSTRING(Directories[DirIdx]->FullPath()) + '\n'; ErrorPaths += TO_QSTRING(Directories[DirIdx]->FullPath()) + QLatin1Char{'\n'};
Directories.removeAt(DirIdx); Directories.removeAt(DirIdx);
DirIdx--; DirIdx--;
} }
@@ -685,7 +685,7 @@ bool CResourceBrowser::Delete(QList<CResourceEntry*> Resources, QList<CVirtualDi
{ {
if (Resources[ResIdx]->IsLoaded() && Resources[ResIdx]->Resource()->IsReferenced()) if (Resources[ResIdx]->IsLoaded() && Resources[ResIdx]->Resource()->IsReferenced())
{ {
ErrorPaths += TO_QSTRING(Resources[ResIdx]->CookedAssetPath(true)) + '\n'; ErrorPaths += TO_QSTRING(Resources[ResIdx]->CookedAssetPath(true)) + QLatin1Char{'\n'};
Resources.removeAt(ResIdx); Resources.removeAt(ResIdx);
ResIdx--; ResIdx--;
} }
@@ -986,7 +986,7 @@ void CResourceBrowser::ImportAssetNameMap()
void CResourceBrowser::ExportAssetNames() void CResourceBrowser::ExportAssetNames()
{ {
const QString OutFile = UICommon::SaveFileDialog(this, tr("Export asset name map"), QStringLiteral("*.xml"), 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()) if (OutFile.isEmpty())
return; return;

View File

@@ -99,10 +99,10 @@ void CResourceBrowserDelegate::paint(QPainter *pPainter, const QStyleOptionViewI
// Draw resource info string // Draw resource info string
if (pEntry) if (pEntry)
{ {
QString ResInfo = TO_QSTRING( pEntry->TypeInfo()->TypeName() ); QString ResInfo = TO_QSTRING(pEntry->TypeInfo()->TypeName());
if (mDisplayAssetIDs) 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()); QString ElidedResInfo = FontInfo.InfoFontMetrics.elidedText(ResInfo, Qt::ElideRight, GeomInfo.InfoStringRect.width());

View File

@@ -5,6 +5,7 @@
#include "Editor/UICommon.h" #include "Editor/UICommon.h"
#include "Editor/Undo/TSerializeUndoCommand.h" #include "Editor/Undo/TSerializeUndoCommand.h"
#include <QCoreApplication>
#include <QSettings> #include <QSettings>
#include <QShortcut> #include <QShortcut>
@@ -18,7 +19,8 @@ class CSetStringIndexCommand : public IUndoCommand
int mOldIndex, mNewIndex; int mOldIndex, mNewIndex;
public: public:
CSetStringIndexCommand(CStringEditor* pEditor, int OldIndex, int NewIndex) 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); } void undo() override { mpEditor->SetActiveString(mOldIndex); }
@@ -32,7 +34,8 @@ class CSetLanguageCommand : public IUndoCommand
ELanguage mOldLanguage, mNewLanguage; ELanguage mOldLanguage, mNewLanguage;
public: public:
CSetLanguageCommand(CStringEditor* pEditor, ELanguage OldLanguage, ELanguage NewLanguage) 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); } void undo() override { mpEditor->SetActiveLanguage(mOldLanguage); }
@@ -111,7 +114,7 @@ void CStringEditor::InitUI()
{ {
const ELanguage Language = mpStringTable->LanguageByIndex(LanguageIdx); const ELanguage Language = mpStringTable->LanguageByIndex(LanguageIdx);
const char* pkLanguageName = TEnumReflection<ELanguage>::ConvertValueToString(Language); const char* pkLanguageName = TEnumReflection<ELanguage>::ConvertValueToString(Language);
mpUI->EditLanguageTabBar->addTab(pkLanguageName); mpUI->EditLanguageTabBar->addTab(QString::fromUtf8(pkLanguageName));
} }
// Connect signals & slots // Connect signals & slots

View File

@@ -1,4 +1,5 @@
#include "UICommon.h" #include "UICommon.h"
#include <QCoreApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QProcess> #include <QProcess>
@@ -31,8 +32,8 @@ void OpenContainingFolder(QWidget* parent, const QString& pathIn)
} }
if (explorer.isEmpty()) if (explorer.isEmpty())
{ {
QMessageBox::warning(parent, "Launching Windows Explorer Failed", QMessageBox::warning(parent, QCoreApplication::translate("OpenContainingFoleder", "Launching Windows Explorer Failed"),
"Could not find explorer.exe in path to launch Windows Explorer."); QCoreApplication::translate("OpenContainingFolder", "Could not find explorer.exe in path to launch Windows Explorer."));
return; return;
} }
QStringList param; QStringList param;
@@ -60,7 +61,7 @@ void OpenContainingFolder(QWidget* parent, const QString& pathIn)
bool OpenInExternalApplication(const QString& rkPath) bool OpenInExternalApplication(const QString& rkPath)
{ {
return QDesktopServices::openUrl( QString("file:///") + QDir::toNativeSeparators(rkPath) ); return QDesktopServices::openUrl(QStringLiteral("file:///") + QDir::toNativeSeparators(rkPath));
} }
} }

View File

@@ -3,6 +3,7 @@
#include "CEditorApplication.h" #include "CEditorApplication.h"
#include <Common/TString.h> #include <Common/TString.h>
#include <QCoreApplication>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QFileDialog> #include <QFileDialog>
#include <QMap> #include <QMap>
@@ -15,9 +16,9 @@
#define UI_APPVAR_VERSION "%APP_VERSION%" #define UI_APPVAR_VERSION "%APP_VERSION%"
#define REPLACE_APPVARS(InQString) \ #define REPLACE_APPVARS(InQString) \
InQString.replace(UI_APPVAR_NAME, APP_NAME); \ InQString.replace(QStringLiteral(UI_APPVAR_NAME), QStringLiteral(APP_NAME)); \
InQString.replace(UI_APPVAR_FULLNAME, APP_FULL_NAME); \ InQString.replace(QStringLiteral(UI_APPVAR_FULLNAME), QStringLiteral(APP_FULL_NAME)); \
InQString.replace(UI_APPVAR_VERSION, APP_VERSION); InQString.replace(QStringLiteral(UI_APPVAR_VERSION), QStringLiteral(APP_VERSION));
#define SET_WINDOWTITLE_APPVARS(InString) \ #define SET_WINDOWTITLE_APPVARS(InString) \
{ \ { \
@@ -100,7 +101,7 @@ inline T16String ToT16String(const QString& rkStr)
#define POP_TICKS_ENABLED \ #define POP_TICKS_ENABLED \
gpEdApp->SetEditorTicksEnabled(TicksEnabled); 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; PUSH_TICKS_ENABLED;
QString Result = QFileDialog::getOpenFileName(pParent, rkCaption, rkStartingDir, rkFilter); QString Result = QFileDialog::getOpenFileName(pParent, rkCaption, rkStartingDir, rkFilter);
@@ -108,7 +109,7 @@ inline QString OpenFileDialog(QWidget *pParent, const QString& rkCaption, const
return Result; 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; PUSH_TICKS_ENABLED;
QStringList Result = QFileDialog::getOpenFileNames(pParent, rkCaption, rkStartingDir, rkFilter); QStringList Result = QFileDialog::getOpenFileNames(pParent, rkCaption, rkStartingDir, rkFilter);
@@ -116,7 +117,7 @@ inline QStringList OpenFilesDialog(QWidget *pParent, const QString& rkCaption, c
return Result; 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; PUSH_TICKS_ENABLED;
QString Result = QFileDialog::getSaveFileName(pParent, rkCaption, rkStartingDir, rkFilter); QString Result = QFileDialog::getSaveFileName(pParent, rkCaption, rkStartingDir, rkFilter);
@@ -124,7 +125,7 @@ inline QString SaveFileDialog(QWidget *pParent, const QString& rkCaption, const
return Result; 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; PUSH_TICKS_ENABLED;
QString Result = QFileDialog::getExistingDirectory(pParent, rkCaption, rkStartingDir); QString Result = QFileDialog::getExistingDirectory(pParent, rkCaption, rkStartingDir);
@@ -133,17 +134,17 @@ inline QString OpenDirDialog(QWidget *pParent, const QString& rkCaption, const Q
} }
// QMessageBox wrappers // 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); 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); QMessageBox::StandardButton Button = QMessageBox::question(pParent, InfoBoxTitle, Question, QMessageBox::Yes | QMessageBox::No);
return Button == QMessageBox::Yes; return Button == QMessageBox::Yes;
@@ -152,7 +153,7 @@ inline bool YesNoQuestion(QWidget *pParent, QString InfoBoxTitle, QString Questi
inline bool OpenProject() inline bool OpenProject()
{ {
QWidget* pMainWindow = (QWidget*) gpEdApp->WorldEditor(); 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); return ProjPath.isEmpty() ? false : gpEdApp->OpenProject(ProjPath);
} }

View File

@@ -96,8 +96,8 @@ void CResourceSelector::UpdateUI()
bool HasResource = mpResEntry != nullptr; bool HasResource = mpResEntry != nullptr;
// Update main UI // Update main UI
mpResNameButton->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + "." + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : ""); mpResNameButton->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + QLatin1Char{'.'} + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : QString());
mpResNameButton->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : ""); mpResNameButton->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : QString());
mpClearButton->setEnabled(HasResource); mpClearButton->setEnabled(HasResource);
// Update context menu // Update context menu
@@ -259,7 +259,7 @@ void CResourceSelector::CopyName()
void CResourceSelector::CopyPath() void CResourceSelector::CopyPath()
{ {
QString Text = (mpResEntry ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : ""); QString Text = (mpResEntry ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : QString());
gpEdApp->clipboard()->setText(Text); gpEdApp->clipboard()->setText(Text);
} }

View File

@@ -40,18 +40,18 @@ protected slots:
if ( mpSoftValidator->validate(Text, DummyPos) == QValidator::Acceptable ) if ( mpSoftValidator->validate(Text, DummyPos) == QValidator::Acceptable )
{ {
NewValidity = true; NewValidity = true;
setStyleSheet("border: 1px solid green"); setStyleSheet(QStringLiteral("border: 1px solid green"));
} }
else else
{ {
NewValidity = false; NewValidity = false;
setStyleSheet("border: 1px solid red"); setStyleSheet(QStringLiteral("border: 1px solid red"));
} }
} }
else else
{ {
NewValidity = true; NewValidity = true;
setStyleSheet(""); setStyleSheet(QString());
} }
if (NewValidity != mInputIsValid) if (NewValidity != mInputIsValid)

View File

@@ -23,7 +23,7 @@ public:
{ {
if (It.Value() != TEnumReflection<EnumT>::ErrorValue()) if (It.Value() != TEnumReflection<EnumT>::ErrorValue())
{ {
addItem(It.Name()); addItem(QString::fromUtf8(It.Name()));
mValueList.push_back(It.Value()); mValueList.push_back(It.Value());
} }
} }

View File

@@ -98,7 +98,7 @@ bool WDraggableSpinBox::eventFilter(QObject *, QEvent *pEvent)
QString WDraggableSpinBox::textFromValue(double Val) const QString WDraggableSpinBox::textFromValue(double Val) const
{ {
QString Str = QString::number(Val, 'f', decimals()); QString Str = QString::number(Val, 'f', decimals());
int DecIndex = Str.indexOf('.'); int DecIndex = Str.indexOf(QLatin1Char{'.'});
int NumDecs; int NumDecs;
if (DecIndex == -1) if (DecIndex == -1)
@@ -111,23 +111,23 @@ QString WDraggableSpinBox::textFromValue(double Val) const
int Size = Str.size() + mMinDecimals + 1; int Size = Str.size() + mMinDecimals + 1;
Str.reserve(Size); Str.reserve(Size);
Str += '.'; Str += QLatin1Char{'.'};
for (int iDec = 0; iDec < mMinDecimals; iDec++) for (int iDec = 0; iDec < mMinDecimals; iDec++)
Str += '0'; Str += QLatin1Char{'0'};
} }
else if ((NumDecs > mMinDecimals) && mTrimTrailingZeroes) else if ((NumDecs > mMinDecimals) && mTrimTrailingZeroes)
{ {
while (NumDecs > mMinDecimals) while (NumDecs > mMinDecimals)
{ {
if (Str.endsWith('0')) if (Str.endsWith(QLatin1Char{'0'}))
{ {
Str.chop(1); Str.chop(1);
NumDecs--; NumDecs--;
} }
else if (Str.endsWith('.')) else if (Str.endsWith(QLatin1Char{'.'}))
{ {
Str.chop(1); Str.chop(1);
break; break;

View File

@@ -35,8 +35,8 @@ void CCollisionRenderSettingsDialog::SetupWidgets()
EGame Game = mpEditor->CurrentGame(); EGame Game = mpEditor->CurrentGame();
// Set widgets to match current render setting values // Set widgets to match current render setting values
mpUi->HideMaskLineEdit->setText( "0x" + QString::number(rSettings.HideMask, 16).toUpper() ); mpUi->HideMaskLineEdit->setText(QStringLiteral("0x") + QString::number(rSettings.HideMask, 16).toUpper());
mpUi->HighlightMaskLineEdit->setText( "0x" + QString::number(rSettings.HighlightMask, 16).toUpper() ); mpUi->HighlightMaskLineEdit->setText(QStringLiteral("0x") + QString::number(rSettings.HighlightMask, 16).toUpper());
mpUi->WireframeCheckBox->setChecked(rSettings.DrawWireframe); mpUi->WireframeCheckBox->setChecked(rSettings.DrawWireframe);
mpUi->SurfaceTypeCheckBox->setChecked(rSettings.TintWithSurfaceColor); mpUi->SurfaceTypeCheckBox->setChecked(rSettings.TintWithSurfaceColor);
mpUi->StandableTrisCheckBox->setChecked(rSettings.TintUnwalkableTris); mpUi->StandableTrisCheckBox->setChecked(rSettings.TintUnwalkableTris);

View File

@@ -174,7 +174,7 @@ void CTemplateEditDialog::RefreshTypeNameOverride()
} }
else else
{ {
mpValidator->SetTypeNameOverride(""); mpValidator->SetTypeNameOverride(QString());
} }
} }

View File

@@ -741,7 +741,7 @@ void CWorldEditor::UpdateOpenRecentActions()
// Remove projects that don't exist anymore // Remove projects that don't exist anymore
for (const QString& rkProj : RecentProjectsList) 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); RecentProjectsList.removeAll(rkProj);
} }
@@ -771,14 +771,14 @@ void CWorldEditor::UpdateWindowTitle()
if (pProj) if (pProj)
{ {
WindowTitle += " - " + TO_QSTRING( pProj->Name() ); WindowTitle += QStringLiteral(" - ") + TO_QSTRING(pProj->Name());
if (mpWorld) if (mpWorld)
{ {
WindowTitle += " - " + TO_QSTRING(mpWorld->InGameName()); WindowTitle += QStringLiteral(" - ") + TO_QSTRING(mpWorld->InGameName());
if (mpArea && CurrentGame() < EGame::DKCReturns) if (mpArea && CurrentGame() < EGame::DKCReturns)
WindowTitle += " - " + TO_QSTRING( mpWorld->AreaInGameName(mpArea->WorldIndex()) ); WindowTitle += QStringLiteral(" - ") + TO_QSTRING(mpWorld->AreaInGameName(mpArea->WorldIndex()));
} }
} }

View File

@@ -316,7 +316,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
// Add remaining worlds to FrontEnd world // Add remaining worlds to FrontEnd world
mWorldList.prepend(SWorldInfo()); mWorldList.prepend(SWorldInfo());
pInfo = &mWorldList.front(); pInfo = &mWorldList.front();
pInfo->WorldName = "FrontEnd"; pInfo->WorldName = QStringLiteral("FrontEnd");
for (TResourceIterator<EResourceType::World> It; It; ++It) for (TResourceIterator<EResourceType::World> It; It; ++It)
{ {

View File

@@ -119,7 +119,7 @@ void WEditorProperties::OnSelectionModified()
} }
else else
{ {
mpInstanceInfoLabel->setText(QString("<i>[%1 objects selected]</i>").arg(pSelection->Size())); mpInstanceInfoLabel->setText(tr("<i>[%1 objects selected]</i>").arg(pSelection->Size()));
mpInstanceNameLineEdit->clear(); mpInstanceNameLineEdit->clear();
} }

View File

@@ -8,6 +8,7 @@
#include <Core/Resource/Script/NGameList.h> #include <Core/Resource/Script/NGameList.h>
#include <QApplication> #include <QApplication>
#include <QCoreApplication>
#include <QIcon> #include <QIcon>
#include <QStyleFactory> #include <QStyleFactory>
#include <QtGlobal> #include <QtGlobal>
@@ -95,7 +96,7 @@ public:
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
CEditorApplication App(argc, argv); CEditorApplication App(argc, argv);
App.setApplicationName(QStringLiteral("PrimeWorldEditor")); App.setApplicationName(QStringLiteral("PrimeWorldEditor"));
App.setApplicationVersion( APP_VERSION ); App.setApplicationVersion(QStringLiteral(APP_VERSION));
App.setOrganizationName(QStringLiteral("AxioDL")); App.setOrganizationName(QStringLiteral("AxioDL"));
App.setWindowIcon(QIcon(QStringLiteral(":/icons/win/AppIcon.ico"))); App.setWindowIcon(QIcon(QStringLiteral(":/icons/win/AppIcon.ico")));
@@ -116,7 +117,7 @@ public:
// Init log // Init log
bool Initialized = NLog::InitLog(LocateLogPath()); bool Initialized = NLog::InitLog(LocateLogPath());
if (!Initialized) 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); qInstallMessageHandler(QtLogRedirect);
// Locate data directory and check write permissions // Locate data directory and check write permissions
@@ -129,8 +130,8 @@ public:
if (!gpEditorStore->DatabasePathExists()) if (!gpEditorStore->DatabasePathExists())
{ {
UICommon::ErrorMsg(nullptr, "Unable to locate PWE resources directory; " UICommon::ErrorMsg(nullptr, QCoreApplication::translate("Main", "Unable to locate PWE resources directory; "
"PWE's executable must remain as deployed."); "PWE's executable must remain as deployed."));
return 1; return 1;
} }