Skip to content

Commit

Permalink
微调ChatBox显示
Browse files Browse the repository at this point in the history
  • Loading branch information
wkcn committed Jul 27, 2015
1 parent 9619090 commit 2aefd43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 43 deletions.
7 changes: 5 additions & 2 deletions ChatBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ChatMsg::ChatMsg(string message, int msgLife):life(msgLife),msg(message){

ChatBox::ChatBox(QWidget *parent) :QDialog(parent,Qt::FramelessWindowHint),ui(new Ui::ChatBox){
ui->setupUi(this);
this->hide();

this->setAttribute(Qt::WA_TranslucentBackground);
//Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::SubWindow

Expand All @@ -20,9 +20,12 @@ ChatBox::ChatBox(QWidget *parent) :QDialog(parent,Qt::FramelessWindowHint),ui(ne
connect(timer, SIGNAL(timeout()), this, SLOT(timerUpDate()));
timer->start(1000);//1s

boxLife = 0;
lines = 0;
cancover = true;

this->hide();

this->setMinimumWidth(219);
this->setMaximumWidth(219);
}
Expand Down Expand Up @@ -126,7 +129,7 @@ void ChatBox::UpdateChatBox(){
cancover = false;
msgQueue.pop();
UpdateChatBoxDis();
this->update();
Update();
}
}
}
Expand Down
44 changes: 3 additions & 41 deletions Sicily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Sicily::Sicily(QWidget *parent):QMainWindow(parent,WINDOW_FLAG_TOPHINT),ui(new U
ReadResource();

chatbox = new ChatBox(this);
//chatbox->show();

QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(timerUpDate()));
Expand All @@ -31,11 +30,6 @@ Sicily::Sicily(QWidget *parent):QMainWindow(parent,WINDOW_FLAG_TOPHINT),ui(new U
}

Sicily::~Sicily(){
/*
for(size_t i = 0;i < cstrList.size();++i){
delete [] cstrList[i];
}
*/
//chatbox和timer在关闭父窗体时会被析构
delete ui;
}
Expand Down Expand Up @@ -157,15 +151,6 @@ void Sicily::UpdateButton(){
mouseCount = 0;
}

//REPEAT SAY
/*
if (mouseCount == 2 && mouseList[0] && mouseList[1]){
SicilySay("",5);
mouseCount = 0;
}
*/


if(sleeped && mouseCount > 0){
//醒来了
//警示:startTime = lastWakeTime - playTime;//伪造时间[=]很好看嘛 (一个错误的做法)
Expand All @@ -189,7 +174,6 @@ void Sicily::UpdateButton(){
//notice: clock() is different between Ubuntu and Windows!
//clock()/ CLOCKS_PER_SEC

//qDebug("hha%d",GetClock() - mouseTime);
if(GetClock() - mouseTime >= 400){
mouseCount = 0;
}
Expand Down Expand Up @@ -249,28 +233,7 @@ void Sicily::UpdateButton(){
}

}
/*
void Sicily::FixPos(int h){
static int ow = 300;
static int oh = 450;
if (h == oh)return;
int ox = (this->pos()).x();
int oy = (this->pos()).y();
//sicilyPosY指现在sicily在窗口的位置
sicilyPosY = h - 450;
//this->setMaximumSize(ow,h);
this->setHidden(true);
this->setMinimumSize(ow,h);
this->setMaximumSize(ow,h);
//this->resize(ow,h);
ui->sicily->move(0, sicilyPosY);
ui->eye->move(0, sicilyPosY);
this->move(ox,oy+oh-h);
this->setHidden(false);
oh = h;
}*/

void Sicily::timerUpDate(){
//UpdateChatBox();
UpdateAnimation();
Expand Down Expand Up @@ -299,8 +262,7 @@ void Sicily::LoadData(){

void Sicily::Restart(){
SaveData();
//();
//show();
this->hide();
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
exit('r'+'e'+'s'+'t'+'a'+'r'+'t');
}
Expand Down Expand Up @@ -365,7 +327,7 @@ void Sicily::mousePressEvent(QMouseEvent *event){
char str[256];
//int totalTime = (time(0)-startTime)/60;
sprintf(str,"已经玩%d分钟了哦 >.<",playTime / 60);
SicilySay(str,3);
SicilySay(str,1);
event->accept();
}
else if(event->button() == Qt::MiddleButton){
Expand Down

0 comments on commit 2aefd43

Please sign in to comment.