Icons updated. Now use 4 icon types depending on internal state.
41
Manager.cpp
@ -26,12 +26,13 @@
|
||||
|
||||
Manager::Manager (QObject *parent) :
|
||||
QObject (parent),
|
||||
trayIcon_ (new QSystemTrayIcon (QIcon (":/images/icon.png"), this)),
|
||||
trayIcon_ (new QSystemTrayIcon (this)),
|
||||
dictionary_ (new LanguageHelper),
|
||||
resultDialog_ (new ResultDialog (*dictionary_)),
|
||||
captureAction_ (NULL), repeatCaptureAction_ (NULL),
|
||||
repeatAction_ (NULL), clipboardAction_ (NULL),
|
||||
useResultDialog_ (true), doTranslation_ (true) {
|
||||
useResultDialog_ (true), doTranslation_ (true), itemProcessingCount_ (0) {
|
||||
updateNormalIcon ();
|
||||
GlobalActionHelper::init ();
|
||||
qRegisterMetaType<ProcessingItem>();
|
||||
|
||||
@ -215,6 +216,8 @@ void Manager::handleSelection (ProcessingItem item) {
|
||||
item.translateLanguage = defaultTranslationLanguage_;
|
||||
}
|
||||
emit requestRecognize (item);
|
||||
++itemProcessingCount_;
|
||||
updateNormalIcon ();
|
||||
if (!(item.modifiers & Qt::ControlModifier)) {
|
||||
emit closeSelections ();
|
||||
}
|
||||
@ -279,7 +282,6 @@ void Manager::processTrayAction (QSystemTrayIcon::ActivationReason reason) {
|
||||
}
|
||||
|
||||
void Manager::editRecognized (ProcessingItem item) {
|
||||
ST_ASSERT (item.isValid ());
|
||||
QString fixed = QInputDialog::getMultiLineText (
|
||||
NULL, tr ("Правка"), tr ("Исправьте распознанный текст"), item.recognized);
|
||||
if (!fixed.isEmpty ()) {
|
||||
@ -316,7 +318,13 @@ void Manager::copyLastImageToClipboard () {
|
||||
}
|
||||
|
||||
void Manager::showResult (ProcessingItem item) {
|
||||
ST_ASSERT (item.isValid ());
|
||||
--itemProcessingCount_;
|
||||
if (!item.isValid ()) {
|
||||
// delay because it can show error
|
||||
QTimer::singleShot (3000, this, SLOT (updateNormalIcon ()));
|
||||
return;
|
||||
}
|
||||
changeIcon (IconTypeSuccess);
|
||||
if (useResultDialog_) {
|
||||
resultDialog_->showResult (item);
|
||||
}
|
||||
@ -329,5 +337,30 @@ void Manager::showResult (ProcessingItem item) {
|
||||
|
||||
void Manager::showError (QString text) {
|
||||
qCritical () << text;
|
||||
changeIcon (IconTypeError);
|
||||
trayIcon_->showMessage (tr ("Ошибка"), text, QSystemTrayIcon::Critical);
|
||||
}
|
||||
|
||||
void Manager::changeIcon (int iconType, int timeoutMsec) {
|
||||
QString fileName;
|
||||
switch (iconType) {
|
||||
case IconTypeSuccess:
|
||||
fileName = ":/images/STIconGreen.png";
|
||||
break;
|
||||
case IconTypeError:
|
||||
fileName = ":/images/STIconRed.png";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
trayIcon_->setIcon (QIcon (fileName));
|
||||
if (timeoutMsec > 0) {
|
||||
QTimer::singleShot (timeoutMsec, this, SLOT (updateNormalIcon ()));
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::updateNormalIcon () {
|
||||
QString fileName = itemProcessingCount_ > 0
|
||||
? ":/images/STIconOrange.png" : ":/images/STIconBlue.png";
|
||||
trayIcon_->setIcon (QIcon (fileName));
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ class LanguageHelper;
|
||||
class Manager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
enum IconType {
|
||||
IconTypeNormal, IconTypeWorking, IconTypeError, IconTypeSuccess
|
||||
};
|
||||
|
||||
public:
|
||||
explicit Manager (QObject *parent = 0);
|
||||
~Manager ();
|
||||
@ -46,9 +50,12 @@ class Manager : public QObject {
|
||||
void showResult (ProcessingItem item);
|
||||
void showError (QString text);
|
||||
|
||||
void updateNormalIcon ();
|
||||
|
||||
private:
|
||||
QMenu * trayContextMenu ();
|
||||
void updateActionsState (bool isEnabled = true);
|
||||
void changeIcon (int iconType, int timeoutMsec = 3000);
|
||||
|
||||
private:
|
||||
QSystemTrayIcon *trayIcon_;
|
||||
@ -65,6 +72,7 @@ class Manager : public QObject {
|
||||
QList<QThread *> threads_;
|
||||
QString defaultTranslationLanguage_;
|
||||
bool doTranslation_;
|
||||
int itemProcessingCount_;
|
||||
};
|
||||
|
||||
#endif // MANAGER_H
|
||||
|
@ -2,6 +2,9 @@
|
||||
<qresource prefix="/">
|
||||
<file>translations/translation_en.qm</file>
|
||||
<file>translations/translation_ru.qm</file>
|
||||
<file>images/icon.png</file>
|
||||
<file>images/STIconBlue.png</file>
|
||||
<file>images/STIconGreen.png</file>
|
||||
<file>images/STIconOrange.png</file>
|
||||
<file>images/STIconRed.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
images/STIconBlue.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
images/STIconGreen.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
images/STIconOrange.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
images/STIconRed.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
images/icon.ico
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 97 KiB |
BIN
images/icon.png
Before Width: | Height: | Size: 6.5 KiB |