main.cpp
changeset 625 22955004d512
parent 550 55236fe5a630
child 657 8e596f73f258
     1.1 --- a/main.cpp	Fri Nov 09 12:07:21 2007 +0000
     1.2 +++ b/main.cpp	Fri Nov 09 12:07:22 2007 +0000
     1.3 @@ -6,6 +6,11 @@
     1.4  #include "settings.h"
     1.5  #include "version.h"
     1.6  
     1.7 +#if defined(Q_OS_WIN32)
     1.8 +#define WIN32_LEAN_AND_MEAN
     1.9 +#include <windows.h>
    1.10 +#endif
    1.11 +
    1.12  // Global variables
    1.13  TextEditor *textEditor;			// used in Constr. of LinkableMapObj
    1.14  								// initialized in mainwindow
    1.15 @@ -21,6 +26,9 @@
    1.16  QDir vymBaseDir;				// Containing all styles, scripts, images, ...
    1.17  QDir lastImageDir;
    1.18  QDir lastFileDir;
    1.19 +#if defined(Q_OS_WIN32)
    1.20 +QDir vymInstallDir;
    1.21 +#endif
    1.22  QString iconPath;				// Pointing to icons used for toolbars
    1.23  QString flagsPath;				// Pointing to flags
    1.24  bool clipboardEmpty;			
    1.25 @@ -97,6 +105,27 @@
    1.26  		#if defined (Q_OS_MACX)
    1.27  			vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
    1.28  
    1.29 +        #elif defined (Q_OS_WIN32)
    1.30 +            QString basePath;
    1.31 +
    1.32 +            wchar_t wbuf[512];
    1.33 +            if (GetModuleFileName(NULL, wbuf, 512))
    1.34 +            {
    1.35 +                QString mfn(QString::fromWCharArray(wbuf));
    1.36 +                mfn.replace('\\', '/');
    1.37 +                if (mfn.endsWith("/bin/vym.exe", Qt::CaseInsensitive))
    1.38 +                {
    1.39 +                    mfn.chop(12);
    1.40 +                    basePath = mfn;
    1.41 +                }
    1.42 +            }
    1.43 +
    1.44 +            if (basePath.isEmpty())
    1.45 +                basePath = vymBaseDir.currentDirPath();
    1.46 +
    1.47 +            vymInstallDir.setPath(basePath);
    1.48 +            vymBaseDir.setPath(basePath + "/share/vym");
    1.49 +
    1.50  		#else
    1.51  			vymBaseDir.setPath ("/usr/share/vym");
    1.52  			if (!vymBaseDir.exists())
    1.53 @@ -137,7 +166,12 @@
    1.54  	textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
    1.55  
    1.56  	// Initialize mainwindow 
    1.57 +#if defined(Q_OS_WIN32)
    1.58 +    Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC));
    1.59 +#else
    1.60      Main m;
    1.61 +#endif
    1.62 +
    1.63  	//m.resize(m.sizeHint());
    1.64  	m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
    1.65  	m.show();
    1.66 @@ -178,4 +212,3 @@
    1.67  
    1.68      return app.exec();
    1.69  }
    1.70 -