On Fri, Jun 27, 2014 at 6:02 PM, Sergey Starosek <sergey.staro...@gmail.com>
wrote:

> > So this hardcodes the icons for all OSs. Wouldn't it make more sense to
> do
> > this only for Windows. Oh, and is there some way of doing "#ifdef WIN32"
> > in a .ui file?
> >
> > Just wondering...
>
> Then ignore this patch for now. I'll try to implement such callback in
> next few days.
>

Another attempt. Tested on Linux and Windows. Please test on OSX.

Sergey
From c11acd0fa96a798c8bcdd0ce6953f09e821e92df Mon Sep 17 00:00:00 2001
From: Sergey Starosek <sergey.staro...@gmail.com>
Date: Sat, 28 Jun 2014 12:14:36 +0400
Subject: [PATCH] Fallback to loading theme icons from resources
To: subsurface@hohndel.org

Since not all platforms support theme icons, we need to pack
them into resources and fallback to that resource theme.

There seems to be a bug in Qt
(https://bugreports.qt-project.org/browse/QTBUG-16697), thus
default theme name (hicolor) does not work. So we test for
'window-close' theme icon on startup and if not found, set theme
name to 'subsurface'

Signed-off-by: Sergey Starosek <sergey.staro...@gmail.com>
---
 icons/subsurface/32x32/actions/go-down.png      | Bin 0 -> 649 bytes
 icons/subsurface/32x32/actions/go-up.png        | Bin 0 -> 622 bytes
 icons/subsurface/32x32/actions/window-close.png | Bin 0 -> 338 bytes
 icons/subsurface/index.theme                    |   7 +++++++
 qt-ui/mainwindow.cpp                            |   3 +++
 qt-ui/usermanual.ui                             |   4 ++--
 subsurface.qrc                                  |   6 +++++-
 7 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100644 icons/subsurface/32x32/actions/go-down.png
 create mode 100644 icons/subsurface/32x32/actions/go-up.png
 create mode 100644 icons/subsurface/32x32/actions/window-close.png
 create mode 100644 icons/subsurface/index.theme

diff --git a/icons/subsurface/32x32/actions/go-down.png b/icons/subsurface/32x32/actions/go-down.png
new file mode 100644
index 0000000000000000000000000000000000000000..0d08df9cb4d1f8a6349d06f5b11f8dd43c1383db
GIT binary patch
literal 649
zcmV;40(Sk0P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80006|Nkl<ZSVv=I
z7+}CS!1gnYI$$&eMnhn5hJdcFt_B+$+oQ8*&wisuIbm#U%=PQnFS*N?FW*2n4<iJC
zmMgKcvKBEiGQI;Uo&<En8%i8uXlN+P#Ke^Q|NnoX-@kwN0UdD<**p{nXlrW=ad2={
z0~Pav6agLa8R+t<=$eRi5XdvYkjzFl@5hfHtyiyJ1$hn(&_jR)=;C;w#pXzs`~vdl
z0Yl;(u@-~W85tQF1F1wHW`pSiI^^W}^XC@=`G0UZ04xr4gdfmSZzKo)2eQ|lJ9lm;
zF^&LQ?haHJgsdNE`BtFin+T=>m;wU>11n}`<`|$x79>rFfR0!O<p0Cr5GJ7IQ9wC6
zxDOc_|NQ;?cgckd7mi`mgEt%M>FKEh6J#dP5nM<HUU~cW?W_k69{fNyP(eX~Ls(ci
z4X9QJN$oda!kd2S(xscYLXKcLpsA@T$;HK$2Q*k1$>1lz#5oz5INyWBfQd~InAkum
zT?R?b+i%~#O}c*l`g45IM$iEu&DPe|yuj3(1GGR9$*>Q=D4Go71A{mhNC_ZWejk{d
zrW`$b^fRF}LzDwRh5)lD8_>{Xpd$>C4E+gZvm;r49_ZM)z^wL*kmVqGq8$J=j1ibP
zLx2T~D>lRb{rk5YnAp|;<v_WHC_t(Mz=i@H;Q(|*1dz!DwFPMRzZF2s4-jQ5k|MGk
z0Mc(_Vxj}IG#wm_jEu8@1=VFzEhi@mQ0y=@HI)SkoIZW}F*%k~>;Q5tMb<}l6i~zR
j(GVC7fzc2c6d?crXnN5huIUwU00000NkvXXu0mjfFvSpZ

literal 0
HcmV?d00001

diff --git a/icons/subsurface/32x32/actions/go-up.png b/icons/subsurface/32x32/actions/go-up.png
new file mode 100644
index 0000000000000000000000000000000000000000..397511707818d6c2d2abe690d9f16e8f1d6d6f04
GIT binary patch
literal 622
zcmV-!0+IcRP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80006tNkl<ZSV!%Y
zT_{6g7{{H>j&(|5ZWJ0ftl8Q}OIgW{TqqZEAt_0%<m1AvYqxGj;)0~)LN1gGxsh7Z
zKHIEu!$P@Wqm*Vd^MA|H+d6YTsHM)S(|OPPKF{<2o#*`Dm#HZ8#gtjULIqGepmyMY
zcfjRxHIZ|~@Auy-Jx>&O!0B{a3Wb7)2x~N&)j%L{t^`66fX!y>f#@*N{u2GbwG)X%
zj^#qg1z;dP1o2)WAwV1fVi#)#sUVU8%w{vI*Xt+Hb~{!4?Q2}c&oK-W%49O@@pwEd
z1ws;l+wHDK(P@acP(`1$TCJD7=kxg)JZdP2Yrrn~e7+Yk2vGo&$<)Ac+$_Wml)zm!
zoAt(Gu_rQTu~=$ZmYqRNBOinDBcQ#BMB@G@h#vv0R%@G1r<+7EjuJmlrBZ9jWHLh+
zHX4n3gTdfIYzGzln#<)@qS5GODTtB)Fk2T|Jc@#qRPsqE6xzo7M~Q+Ohr=;~wQdUH
z9p>B$hr_2rIf4LoyL|v=>PG^<PF%eQ@k6nHO4b3<hsPkDj}JKj#C~ypF+e56#~|KG
z1rj%JKs+c#oR0y76XS8*Eai(cKy2du{kubSQEat3xOX13)npzZFEHCO%yuP5oR5V$
zTVc*Ax*m+VfGwI91R#?n3C5d)cpCrC3*rYQ;(QK{?0SsJE~<ke7mGhe&;x*I2l-7f
z7<~PWI0eC>lg$vn5c9xa=*g-fdJxH~rXW}aP&=S@pzIy^1VSg*Ax~{0!2kdN07*qo
IM6N<$f=QPZQ~&?~

literal 0
HcmV?d00001

diff --git a/icons/subsurface/32x32/actions/window-close.png b/icons/subsurface/32x32/actions/window-close.png
new file mode 100644
index 0000000000000000000000000000000000000000..2d02aaf3ea874d632bc20bf87ee44ebf372eec32
GIT binary patch
literal 338
zcmV-Y0j>UtP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80003QNkl<ZSVv=I
z7+}CS!1gnYIsj(~XlrY;UA=ns7d4^?pIKNPpr@y&$il*s1+;wLxpU{PQ{o6CBO^_q
z{-i&D{!F`c>C%04voIV0axFVMdn-^OKM;dLU@EzefLfjnG=mL@KmPprvl=~Av4#Me
zMzS11tQk1d0I>#Oiyl(+;?0Jn7zA?&sd@;O1Ed&8idvY12|56zkQjrBQG+eIh;jfS
zN04hd$XucwfXfk3U%|2($vK832jFl7NEnpQNw%Ei5WtbrLBeENJ~SPGCBe}z3b3Vi
zx+Ow<S&in|kQfVyQA1WiM2f+rs3oc>CdWWh^$gDHm{ea-(k2+3O|k)Pl){2@K%3>*
k;*?fmBv;4OcF3p$0L*9tFc46<{Qv*}07*qoM6N<$g0=64=Kufz

literal 0
HcmV?d00001

diff --git a/icons/subsurface/index.theme b/icons/subsurface/index.theme
new file mode 100644
index 0000000..e7835db
--- /dev/null
+++ b/icons/subsurface/index.theme
@@ -0,0 +1,7 @@
+[Icon Theme]
+Name=Subsurface
+Comment=Subsurface fallback theme
+Directories=32x32/actions
+
+[32x32/actions]
+Size=32
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index ed04889..146dced 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -70,6 +70,9 @@ MainWindow::MainWindow() : QMainWindow(),
 	m_Instance = this;
 	ui.setupUi(this);
 	setWindowIcon(QIcon(":subsurface-icon"));
+	if (!QIcon::hasThemeIcon("window-close")) {
+		QIcon::setThemeName("subsurface");
+	}
 	connect(ui.ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int)));
 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings()));
 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(update()));
diff --git a/qt-ui/usermanual.ui b/qt-ui/usermanual.ui
index 506b5c2..e8f0095 100644
--- a/qt-ui/usermanual.ui
+++ b/qt-ui/usermanual.ui
@@ -74,7 +74,7 @@
           <string/>
          </property>
          <property name="icon">
-          <iconset theme="go-previous">
+          <iconset theme="go-up">
            <normaloff/>
           </iconset>
          </property>
@@ -98,7 +98,7 @@
           <string/>
          </property>
          <property name="icon">
-          <iconset theme="go-next">
+          <iconset theme="go-down">
            <normaloff/>
           </iconset>
          </property>
diff --git a/subsurface.qrc b/subsurface.qrc
index 47a8ce4..48dce73 100644
--- a/subsurface.qrc
+++ b/subsurface.qrc
@@ -53,6 +53,10 @@
         <file alias="icon_ceiling_dc">icons/pc.png</file>
         <file alias="icon_ead">icons/ead.png</file>
         <file alias="icon_HR">icons/icon-HR.png</file>
-	<file alias="calendar">icons/calendarbg.png</file>
+        <file alias="calendar">icons/calendarbg.png</file>
+        <file>icons/subsurface/index.theme</file>
+        <file>icons/subsurface/32x32/actions/go-down.png</file>
+        <file>icons/subsurface/32x32/actions/go-up.png</file>
+        <file>icons/subsurface/32x32/actions/window-close.png</file>
     </qresource>
 </RCC>
-- 
1.8.5.5

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to