# # # patch "src/util/Platform.cpp" # from [ed200bdda30465773d562b61f58477280adb197c] # to [a3ad7cd82561e09dec72302b40956baea8d50502] # # patch "src/util/Platform.h" # from [d01ea9bdf4b801be54df7f565f367ca51101992d] # to [992ab64a32420a430ace5f8597ab78ca7979d859] # # patch "src/view/WorkspaceWindow.cpp" # from [7b07547c8eca3d8d026c69dbd62977638fdb2964] # to [c10f2d00a86eb48c8436b52f8376012d6f27d996] # # patch "src/view/dialogs/ApplicationUpdate.cpp" # from [4cdbf4e98e250073e598f6938be619b5dd3b8744] # to [c0b3ef7d07d9095db4f36229c76e3e523b74bffe] # # patch "src/view/dialogs/RevisionManifest.cpp" # from [4dd1a71a3937be591ba179bf12bb4d134f22c250] # to [4965902b6ef1e583149e4ec1a76bca7db4cddaf5] # ============================================================ --- src/util/Platform.cpp ed200bdda30465773d562b61f58477280adb197c +++ src/util/Platform.cpp a3ad7cd82561e09dec72302b40956baea8d50502 @@ -30,11 +30,11 @@ #ifdef Q_WS_WIN #include #include +#include #endif #ifdef Q_WS_MACX #include -#include #endif #include @@ -47,63 +47,75 @@ using namespace std; // It opens a file with the associated program on the specific platform // Original author: Chris Thompson // -bool Platform::openFile(QWidget *widget, const QString &filename) +bool Platform::openFile(const QString &filename) { - bool retval = false; + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + bool retval = false; - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - #ifdef Q_WS_X11 - Q_UNUSED(widget); - // due to a bug in KDE < 3.5.3 we can't trust the return value kfmclient - // gives us back (its always 1!) - if (system("which kfmclient >/dev/null 2>&1") == 0) - { - D("Using kfmclient"); - string s("kfmclient exec \""); - s += filename.toUtf8().data(); - s += "\""; - // just cross your fingers - system(s.c_str()); - retval = true; - } - else - if (system("which gnome-open >/dev/null 2>&1") == 0) - { - D("Using gnome-open"); - string s("gnome-open \""); - s += filename.toUtf8().data(); - s += "\""; - retval = (system(s.c_str()) == 0); - } - else - { - C("Neither kfmclient nor gnome-open found"); - } + Q_UNUSED(widget); + // due to a bug in KDE < 3.5.3 we can't trust the return value kfmclient + // gives us back (its always 1!) + if (system("which kfmclient >/dev/null 2>&1") == 0) + { + D("Using kfmclient"); + string s("kfmclient exec \""); + s += filename.toUtf8().data(); + s += "\""; + // just cross your fingers + system(s.c_str()); + retval = true; + } + else + if (system("which gnome-open >/dev/null 2>&1") == 0) + { + D("Using gnome-open"); + string s("gnome-open \""); + s += filename.toUtf8().data(); + s += "\""; + retval = (system(s.c_str()) == 0); + } + else + { + C("Neither kfmclient nor gnome-open found"); + } #endif #ifdef Q_WS_MACX - // Running on a Mac in OS X - Q_UNUSED(widget); - string s("open \""); - s += filename.toUtf8().data(); - s += "\""; - retval = (system(s.c_str()) == 0); + // Running on a Mac in OS X + Q_UNUSED(widget); + string s("open \""); + s += filename.toUtf8().data(); + s += "\""; + retval = (system(s.c_str()) == 0); #endif #ifdef Q_WS_WIN - // Running in an MS Windows environment - if (NULL != widget) - { - QString winfilename(filename); - winfilename.replace(QChar('/'), QString("\\")); - retval = (reinterpret_cast(ShellExecute(widget->winId(), L"open", - winfilename.toStdWString().data(), NULL, NULL, SW_SHOW)) > 32); - } + QString winfilename(filename); + winfilename.replace(QChar('/'), QString("\\")); + int code = reinterpret_cast( + ShellExecute(NULL, L"open", winfilename.toStdWString().data(), + NULL, NULL, SW_SHOW) + ); + + // if shellexec fails (return value < 32, see + // http://msdn2.microsoft.com/en-us/library/bb762153.aspx) + // f.e. because the file's extension is not registered, + // try to open in with the "Open With" dialog + if (code > 32) + { + retval = true; + } + else + { + QStringList arguments; + arguments << "shell32.dll,OpenAs_RunDLL" << winfilename; + retval = QProcess::startDetached("rundll32.exe", arguments); + } #endif - QApplication::restoreOverrideCursor(); - return retval; + QApplication::restoreOverrideCursor(); + return retval; } // @@ -114,15 +126,15 @@ QString Platform::getUsername() QString Platform::getUsername() { QString username; - + #ifdef Q_WS_WIN #if defined(UNICODE) - if ( QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) + if ( QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) { TCHAR winUserName[UNLEN + 1]; // UNLEN is defined in LMCONS.H DWORD winUserNameSize = sizeof(winUserName); GetUserNameW( winUserName, &winUserNameSize ); - username = QString::fromStdWString( winUserName ); + username = QString::fromStdWString( winUserName ); } else #endif { @@ -146,7 +158,7 @@ QString Platform::getUsername() #endif D(QString("Found username %1").arg(username)); - + return username; } ============================================================ --- src/util/Platform.h d01ea9bdf4b801be54df7f565f367ca51101992d +++ src/util/Platform.h 992ab64a32420a430ace5f8597ab78ca7979d859 @@ -21,7 +21,6 @@ #ifndef PLATFORM_H #define PLATFORM_H -#include #include class Platform @@ -34,7 +33,7 @@ public: * not used on some platforms. * @arg const string &filename The URL to open. */ - static bool openFile(QWidget *widget, const QString &filename); + static bool openFile(const QString & filename); /** * Returns the name of the currently logged in user of the system */ ============================================================ --- src/view/WorkspaceWindow.cpp 7b07547c8eca3d8d026c69dbd62977638fdb2964 +++ src/view/WorkspaceWindow.cpp c10f2d00a86eb48c8436b52f8376012d6f27d996 @@ -262,7 +262,7 @@ void WorkspaceWindow::openFile(const QSt return; } - if (!Platform::openFile(this, file.absoluteFilePath())) + if (!Platform::openFile(file.absoluteFilePath())) { QMessageBox::critical( this, ============================================================ --- src/view/dialogs/ApplicationUpdate.cpp 4cdbf4e98e250073e598f6938be619b5dd3b8744 +++ src/view/dialogs/ApplicationUpdate.cpp c0b3ef7d07d9095db4f36229c76e3e523b74bffe @@ -107,7 +107,7 @@ void ApplicationUpdate::openWebsite() void ApplicationUpdate::openWebsite() { - Platform::openFile(this, "http://guitone.thomaskeller.biz"); + Platform::openFile("http://guitone.thomaskeller.biz"); accept(); } ============================================================ --- src/view/dialogs/RevisionManifest.cpp 4dd1a71a3937be591ba179bf12bb4d134f22c250 +++ src/view/dialogs/RevisionManifest.cpp 4965902b6ef1e583149e4ec1a76bca7db4cddaf5 @@ -122,7 +122,7 @@ void RevisionManifest::openFile(const QM file.write(out.getOutput()); file.close(); - if (!Platform::openFile(this, tempPath)) + if (!Platform::openFile(tempPath)) { QMessageBox::critical( this,