Put all application logic into Application class.

Application process message and split it into params list itself (this
prevents code duplication).
Application store params unless other components ready to process them.
Application incapsulate all QMacApplication and SessionApplication logic
(this is too small to have separate classes).
This commit is contained in:
Vladimir Golovnev (Glassez) 2015-01-22 15:56:16 +03:00
commit 0c50a8b98b
11 changed files with 210 additions and 486 deletions

View file

@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@ -34,8 +34,9 @@
#include <QTranslator>
#ifndef DISABLE_GUI
#include "sessionapplication.h"
typedef SessionApplication BaseApplication;
#include "qtsingleapplication.h"
typedef QtSingleApplication BaseApplication;
class MainWindow;
#else
#include "qtsinglecoreapplication.h"
typedef QtSingleCoreApplication BaseApplication;
@ -43,18 +44,40 @@ typedef QtSingleCoreApplication BaseApplication;
class Application : public BaseApplication
{
Q_OBJECT
public:
Application(const QString &id, int &argc, char **argv);
~Application();
#ifdef Q_OS_WIN
#if (defined(Q_OS_WIN) && !defined(DISABLE_GUI))
bool isRunning();
#endif
int exec(const QStringList &params);
bool sendParams(const QStringList &params);
protected:
#ifndef DISABLE_GUI
#ifdef Q_OS_MAC
bool event(QEvent *);
#endif
bool notify(QObject* receiver, QEvent* event);
#endif
private slots:
void processMessage(const QString &message);
private:
bool m_running;
#ifndef DISABLE_GUI
MainWindow *m_window;
#endif
QTranslator m_qtTranslator;
QTranslator m_translator;
QStringList m_paramsQueue;
void initializeTranslation();
void processParams(const QStringList &params);
};
#endif // APPLICATION_H