summaryrefslogtreecommitdiffstats
path: root/kgeography/src/mypopup.cpp
blob: c7dede676e90646017f5bdff2b766b37c0eee78d (plain)
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
/***************************************************************************
 *   Copyright (C) 2004-2005 by Albert Astals Cid                          *
 *   tsdgeos@terra.es                                                      *
 *                                                                         *
 *   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 <qlabel.h>
#include <qlayout.h>
#include <qimage.h>
#include <qpixmap.h>

#include "mypopup.h"


myPopup::myPopup(QWidget *parent, const QString &text, const QString &text2, const QString &flagFile) : QFrame(parent)
{
	QHBoxLayout *lay = new QHBoxLayout(this);
	lay -> setMargin(4);
	lay -> setSpacing(4);
	
	QWidget *vbox = new QWidget(this);
	lay -> addWidget(vbox);
	QVBoxLayout *vboxLayout = new QVBoxLayout(vbox);
	vboxLayout -> setMargin(0);
	vboxLayout -> setSpacing(0);
	QLabel *l = new QLabel(text, vbox);
	vboxLayout -> addWidget(l);
	
	if (!text2.isNull())
	{
		QLabel *l2 = new QLabel(text2, vbox);
		l2 -> setAlignment(Qt::AlignCenter);
		vboxLayout -> addWidget(l2);
	}
	
	if (!flagFile.isNull())
	{
		QLabel *flag = new QLabel(this);
		lay -> addWidget(flag);
		QImage flagImg(flagFile);
		flag -> setPixmap(flagImg.smoothScale(flagImg.width() / 5, flagImg. height() / 5));
		flag -> setAlignment(Qt::AlignCenter);
	}
	
	l -> setAlignment(Qt::AlignCenter);
	QFont f = l -> font();
	f.setBold(true);
	l -> setFont(f);
	
	
	setFrameStyle(QFrame::Box | QFrame::Plain);
	setLineWidth(2);
	
	setFixedSize(sizeHint());
}

void myPopup::mousePressEvent(QMouseEvent *)
{
	emit deleteMe();
}

#include "mypopup.moc"