Mockup made (Recognizer and Translator added)
This commit is contained in:
parent
0ebd631978
commit
7f15cabdf0
30
Manager.cpp
30
Manager.cpp
@ -6,26 +6,44 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include "SettingsEditor.h"
|
#include "SettingsEditor.h"
|
||||||
#include "SelectionDialog.h"
|
#include "SelectionDialog.h"
|
||||||
#include "GlobalActionHelper.h"
|
#include "GlobalActionHelper.h"
|
||||||
|
#include "Recognizer.h"
|
||||||
|
#include "Translator.h"
|
||||||
|
|
||||||
Manager::Manager(QObject *parent) :
|
Manager::Manager(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
trayIcon_ (new QSystemTrayIcon (QIcon (":/images/icon.png"), this)),
|
trayIcon_ (new QSystemTrayIcon (QIcon (":/images/icon.png"), this)),
|
||||||
selection_ (new SelectionDialog)
|
selection_ (new SelectionDialog)
|
||||||
{
|
{
|
||||||
trayIcon_->show ();
|
GlobalActionHelper::init ();
|
||||||
trayIcon_->setContextMenu (trayContextMenu ());
|
|
||||||
|
|
||||||
selection_->setWindowIcon (trayIcon_->icon ());
|
selection_->setWindowIcon (trayIcon_->icon ());
|
||||||
connect (this, SIGNAL (showPixmap (QPixmap)),
|
connect (this, SIGNAL (showPixmap (QPixmap)),
|
||||||
selection_, SLOT (setPixmap (QPixmap)));
|
selection_, SLOT (setPixmap (QPixmap)));
|
||||||
connect (selection_, SIGNAL (selected (QPixmap)),
|
|
||||||
SLOT (processRegion (QPixmap)));
|
|
||||||
|
|
||||||
GlobalActionHelper::init ();
|
Recognizer* recognizer = new Recognizer;
|
||||||
|
connect (selection_, SIGNAL (selected (QPixmap)),
|
||||||
|
recognizer, SLOT (recognize (QPixmap)));
|
||||||
|
QThread* recognizerThread = new QThread (this);
|
||||||
|
recognizer->moveToThread (recognizerThread);
|
||||||
|
recognizerThread->start ();
|
||||||
|
|
||||||
|
Translator* translator = new Translator;
|
||||||
|
connect (recognizer, SIGNAL (recognized (QString)),
|
||||||
|
translator, SLOT (translate (QString)));
|
||||||
|
QThread* translatorThread = new QThread (this);
|
||||||
|
translator->moveToThread (translatorThread);
|
||||||
|
translatorThread->start ();
|
||||||
|
|
||||||
|
connect (translator, SIGNAL (translated (QString, QString)),
|
||||||
|
SLOT (showTranslation (QString, QString)));
|
||||||
|
|
||||||
|
trayIcon_->setContextMenu (trayContextMenu ());
|
||||||
|
trayIcon_->show ();
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::~Manager()
|
Manager::~Manager()
|
||||||
@ -67,7 +85,7 @@ void Manager::close()
|
|||||||
QApplication::quit ();
|
QApplication::quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::processRegion(QPixmap selected)
|
void Manager::showTranslation(QString sourceText, QString translatedText)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,14 @@ class Manager : public QObject
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void showPixmap (QPixmap pixmap);
|
void showPixmap (QPixmap pixmap);
|
||||||
|
void recognize (QPixmap pixmap);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void capture ();
|
void capture ();
|
||||||
void settings ();
|
void settings ();
|
||||||
void close ();
|
void close ();
|
||||||
|
|
||||||
void processRegion (QPixmap selected);
|
void showTranslation (QString sourceText, QString translatedText);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMenu* trayContextMenu ();
|
QMenu* trayContextMenu ();
|
||||||
|
11
Recognizer.cpp
Normal file
11
Recognizer.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "Recognizer.h"
|
||||||
|
|
||||||
|
Recognizer::Recognizer(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recognizer::recognize(QPixmap pixmap)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
21
Recognizer.h
Normal file
21
Recognizer.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef RECOGNIZER_H
|
||||||
|
#define RECOGNIZER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "QPixmap"
|
||||||
|
|
||||||
|
class Recognizer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit Recognizer(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void recognized (QString text);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void recognize (QPixmap pixmap);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RECOGNIZER_H
|
@ -16,13 +16,17 @@ SOURCES += main.cpp\
|
|||||||
Manager.cpp \
|
Manager.cpp \
|
||||||
SettingsEditor.cpp \
|
SettingsEditor.cpp \
|
||||||
SelectionDialog.cpp \
|
SelectionDialog.cpp \
|
||||||
GlobalActionHelper.cpp
|
GlobalActionHelper.cpp \
|
||||||
|
Recognizer.cpp \
|
||||||
|
Translator.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
Manager.h \
|
Manager.h \
|
||||||
SettingsEditor.h \
|
SettingsEditor.h \
|
||||||
SelectionDialog.h \
|
SelectionDialog.h \
|
||||||
GlobalActionHelper.h
|
GlobalActionHelper.h \
|
||||||
|
Recognizer.h \
|
||||||
|
Translator.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
SettingsEditor.ui \
|
SettingsEditor.ui \
|
||||||
|
11
Translator.cpp
Normal file
11
Translator.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "Translator.h"
|
||||||
|
|
||||||
|
Translator::Translator(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Translator::translate(QString text)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
20
Translator.h
Normal file
20
Translator.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef TRANSLATOR_H
|
||||||
|
#define TRANSLATOR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class Translator : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit Translator(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void translated (QString sourceText, QString translatedText);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void translate (QString text);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSLATOR_H
|
Loading…
Reference in New Issue
Block a user