| /* PE Header Editor |
| Copyright 2007-2014 PC GO Ld. |
| |
| This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| */ |
| |
| #include "mainwindow.h" |
| #include <sys/stat.h> |
| #include <QtCore/QDir> |
| #include <QtCore/QFile> |
| #include <QtCore/QSettings> |
| #include <QtGui/QApplication> |
| |
| #define CONFIG_FILE_NAME "pe-editor.cfg" |
| |
| QString config_dir() { |
| QString appath = QApplication::applicationDirPath(); |
| #ifndef Q_OS_WINCE |
| if(QFile::exists(appath + "/" CONFIG_FILE_NAME)) { |
| #endif |
| return appath; |
| #ifndef Q_OS_WINCE |
| } |
| QString inhome = QDir::homePath() + "/.pc-go"; |
| if(!QFile::exists(inhome)) mkdir(inhome.toLocal8Bit().data(), 0755); |
| return inhome; |
| #endif |
| } |
| |
| int main(int argc, char *argv[]) { |
| for(int i=1; i<argc; i++) if(strcmp(argv[i], "--style") == 0) { |
| QApplication::setStyle(argv[i+1]); |
| for(int j=i; j<argc-1; j++) argv[j] = argv[j+2]; |
| argc -= 2; |
| } |
| QApplication a(argc, argv); |
| MainWindow w; |
| w.config = new QSettings(config_dir() + "/" CONFIG_FILE_NAME, (QSettings::Format)1, &w); |
| w.config->setIniCodec("UTF-8"); |
| QSize windowsize = w.config->value("MainWindowSize").toSize(); |
| if(windowsize.width() > 0 && windowsize.height() > 0) w.resize(windowsize); |
| if(argc > 1) w.load(QString::fromLocal8Bit(argv[1])); |
| w.show(); |
| |
| return a.exec(); |
| } |