2013-11-23 13:48:34 +07:00
|
|
|
#ifndef MANAGER_H
|
|
|
|
#define MANAGER_H
|
|
|
|
|
|
|
|
#include <QPixmap>
|
2013-11-24 20:06:19 +07:00
|
|
|
#include <QSystemTrayIcon>
|
2015-09-28 00:50:19 +07:00
|
|
|
#include <QMap>
|
2013-11-23 13:48:34 +07:00
|
|
|
|
2013-11-26 13:44:00 +07:00
|
|
|
#include "ProcessingItem.h"
|
|
|
|
|
2013-11-24 19:43:37 +07:00
|
|
|
class QAction;
|
2013-11-23 13:48:34 +07:00
|
|
|
class QMenu;
|
|
|
|
|
|
|
|
class SelectionDialog;
|
2013-11-26 13:44:00 +07:00
|
|
|
class ResultDialog;
|
2014-04-04 21:39:10 +07:00
|
|
|
class LanguageHelper;
|
2015-10-18 16:19:59 +07:00
|
|
|
class Updater;
|
2013-11-23 13:48:34 +07:00
|
|
|
|
2015-09-23 01:41:08 +07:00
|
|
|
class Manager : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2015-10-10 23:07:25 +07:00
|
|
|
enum IconType {
|
|
|
|
IconTypeNormal, IconTypeWorking, IconTypeError, IconTypeSuccess
|
|
|
|
};
|
|
|
|
|
2013-11-23 13:48:34 +07:00
|
|
|
public:
|
2015-09-23 01:41:08 +07:00
|
|
|
explicit Manager (QObject *parent = 0);
|
2013-11-23 13:48:34 +07:00
|
|
|
~Manager ();
|
|
|
|
|
|
|
|
signals:
|
2015-09-30 23:49:10 +07:00
|
|
|
void requestRecognize (ProcessingItem item);
|
2015-09-29 19:30:04 +07:00
|
|
|
void requestTranslate (ProcessingItem item);
|
2015-09-28 00:50:19 +07:00
|
|
|
void closeSelections ();
|
2013-11-24 19:43:37 +07:00
|
|
|
void settingsEdited ();
|
2013-11-23 13:48:34 +07:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void capture ();
|
2015-09-29 22:14:56 +07:00
|
|
|
void repeatCapture ();
|
2013-11-23 13:48:34 +07:00
|
|
|
void settings ();
|
|
|
|
void close ();
|
2013-11-24 20:06:19 +07:00
|
|
|
void about ();
|
2013-11-26 23:59:47 +07:00
|
|
|
void showLast ();
|
|
|
|
void copyLastToClipboard ();
|
2015-10-10 04:20:14 +07:00
|
|
|
void copyLastImageToClipboard ();
|
2013-11-23 13:48:34 +07:00
|
|
|
|
2013-11-24 19:43:37 +07:00
|
|
|
void applySettings ();
|
2015-10-18 16:19:59 +07:00
|
|
|
void checkForUpdates ();
|
2013-11-24 19:43:37 +07:00
|
|
|
|
2013-11-24 20:06:19 +07:00
|
|
|
void processTrayAction (QSystemTrayIcon::ActivationReason reason);
|
|
|
|
|
2015-10-02 00:49:53 +07:00
|
|
|
void editRecognized (ProcessingItem item);
|
2015-09-30 23:49:10 +07:00
|
|
|
void handleSelection (ProcessingItem item);
|
2013-11-26 13:44:00 +07:00
|
|
|
void showResult (ProcessingItem item);
|
2013-11-24 19:43:37 +07:00
|
|
|
void showError (QString text);
|
2013-11-23 13:48:34 +07:00
|
|
|
|
2015-10-10 23:07:25 +07:00
|
|
|
void updateNormalIcon ();
|
|
|
|
|
2013-11-23 13:48:34 +07:00
|
|
|
private:
|
2015-09-23 01:41:08 +07:00
|
|
|
QMenu * trayContextMenu ();
|
2015-09-29 22:14:56 +07:00
|
|
|
void updateActionsState (bool isEnabled = true);
|
2015-10-10 23:07:25 +07:00
|
|
|
void changeIcon (int iconType, int timeoutMsec = 3000);
|
2015-10-18 16:19:59 +07:00
|
|
|
void scheduleUpdate (bool justChecked = false);
|
2013-11-23 13:48:34 +07:00
|
|
|
|
|
|
|
private:
|
2015-09-23 01:41:08 +07:00
|
|
|
QSystemTrayIcon *trayIcon_;
|
|
|
|
LanguageHelper *dictionary_;
|
2015-09-28 00:50:19 +07:00
|
|
|
//! Selection dialogs for each screen. Key - screen name.
|
|
|
|
QMap<QString, SelectionDialog *> selections_;
|
2015-09-23 01:41:08 +07:00
|
|
|
ResultDialog *resultDialog_;
|
2015-10-18 16:19:59 +07:00
|
|
|
Updater *updater_;
|
|
|
|
QTimer *updateTimer_;
|
2015-09-23 01:41:08 +07:00
|
|
|
QAction *captureAction_;
|
2015-09-29 22:14:56 +07:00
|
|
|
QAction *repeatCaptureAction_;
|
2015-09-23 01:41:08 +07:00
|
|
|
QAction *repeatAction_;
|
|
|
|
QAction *clipboardAction_;
|
2013-11-26 23:59:47 +07:00
|
|
|
bool useResultDialog_;
|
2015-09-29 02:17:24 +07:00
|
|
|
//! Used threads. For proper termination.
|
|
|
|
QList<QThread *> threads_;
|
2015-10-08 22:38:16 +07:00
|
|
|
QString defaultTranslationLanguage_;
|
2015-10-11 01:04:28 +07:00
|
|
|
QString defaultOrcLanguage_;
|
2015-10-10 03:56:48 +07:00
|
|
|
bool doTranslation_;
|
2015-10-10 23:07:25 +07:00
|
|
|
int itemProcessingCount_;
|
2013-11-23 13:48:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MANAGER_H
|