Skip to content
Snippets Groups Projects
Commit 7b6978b0 authored by Olivier Langella's avatar Olivier Langella
Browse files

parse command line argument, associate XPIP mime type to xtpcpp

parent 17268dbd
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
#include <QCommandLineParser>
#include "../config.h" #include "../config.h"
#include "mainwindow.h" #include "mainwindow.h"
...@@ -51,6 +52,7 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -51,6 +52,7 @@ MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::Main) ui(new Ui::Main)
{ {
_p_app = QCoreApplication::instance();
ui->setupUi(this); ui->setupUi(this);
setWindowTitle(QString("%1 %2").arg(SOFTWARE_NAME).arg(XTPCPP_VERSION)); setWindowTitle(QString("%1 %2").arg(SOFTWARE_NAME).arg(XTPCPP_VERSION));
...@@ -456,3 +458,50 @@ void MainWindow::doActionAbout() { ...@@ -456,3 +458,50 @@ void MainWindow::doActionAbout() {
qDebug() << "MainWindow::doActionAbout end"; 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()));
}
}
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
bool stopWorkerThread(); bool stopWorkerThread();
public slots: public slots:
void run();
void loadResults(); void loadResults();
void selectXpipFile(); void selectXpipFile();
void doActionAbout(); void doActionAbout();
...@@ -112,6 +113,7 @@ private: ...@@ -112,6 +113,7 @@ private:
void viewError(QString error); void viewError(QString error);
private : private :
QCoreApplication * _p_app;
Ui::Main *ui; Ui::Main *ui;
QThread _worker_thread; QThread _worker_thread;
ProjectSp _project_sp=nullptr; ProjectSp _project_sp=nullptr;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
******************************************************************************/ ******************************************************************************/
#include <QApplication> #include <QApplication>
#include <QTimer>
#include <iostream> #include <iostream>
#include <pappsomspp/pappsoexception.h> #include <pappsomspp/pappsoexception.h>
#include "config.h" #include "config.h"
...@@ -35,6 +36,7 @@ int main(int argc, char *argv[]) ...@@ -35,6 +36,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
qRegisterMetaType<TandemRunBatch>("TandemRunBatch"); qRegisterMetaType<TandemRunBatch>("TandemRunBatch");
try { try {
QCoreApplication::setOrganizationName("PAPPSO"); QCoreApplication::setOrganizationName("PAPPSO");
QCoreApplication::setOrganizationDomain("pappso.inra.fr"); QCoreApplication::setOrganizationDomain("pappso.inra.fr");
...@@ -42,6 +44,10 @@ int main(int argc, char *argv[]) ...@@ -42,6 +44,10 @@ int main(int argc, char *argv[])
MainWindow window; MainWindow window;
window.show(); 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(); return app.exec();
} }
catch (pappso::PappsoException& error) catch (pappso::PappsoException& error)
......
...@@ -4,9 +4,10 @@ Version=1.0 ...@@ -4,9 +4,10 @@ Version=1.0
Name=X!TandemPipeline C++ Name=X!TandemPipeline C++
Categories=Science;Biology;Education;Qt; Categories=Science;Biology;Education;Qt;
Comment=Protein inference tool 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 Icon=${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/xtpcpp.svg
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Keywords=Mass spectrometry;Protein inference;Peptide; Keywords=Mass spectrometry;Protein inference;Peptide;
MimeType=application/x-xtandempipeline;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment