/***
   This file is part of fly-ocr.

   Copyright (C) 2021 LLC "RusBITech-Astra" (https://astralinux.ru)

   Foobar is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   Foobar is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with fly-ocr. If not, see <https://www.gnu.org/licenses/>.
***/

#ifndef FLYOCRSTARTER_H
#define FLYOCRSTARTER_H

#include <QObject>
#include <QCommandLineParser>
#include <QCommandLineOption>

class QtSingleApplication;
class MainWindow;

class FlyOcrStarter : public QObject
{
    Q_OBJECT
public:
    explicit FlyOcrStarter(QtSingleApplication* app);
    ~FlyOcrStarter();
    bool isFinished() const;
    int exitCode() const;

private slots:
    void onMessageReceived(const QString& message);

private:
    void processCommands(const QString& currentWorkingDir);

    bool m_finished = false;
    int m_exitCode = EXIT_SUCCESS;
    MainWindow* m_mw = nullptr;
    QCommandLineParser m_parser;

    QCommandLineOption m_quitOption = {{"q", "quit"}, tr("Quit application.")};
    QCommandLineOption m_raiseOption = {"raise", tr("Bring window to top.")};
    QCommandLineOption m_ocrOption = {"ocr", tr("Recognize image file.")};
    QCommandLineOption m_statusOption = {"status", tr("Check if the application is running.")};
};

#endif // FLYOCRSTARTER_H
