diff -r 4ffc47ae27e4 -r 22955004d512 main.cpp --- a/main.cpp Fri Nov 09 12:07:21 2007 +0000 +++ b/main.cpp Fri Nov 09 12:07:22 2007 +0000 @@ -6,6 +6,11 @@ #include "settings.h" #include "version.h" +#if defined(Q_OS_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif + // Global variables TextEditor *textEditor; // used in Constr. of LinkableMapObj // initialized in mainwindow @@ -21,6 +26,9 @@ QDir vymBaseDir; // Containing all styles, scripts, images, ... QDir lastImageDir; QDir lastFileDir; +#if defined(Q_OS_WIN32) +QDir vymInstallDir; +#endif QString iconPath; // Pointing to icons used for toolbars QString flagsPath; // Pointing to flags bool clipboardEmpty; @@ -97,6 +105,27 @@ #if defined (Q_OS_MACX) vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources"); + #elif defined (Q_OS_WIN32) + QString basePath; + + wchar_t wbuf[512]; + if (GetModuleFileName(NULL, wbuf, 512)) + { + QString mfn(QString::fromWCharArray(wbuf)); + mfn.replace('\\', '/'); + if (mfn.endsWith("/bin/vym.exe", Qt::CaseInsensitive)) + { + mfn.chop(12); + basePath = mfn; + } + } + + if (basePath.isEmpty()) + basePath = vymBaseDir.currentDirPath(); + + vymInstallDir.setPath(basePath); + vymBaseDir.setPath(basePath + "/share/vym"); + #else vymBaseDir.setPath ("/usr/share/vym"); if (!vymBaseDir.exists()) @@ -137,7 +166,12 @@ textEditor->setIcon (QPixmap (iconPath+"vym-editor.png")); // Initialize mainwindow +#if defined(Q_OS_WIN32) + Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC)); +#else Main m; +#endif + //m.resize(m.sizeHint()); m.setIcon (QPixmap (iconPath+"vym-48x48.png")); m.show(); @@ -178,4 +212,3 @@ return app.exec(); } -