-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAbout_HiView_Dialog.cc
288 lines (248 loc) · 7.93 KB
/
About_HiView_Dialog.cc
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/* About_HiView_Dialog
HiROC CVS ID: $Id: About_HiView_Dialog.cc,v 1.4 2012/03/09 02:13:54 castalia Exp $
Copyright (C) 2011 Arizona Board of Regents on behalf of the
Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
the University of Arizona.
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License, version 2.1,
as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*******************************************************************************/
#include "About_HiView_Dialog.hh"
#include "Icon_Button.hh"
#include <QApplication>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPainter>
#include <QLabel>
#include <QPixmap>
#include <QIcon>
#include <QPushButton>
#include <QAction>
#include <QScrollArea>
#if defined (DEBUG_SECTION)
/* DEBUG_SECTION controls
DEBUG_SECTION report selection options.
Define any of the following options to obtain the desired debug reports:
*/
#define DEBUG_OFF 0
#define DEBUG_ALL -1
#define DEBUG_CONSTRUCTORS (1 << 0)
#define DEBUG_SLOTS (1 << 2)
#define DEBUG_DEFAULT DEBUG_ALL
#if (DEBUG_SECTION +0) == 0
#undef DEBUG_SECTION
#define DEBUG_SECTION DEBUG_OFF
#endif
#include "HiView_Utilities.hh"
#include <iostream>
#include <iomanip>
using std::clog;
using std::endl;
using std::boolalpha;
#endif // DEBUG_SECTION
namespace UA
{
namespace HiRISE
{
/*==============================================================================
Constants
*/
const char* const
About_HiView_Dialog::ID =
"UA::HiRISE::About_HiView_Dialog ($Revision: 1.4 $ $Date: 2012/03/09 02:13:54 $)";
#ifndef ABOUT_HIVIEW_DIALOG_MARGIN
#define ABOUT_HIVIEW_DIALOG_MARGIN 10
#endif
#ifndef HIVIEW_LOGO_MARGIN
#define HIVIEW_LOGO_MARGIN 10
#endif
#ifndef ABOUT_HIVIEW_DIALOG_TEXT_Y_OFFSET
#define ABOUT_HIVIEW_DIALOG_TEXT_Y_OFFSET -10
#endif
#ifndef ABOUT_HIVIEW_DIALOG_CREDITS_X_OFFSET
#define ABOUT_HIVIEW_DIALOG_CREDITS_X_OFFSET -10
#endif
/*==============================================================================
Constructor
*/
About_HiView_Dialog::About_HiView_Dialog ()
{
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << ">>> About_HiView_Dialog" << endl;
#endif
setWindowTitle (tr ("About") + ' ' + qApp->applicationName ());
// Allow non-modal (show instead of exec) operation.
setModal (false);
QVBoxLayout
*dialog_layout = new QVBoxLayout (this);
dialog_layout->setAlignment (Qt::AlignTop);
dialog_layout->setContentsMargins (0, 0, 0, 0);
dialog_layout->setSpacing (0);
dialog_layout->setSizeConstraint (QLayout::SetFixedSize);
// Background image.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " Background image" << endl;
#endif
QPixmap
background (":/Images/About_Background.png");
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " size " << background.size () << endl;
#endif
QPainter
painter (&background);
QLabel
*content;
// Application logo.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " Application logo" << endl;
#endif
QPixmap
logo (":/Images/HiView_Icon.png");
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " size " << logo.size () << endl
<< " draw HiView logo onto the background image" << endl
<< " at 0x, 0y" << endl;
#endif
painter.drawPixmap (0, 0, logo);
// Content text.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " Content text" << endl
<< " size "
<< (background.width ()
- (logo.width () + ABOUT_HIVIEW_DIALOG_MARGIN)) << "w, "
<< (background.height ()
- (ABOUT_HIVIEW_DIALOG_MARGIN * 2)) << 'h' << endl
<< " default font family = " <<
font ().defaultFamily () << endl;
#endif
content = new QLabel
(tr (
#include "About_HiView.html"
)
.arg (qApp->applicationVersion ()));
content->setStyleSheet ("background:transparent;");
content->setFixedSize
(background.width () - (logo.width () + ABOUT_HIVIEW_DIALOG_MARGIN),
background.height () - (ABOUT_HIVIEW_DIALOG_MARGIN * 2));
content->setContentsMargins (0, 0, 0, 0);
content->setWordWrap (true);
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " render content text label onto the background image" << endl
<< " at " << logo.width () << "x, "
<< (ABOUT_HIVIEW_DIALOG_MARGIN + ABOUT_HIVIEW_DIALOG_TEXT_Y_OFFSET)
<< 'y' << endl;
#endif
content->render (&painter, QPoint
(logo.width (),
ABOUT_HIVIEW_DIALOG_MARGIN + ABOUT_HIVIEW_DIALOG_TEXT_Y_OFFSET));
delete content;
// Primary panel label image.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " add content label with background image to layout" << endl;
#endif
content = new QLabel;
content->setPixmap (background);
dialog_layout->addWidget (content);
// Buttons panel.
QHBoxLayout
*horizontal_layout = new QHBoxLayout;
horizontal_layout->setContentsMargins (10, 5, 5, 5);
// Close button.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " Close button" << endl;
#endif
QPushButton
*close_button = new QPushButton (tr ("Close"));
connect (close_button,
SIGNAL (clicked ()),
SLOT (close ()));
horizontal_layout->addWidget (close_button);
// Close action.
QAction
*action = new QAction (tr ("Close Window"), this);
action->setShortcut (tr ("Ctrl+W"));
connect (action,
SIGNAL (triggered ()),
SLOT (close ()));
addAction (action);
horizontal_layout->addStretch (100);
// Expand button.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " Expand button" << endl;
#endif
Expand_Down_Icon = new QIcon (":/Images/Expand_Down_Icon.png");
Expand_Up_Icon = new QIcon (":/Images/Expand_Up_Icon.png");
Expand_Button = new Icon_Button (*Expand_Down_Icon);
Expand_Button->setCheckable (true);
Expand_Button->setChecked (false);
Expand_Button->setToolTip (tr ("Open credits panel"));
connect (Expand_Button,
SIGNAL (toggled (bool)),
SLOT (expand_button_toggled (bool)));
horizontal_layout->addWidget (Expand_Button);
dialog_layout->addLayout (horizontal_layout);
// Credits panel.
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << " Credits panel" << endl
<< " label column width = "
<< (logo.width ()
- HIVIEW_LOGO_MARGIN + ABOUT_HIVIEW_DIALOG_CREDITS_X_OFFSET) << endl
<< " cell spacing = " << HIVIEW_LOGO_MARGIN << endl;
#endif
content = new QLabel
(tr (
#include "Credits.html"
)
.arg (logo.width ()
- HIVIEW_LOGO_MARGIN + ABOUT_HIVIEW_DIALOG_CREDITS_X_OFFSET)
.arg (HIVIEW_LOGO_MARGIN));
content->setStyleSheet ("background:transparent;");
content->setContentsMargins (0, 0, 0, 0);
// Enable links to be opened in the user's web browser.
content->setOpenExternalLinks (true);
Expand_Panel = new QScrollArea;
Expand_Panel->setMaximumHeight (background.height ());
Expand_Panel->viewport ()->setPalette (QPalette (QColor (255, 247, 228)));
Expand_Panel->viewport ()->setAutoFillBackground (true);
Expand_Panel->setWidget (content);
Expand_Panel->setVisible (Expand_Button->isChecked ());
dialog_layout->addWidget (Expand_Panel);
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << "<<< About_HiView_Dialog" << endl;
#endif
}
void
About_HiView_Dialog::expand_button_toggled
(
bool down
)
{
#if ((DEBUG_SECTION) & DEBUG_SLOTS)
clog << ">>> About_HiView_Dialog::expand_button_toggled: "
<< boolalpha << down << endl;
#endif
if (down)
{
Expand_Button->setIcon (*Expand_Up_Icon);
Expand_Button->setToolTip (tr ("Close credits panel"));
resize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
}
else
{
Expand_Button->setIcon (*Expand_Down_Icon);
Expand_Button->setToolTip (tr ("Open credits panel"));
}
Expand_Panel->setVisible (down);
#if ((DEBUG_SECTION) & DEBUG_SLOTS)
clog << "<<< About_HiView_Dialog::expand_button_toggled" << endl;
#endif
}
} // namespace HiRISE
} // namespace UA