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 <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QThread>
|
||||
|
||||
#include "SettingsEditor.h"
|
||||
#include "SelectionDialog.h"
|
||||
#include "GlobalActionHelper.h"
|
||||
#include "Recognizer.h"
|
||||
#include "Translator.h"
|
||||
|
||||
Manager::Manager(QObject *parent) :
|
||||
QObject(parent),
|
||||
trayIcon_ (new QSystemTrayIcon (QIcon (":/images/icon.png"), this)),
|
||||
selection_ (new SelectionDialog)
|
||||
{
|
||||
trayIcon_->show ();
|
||||
trayIcon_->setContextMenu (trayContextMenu ());
|
||||
GlobalActionHelper::init ();
|
||||
|
||||
selection_->setWindowIcon (trayIcon_->icon ());
|
||||
connect (this, SIGNAL (showPixmap (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()
|
||||
@ -67,7 +85,7 @@ void Manager::close()
|
||||
QApplication::quit ();
|
||||
}
|
||||
|
||||
void Manager::processRegion(QPixmap selected)
|
||||
void Manager::showTranslation(QString sourceText, QString translatedText)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -18,13 +18,14 @@ class Manager : public QObject
|
||||
|
||||
signals:
|
||||
void showPixmap (QPixmap pixmap);
|
||||
void recognize (QPixmap pixmap);
|
||||
|
||||
private slots:
|
||||
void capture ();
|
||||
void settings ();
|
||||
void close ();
|
||||
|
||||
void processRegion (QPixmap selected);
|
||||
void showTranslation (QString sourceText, QString translatedText);
|
||||
|
||||
private:
|
||||
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 \
|
||||
SettingsEditor.cpp \
|
||||
SelectionDialog.cpp \
|
||||
GlobalActionHelper.cpp
|
||||
GlobalActionHelper.cpp \
|
||||
Recognizer.cpp \
|
||||
Translator.cpp
|
||||
|
||||
HEADERS += \
|
||||
Manager.h \
|
||||
SettingsEditor.h \
|
||||
SelectionDialog.h \
|
||||
GlobalActionHelper.h
|
||||
GlobalActionHelper.h \
|
||||
Recognizer.h \
|
||||
Translator.h
|
||||
|
||||
FORMS += \
|
||||
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