author | unc0rr |
Sun, 21 Oct 2012 19:17:00 +0400 | |
changeset 7779 | 0c5f822916a7 |
parent 6952 | 7f70f37bbf08 |
child 7781 | 6505805e7f98 |
permissions | -rw-r--r-- |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
1 |
/* |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
6952 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
4 |
* |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
8 |
* |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
13 |
* |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
17 |
*/ |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
18 |
|
6200 | 19 |
/** |
20 |
* @file |
|
21 |
* @brief AbstractPage class implementation |
|
22 |
*/ |
|
23 |
||
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
24 |
#include "AbstractPage.h" |
6477 | 25 |
#include <QLabel> |
26 |
#include <QSize> |
|
27 |
#include <QFontMetricsF> |
|
6572 | 28 |
#include <QMessageBox> |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
29 |
|
7779 | 30 |
#include "qpushbuttonwithsound.h" |
31 |
||
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
32 |
AbstractPage::AbstractPage(QWidget* parent) |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
33 |
{ |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
34 |
Q_UNUSED(parent); |
6477 | 35 |
defautDesc = new QString(); |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
36 |
|
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
37 |
font14 = new QFont("MS Shell Dlg", 14); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
38 |
} |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
39 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
40 |
void AbstractPage::initPage() |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
41 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
42 |
QGridLayout * pageLayout = new QGridLayout(this); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
43 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
44 |
// stretch grid space for body and footer |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
45 |
pageLayout->setColumnStretch(0,0); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
46 |
pageLayout->setColumnStretch(1,1); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
47 |
pageLayout->setRowStretch(0,1); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
48 |
pageLayout->setRowStretch(1,0); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
49 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
50 |
// add back/exit button |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
51 |
btnBack = formattedButton(":/res/Exit.png", true); |
6699
83dd3447a212
exploit the new setWhatsThis feature in our desktop frontend
koda
parents:
6577
diff
changeset
|
52 |
btnBack->setWhatsThis(tr("Go back")); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
53 |
pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
54 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
55 |
// add body layout as defined by the subclass |
6477 | 56 |
pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 3); |
57 |
||
58 |
descLabel = new QLabel(); |
|
59 |
descLabel->setAlignment(Qt::AlignCenter); |
|
60 |
descLabel->setWordWrap(true); |
|
61 |
descLabel->setOpenExternalLinks(true); |
|
62 |
descLabel->setFixedHeight(50); |
|
63 |
descLabel->setStyleSheet("font-size: 16px"); |
|
64 |
pageLayout->addWidget(descLabel, 1, 1); |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
65 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
66 |
// add footer layout |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
67 |
QLayout * fld = footerLayoutDefinition(); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
68 |
if (fld != NULL) |
6477 | 69 |
pageLayout->addLayout(fld, 1, 2); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
70 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
71 |
// connect signals |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
72 |
connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack())); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
73 |
connectSignals(); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
74 |
} |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
75 |
|
6577 | 76 |
QPushButtonWithSound * AbstractPage::formattedButton(const QString & name, bool hasIcon) |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
77 |
{ |
6572 | 78 |
QPushButtonWithSound * btn = new QPushButtonWithSound(this); |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
79 |
|
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
80 |
if (hasIcon) |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
81 |
{ |
6200 | 82 |
const QIcon& lp=QIcon(name); |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
83 |
QSize sz = lp.actualSize(QSize(65535, 65535)); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
84 |
btn->setIcon(lp); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
85 |
btn->setFixedSize(sz); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
86 |
btn->setIconSize(sz); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
87 |
btn->setFlat(true); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
88 |
btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
89 |
} |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
90 |
else |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
91 |
{ |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
92 |
btn->setFont(*font14); |
6200 | 93 |
btn->setText(name); |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
94 |
} |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
95 |
return btn; |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
96 |
} |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
97 |
|
6577 | 98 |
QPushButtonWithSound * AbstractPage::addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan, int columnSpan, bool hasIcon) |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
99 |
{ |
6577 | 100 |
QPushButtonWithSound * btn = formattedButton(name, hasIcon); |
6200 | 101 |
grid->addWidget(btn, row, column, rowSpan, columnSpan); |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
102 |
return btn; |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
103 |
} |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
104 |
|
6577 | 105 |
QPushButtonWithSound * AbstractPage::addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon) |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
106 |
{ |
6577 | 107 |
QPushButtonWithSound * btn = formattedButton(name, hasIcon); |
6038
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
108 |
box->addWidget(btn, where); |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
109 |
return btn; |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
110 |
} |
58d9badf3e7f
wow, somebody was smoking some reaaally good sh!t right there, man!
sheepluva
parents:
diff
changeset
|
111 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
112 |
void AbstractPage::setBackButtonVisible(bool visible) |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
113 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
114 |
btnBack->setVisible(visible); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6038
diff
changeset
|
115 |
} |
6477 | 116 |
|
117 |
void AbstractPage::setButtonDescription(QString desc) |
|
118 |
{ |
|
119 |
descLabel->setText(desc); |
|
120 |
} |
|
121 |
||
122 |
void AbstractPage::setDefautDescription(QString text) |
|
123 |
{ |
|
124 |
*defautDesc = text; |
|
125 |
descLabel->setText(text); |
|
126 |
} |
|
127 |
||
128 |
QString * AbstractPage::getDefautDescription() |
|
129 |
{ |
|
130 |
return defautDesc; |
|
131 |
} |