text: //
  //          Copyright (c) 2016, Scientific Toolworks, Inc.
  //
  // This software is licensed under the MIT License. The LICENSE.md file
  // describes the conditions under which this software may be distributed.
  //
  // Author: Jason Haslam
  //
  
  #ifndef APPLICATION_H
  #define APPLICATION_H
  
  #include "Theme.h"
  #include <QApplication>
  
  class QNetworkAccessManager;
  class QNetworkReply;
  class QSslError;
  class QUrlQuery;
  
  class Application : public QApplication
  {
    Q_OBJECT
  
  public:
    Application(
      int &argc,
      char **argv,
      bool haltOnParseError = false,
      const QString &defaultTheme = QString());
  
    void autoUpdate();
    bool restoreWindows();
    bool runSingleInstance();
  
    static Theme *theme();
  
    static void track(const QString &screen);
    static void track(
      const QString &category,
      const QString &action,
      const QString &label = QString(),
      int value = -1);
  
  protected:
    bool event(QEvent *event) override;
  
  private:
    void registerService();
    void track(const QUrlQuery &query);
    void handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
  
    QString mPathspec = QString();
    QScopedPointer<Theme> mTheme;
    QStringList mPositionalArguments;
  
    QString mClientId;
    QNetworkAccessManager *mTrackingMgr = nullptr;
  };
  
  #ifdef Q_OS_LINUX
  class DBusGitAhead: public QObject
  {
    Q_OBJECT
  
  public:
    DBusGitAhead(QObject *parent = nullptr);
  
  public slots:
    Q_SCRIPTABLE void openRepository(const QString &repo);
    Q_SCRIPTABLE void openAndFocusRepository(const QString &repo);
    Q_SCRIPTABLE void setFocus();
  };
  #endif
  
  #endif
  