-
Notifications
You must be signed in to change notification settings - Fork 0
/
presentW.cpp
84 lines (54 loc) · 2.15 KB
/
presentW.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "presentW.h"
PresentWidget::PresentWidget(QWidget *parent) :QWidget(parent)
//,ui(new Ui::TrnslateW)
{
tW.setupUi(this);
//поверх других окон
PresentWidget::setWindowFlags(Qt::WindowStaysOnTopHint);
//местоположение
this->move(QApplication::desktop()->width()-this->width()-QApplication::desktop()->width()*0.01,
QApplication::desktop()->height()-this->height()-QApplication::desktop()->height()*0.1);
QPalette pall;
pall.setBrush(this->backgroundRole(), QBrush(QPixmap("data/background")));
this->setPalette(pall);
this->setAutoFillBackground(true);
QAction* pointMenu1=new QAction("&Показать новое слово сейчас",this);
connect(pointMenu1, SIGNAL(triggered()), this, SLOT(show()));
QAction* pointMenu2=new QAction("&Закрыть программу",this);
connect(pointMenu2, SIGNAL(triggered()), this, SLOT(hideIconAndOut()));
tIcMenu= new QMenu(this);
tIcMenu->addAction(pointMenu1);
tIcMenu->addAction(pointMenu2);
tIc=new QSystemTrayIcon(this);
tIc->setContextMenu(tIcMenu);
tIc->setToolTip("English train 1.0");
tIc->setIcon(QPixmap("data/icon"));
QObject::connect(tW.okey,SIGNAL(clicked()),this,SLOT(sendToTranslation()));
QObject::connect(tW.dontKnow,SIGNAL(clicked()),this,SLOT(dontKnowSlot()));
QObject::connect(tW.Exit,SIGNAL(clicked()),this,SLOT(hideIconAndOut()));
}
void PresentWidget::sendToTranslation(){
emit checkTranslation(tW.userTranslate->text());
setVisible(false);
emit sendTimer(tW.timer->text());
}
void PresentWidget::toPresentWidget(QString eWord){
QString word='"'+eWord+'"';
tW.wordToTranslate->setText(word);
}
void PresentWidget::dontKnowSlot(){
emit dontKnowSignal(tW.userTranslate->text(),tW.timer->text());
setVisible(false);
}
void PresentWidget::timeToW(QString time){
tW.timer->setText(time);
}
//слоты/методы работы с треем
void PresentWidget::closeEvent(QCloseEvent * pe){
if(tIc->isVisible()) hide();
}
void PresentWidget::hideIconAndOut(){
emit toFile();
tIc->hide();
qApp->quit();
}