About added
This commit is contained in:
parent
ff43ab624b
commit
46e13d5141
34
Manager.cpp
34
Manager.cpp
@ -1,13 +1,13 @@
|
||||
#include "Manager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QThread>
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "Settings.h"
|
||||
#include "SettingsEditor.h"
|
||||
@ -54,6 +54,9 @@ Manager::Manager(QObject *parent) :
|
||||
connect (this, SIGNAL (settingsEdited ()), recognizer, SLOT (applySettings ()));
|
||||
connect (this, SIGNAL (settingsEdited ()), translator, SLOT (applySettings ()));
|
||||
|
||||
connect (trayIcon_, SIGNAL (activated (QSystemTrayIcon::ActivationReason)),
|
||||
SLOT (processTrayAction (QSystemTrayIcon::ActivationReason)));
|
||||
|
||||
trayIcon_->setContextMenu (trayContextMenu ());
|
||||
trayIcon_->show ();
|
||||
|
||||
@ -65,6 +68,7 @@ QMenu*Manager::trayContextMenu()
|
||||
QMenu* menu = new QMenu ();
|
||||
captureAction_ = menu->addAction (tr ("Захват"), this, SLOT (capture ()));
|
||||
menu->addAction (tr ("Настройки"), this, SLOT (settings ()));
|
||||
menu->addAction (tr ("О программе"), this, SLOT (about ()));
|
||||
menu->addAction (tr ("Выход"), this, SLOT (close ()));
|
||||
return menu;
|
||||
}
|
||||
@ -82,6 +86,18 @@ void Manager::applySettings()
|
||||
GlobalActionHelper::makeGlobal (captureAction_);
|
||||
}
|
||||
|
||||
void Manager::processTrayAction(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
if (reason == QSystemTrayIcon::Trigger)
|
||||
{
|
||||
if (!lastMessage_.isEmpty ())
|
||||
{
|
||||
trayIcon_->showMessage (tr ("Последний перевод"), lastMessage_,
|
||||
QSystemTrayIcon::Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Manager::~Manager()
|
||||
{
|
||||
}
|
||||
@ -111,11 +127,23 @@ void Manager::close()
|
||||
QApplication::quit ();
|
||||
}
|
||||
|
||||
void Manager::about()
|
||||
{
|
||||
QString text = tr ("Программа для распознавания текста на экране.\n"\
|
||||
"Создана с использованием Qt, tesseract-ocr, Google Translate.\n"
|
||||
"Автор: Gres (dariusiii@qip.ru)");
|
||||
|
||||
QMessageBox message (QMessageBox::Information, tr ("О программе"), text,
|
||||
QMessageBox::Ok);
|
||||
message.setIconPixmap (trayIcon_->icon ().pixmap (QSize (64, 64)));
|
||||
message.exec ();
|
||||
}
|
||||
|
||||
void Manager::showTranslation(QString sourceText, QString translatedText)
|
||||
{
|
||||
QString message = sourceText + " - " + translatedText;
|
||||
lastMessage_ = sourceText + " - " + translatedText;
|
||||
qDebug () << sourceText << translatedText;
|
||||
trayIcon_->showMessage (tr ("Перевод"), message, QSystemTrayIcon::Information);
|
||||
trayIcon_->showMessage (tr ("Перевод"), lastMessage_, QSystemTrayIcon::Information);
|
||||
}
|
||||
|
||||
void Manager::showError(QString text)
|
||||
|
@ -1,12 +1,11 @@
|
||||
#ifndef MANAGER_H
|
||||
#define MANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
class QSystemTrayIcon;
|
||||
|
||||
class SelectionDialog;
|
||||
|
||||
@ -26,9 +25,12 @@ class Manager : public QObject
|
||||
void capture ();
|
||||
void settings ();
|
||||
void close ();
|
||||
void about ();
|
||||
|
||||
void applySettings ();
|
||||
|
||||
void processTrayAction (QSystemTrayIcon::ActivationReason reason);
|
||||
|
||||
void showTranslation (QString sourceText, QString translatedText);
|
||||
void showError (QString text);
|
||||
|
||||
@ -39,7 +41,7 @@ class Manager : public QObject
|
||||
QSystemTrayIcon* trayIcon_;
|
||||
SelectionDialog* selection_;
|
||||
QAction* captureAction_;
|
||||
|
||||
QString lastMessage_;
|
||||
};
|
||||
|
||||
#endif // MANAGER_H
|
||||
|
@ -21,6 +21,10 @@ void Recognizer::applySettings()
|
||||
|
||||
tessDataDir_ = settings.value (settings_names::tessDataPlace,
|
||||
settings_values::tessDataPlace).toString ();
|
||||
if (tessDataDir_.right (1) != "/")
|
||||
{
|
||||
tessDataDir_ += "/";
|
||||
}
|
||||
ocrLanguage_ = settings.value (settings_names::ocrLanguage,
|
||||
settings_values::ocrLanguage).toString ();
|
||||
imageScale_ = settings.value (settings_names::imageScale,
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>456</width>
|
||||
<height>165</height>
|
||||
<height>166</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -22,9 +22,15 @@
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Сочетание клавиш для перехода в режим захвата.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Захват</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>captureEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -41,9 +47,15 @@
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Необходимо для распознавания.</p><p>Скачивается отсюда: <a href="https://code.google.com/p/tesseract-ocr/downloads/list"><span style=" text-decoration: underline; color:#0000ff;">https://code.google.com/p/tesseract-ocr/downloads/list</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Путь к tessdata</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tessdataEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -58,16 +70,28 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Заполняется на основании содержания tessdata</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Язык распознавания</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ocrLangCombo</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Масштабирование изображения для улучшения распознания. Больше - лучше (до определенных пределов), но медленнее.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Увеличение масштаба</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>imageScaleSpin</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
@ -87,9 +111,15 @@
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Язык, на который осуществляется перевод.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Язык результата</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>translateLangCombo</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -136,6 +166,15 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>captureEdit</tabstop>
|
||||
<tabstop>translateLangCombo</tabstop>
|
||||
<tabstop>tessdataEdit</tabstop>
|
||||
<tabstop>tessdataButton</tabstop>
|
||||
<tabstop>ocrLangCombo</tabstop>
|
||||
<tabstop>imageScaleSpin</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
Loading…
Reference in New Issue
Block a user