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
|
/***************************************************************************
knutmessage.cpp - description
-------------------
begin : So led 24 2004
copyright : (C) 2004 by Daniel Prynych
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "knutmessage.h"
#include <tdeglobal.h>
#include <kiconloader.h>
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqframe.h>
#include <tqpixmap.h>
#include <tqtimer.h>
KNutMessage::KNutMessage(const TQString messageText, const typeOfMessage type, const long int timeValidity, TQWidget *parent, const char *name) : KDialogBase(Plain, "Messages",Ok,Ok, parent, name, false, false) {
setCaption("KNutClient");
m_messageTimer = 0;
TDEIconLoader *loader = TDEGlobal::iconLoader();
switch(type) {
case infoMess:
m_ret = loader->loadIcon("messagebox_info", TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState, 0, true);
break;
case warningMess:
m_ret = loader->loadIcon("messagebox_warning", TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState, 0, true);
break;
case criticalMess:
m_ret = loader->loadIcon("messagebox_critical", TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState, 0, true);
break;
}
TQFrame *page = plainPage();
TQVBoxLayout *setTopLayout = new TQVBoxLayout( page, 10, spacingHint(), "setTopLayout" );
TQHBoxLayout *setMessageLayout = new TQHBoxLayout( setTopLayout, spacingHint(), "setMessageLayout" );
TQLabel* picture = new TQLabel (page);
TQLabel* text = new TQLabel (messageText,page);
picture->setPixmap(m_ret);
setMessageLayout->addWidget(picture);
setMessageLayout->addWidget(text);
if (timeValidity > 0 ) {
m_messageTimer = new TQTimer(this);
if (timeValidity > maxTime)
m_messageTimer->start(maxTime*1000);
else
m_messageTimer->start(timeValidity*1000);
connect (m_messageTimer,TQT_SIGNAL(timeout()),this,TQT_SLOT(timeout()));
disableResize();
}
}
KNutMessage::~KNutMessage(){
}
void KNutMessage::timeout(void) {
if (m_messageTimer) m_messageTimer->stop();
emit endMessage();
}
void KNutMessage::slotOk (void) {
if (m_messageTimer) m_messageTimer->stop();
emit endMessage();
}
void KNutMessage::moveEvent ( TQMoveEvent * e) {
KDialogBase::moveEvent (e);
emit messageMoved(x(),y());
}
#include "knutmessage.moc"
|