/
qgstipgui.cpp
109 lines (94 loc) · 3.2 KB
/
qgstipgui.cpp
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
/***************************************************************************
qgstipgui.cpp - description
-------------------
begin : Sat Aug 10 2002
copyright : (C) 2002 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
* *
* 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 <QSettings>
#include <QPushButton>
#include "qgstipgui.h"
#include "qgsapplication.h"
#include <qgstip.h>
#include <qgstipfactory.h>
#ifdef Q_OS_MACX
QgsTipGui::QgsTipGui()
: QDialog( NULL, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only
#else
QgsTipGui::QgsTipGui()
: QDialog( NULL ) // Normal dialog in non Mac-OS
#endif
{
setupUi( this );
init();
}
QgsTipGui::~QgsTipGui()
{
}
void QgsTipGui::init()
{
QgsTipFactory myFactory;
QgsTip myTip = myFactory.getTip();
mTipPosition = myFactory.position( myTip );
showTip( myTip );
QPushButton *pb;
pb = new QPushButton( tr( "&Previous" ) );
connect( pb, SIGNAL( clicked() ), this, SLOT( prevClicked() ) );
buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
pb = new QPushButton( tr( "&Next" ) );
connect( pb, SIGNAL( clicked() ), this, SLOT( nextClicked() ) );
buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
}
void QgsTipGui::showTip( QgsTip myTip )
{
// TODO - This html construction can be simplified using QStringBuilder
// once Qt 4.6 is the minimum required version for building QGIS.
//
QString content = "<img src='"
+ QgsApplication::iconsPath()
+ "qgis-icon-60x60.png"
+ "' style='float:left;'>"
+ "<h2>"
+ myTip.title()
+ "</h2><br clear='all'/>"
+ myTip.content();
txtTip->setHtml( content );
}
void QgsTipGui::on_cbxDisableTips_toggled( bool theFlag )
{
QSettings settings;
//note the ! below as when the cbx is checked (true) we want to
//change the setting to false
settings.setValue( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), !theFlag );
hide();
}
void QgsTipGui::nextClicked()
{
mTipPosition += 1;
QgsTipFactory myFactory;
if ( mTipPosition >= myFactory.count() )
{
mTipPosition = 0;
}
QgsTip myTip = myFactory.getTip( mTipPosition );
showTip( myTip );
}
void QgsTipGui::prevClicked()
{
mTipPosition -= 1;
QgsTipFactory myFactory;
if ( mTipPosition < 0 )
{
mTipPosition = myFactory.count() - 1;
}
QgsTip myTip = myFactory.getTip( mTipPosition );
showTip( myTip );
}