[X2Go-Commits] [x2goclient] 02/04: src/onmainwindow.{cpp, h}: let images_resource_path () take a new, optional "base" parameter, that might be empty and is put in-between the fixed resource path string and the filename parameter.

git-admin at x2go.org git-admin at x2go.org
Wed Jan 18 07:54:00 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit 5eca0cffdfb303364f21150271284524511340da
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Jan 18 07:45:38 2017 +0100

    src/onmainwindow.{cpp,h}: let images_resource_path () take a new, optional "base" parameter, that might be empty and is put in-between the fixed resource path string and the filename parameter.
---
 debian/changelog     |    3 +++
 src/onmainwindow.cpp |   34 ++++++++++++++++++++++++++++++++--
 src/onmainwindow.h   |    2 +-
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d12436a..13b269b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -27,6 +27,9 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
       finally get a yummy hamburger.
     - src/onmainwindow.{cpp,h}: let iconsPath () take a const-reference
       instead of an object and make it a const member function.
+    - src/onmainwindow.{cpp,h}: let images_resource_path () take a new,
+      optional "base" parameter, that might be empty and is put in-between the
+      fixed resource path string and the filename parameter.
 
   [ Bernard Cafarelli ]
   * New upstream version (4.0.5.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 73f5a3d..e11269d 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -1670,8 +1670,38 @@ QString ONMainWindow::iconsPath ( const QString &fname ) const
     return ( QString ) ":/img/icons"+fname;
 }
 
-QString ONMainWindow::images_resource_path (const QString &filename) const {
-  return (QString (":/img/" + filename));
+QString ONMainWindow::images_resource_path (const QString &filename, const QString &base) const {
+  QString ret = ":/img";
+
+  /*
+   * The base parameter is optional and might be empty.
+   * In this case, it's completely skipped.
+   * Otherwise, we want to make sure that the base parameter
+   * is appended to the fixed start with a slash, but doesn't
+   * end in a slash to avoid double-slashes.
+   * We add a trailing slash if the file name doesn't start
+   * with one.
+   */
+  if (!(base.isEmpty ())) {
+    if (!(base.startsWith ('/'))) {
+      ret.append ('/');
+    }
+
+    ret.append (base);
+
+    if (ret.endsWith ('/')) {
+      ret.chop (1);
+    }
+  }
+
+  if (!(filename.startsWith ('/'))) {
+    ret.append ('/');
+  }
+
+  ret.append (filename);
+
+  x2goDebug << "returning " << ret;
+  return (ret);
 }
 
 void ONMainWindow::displayUsers()
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index bd3e31a..45c096d 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -352,7 +352,7 @@ public:
     ~ONMainWindow();
     static void installTranslator();
     QString iconsPath ( const QString &fname ) const;
-    QString images_resource_path (const QString &filename) const;
+    QString images_resource_path (const QString &filename, const QString &base = "") const;
     static bool isServerRunning ( int port );
     void startNewSession();
     void suspendSession ( QString sessId );

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list