-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPredictKeyHandleUI.cpp
More file actions
135 lines (117 loc) · 2.76 KB
/
PredictKeyHandleUI.cpp
File metadata and controls
135 lines (117 loc) · 2.76 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
Time : 2016/06/13
Author: Kay Yang (1025115216@qq.com)
*/
#ifndef CONSOLE
#include "PredictKeyHandleUI.h"
#include "PredictGeneratorKey.h"
#include "PredictMainWindow.h"
#include "QDebug"
#include "PredictCheck.h"
TextEditorThread::TextEditorThread() : mStopped(false)
{
}
TextEditorThread::~TextEditorThread()
{
mMessages.Clear();
}
void TextEditorThread::Push(const QString& text)
{
mMutex.Lock();
mMessages.Push(text);
mMutex.Unlock();
}
void TextEditorThread::SetStop(bool isStop)
{
mStopped = isStop;
}
void TextEditorThread::run()
{
while (!mStopped)
{
while (mMessages.Size() > 0)
{
mMutex.Lock();
emit MsgSignal(mMessages.Pop());
mMutex.Unlock();
}
QThread::msleep(1);
}
}
PredictKeyHandleUI::PredictKeyHandleUI(QWidget* parent) : QWidget(parent), ui(new Ui::GeneratorUI())
{
ui->setupUi(this);
mTextEditor = new TextEditorThread();
mTextEditor->start();
}
PredictKeyHandleUI::~PredictKeyHandleUI()
{
if (ui)
{
delete ui;
}
ui = 0;
mTextEditor->SetStop(true);
while (mTextEditor->isRunning())
{
Sleep(2);
}
if (mTextEditor)
delete mTextEditor;
mTextEditor = 0;
}
void PredictKeyHandleUI::LoadOldKeySequence()
{
//PredictGeneratorKey::Instance()->Clear();
//PredictGeneratorKey::Instance()->LoadFromFile(PredictConfig::Inistance()->mConfigData.GetFullGeneratorPath().C_String());
}
void PredictKeyHandleUI::onStart()
{
//LoadOldKeySequence();
//PredictCheck::Instance()->Start();
//PredictMainWindow* mainWind = (PredictMainWindow*)mOwner;
//mainWind->StartServer();
//ui->mGeneratorKey->setEnabled(false);
//ui->mStart->setEnabled(false);
//ui->mDump->setEnabled(true);
//ui->mStop->setEnabled(true);
}
void PredictKeyHandleUI::onDump()
{
//PredictGeneratorKey::Instance()->WriteToFile(PredictConfig::Inistance()->mConfigData.GetFullGeneratorPath().C_String());
}
void PredictKeyHandleUI::onStop()
{
//PredictGeneratorKey::Instance()->WriteToFile(PredictConfig::Inistance()->mConfigData.GetFullGeneratorPath().C_String());
//mTextEditor->Push("Write keys file successfully!");
//PredictMainWindow* mainWind = (PredictMainWindow*)mOwner;
//mainWind->StopServer();
//ui->mGeneratorKey->setEnabled(true);
//ui->mStart->setEnabled(true);
//ui->mDump->setEnabled(false);
//ui->mStop->setEnabled(false);
}
void PredictKeyHandleUI::onToggle(bool state)
{
//PredictGeneratorKey::Instance()->ToggleGeneratorKey(state);
}
void PredictKeyHandleUI::PrintMessage(const QString& text)
{
mTextEditor->Push(text);
}
void PredictKeyHandleUI::SetMainWidget(PredictMainWindow* owner)
{
mOwner = owner;
if (mOwner)
{
connect(mTextEditor, SIGNAL(MsgSignal(const QString&)), mOwner, SLOT(printText(const QString&)));
}
}
void PredictKeyHandleUI::closeEvent(QCloseEvent *event)
{
//if (ui->mStop->isEnabled())
//{
// onStop();
//}
}
#endif