mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 22:45:36 +00:00
Added dedicated functions for conversions between QString and std::filesystem::path.
This commit is contained in:
parent
c226b35f1f
commit
ca14fc00dc
16 changed files with 164 additions and 88 deletions
|
@ -19,13 +19,15 @@
|
|||
#include <components/config/gamesettings.hpp>
|
||||
#include <components/config/launchersettings.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/bsa/compressedbsafile.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/navmeshtool/protocol.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/vfs/bsaarchive.hpp>
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
#include "utils/profilescombobox.hpp"
|
||||
#include "utils/textinputdialog.hpp"
|
||||
|
||||
#include "ui_directorypicker.h"
|
||||
|
||||
|
@ -232,7 +234,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
|||
|
||||
const auto& globalDataDir = mGameSettings.getGlobalDataDir();
|
||||
if (!globalDataDir.empty())
|
||||
directories.insert(0, QString::fromStdU32String(globalDataDir.u32string()));
|
||||
directories.insert(0, Files::pathToQString(globalDataDir));
|
||||
|
||||
// normalize user supplied directories: resolve symlink, convert to native separator, make absolute
|
||||
for (auto& currentDir : directories)
|
||||
|
@ -264,7 +266,8 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
|
|||
}
|
||||
|
||||
// deactivate data-local and global data directory: they are always included
|
||||
if (currentDir == mDataLocal || std::filesystem::path(currentDir.toStdU32String()) == globalDataDir)
|
||||
const auto tmp = currentDir.toUtf8();
|
||||
if (currentDir == mDataLocal || std::filesystem::path(Misc::StringUtils::stringToU8String(tmp)) == globalDataDir)
|
||||
{
|
||||
auto flags = item->flags();
|
||||
item->setFlags(flags & ~(Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsEnabled));
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
#include <boost/program_options/options_description.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "playpage.hpp"
|
||||
#include "graphicspage.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
#include "settingspage.hpp"
|
||||
#include "advancedpage.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
#include "graphicspage.hpp"
|
||||
#include "playpage.hpp"
|
||||
#include "settingspage.hpp"
|
||||
|
||||
using namespace Process;
|
||||
|
||||
|
@ -163,7 +164,7 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
|
|||
cfgError(tr("Error opening OpenMW configuration file"),
|
||||
tr("<br><b>Could not create directory %0</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(QString::fromStdU32String(canonical(userConfigDir).u32string()))
|
||||
and try again.<br>").arg(Files::pathToQString(canonical(userConfigDir)))
|
||||
);
|
||||
return FirstRunDialogResultFailure;
|
||||
}
|
||||
|
@ -296,7 +297,7 @@ bool Launcher::MainDialog::setupLauncherSettings()
|
|||
|
||||
mLauncherSettings.setMultiValueEnabled(true);
|
||||
|
||||
QString userPath = QString::fromStdU32String(mCfgMgr.getUserConfigPath().u32string());
|
||||
const auto userPath = Files::pathToQString(mCfgMgr.getUserConfigPath());
|
||||
|
||||
QStringList paths;
|
||||
paths.append(QString(Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
@ -329,9 +330,9 @@ bool Launcher::MainDialog::setupGameSettings()
|
|||
{
|
||||
mGameSettings.clear();
|
||||
|
||||
QString localPath = QString::fromStdU32String(mCfgMgr.getLocalPath().u32string());
|
||||
QString userPath = QString::fromStdU32String(mCfgMgr.getUserConfigPath().u32string());
|
||||
QString globalPath = QString::fromStdU32String(mCfgMgr.getGlobalPath().u32string());
|
||||
const auto localPath = Files::pathToQString(mCfgMgr.getLocalPath());
|
||||
const auto userPath = Files::pathToQString(mCfgMgr.getUserConfigPath());
|
||||
const auto globalPath = Files::pathToQString(mCfgMgr.getGlobalPath());
|
||||
|
||||
QFile file;
|
||||
|
||||
|
@ -487,13 +488,17 @@ bool Launcher::MainDialog::writeSettings()
|
|||
cfgError(tr("Error creating OpenMW configuration directory"),
|
||||
tr("<br><b>Could not create %0</b><br><br> \
|
||||
Please make sure you have the right permissions \
|
||||
and try again.<br>").arg(QString::fromStdU32String(userPath.u32string())));
|
||||
and try again.<br>").arg(Files::pathToQString(userPath)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Game settings
|
||||
QFile file(QString::fromStdU32String((userPath / "openmw.cfg").u32string()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QFile file(userPath / "openmw.cfg");
|
||||
#else
|
||||
QFile file(Files::pathToQString(userPath / "openmw.cfg"));
|
||||
#endif
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||
// File cannot be opened or created
|
||||
|
@ -521,7 +526,7 @@ bool Launcher::MainDialog::writeSettings()
|
|||
}
|
||||
|
||||
// Launcher settings
|
||||
file.setFileName(QString::fromStdU32String((userPath / Config::LauncherSettings::sLauncherConfigFileName).u32string()));
|
||||
file.setFileName(Files::pathToQString(userPath / Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or created
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
|
||||
|
@ -104,7 +107,11 @@ void Launcher::SettingsPage::on_importerButton_clicked()
|
|||
// Create the file if it doesn't already exist, else the importer will fail
|
||||
auto path = mCfgMgr.getUserConfigPath();
|
||||
path /= "openmw.cfg";
|
||||
QFile file(QString::fromStdU32String(path.u32string()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QFile file(path);
|
||||
#else
|
||||
QFile file(Files::pathToQString(path));
|
||||
#endif
|
||||
|
||||
if (!file.exists()) {
|
||||
if (!file.open(QIODevice::ReadWrite)) {
|
||||
|
@ -137,7 +144,7 @@ void Launcher::SettingsPage::on_importerButton_clicked()
|
|||
arguments.append(QString("--ini"));
|
||||
arguments.append(settingsComboBox->currentText());
|
||||
arguments.append(QString("--cfg"));
|
||||
arguments.append(QString::fromStdU32String(path.u32string()));
|
||||
arguments.append(Files::pathToQString(path));
|
||||
|
||||
qDebug() << "arguments " << arguments;
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
#include <components/debug/debugging.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/fallback/validate.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/nifosg/nifloader.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
|
@ -230,8 +233,9 @@ void CS::Editor::openFiles (const std::filesystem::path &savePath, const std::ve
|
|||
|
||||
if(discoveredFiles.empty())
|
||||
{
|
||||
for (const QString &path : mFileDialog.selectedFilePaths())
|
||||
files.emplace_back(path.toStdU32String());
|
||||
for (const QString &path : mFileDialog.selectedFilePaths()) {
|
||||
files.emplace_back(Files::pathFromQString(path));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -248,7 +252,7 @@ void CS::Editor::createNewFile (const std::filesystem::path &savePath)
|
|||
std::vector<std::filesystem::path> files;
|
||||
|
||||
for (const QString &path : mFileDialog.selectedFilePaths()) {
|
||||
files.emplace_back(path.toStdU32String());
|
||||
files.emplace_back(Files::pathFromQString(path));
|
||||
}
|
||||
|
||||
files.push_back (savePath);
|
||||
|
@ -320,12 +324,13 @@ bool CS::Editor::makeIPCServer()
|
|||
mServer->close();
|
||||
fullPath.remove(QRegExp("dummy$"));
|
||||
fullPath += mIpcServerName;
|
||||
if(std::filesystem::exists(fullPath.toUtf8().constData()))
|
||||
const auto path = Files::pathFromQString(fullPath);
|
||||
if(exists(path))
|
||||
{
|
||||
// TODO: compare pid of the current process with that in the file
|
||||
Log(Debug::Info) << "Detected unclean shutdown.";
|
||||
// delete the stale file
|
||||
if(remove(fullPath.toUtf8().constData()))
|
||||
if(remove(path))
|
||||
Log(Debug::Error) << "Error: can not remove stale connection file.";
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +395,7 @@ int CS::Editor::run()
|
|||
}
|
||||
discoveredFiles.push_back(mFileToLoad);
|
||||
|
||||
QString extension = QString::fromStdU32String(mFileToLoad.extension().u32string()).toLower();
|
||||
const auto extension = Files::pathToQString(mFileToLoad.extension()).toLower();
|
||||
if (extension == ".esm")
|
||||
{
|
||||
mFileToLoad.replace_extension(".omwgame");
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "operationholder.hpp"
|
||||
|
||||
CSMDoc::Runner::Runner (std::filesystem::path projectPath)
|
||||
|
@ -80,22 +83,21 @@ void CSMDoc::Runner::start (bool delayed)
|
|||
else
|
||||
arguments << "--new-game=1";
|
||||
|
||||
arguments << ("--script-run="+mStartup->fileName());
|
||||
arguments << ("--script-run=" + mStartup->fileName());
|
||||
|
||||
arguments <<
|
||||
QString::fromStdU32String (U"--data=\""+mProjectPath.parent_path().u32string()+U"\"");
|
||||
arguments << "--data=\"" + Files::pathToQString(mProjectPath.parent_path()) + "\"";
|
||||
|
||||
arguments << "--replace=content";
|
||||
|
||||
for (const auto & mContentFile : mContentFiles)
|
||||
for (const auto& mContentFile : mContentFiles)
|
||||
{
|
||||
arguments << QString::fromStdU32String (U"--content="+mContentFile.u32string());
|
||||
arguments << "--content=" + Files::pathToQString(mContentFile);
|
||||
}
|
||||
|
||||
arguments
|
||||
<< QString::fromStdU32String (U"--content="+mProjectPath.filename().u32string());
|
||||
<< "--content=" + Files::pathToQString(mProjectPath.filename());
|
||||
|
||||
mProcess.start (path, arguments);
|
||||
mProcess.start(path, arguments);
|
||||
}
|
||||
|
||||
mRunning = true;
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
#include "adjusterwidget.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QStyle>
|
||||
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
|
||||
CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent)
|
||||
: QWidget (parent), mValid (false), mAction (ContentAction_Undefined)
|
||||
{
|
||||
|
@ -68,7 +70,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::filesystem::path path (name.toStdU32String());
|
||||
auto path = Files::pathFromQString(name);
|
||||
|
||||
const auto extension = Misc::StringUtils::lowerCase(path.extension().u8string());
|
||||
|
||||
|
@ -85,7 +87,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
|||
if (!isFilePathChanged && !isLegacyPath)
|
||||
{
|
||||
// path already points to the local data directory
|
||||
message = QString::fromStdU32String (U"Will be saved as: " + path.u32string());
|
||||
message = "Will be saved as: " + Files::pathToQString(path);
|
||||
mResultPath = path;
|
||||
}
|
||||
//in all other cases, ensure the path points to data-local and do an existing file check
|
||||
|
@ -95,7 +97,7 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
|||
if (isFilePathChanged)
|
||||
path = mLocalData / path.filename();
|
||||
|
||||
message = QString::fromStdU32String (U"Will be saved as: " + path.u32string());
|
||||
message = "Will be saved as: " + Files::pathToQString(path);
|
||||
mResultPath = path;
|
||||
|
||||
if (std::filesystem::exists (path))
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QListWidget>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
void CSVDoc::LoadingDocument::closeEvent (QCloseEvent *event)
|
||||
|
@ -19,7 +22,7 @@ void CSVDoc::LoadingDocument::closeEvent (QCloseEvent *event)
|
|||
CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
||||
: mDocument (document), mTotalRecordsLabel (0), mRecordsLabel (0), mAborted (false), mMessages (nullptr), mRecords(0)
|
||||
{
|
||||
setWindowTitle (QString::fromStdU32String(U"Opening " + document->getSavePath().filename().u32string()));
|
||||
setWindowTitle ("Opening " + Files::pathToQString(document->getSavePath().filename()));
|
||||
|
||||
setMinimumWidth (400);
|
||||
|
||||
|
@ -89,16 +92,16 @@ void CSVDoc::LoadingDocument::nextStage (const std::string& name, int fileRecord
|
|||
mRecords = fileRecords;
|
||||
}
|
||||
|
||||
void CSVDoc::LoadingDocument::nextRecord (int records)
|
||||
void CSVDoc::LoadingDocument::nextRecord(int records)
|
||||
{
|
||||
if (records <= mRecords)
|
||||
{
|
||||
mTotalProgress->setValue (mTotalRecords+records);
|
||||
mTotalProgress->setValue(mTotalRecords + records);
|
||||
|
||||
mRecordProgress->setValue(records);
|
||||
|
||||
mRecordsLabel->setText(QString::fromStdString(
|
||||
"Records: "+std::to_string(records)+" of "+std::to_string(mRecords)));
|
||||
mRecordsLabel->setText(
|
||||
"Records: " + QString::number(records) + " of " + QString::number(mRecords));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
#include "../../model/doc/state.hpp"
|
||||
|
||||
#include "../../model/world/columns.hpp"
|
||||
|
@ -261,7 +263,7 @@ bool CSVDoc::ViewManager::showModifiedDocumentMessageBox (CSVDoc::View *view)
|
|||
QMessageBox messageBox(view);
|
||||
CSMDoc::Document *document = view->getDocument();
|
||||
|
||||
messageBox.setWindowTitle (QString::fromStdU32String(document->getSavePath().filename().u32string()));
|
||||
messageBox.setWindowTitle (Files::pathToQString(document->getSavePath().filename()));
|
||||
messageBox.setText ("The document has been modified.");
|
||||
messageBox.setInformativeText ("Do you want to save your changes?");
|
||||
messageBox.setStandardButtons (QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
|
||||
#include "merge.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSplitter>
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
#include <QLabel>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
|
@ -102,7 +105,7 @@ void CSVTools::Merge::configure (CSMDoc::Document *document)
|
|||
|
||||
for (std::vector<std::filesystem::path>::const_iterator iter (files.begin());
|
||||
iter!=files.end(); ++iter)
|
||||
mFiles->addItem (QString::fromStdU32String(iter->filename().u32string()));
|
||||
mFiles->addItem (Files::pathToQString(iter->filename()));
|
||||
}
|
||||
|
||||
void CSVTools::Merge::setLocalData (const std::filesystem::path& localData)
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
#include "mainwizard.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
|
||||
#include "intropage.hpp"
|
||||
#include "methodselectionpage.hpp"
|
||||
#include "languageselectionpage.hpp"
|
||||
#include "existinginstallationpage.hpp"
|
||||
#include "installationtargetpage.hpp"
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
#include "componentselectionpage.hpp"
|
||||
#include "importpage.hpp"
|
||||
#include "conclusionpage.hpp"
|
||||
#include "existinginstallationpage.hpp"
|
||||
#include "importpage.hpp"
|
||||
#include "installationtargetpage.hpp"
|
||||
#include "intropage.hpp"
|
||||
#include "languageselectionpage.hpp"
|
||||
#include "methodselectionpage.hpp"
|
||||
|
||||
#ifdef OPENMW_USE_UNSHIELD
|
||||
#include "installationpage.hpp"
|
||||
|
@ -67,7 +70,7 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
|
|||
if (!installationPath.empty())
|
||||
{
|
||||
const std::filesystem::path& dataPath = installationPath / "Data Files";
|
||||
addInstallation(toQString(dataPath));
|
||||
addInstallation(Files::pathToQString(dataPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,7 @@ Wizard::MainWizard::~MainWizard()
|
|||
|
||||
void Wizard::MainWizard::setupLog()
|
||||
{
|
||||
QString logPath(toQString(mCfgMgr.getLogPath()));
|
||||
QString logPath(Files::pathToQString(mCfgMgr.getLogPath()));
|
||||
logPath.append(QLatin1String("wizard.log"));
|
||||
|
||||
QFile file(logPath);
|
||||
|
@ -101,7 +104,7 @@ void Wizard::MainWizard::setupLog()
|
|||
|
||||
void Wizard::MainWizard::addLogText(const QString &text)
|
||||
{
|
||||
QString logPath(toQString(mCfgMgr.getLogPath()));
|
||||
QString logPath(Files::pathToQString(mCfgMgr.getLogPath()));
|
||||
logPath.append(QLatin1String("wizard.log"));
|
||||
|
||||
QFile file(logPath);
|
||||
|
@ -131,8 +134,8 @@ void Wizard::MainWizard::addLogText(const QString &text)
|
|||
|
||||
void Wizard::MainWizard::setupGameSettings()
|
||||
{
|
||||
QString userPath(toQString(mCfgMgr.getUserConfigPath()));
|
||||
QString globalPath(toQString(mCfgMgr.getGlobalPath()));
|
||||
QString userPath(Files::pathToQString(mCfgMgr.getUserConfigPath()));
|
||||
QString globalPath(Files::pathToQString(mCfgMgr.getGlobalPath()));
|
||||
QString message(tr("<html><head/><body><p><b>Could not open %1 for reading</b></p> \
|
||||
<p>Please make sure you have the right permissions \
|
||||
and try again.</p></body></html>"));
|
||||
|
@ -196,7 +199,7 @@ void Wizard::MainWizard::setupGameSettings()
|
|||
|
||||
void Wizard::MainWizard::setupLauncherSettings()
|
||||
{
|
||||
QString path(toQString(mCfgMgr.getUserConfigPath()));
|
||||
QString path(Files::pathToQString(mCfgMgr.getUserConfigPath()));
|
||||
path.append(QLatin1String(Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
||||
QString message(tr("<html><head/><body><p><b>Could not open %1 for reading</b></p> \
|
||||
|
@ -246,7 +249,7 @@ void Wizard::MainWizard::runSettingsImporter()
|
|||
|
||||
QString path(field(QLatin1String("installation.path")).toString());
|
||||
|
||||
QString userPath(toQString(mCfgMgr.getUserConfigPath()));
|
||||
QString userPath(Files::pathToQString(mCfgMgr.getUserConfigPath()));
|
||||
QFile file(userPath + QLatin1String("openmw.cfg"));
|
||||
|
||||
// Construct the arguments to run the importer
|
||||
|
@ -392,7 +395,7 @@ void Wizard::MainWizard::writeSettings()
|
|||
mGameSettings.removeDataDir(path);
|
||||
mGameSettings.addDataDir(path);
|
||||
|
||||
QString userPath(toQString(mCfgMgr.getUserConfigPath()));
|
||||
QString userPath(Files::pathToQString(mCfgMgr.getUserConfigPath()));
|
||||
QDir dir(userPath);
|
||||
|
||||
if (!dir.exists()) {
|
||||
|
@ -468,8 +471,3 @@ bool Wizard::MainWizard::findFiles(const QString &name, const QString &path)
|
|||
return (dir.entryList().contains(name + QLatin1String(".esm"), Qt::CaseInsensitive)
|
||||
&& dir.entryList().contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
QString Wizard::MainWizard::toQString(const std::filesystem::path& path)
|
||||
{
|
||||
return QString::fromStdU32String(path.u32string());
|
||||
}
|
||||
|
|
|
@ -58,9 +58,6 @@ namespace Wizard
|
|||
void addLogText(const QString &text);
|
||||
|
||||
private:
|
||||
/// convert std::filesystem::path to QString
|
||||
QString toQString(const std::filesystem::path& path);
|
||||
|
||||
void setupLog();
|
||||
void setupGameSettings();
|
||||
void setupLauncherSettings();
|
||||
|
|
|
@ -379,6 +379,10 @@ if (USE_QT)
|
|||
helpviewer
|
||||
)
|
||||
|
||||
add_component_qt_dir (files
|
||||
qtconversion
|
||||
)
|
||||
|
||||
QT5_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
||||
endif()
|
||||
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
|
||||
const char Config::GameSettings::sArchiveKey[] = "fallback-archive";
|
||||
const char Config::GameSettings::sContentKey[] = "content";
|
||||
|
@ -24,19 +26,16 @@ void Config::GameSettings::validatePaths()
|
|||
|
||||
for (const QString &path : paths)
|
||||
{
|
||||
dataDirs.emplace_back(path.toStdU32String());
|
||||
dataDirs.emplace_back(Files::pathFromQString(path));
|
||||
}
|
||||
|
||||
// Parse the data dirs to convert the tokenized paths
|
||||
mCfgMgr.processPaths(dataDirs, /*basePath=*/"");
|
||||
mDataDirs.clear();
|
||||
|
||||
for (auto & dataDir : dataDirs) {
|
||||
QString path = QString::fromStdU32String(dataDir.u32string());
|
||||
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
mDataDirs.append(path);
|
||||
for (const auto & dataDir : dataDirs) {
|
||||
if (is_directory(dataDir))
|
||||
mDataDirs.append(Files::pathToQString(dataDir));
|
||||
}
|
||||
|
||||
// Do the same for data-local
|
||||
|
@ -51,16 +50,14 @@ void Config::GameSettings::validatePaths()
|
|||
return;
|
||||
|
||||
dataDirs.clear();
|
||||
dataDirs.emplace_back(local.toStdU32String());
|
||||
dataDirs.emplace_back(Files::pathFromQString(local));
|
||||
|
||||
mCfgMgr.processPaths(dataDirs, /*basePath=*/"");
|
||||
|
||||
if (!dataDirs.empty()) {
|
||||
QString path = QString::fromStdU32String(dataDirs.front().u32string());
|
||||
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
mDataLocal = path;
|
||||
const auto& path = dataDirs.front();
|
||||
if (is_directory(path))
|
||||
mDataLocal = Files::pathToQString(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
|
||||
const char Config::LauncherSettings::sCurrentContentListKey[] = "Profiles/currentprofile";
|
||||
const char Config::LauncherSettings::sLauncherConfigFileName[] = "launcher.cfg";
|
||||
|
@ -119,7 +121,7 @@ void Config::LauncherSettings::setContentList(const GameSettings& gameSettings)
|
|||
}
|
||||
|
||||
// global and local data directories are not part of any profile
|
||||
const auto globalDataDir = QString::fromStdU32String(gameSettings.getGlobalDataDir().u32string());
|
||||
const auto globalDataDir = Files::pathToQString(gameSettings.getGlobalDataDir());
|
||||
const auto dataLocal = gameSettings.getDataLocal();
|
||||
dirs.removeAll(globalDataDir);
|
||||
dirs.removeAll(dataLocal);
|
||||
|
|
28
components/files/qtconversion.cpp
Normal file
28
components/files/qtconversion.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
#include "qtconversion.hpp"
|
||||
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
|
||||
QString Files::pathToQString(const std::filesystem::path& path)
|
||||
{
|
||||
const auto tmp = path.u8string();
|
||||
return QString::fromUtf8(Misc::StringUtils::u8StringToString(tmp.data()), tmp.size());
|
||||
}
|
||||
|
||||
QString Files::pathToQString(std::filesystem::path&& path)
|
||||
{
|
||||
const auto tmp = path.u8string();
|
||||
return QString::fromUtf8(Misc::StringUtils::u8StringToString(tmp.data()), tmp.size());
|
||||
}
|
||||
|
||||
std::filesystem::path Files::pathFromQString(QStringView path)
|
||||
{
|
||||
const auto tmp = path.toUtf8();
|
||||
return std::filesystem::path{ Misc::StringUtils::stringToU8String(tmp) };
|
||||
}
|
||||
|
||||
std::filesystem::path Files::pathFromQString(QString&& path)
|
||||
{
|
||||
const auto tmp = path.toUtf8();
|
||||
return std::filesystem::path{ Misc::StringUtils::stringToU8String(tmp) };
|
||||
}
|
18
components/files/qtconversion.hpp
Normal file
18
components/files/qtconversion.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef COMPONENTS_FILES_QTCONVERSION_HPP
|
||||
#define COMPONENTS_FILES_QTCONVERSION_HPP
|
||||
|
||||
#include <QString>
|
||||
#include <filesystem>
|
||||
|
||||
namespace Files
|
||||
{
|
||||
QString pathToQString(const std::filesystem::path& path);
|
||||
|
||||
QString pathToQString(std::filesystem::path&& path);
|
||||
|
||||
std::filesystem::path pathFromQString(QStringView path);
|
||||
|
||||
std::filesystem::path pathFromQString(QString&& path);
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_FILES_QTCONVERSION_HPP
|
Loading…
Reference in a new issue