amuse/Editor/Common.cpp

39 lines
897 B
C++
Raw Normal View History

#include "Common.hpp"
#include <QMessageBox>
#include <QObject>
boo::SystemString QStringToSysString(const QString& str)
{
#ifdef _WIN32
return (wchar_t*)str.utf16();
#else
return str.toUtf8().toStdString();
#endif
}
QString SysStringToQString(const boo::SystemString& str)
{
#ifdef _WIN32
return QString::fromStdWString(str);
#else
return QString::fromStdString(str);
#endif
}
2018-07-17 04:48:38 +00:00
bool MkPath(const QString& path, UIMessenger& messenger)
{
QFileInfo fInfo(path);
2018-07-17 04:48:38 +00:00
return MkPath(fInfo.dir(), fInfo.fileName(), messenger);
}
2018-07-17 04:48:38 +00:00
bool MkPath(const QDir& dir, const QString& file, UIMessenger& messenger)
{
if (!dir.mkpath(file))
{
2018-07-17 04:48:38 +00:00
QString msg = QString(QObject::tr("A directory at '%1/%2' could not be created.")).arg(dir.path()).arg(file);
messenger.critical(QObject::tr("Unable to create directory"), msg);
return false;
}
return true;
}