//using namespace std;
void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
-void loadMainFormFromXML(QFile *, UIInformation *);
+void loadMainFormFromXML(QString, UIInformation *);
void loadConFormFromXML(QFile *, UIInformation *);
bool qt5IsOnscreen;
}
qDebug() << "VM path:" << uiInfo->vmDataPath;
- uiInfo->skinPath = QDir(
- QString::fromLocal8Bit(get_emul_skin_path())).canonicalPath();
- if (uiInfo->skinPath.endsWith(QDir::separator()) == false) {
- uiInfo->skinPath += QDir::separator();
- }
+ uiInfo->skinPath = QDir::toNativeSeparators(
+ QString::fromLocal8Bit(get_emul_skin_path()));
qDebug() << "skin path:" << uiInfo->skinPath;
/* read skin information */
- QSettings skinInfo(uiInfo->skinPath + LAYOUT_SKIN_INFO_FILE,
- QSettings::IniFormat);
+ QSettings skinInfo(uiInfo->skinPath + QDir::separator() +
+ LAYOUT_SKIN_INFO_FILE, QSettings::IniFormat);
QString skinName = skinInfo.value(SKIN_PROPERTY_NAME).toString();
if (skinName.isEmpty() == true) {
skinName = GENERIC_TEXT_UNDEFINED;
uiInfo->vmDataPath + GUI_PROPERTIES_FILE, QSettings::IniFormat);
/* XML layout */
- QFile mainXMLFile(uiInfo->skinPath + LAYOUT_FORM_FILE_NAME);
/* load main form */
- loadMainFormFromXML(&mainXMLFile, uiInfo);
+ loadMainFormFromXML(uiInfo->skinPath + QDir::separator() +
+ LAYOUT_FORM_FILE_NAME, uiInfo);
- QDir skinDir(uiInfo->skinPath + LAYOUT_CON_FORM_SUBPATH);
/* load controller forms */
+ QDir skinDir(uiInfo->skinPath + QDir::separator() + LAYOUT_CON_FORM_SUBPATH);
QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
if (entries.isEmpty() == false) {
}
}
-void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
+void loadMainFormFromXML(QString xmlPath, UIInformation *uiInfo/* out */)
{
- if (file->exists() == false) {
- qFatal("%s %s", qPrintable(file->fileName()), MSG_NOT_FOUND);
- return;
- }
+ QFile file(xmlPath);
- if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
- qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2);
+ if (file.exists() == false ||
+ file.open(QIODevice::ReadOnly | QIODevice::Text) == false) {
+ qFatal("Failed to load the emulator skin. %s%s", MSG_CHECK_PATH,
+ qPrintable(xmlPath));
return;
}
- qDebug("main form is loaded from %s", qPrintable(file->fileName()));
+ qDebug("main form is loaded from %s", qPrintable(file.fileName()));
/* read xml */
- QFileInfo fileInfo(*file);
- QXmlStreamReader xml(file);
+ QXmlStreamReader xml(&file);
/* parse xml */
+ QFileInfo fileInfo(xmlPath);
XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
QString version = parser.parseEmulatorUI(xml);
- qDebug() << "layout version :" << version;
+ qDebug() << "layout version:" << version;
const bool hasError = xml.hasError();
xml.clear();
- file->close();
+ file.close();
if (hasError == true) {
- qFatal(MSG_INVALID_XML_FORMAT);
+ qFatal("%s %s%s", MSG_INVALID_XML_FORMAT, MSG_CHECK_PATH,
+ qPrintable(xmlPath));
return;
}
}
void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
{
- if (file->exists() == false) {
- qWarning("%s is not found", qPrintable(file->fileName()));
- return;
- }
-
- if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
- qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2);
+ if (file->exists() == false ||
+ file->open(QIODevice::ReadOnly | QIODevice::Text) == false) {
+ qWarning() << "Failed to load the controller skin:" <<
+ file->fileName();
return;
}
qDebug("controller form is loaded from %s", qPrintable(file->fileName()));
/* read xml */
- QFileInfo fileInfo(*file);
QXmlStreamReader xml(file);
/* parse xml */
+ QFileInfo fileInfo(*file);
XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
QString version = parser.parseControllerUI(xml);
- qDebug() << "layout version :" << version;
+ qDebug() << "layout version:" << version;
const bool hasError = xml.hasError();
xml.clear();
file->close();
- if (hasError == true) {
- qFatal(MSG_INVALID_XML_FORMAT);
+ if (hasError == false) {
+ qFatal("%s %s%s", MSG_INVALID_XML_FORMAT, MSG_CHECK_PATH,
+ qPrintable(fileInfo.absoluteFilePath()));
return;
}
}