mirror of
https://github.com/AxioDL/amuse.git
synced 2025-12-09 05:27:57 +00:00
Lots of foundational work for Amuse editor
This commit is contained in:
38
Editor/Common.cpp
Normal file
38
Editor/Common.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#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
|
||||
}
|
||||
|
||||
bool MkPath(const QString& path, QWidget* parent)
|
||||
{
|
||||
QFileInfo fInfo(path);
|
||||
return MkPath(fInfo.dir(), fInfo.fileName(), parent);
|
||||
}
|
||||
|
||||
bool MkPath(const QDir& dir, const QString& file, QWidget* parent)
|
||||
{
|
||||
if (!dir.mkpath(file))
|
||||
{
|
||||
QString msg = QString(parent->tr("A directory at '%1/%2' could not be created.")).arg(dir.path()).arg(file);
|
||||
QMessageBox::critical(parent, parent->tr("Unable to create directory"), msg);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user