tip_navigation.diff
src/app/qgstipfactory.h (working copy) | ||
---|---|---|
32 | 32 |
* @see also QgsTipOfTheDay, QgsTip |
33 | 33 |
*/ |
34 | 34 | |
35 |
class QgsTipFactory : public QObject
|
|
35 |
class QgsTipFactory : public QObject |
|
36 | 36 |
{ |
37 | 37 |
Q_OBJECT; //used for tr() so we dont need to do QObject::tr() |
38 | 38 |
public: |
... | ... | |
45 | 45 |
*/ |
46 | 46 |
QgsTip getTip(); |
47 | 47 |
/** Get a specific tip (generic or gui-centric). |
48 |
* @param thePosition The tip returned will be based on the
|
|
48 |
* @param thePosition The tip returned will be based on the |
|
49 | 49 |
* number passed in as thePosition. If the |
50 |
* position is invalid, an empty string will be
|
|
50 |
* position is invalid, an empty string will be |
|
51 | 51 |
* returned. |
52 | 52 |
* @return An QgsTip containing the tip |
53 | 53 |
*/ |
... | ... | |
61 | 61 |
*/ |
62 | 62 |
QgsTip getGuiTip(); |
63 | 63 | |
64 |
int position( QgsTip ); |
|
65 |
int count(); |
|
66 | ||
64 | 67 |
private: |
65 | 68 |
void addGenericTip(QgsTip); |
66 | 69 |
void addGuiTip(QgsTip); |
src/app/qgstipfactory.cpp (working copy) | ||
---|---|---|
145 | 145 |
return 0; |
146 | 146 |
} |
147 | 147 | |
148 |
int QgsTipFactory::position(QgsTip tip) |
|
149 |
{ |
|
150 |
for(int i = 0; i < mAllTips.count(); ++i) |
|
151 |
{ |
|
152 |
QgsTip myTip = mAllTips.at( i ); |
|
153 |
if ( myTip.title() == tip.title() ) |
|
154 |
{ |
|
155 |
return i; |
|
156 |
} |
|
157 |
} |
|
158 |
return -1; |
|
159 |
} |
|
160 | ||
161 |
int QgsTipFactory::count() |
|
162 |
{ |
|
163 |
return mAllTips.count(); |
|
164 |
} |
src/app/qgstipgui.cpp (working copy) | ||
---|---|---|
46 | 46 |
qgisIcon->setPixmap( icon ); |
47 | 47 |
QgsTipFactory myFactory; |
48 | 48 |
QgsTip myTip = myFactory.getTip(); |
49 |
mTipPosition = myFactory.position( myTip ); |
|
49 | 50 |
lblTitle->setText(myTip.title()); |
50 | 51 |
txtTip->setHtml(myTip.content()); |
51 | ||
52 | 52 |
} |
53 | 53 | |
54 | 54 |
void QgsTipGui::on_cbxDisableTips_toggled(bool theFlag) |
55 | 55 |
{ |
56 | 56 |
QSettings settings; |
57 |
//note the ! below as when the cbx is checked (true) we want to
|
|
57 |
//note the ! below as when the cbx is checked (true) we want to |
|
58 | 58 |
//change the setting to false |
59 | 59 |
settings.setValue( "/qgis/showTips", !theFlag ); |
60 | 60 |
hide(); |
61 | 61 |
} |
62 | ||
63 |
void QgsTipGui::on_btnNext_clicked() |
|
64 |
{ |
|
65 |
mTipPosition += 1; |
|
66 |
QgsTipFactory myFactory; |
|
67 |
if ( mTipPosition >= myFactory.count() ) |
|
68 |
{ |
|
69 |
mTipPosition = 0; |
|
70 |
} |
|
71 |
QgsTip myTip = myFactory.getTip( mTipPosition ); |
|
72 |
lblTitle->setText( myTip.title() ); |
|
73 |
txtTip->setHtml( myTip.content() ); |
|
74 |
} |
|
75 | ||
76 |
void QgsTipGui::on_btnPrev_clicked() |
|
77 |
{ |
|
78 |
mTipPosition -= 1; |
|
79 |
QgsTipFactory myFactory; |
|
80 |
if ( mTipPosition < 0 ) |
|
81 |
{ |
|
82 |
mTipPosition = myFactory.count() - 1; |
|
83 |
} |
|
84 |
QgsTip myTip = myFactory.getTip( mTipPosition ); |
|
85 |
lblTitle->setText( myTip.title() ); |
|
86 |
txtTip->setHtml( myTip.content() ); |
|
87 |
} |
src/app/qgstipgui.h (working copy) | ||
---|---|---|
30 | 30 |
private: |
31 | 31 |
void init(); |
32 | 32 | |
33 |
int mTipPosition; |
|
34 | ||
33 | 35 |
private slots: |
34 | 36 |
void on_cbxDisableTips_toggled(bool theFlag); |
37 |
void on_btnPrev_clicked(); |
|
38 |
void on_btnNext_clicked(); |
|
35 | 39 |
}; |
36 | 40 | |
37 | 41 |
#endif |
src/ui/qgstipguibase.ui (working copy) | ||
---|---|---|
21 | 21 |
</property> |
22 | 22 |
</widget> |
23 | 23 |
</item> |
24 |
<item row="0" column="1"> |
|
24 |
<item row="0" column="1" colspan="2">
|
|
25 | 25 |
<widget class="QLabel" name="lblTitle"> |
26 | 26 |
<property name="styleSheet"> |
27 | 27 |
<string notr="true">font-weight: bold; </string> |
... | ... | |
34 | 34 |
</property> |
35 | 35 |
</widget> |
36 | 36 |
</item> |
37 |
<item row="1" column="1"> |
|
37 |
<item row="1" column="1" colspan="3">
|
|
38 | 38 |
<widget class="QTextBrowser" name="txtTip"> |
39 | 39 |
<property name="sizePolicy"> |
40 | 40 |
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> |
... | ... | |
46 | 46 |
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> |
47 | 47 |
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> |
48 | 48 |
p, li { white-space: pre-wrap; } |
49 |
</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;">
|
|
50 |
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A nice tip goes here...</p></body></html></string>
|
|
49 |
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
|
50 |
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">A nice tip goes here...</span></p></body></html></string>
|
|
51 | 51 |
</property> |
52 | 52 |
<property name="openExternalLinks"> |
53 | 53 |
<bool>true</bool> |
54 | 54 |
</property> |
55 | 55 |
</widget> |
56 | 56 |
</item> |
57 |
<item row="2" column="1"> |
|
57 |
<item row="2" column="1" colspan="3">
|
|
58 | 58 |
<widget class="QCheckBox" name="cbxDisableTips"> |
59 | 59 |
<property name="text"> |
60 | 60 |
<string>I've had enough tips, don't show this on start up any more!</string> |
... | ... | |
62 | 62 |
</widget> |
63 | 63 |
</item> |
64 | 64 |
<item row="3" column="1"> |
65 |
<widget class="QPushButton" name="btnPrev"> |
|
66 |
<property name="text"> |
|
67 |
<string>Previous tip</string> |
|
68 |
</property> |
|
69 |
</widget> |
|
70 |
</item> |
|
71 |
<item row="3" column="2"> |
|
72 |
<widget class="QPushButton" name="btnNext"> |
|
73 |
<property name="text"> |
|
74 |
<string>Next tip</string> |
|
75 |
</property> |
|
76 |
</widget> |
|
77 |
</item> |
|
78 |
<item row="3" column="3"> |
|
65 | 79 |
<widget class="QDialogButtonBox" name="buttonBox"> |
66 | 80 |
<property name="orientation"> |
67 | 81 |
<enum>Qt::Horizontal</enum> |