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 : Daniel.Prynych@alo.cz
***************************************************************************/
/***************************************************************************
* *
* 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 <kglobal.h>
#include <kiconloader.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qtimer.h>
KNutMessage::KNutMessage(const QString messageText, const typeOfMessage type, const long int timeValidity, QWidget *parent, const char *name) : KDialogBase(Plain, "Messages",Ok,Ok, parent, name, false, false) {
setCaption("KNutClient");
m_messageTimer = 0;
KIconLoader *loader = KGlobal::iconLoader();
switch(type) {
case infoMess:
m_ret = loader->loadIcon("messagebox_info", KIcon::NoGroup, KIcon::SizeMedium, KIcon::DefaultState, 0, true);
break;
case warningMess:
m_ret = loader->loadIcon("messagebox_warning", KIcon::NoGroup, KIcon::SizeMedium, KIcon::DefaultState, 0, true);
break;
case criticalMess:
m_ret = loader->loadIcon("messagebox_critical", KIcon::NoGroup, KIcon::SizeMedium, KIcon::DefaultState, 0, true);
break;
}
QFrame *page = plainPage();
QVBoxLayout *setTopLayout = new QVBoxLayout( page, 10, spacingHint(), "setTopLayout" );
QHBoxLayout *setMessageLayout = new QHBoxLayout( setTopLayout, spacingHint(), "setMessageLayout" );
QLabel* picture = new QLabel (page);
QLabel* text = new QLabel (messageText,page);
picture->setPixmap(m_ret);
setMessageLayout->addWidget(picture);
setMessageLayout->addWidget(text);
if (timeValidity > 0 ) {
m_messageTimer = new QTimer(this);
if (timeValidity > maxTime)
m_messageTimer->start(maxTime*1000);
else
m_messageTimer->start(timeValidity*1000);
connect (m_messageTimer,SIGNAL(timeout()),this,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 ( QMoveEvent * e) {
KDialogBase::moveEvent (e);
emit messageMoved(x(),y());
}
#include "knutmessage.moc"
|