From 327f70240c78e5b48371370e38a7fe7a6d1e39bb Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Fri, 1 Aug 2014 14:28:34 +0200 Subject: [PATCH] GUI: Load the finder overlay icon script on MacOSX. --- src/mirall/owncloudgui.cpp | 40 +++++++++++++++++++++++++++++++++++++- src/mirall/owncloudgui.h | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp index 7de5c5cb0..c1c5a1e67 100644 --- a/src/mirall/owncloudgui.cpp +++ b/src/mirall/owncloudgui.cpp @@ -84,6 +84,45 @@ ownCloudGui::ownCloudGui(Application *parent) : SLOT(slotShowOptionalTrayMessage(QString,QString))); connect( Logger::instance(), SIGNAL(guiMessage(QString,QString)), SLOT(slotShowGuiMessage(QString,QString))); + + setupOverlayIcons(); +} + +// Use this to do platform specific code to make overlay icons appear +// in the gui +// MacOSX: perform a AppleScript code peace to load the Finder Plugin. + +// "tell application \"Finder\" \ +// try \ +// «event NVTYload» \ +// end try \ +// end tell"; + + +void ownCloudGui::setupOverlayIcons() +{ + + if( Utility::isMac() && QFile::exists("/Library/ScriptingAdditions/LiferayNativity.osax") ) { + QString aScript = QString::fromUtf8("tell application \"Finder\"\n" + " try\n" + " «event NVTYload»\n" + " end try\n" + "end tell\n"); + + QString osascript = "/usr/bin/osascript"; + QStringList processArguments; + // processArguments << "-l" << "AppleScript"; + + QProcess p; + p.start(osascript, processArguments); + p.write(aScript.toUtf8()); + p.closeWriteChannel(); + p.waitForReadyRead(-1); + QByteArray result = p.readAll(); + QString resultAsString(result); // if appropriate + qDebug() << "Laod Finder Overlay-Plugin: " << resultAsString << ": " << p.exitCode() + << (p.exitCode() != 0 ? p.errorString() : QString::null); + } } // This should rather be in application.... or rather in MirallConfigFile? @@ -164,7 +203,6 @@ void ownCloudGui::startupConnected( bool connected, const QStringList& fails ) _startupFails = fails; // store that for the settings dialog once it appears. if( !_settingsDialog.isNull() ) _settingsDialog->setGeneralErrors( _startupFails ); - } void ownCloudGui::slotComputeOverallSyncStatus() diff --git a/src/mirall/owncloudgui.h b/src/mirall/owncloudgui.h index c67e43c21..c042c23fd 100644 --- a/src/mirall/owncloudgui.h +++ b/src/mirall/owncloudgui.h @@ -44,6 +44,7 @@ public: bool checkAccountExists(bool openSettings); static void raiseDialog(QWidget *raiseWidget); + void setupOverlayIcons(); signals: void setupProxy();