[QGIS Commit] r15234 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Feb 21 12:13:11 EST 2011


Author: gsherman
Date: 2011-02-21 09:13:11 -0800 (Mon, 21 Feb 2011)
New Revision: 15234

Modified:
   trunk/qgis/src/app/qgstipgui.cpp
   trunk/qgis/src/app/qgstipgui.h
   trunk/qgis/src/ui/qgstipguibase.ui
Log:
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.

Modified: trunk/qgis/src/app/qgstipgui.cpp
===================================================================
--- trunk/qgis/src/app/qgstipgui.cpp	2011-02-21 14:36:46 UTC (rev 15233)
+++ trunk/qgis/src/app/qgstipgui.cpp	2011-02-21 17:13:11 UTC (rev 15234)
@@ -43,15 +43,12 @@
 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" ) );
   connect( pb, SIGNAL( clicked() ), this, SLOT( prevClicked() ) );
@@ -62,6 +59,23 @@
   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 @@
     mTipPosition = 0;
   }
   QgsTip myTip = myFactory.getTip( mTipPosition );
-  lblTitle->setText( myTip.title() );
-  txtTip->setHtml( myTip.content() );
+  showTip( myTip );
 }
 
 void QgsTipGui::prevClicked()
@@ -93,6 +106,5 @@
     mTipPosition = myFactory.count() - 1;
   }
   QgsTip myTip = myFactory.getTip( mTipPosition );
-  lblTitle->setText( myTip.title() );
-  txtTip->setHtml( myTip.content() );
+  showTip( myTip );
 }

Modified: trunk/qgis/src/app/qgstipgui.h
===================================================================
--- trunk/qgis/src/app/qgstipgui.h	2011-02-21 14:36:46 UTC (rev 15233)
+++ trunk/qgis/src/app/qgstipgui.h	2011-02-21 17:13:11 UTC (rev 15234)
@@ -19,6 +19,7 @@
 #define QGSTIPGUI_H
 
 #include "ui_qgstipguibase.h"
+class QgsTip;
 
 class QgsTipGui : public QDialog, private Ui::QgsTipGuiBase
 {
@@ -29,6 +30,7 @@
 
   private:
     void init();
+    void showTip( QgsTip );
 
     int mTipPosition;
 

Modified: trunk/qgis/src/ui/qgstipguibase.ui
===================================================================
--- trunk/qgis/src/ui/qgstipguibase.ui	2011-02-21 14:36:46 UTC (rev 15233)
+++ trunk/qgis/src/ui/qgstipguibase.ui	2011-02-21 17:13:11 UTC (rev 15234)
@@ -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,7 +26,7 @@
       <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">
@@ -54,14 +34,14 @@
      </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>



More information about the QGIS-commit mailing list