kapplication_win.cpp
00001 /* 00002 This file is part of the KDE libraries 00003 Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include <kapplication.h> 00021 #include <kstandarddirs.h> 00022 #include <klocale.h> 00023 #include <kurl.h> 00024 00025 #include "kcheckaccelerators.h" 00026 #include "kappdcopiface.h" 00027 00028 #include <qassistantclient.h> 00029 #include <tqdir.h> 00030 00031 #include "windows.h" 00032 #include "shellapi.h" 00033 00043 void KApplication_init_windows(bool /*GUIenabled*/) 00044 { 00045 TQString qt_transl_file = ::locate( "locale", KGlobal::locale()->language() 00046 + "/LC_MESSAGES/qt_" + KGlobal::locale()->language() + ".qm" ); 00047 QTranslator *qt_transl = new QTranslator(); 00048 if (qt_transl->load( qt_transl_file, "")) 00049 kapp->installTranslator( qt_transl ); 00050 else 00051 delete qt_transl; 00052 } 00053 00054 //unsafe; create kapplication_p.h instead! 00055 typedef void* IceIOErrorHandler; 00056 00057 class KApplicationPrivate 00058 { 00059 public: 00060 KApplicationPrivate(); 00061 ~KApplicationPrivate(); 00062 00063 bool actionRestrictions : 1; 00064 bool guiEnabled : 1; 00065 int refCount; 00066 IceIOErrorHandler oldIceIOErrorHandler; 00067 KCheckAccelerators* checkAccelerators; 00068 TQString overrideStyle; 00069 TQString geometry_arg; 00070 TQCString startup_id; 00071 TQTimer* app_started_timer; 00072 KAppDCOPInterface *m_KAppDCOPInterface; 00073 bool session_save; 00074 QAssistantClient* qassistantclient; 00075 }; 00076 00077 void KApplication::invokeHelp( const TQString& anchor, 00078 const TQString& _appname, const TQCString& startup_id ) const 00079 { 00080 if (!d->qassistantclient) { 00081 d->qassistantclient = new QAssistantClient( 00082 KStandardDirs::findExe( "assistant" ), 0); 00083 TQStringList args; 00084 args << "-profile"; 00085 args << TQDir::convertSeparators( locate("html", TQString(name())+"/"+TQString(name())+".adp") ); 00086 d->qassistantclient->setArguments(args); 00087 } 00088 d->qassistantclient->openAssistant(); 00089 } 00090 00091 // on win32, for invoking browser we're using win32 API 00092 // see kapplication_win.cpp 00093 void KApplication::invokeBrowser( const TQString &url, const TQCString& startup_id ) 00094 { 00095 TQCString s = url.latin1(); 00096 const unsigned short *l = (const unsigned short *)s.data(); 00097 ShellExecuteA(0, "open", s.data(), 0, 0, SW_NORMAL); 00098 } 00099 00100 void KApplication::invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc, 00101 const TQString &subject, const TQString &body, 00102 const TQString & /*messageFile TODO*/, const TQStringList &attachURLs, 00103 const TQCString& startup_id ) 00104 { 00105 KURL url("mailto:"+to); 00106 url.setQuery("?subject="+subject); 00107 url.addQueryItem("cc", cc); 00108 url.addQueryItem("bcc", bcc); 00109 url.addQueryItem("body", body); 00110 for (TQStringList::ConstIterator it = attachURLs.constBegin(); it != attachURLs.constEnd(); ++it) 00111 url.addQueryItem("attach", KURL::encode_string(*it)); 00112 00113 TQCString s = url.url().latin1(); 00114 const unsigned short *l = (const unsigned short *)s.data(); 00115 ShellExecuteA(0, "open", s.data(), 0, 0, SW_NORMAL); 00116 } 00117