This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch feature/cleanup in repository x2goclient. commit 0a9a0a64b3fd6bdc3646520269252443acca31da Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Feb 14 23:17:07 2015 +0100 general: define wrap_legacy_resources() function and use it to wrap legacy resource locations stored in old session config files. --- debian/changelog | 2 ++ src/onmainwindow.cpp | 10 +++++----- src/sessionbutton.cpp | 9 ++++----- src/x2goutils.cpp | 29 +++++++++++++++++++++++++++++ src/x2goutils.h | 1 + 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index b15dc3a..f01bfe9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -191,6 +191,8 @@ x2goclient (4.0.3.2-0x2go1) UNRELEASED; urgency=medium - Work around a bug in qmake generating incorrect make rules for embedding the OS X app bundle Info.plist file. - Work around another bug in qmake and copy icon "manually". + - Define wrap_legacy_resources() function and use it to wrap legacy + resource locations stored in old session config files. -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Thu, 27 Nov 2014 12:01:43 +0100 diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index c5b8769..f09a683 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -2533,11 +2533,11 @@ void ONMainWindow::slotSelectedFromList ( SessionButton* session ) - sessIcon=st->setting()->value ( - sid+"/icon", - ( QVariant ) ":/img/icons/128x128/x2gosession.png" - ).toString(); - sessIcon=expandHome(sessIcon); + sessIcon = wrap_legacy_resources (st->setting()->value ( + sid+"/icon", + (QVariant) ":/img/icons/128x128/x2gosession.png" + ).toString ()); + sessIcon = expandHome(sessIcon); command=st->setting()->value ( sid+"/command", diff --git a/src/sessionbutton.cpp b/src/sessionbutton.cpp index 8967d77..10bf4d8 100644 --- a/src/sessionbutton.cpp +++ b/src/sessionbutton.cpp @@ -310,11 +310,10 @@ void SessionButton::redraw() sessStatus->setText("("+tr("suspended")+")"); } - QString sessIcon=st->setting()->value ( - sid+"/icon", - ( QVariant ) - ":/img/icons/128x128/x2gosession.png" - ).toString(); + QString sessIcon = wrap_legacy_resources (st->setting()->value (sid+"/icon", + (QVariant) + ":/img/icons/128x128/x2gosession.png" + ).toString ()); sessIcon = expandHome(sessIcon); QPixmap* pix; diff --git a/src/x2goutils.cpp b/src/x2goutils.cpp index bd38b2a..5226c47 100644 --- a/src/x2goutils.cpp +++ b/src/x2goutils.cpp @@ -15,6 +15,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ +#include <vector> +#include <algorithm> #include <QString> #include <QDir> @@ -26,3 +28,30 @@ QString expandHome( QString path ) } return path; } + +QString wrap_legacy_resources (const QString res_path) { + QString ret (res_path); + + if (!(res_path.isEmpty ())) { + std::vector<QString> legacy_locations; + legacy_locations.push_back (QString (":/icons/")); + legacy_locations.push_back (QString (":/png/")); + legacy_locations.push_back (QString (":/svg/")); + + bool detected = false; + + /* This would be so much easier with C++ and lambdas... */ + QString::const_iterator it = legacy_locations.begin (); + while (it != legacy_locations.end ()) { + if (res_path.startsWith (*(it++))) { + detected = true; + break; + } + } + + if (detected) + ret.insert (1, QString ("/img")); + } + + return (ret); +} diff --git a/src/x2goutils.h b/src/x2goutils.h index cf9ce08..84bed3c 100644 --- a/src/x2goutils.h +++ b/src/x2goutils.h @@ -21,5 +21,6 @@ #include <QString> QString expandHome( QString path ); +QString wrap_legacy_resources (const QString res_path); #endif -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git