diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 224713ac3ebd694468ae8df53a4def31c14a0885..44520a82edd1d4209ae2b5ac183d4a4889aae84b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -25,6 +25,7 @@ #include <QFileDialog> #include <QMessageBox> #include <QDebug> +#include <QCommandLineParser> #include "../config.h" #include "mainwindow.h" @@ -51,6 +52,7 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::Main) { + _p_app = QCoreApplication::instance(); ui->setupUi(this); setWindowTitle(QString("%1 %2").arg(SOFTWARE_NAME).arg(XTPCPP_VERSION)); @@ -456,3 +458,50 @@ void MainWindow::doActionAbout() { qDebug() << "MainWindow::doActionAbout end"; } + + + + +// 10ms after the application starts this method will run +// all QT messaging is running at this point so threads, signals and slots +// will all work as expected. +void MainWindow::run() +{ + + QTextStream errorStream(stderr, QIODevice::WriteOnly); + + try { + qDebug() << "MainWindow::run() begin"; + QCommandLineParser parser; + + //throw pappso::PappsoException("test"); + parser.setApplicationDescription(QString(SOFTWARE_NAME).append(" ").append(XTPCPP_VERSION)); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("XPIP project file", QCoreApplication::translate("main", "Project file to open.")); + + qDebug() << "MainWindow::run() 1"; + + // Process the actual command line arguments given by the user + parser.process(*_p_app); + + + QStringList xpip_list = parser.positionalArguments(); + if (xpip_list.size() > 0) { + showWaitingMessage(tr("Loading %1 XPIP file").arg(xpip_list.at(0))); + emit operateXpipFile(xpip_list.at(0)); + } + + } + catch (pappso::PappsoException& error) + { + viewError(tr("Oops! an error occurred in X!TandemPipeline. Dont Panic :\n%1").arg(error.qwhat())); + } + + catch (std::exception& error) + { + viewError(tr("Oops! an error occurred in X!TandemPipeline. Dont Panic :\n%1").arg(error.what())); + } + + +} diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index b1e56cefc345f039e579cd296945052393f00df6..0c8adc9d473702406cad8bb796a189e35ade1ce4 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -62,6 +62,7 @@ public: bool stopWorkerThread(); public slots: + void run(); void loadResults(); void selectXpipFile(); void doActionAbout(); @@ -112,6 +113,7 @@ private: void viewError(QString error); private : + QCoreApplication * _p_app; Ui::Main *ui; QThread _worker_thread; ProjectSp _project_sp=nullptr; diff --git a/src/main.cpp b/src/main.cpp index baafd20d1466ca065117a259e928a95b76da1a35..45a4f7bf3a5f1ea9c2c70e31f5910faa3e753da1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ ******************************************************************************/ #include <QApplication> +#include <QTimer> #include <iostream> #include <pappsomspp/pappsoexception.h> #include "config.h" @@ -35,6 +36,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); qRegisterMetaType<TandemRunBatch>("TandemRunBatch"); + try { QCoreApplication::setOrganizationName("PAPPSO"); QCoreApplication::setOrganizationDomain("pappso.inra.fr"); @@ -42,6 +44,10 @@ int main(int argc, char *argv[]) MainWindow window; window.show(); + // This code will start the messaging engine in QT and in + // 10ms it will start the execution in the MainClass.run routine; + QTimer::singleShot(10, &window, SLOT(run())); + return app.exec(); } catch (pappso::PappsoException& error) diff --git a/templates/share/applications/xtpcpp.desktop.cmake b/templates/share/applications/xtpcpp.desktop.cmake index 88ea591233d15ef80bd079776c3694523bd82846..cf13b214c5bfbff9b004671c8e2c64c7e527acdb 100644 --- a/templates/share/applications/xtpcpp.desktop.cmake +++ b/templates/share/applications/xtpcpp.desktop.cmake @@ -4,9 +4,10 @@ Version=1.0 Name=X!TandemPipeline C++ Categories=Science;Biology;Education;Qt; Comment=Protein inference tool -Exec=${CMAKE_INSTALL_PREFIX}/bin/xtpcpp +Exec=${CMAKE_INSTALL_PREFIX}/bin/xtpcpp %U Icon=${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/xtpcpp.svg Terminal=false Type=Application StartupNotify=true Keywords=Mass spectrometry;Protein inference;Peptide; +MimeType=application/x-xtandempipeline;