diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 31f1930..d6558ca 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -1042,6 +1042,20 @@ bool switchTranslator(QTranslator* lpTranslator, const QString& filename) return(false); } +void cMainWindow::onInitialize() +{ + QStringList arguments = QCoreApplication::arguments(); + + for(int x = 0;x < arguments.count();x++) + { + if(arguments[x].contains(".storyWrite")) + { + fileOpen(arguments[x]); + return; + } + } +} + void cMainWindow::onLanguageChanged() { QSettings settings; @@ -1910,6 +1924,11 @@ void cMainWindow::onFileNew() } void cMainWindow::onFileOpen() +{ + fileOpen(); +} + +void cMainWindow::fileOpen(const QString& szFileName) { if(m_lpStoryBook) { @@ -1931,7 +1950,15 @@ void cMainWindow::onFileOpen() } } - QString szProjectName = getProjectLoadName(); + QMessageBox::information(this, "Initialize", szFileName); + + QString szProjectName; + + if(szFileName.isEmpty()) + szProjectName = getProjectLoadName(); + else + szProjectName = szFileName; + if(szProjectName.isEmpty()) return; diff --git a/cmainwindow.h b/cmainwindow.h index 26c3e1a..4f80471 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -112,6 +112,12 @@ public: QAction* actionAlignJustify(); public slots: + /*! + \brief + + \fn onInitialize + */ + void onInitialize(); /*! \brief @@ -972,6 +978,13 @@ private: */ void setCurrentFile(const QString& szFileName); + /*! + \brief + + \fn fileOpen + */ + void fileOpen(const QString& szFileName = QString()); + /*! \brief diff --git a/main.cpp b/main.cpp index 7084722..7abf346 100644 --- a/main.cpp +++ b/main.cpp @@ -16,25 +16,45 @@ #include +#include + #include "csplashscreen.h" #define SHOW_SPLASH +void debugOut(const QString& message) +{ + QFile file("c:\\temp\\log.log"); + file.open(QFile::WriteOnly | QFile::Text | QFile::Append); + QTextStream out(&file); + out << message; + out << "\n"; + file.flush(); + file.close(); +} + int main(int argc, char *argv[]) { + for(int x = 0;x < argc;x++) + debugOut(argv[x]); + + debugOut("1"); QApplication a(argc, argv); + debugOut("2"); a.setApplicationVersion(APP_VERSION); a.setApplicationDisplayName("storyWriter"); a.setOrganizationName("WIN-DESIGN"); a.setOrganizationDomain("windesign.at"); a.setApplicationName("storyWriter"); + debugOut("3"); QSettings settings; QTranslator* lpTranslator = new QTranslator; QString szLanguage = settings.value("main/language").toString(); + debugOut("4"); if(!szLanguage.compare("%SYSTEM%")) { @@ -42,12 +62,14 @@ int main(int argc, char *argv[]) if(languageList.count()) szLanguage = languageList[0]; } + debugOut("5"); if(!szLanguage.isEmpty()) { if(lpTranslator->load(QString("storyWriter_%1").arg(szLanguage), ":/locale")) a.installTranslator(lpTranslator); } + debugOut("6"); #ifdef SHOW_SPLASH QPixmap pixmap(":/images/splash.png"); @@ -62,29 +84,40 @@ int main(int argc, char *argv[]) QString family = QFontDatabase::applicationFontFamilies(id).at(0); QFont splashFont(family); splashFont.setPixelSize(24); + debugOut("7"); cSplashScreen* lpSplash = new cSplashScreen(pixmap, splashFont); + debugOut("8"); #ifdef SHOW_SPLASH lpSplash->setMessageRect(QRect(0, 110, 480, 209)); #else lpSplash->setMessageRect(QRect(0, 110, 480, 209)); #endif + debugOut("9"); lpSplash->show(); a.processEvents(); + debugOut("10"); lpSplash->showStatusMessage(QObject::tr("
initializing...")); + debugOut("11"); cMainWindow w(lpSplash, lpTranslator); + debugOut("12"); + + QTimer::singleShot(0, &w, SLOT(onInitialize())); + debugOut("12a"); if(settings.value("main/maximized").toBool()) w.showMaximized(); else w.show(); + debugOut("13"); lpSplash->finish(&w); delete lpSplash; + debugOut("14"); return a.exec(); }