Skip to content
Permalink
Browse files

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@15234 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman
gsherman committed Feb 21, 2011
1 parent afe5613 commit 4919e800fc3b15b2dc89dca54508062b9c4ff44c
Showing with 29 additions and 35 deletions.
  1. +21 −9 src/app/qgstipgui.cpp
  2. +2 −0 src/app/qgstipgui.h
  3. +6 −26 src/ui/qgstipguibase.ui
@@ -43,14 +43,11 @@ QgsTipGui::~QgsTipGui()
void QgsTipGui::init()
{

// set the 60x60 icon pixmap
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
qgisIcon->setPixmap( icon );
QgsTipFactory myFactory;
QgsTip myTip = myFactory.getTip();
mTipPosition = myFactory.position( myTip );
lblTitle->setText( myTip.title() );
txtTip->setHtml( myTip.content() );

showTip( myTip );

QPushButton *pb;
pb = new QPushButton( tr( "&Previous" ) );
@@ -62,6 +59,23 @@ void QgsTipGui::init()
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;
@@ -80,8 +94,7 @@ void QgsTipGui::nextClicked()
mTipPosition = 0;
}
QgsTip myTip = myFactory.getTip( mTipPosition );
lblTitle->setText( myTip.title() );
txtTip->setHtml( myTip.content() );
showTip( myTip );
}

void QgsTipGui::prevClicked()
@@ -93,6 +106,5 @@ void QgsTipGui::prevClicked()
mTipPosition = myFactory.count() - 1;
}
QgsTip myTip = myFactory.getTip( mTipPosition );
lblTitle->setText( myTip.title() );
txtTip->setHtml( myTip.content() );
showTip( myTip );
}
@@ -19,6 +19,7 @@
#define QGSTIPGUI_H

#include "ui_qgstipguibase.h"
class QgsTip;

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

private:
void init();
void showTip( QgsTip );

int mTipPosition;

@@ -6,35 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>283</height>
<width>541</width>
<height>341</height>
</rect>
</property>
<property name="windowTitle">
<string>QGIS Tips!</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="qgisIcon">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="lblTitle">
<property name="styleSheet">
<string notr="true">font-weight: bold; </string>
</property>
<property name="text">
<string>Tip Title goes here</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<item row="0" column="0" colspan="2">
<widget class="QTextBrowser" name="txtTip">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -46,22 +26,22 @@
<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;
&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;
p, li { white-space: pre-wrap; }
&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;
&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;
&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>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="cbxDisableTips">
<property name="text">
<string>I've had enough tips, don't show this on start up any more!</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>

0 comments on commit 4919e80

Please sign in to comment.
You can’t perform that action at this time.