Skip to content

Commit 574908d

Browse files
author
gsherman
committed
Refactored the tips dialog to use a single QTextBrowser to display
content. This makes better use of the available space and cleans up the dialog a bit. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15234 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 12df5c5 commit 574908d

File tree

3 files changed

+29
-35
lines changed

3 files changed

+29
-35
lines changed

src/app/qgstipgui.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,11 @@ QgsTipGui::~QgsTipGui()
4343
void QgsTipGui::init()
4444
{
4545

46-
// set the 60x60 icon pixmap
47-
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
48-
qgisIcon->setPixmap( icon );
4946
QgsTipFactory myFactory;
5047
QgsTip myTip = myFactory.getTip();
5148
mTipPosition = myFactory.position( myTip );
52-
lblTitle->setText( myTip.title() );
53-
txtTip->setHtml( myTip.content() );
49+
50+
showTip( myTip );
5451

5552
QPushButton *pb;
5653
pb = new QPushButton( tr( "&Previous" ) );
@@ -62,6 +59,23 @@ void QgsTipGui::init()
6259
buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
6360
}
6461

62+
void QgsTipGui::showTip( QgsTip myTip )
63+
{
64+
// TODO - This html construction can be simplified using QStringBuilder
65+
// once Qt 4.6 is the minimum required version for building QGIS.
66+
//
67+
QString content = "<img src='"
68+
+ QgsApplication::iconsPath()
69+
+ "qgis-icon-60x60.png"
70+
+ "' style='float:left;'>"
71+
+ "<h2>"
72+
+ myTip.title()
73+
+ "</h2><br clear='all'/>"
74+
+ myTip.content();
75+
76+
txtTip->setHtml( content );
77+
}
78+
6579
void QgsTipGui::on_cbxDisableTips_toggled( bool theFlag )
6680
{
6781
QSettings settings;
@@ -80,8 +94,7 @@ void QgsTipGui::nextClicked()
8094
mTipPosition = 0;
8195
}
8296
QgsTip myTip = myFactory.getTip( mTipPosition );
83-
lblTitle->setText( myTip.title() );
84-
txtTip->setHtml( myTip.content() );
97+
showTip( myTip );
8598
}
8699

87100
void QgsTipGui::prevClicked()
@@ -93,6 +106,5 @@ void QgsTipGui::prevClicked()
93106
mTipPosition = myFactory.count() - 1;
94107
}
95108
QgsTip myTip = myFactory.getTip( mTipPosition );
96-
lblTitle->setText( myTip.title() );
97-
txtTip->setHtml( myTip.content() );
109+
showTip( myTip );
98110
}

src/app/qgstipgui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define QGSTIPGUI_H
2020

2121
#include "ui_qgstipguibase.h"
22+
class QgsTip;
2223

2324
class QgsTipGui : public QDialog, private Ui::QgsTipGuiBase
2425
{
@@ -29,6 +30,7 @@ class QgsTipGui : public QDialog, private Ui::QgsTipGuiBase
2930

3031
private:
3132
void init();
33+
void showTip( QgsTip );
3234

3335
int mTipPosition;
3436

src/ui/qgstipguibase.ui

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,15 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>560</width>
10-
<height>283</height>
9+
<width>541</width>
10+
<height>341</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>QGIS Tips!</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
17-
<item row="0" column="0">
18-
<widget class="QLabel" name="qgisIcon">
19-
<property name="text">
20-
<string>TextLabel</string>
21-
</property>
22-
</widget>
23-
</item>
24-
<item row="0" column="1" colspan="2">
25-
<widget class="QLabel" name="lblTitle">
26-
<property name="styleSheet">
27-
<string notr="true">font-weight: bold; </string>
28-
</property>
29-
<property name="text">
30-
<string>Tip Title goes here</string>
31-
</property>
32-
<property name="textFormat">
33-
<enum>Qt::PlainText</enum>
34-
</property>
35-
</widget>
36-
</item>
37-
<item row="1" column="1" colspan="3">
17+
<item row="0" column="0" colspan="2">
3818
<widget class="QTextBrowser" name="txtTip">
3919
<property name="sizePolicy">
4020
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -46,22 +26,22 @@
4626
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
4727
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
4828
p, li { white-space: pre-wrap; }
49-
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Wine Sans Serif'; font-size:12pt; font-weight:400; font-style:normal;&quot;&gt;
29+
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
5030
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;A nice tip goes here...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
5131
</property>
5232
<property name="openExternalLinks">
5333
<bool>true</bool>
5434
</property>
5535
</widget>
5636
</item>
57-
<item row="2" column="1" colspan="3">
37+
<item row="1" column="0" colspan="2">
5838
<widget class="QCheckBox" name="cbxDisableTips">
5939
<property name="text">
6040
<string>I've had enough tips, don't show this on start up any more!</string>
6141
</property>
6242
</widget>
6343
</item>
64-
<item row="3" column="1" colspan="3">
44+
<item row="2" column="0" colspan="2">
6545
<widget class="QDialogButtonBox" name="buttonBox">
6646
<property name="orientation">
6747
<enum>Qt::Horizontal</enum>

0 commit comments

Comments
 (0)