23 #ifdef HAVE_XCOMPOSITE
35 #undef TQT_NO_TRANSLATION
36 #undef TQT_NO_TRANSLATION
37 #include <tqtranslator.h>
42 #define TDEAPPLICATION_BINARY_COMPAT_HACK 1
43 #include "tdeapplication.h"
44 #undef TDEAPPLICATION_BINARY_COMPAT_HACK
46 #define TQT_NO_TRANSLATION
47 #define TQT_NO_TRANSLATION
49 #include <tqptrcollection.h>
50 #include <tqwidgetlist.h>
51 #include <tqstrlist.h>
53 #include <tqmessagebox.h>
54 #include <tqtextstream.h>
56 #include <tqlineedit.h>
57 #include <tqtextedit.h>
58 #include <tqsessionmanager.h>
59 #include <tqptrlist.h>
61 #include <tqstylesheet.h>
62 #include <tqpixmapcache.h>
63 #include <tqtooltip.h>
64 #include <tqstylefactory.h>
65 #include <tqmetaobject.h>
68 #include <tqsqlpropertymap.h>
71 #include <tdeglobal.h>
72 #include <kstandarddirs.h>
76 #include <kiconloader.h>
77 #include <kclipboard.h>
78 #include <tdeconfig.h>
79 #include <ksimpleconfig.h>
80 #include <tdecmdlineargs.h>
81 #include <tdeaboutdata.h>
82 #include <tdeglobalsettings.h>
84 #include <kdatastream.h>
85 #include <klibloader.h>
86 #include <kmimesourcefactory.h>
87 #include <tdestdaccel.h>
89 #include "kcheckaccelerators.h"
90 #include <tqptrdict.h>
91 #include <kmacroexpander.h>
93 #include <kprotocolinfo.h>
94 #include <kkeynative.h>
96 #include <kglobalaccel.h>
99 #include <tdestartupinfo.h>
102 #include <dcopclient.h>
105 #include <sys/types.h>
106 #ifdef HAVE_SYS_STAT_H
107 #include <sys/stat.h>
109 #include <sys/wait.h>
111 #include <sys/types.h>
122 #include <sys/time.h>
126 #if defined TQ_WS_X11
131 #include "kprocctrl.h"
138 #include <X11/Xlib.h>
140 #include <X11/extensions/Xrender.h>
141 #include <X11/extensions/Xcomposite.h>
144 #include <X11/Xutil.h>
145 #include <X11/Xatom.h>
146 #include <X11/SM/SMlib.h>
153 #include <KDE-ICE/ICElib.h>
155 typedef void* IceIOErrorHandler;
158 #define Button1Mask (1<<8)
159 #define Button2Mask (1<<9)
160 #define Button3Mask (1<<10)
164 #define DISPLAY "DISPLAY"
165 #elif defined(TQ_WS_QWS)
166 #define DISPLAY "QWS_DISPLAY"
169 #if defined TQ_WS_X11
174 #include <Carbon/Carbon.h>
178 #if defined TQ_WS_X11
179 #include <sys/ioctl.h>
181 #include <linux/vt.h>
184 extern int getfd(
const char *fnam);
188 #include "tdeappdcopinterface.h"
191 TDE_EXPORT
bool kde_have_kipc =
true;
192 bool kde_kiosk_exception =
false;
193 bool kde_kiosk_admin =
false;
196 bool TDEApplication::loadedByKdeinit =
false;
197 DCOPClient *TDEApplication::s_DCOPClient = 0L;
198 bool TDEApplication::s_dcopClientNeedsPostInit =
false;
201 static Atom atom_DesktopWindow;
202 static Atom atom_NetSupported;
205 #if defined(TQ_WS_X11) && defined(COMPOSITE)
206 static int composite_event, composite_error, composite_opcode;
207 static bool x11_composite_error_generated;
208 static int x11_error(Display *dpy, XErrorEvent *ev) {
209 if (ev->request_code == composite_opcode && ev->minor_code == X_CompositeRedirectSubwindows)
211 x11_composite_error_generated =
true;
220 TDECORE_EXPORT
bool tqt_qclipboard_bailout_hack =
false;
222 template class TQPtrList<KSessionManaged>;
226 static int kde_xio_errhandler( Display * dpy )
228 return kapp->xioErrhandler( dpy );
231 static int kde_x_errhandler( Display *dpy, XErrorEvent *err )
233 return kapp->xErrhandler( dpy, err );
239 static void kde_ice_ioerrorhandler( IceConn conn )
242 kapp->iceIOErrorHandler( conn );
249 void TDEApplication_init_windows(
bool GUIenabled);
251 class QAssistantClient;
259 int get_x_vtnum(Display *dpy)
264 unsigned long nitems;
265 unsigned long bytes_after;
269 prop = XInternAtom (dpy,
"XFree86_VT", False);
273 if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), prop, 0, 1,
274 False, AnyPropertyType, &actualtype, &actualformat,
275 &nitems, &bytes_after, &buf)) {
284 switch (actualtype) {
288 switch (actualformat) {
290 num = (*(uint8_t *)(
void *)buf);
293 num = (*(uint16_t *)(
void *)buf);
296 num = (*(uint32_t *)(
void *)buf);
318 class TDEApplicationPrivate
321 TDEApplicationPrivate()
322 : actionRestrictions( false ),
324 oldIceIOErrorHandler( 0 ),
325 checkAccelerators( 0 ),
326 overrideStyle( TQString::null ),
328 app_started_timer( NULL ),
329 m_TDEAppDCOPInterface( 0L ),
330 session_save( false )
332 ,oldXErrorHandler( NULL )
333 ,oldXIOErrorHandler( NULL )
334 #elif defined TQ_WS_WIN
335 ,qassistantclient( 0 )
340 ~TDEApplicationPrivate()
343 delete qassistantclient;
348 bool actionRestrictions : 1;
357 IceIOErrorHandler oldIceIOErrorHandler;
358 KCheckAccelerators* checkAccelerators;
359 TQString overrideStyle;
360 TQString geometry_arg;
361 TQCString startup_id;
362 TQTimer* app_started_timer;
366 int (*oldXErrorHandler)(Display*,XErrorEvent*);
367 int (*oldXIOErrorHandler)(Display*);
368 #elif defined TQ_WS_WIN
369 QAssistantClient* qassistantclient;
375 #define checkExactMatch(s, b) \
376 if (s.isEmpty()) b = true; \
377 else if (s[s.length()-1] == '!') \
378 { b = false; s.truncate(s.length()-1); } \
380 #define checkStartWildCard(s, b) \
381 if (s.isEmpty()) b = true; \
382 else if (s[0] == '*') \
383 { b = true; s = s.mid(1); } \
385 #define checkEqual(s, b) \
388 URLActionRule(
const TQString &act,
389 const TQString &bProt,
const TQString &bHost,
const TQString &bPath,
390 const TQString &dProt,
const TQString &dHost,
const TQString &dPath,
393 baseProt(bProt), baseHost(bHost), basePath(bPath),
394 destProt(dProt), destHost(dHost), destPath(dPath),
397 checkExactMatch(baseProt, baseProtWildCard);
398 checkStartWildCard(baseHost, baseHostWildCard);
399 checkExactMatch(basePath, basePathWildCard);
400 checkExactMatch(destProt, destProtWildCard);
401 checkStartWildCard(destHost, destHostWildCard);
402 checkExactMatch(destPath, destPathWildCard);
403 checkEqual(destProt, destProtEqual);
404 checkEqual(destHost, destHostEqual);
407 bool baseMatch(
const KURL &url,
const TQString &protClass)
409 if (baseProtWildCard)
411 if ( !baseProt.isEmpty() && !url.
protocol().startsWith(baseProt) &&
412 (protClass.isEmpty() || (protClass != baseProt)) )
417 if ( (url.
protocol() != baseProt) &&
418 (protClass.isEmpty() || (protClass != baseProt)) )
421 if (baseHostWildCard)
423 if (!baseHost.isEmpty() && !url.
host().endsWith(baseHost))
428 if (url.
host() != baseHost)
431 if (basePathWildCard)
433 if (!basePath.isEmpty() && !url.
path().startsWith(basePath))
438 if (url.
path() != basePath)
444 bool destMatch(
const KURL &url,
const TQString &protClass,
const KURL &base,
const TQString &baseClass)
449 (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass) )
452 else if (destProtWildCard)
454 if ( !destProt.isEmpty() && !url.
protocol().startsWith(destProt) &&
455 (protClass.isEmpty() || (protClass != destProt)) )
460 if ( (url.
protocol() != destProt) &&
461 (protClass.isEmpty() || (protClass != destProt)) )
464 if (destHostWildCard)
466 if (!destHost.isEmpty() && !url.
host().endsWith(destHost))
469 else if (destHostEqual)
476 if (url.
host() != destHost)
479 if (destPathWildCard)
481 if (!destPath.isEmpty() && !url.
path().startsWith(destPath))
486 if (url.
path() != destPath)
499 bool baseProtWildCard : 1;
500 bool baseHostWildCard : 1;
501 bool basePathWildCard : 1;
502 bool destProtWildCard : 1;
503 bool destHostWildCard : 1;
504 bool destPathWildCard : 1;
505 bool destProtEqual : 1;
506 bool destHostEqual : 1;
509 TQPtrList<URLActionRule> urlActionRestrictions;
512 TQString pSessionConfigFile;
516 static TQPtrList<TQWidget>*x11Filter = 0;
517 static bool autoDcopRegistration =
true;
524 x11Filter =
new TQPtrList<TQWidget>;
525 connect ( filter, TQ_SIGNAL( destroyed() ),
this, TQ_SLOT( x11FilterDestroyed() ) );
526 x11Filter->append( filter );
529 void TDEApplication::x11FilterDestroyed()
536 if ( !x11Filter || !filter )
538 x11Filter->removeRef( filter );
539 if ( x11Filter->isEmpty() ) {
549 extern bool kde_g_bKillAccelOverride;
551 bool TDEApplication::notify(TQObject *receiver, TQEvent *event)
553 TQEvent::Type t = event->type();
554 if (kde_g_bKillAccelOverride)
556 kde_g_bKillAccelOverride =
false;
558 if (t == TQEvent::AccelOverride)
560 static_cast<TQKeyEvent*
>(event)->accept();
564 kdWarning(125) <<
"kde_g_bKillAccelOverride set, but received an event other than AccelOverride." <<
endl;
567 if ((t == TQEvent::AccelOverride) || (t == TQEvent::KeyPress))
570 TQLineEdit *edit = ::tqt_cast<TQLineEdit *>(receiver);
574 TQKeyEvent *kevent =
static_cast<TQKeyEvent*
>(
event);
578 if (t == TQEvent::KeyPress)
589 if (key ==
KKey(TQt::CTRL + TQt::Key_U))
591 if (t == TQEvent::KeyPress)
593 if (!edit->isReadOnly())
595 TQString t(edit->text());
596 t = t.mid(edit->cursorPosition());
597 edit->validateAndSet(t, 0, 0, 0);
608 TQTextEdit *medit = ::tqt_cast<TQTextEdit *>(receiver);
612 TQKeyEvent *kevent =
static_cast<TQKeyEvent*
>(
event);
615 if (t == TQEvent::KeyPress)
627 if( t == TQEvent::Show && receiver->isWidgetType())
629 TQWidget* w =
static_cast<TQWidget*
>( receiver );
630 #if defined TQ_WS_X11
631 if( w->isTopLevel() && !
startupId().isEmpty() && !
static_cast<TQShowEvent*
>(
event)->spontaneous())
632 TDEStartupInfo::setWindowStartupId( w->winId(),
startupId());
634 if( w->isTopLevel() && !w->testWFlags( WX11BypassWM ) && !w->isPopup() && !
event->spontaneous())
636 if( d->app_started_timer == NULL )
638 d->app_started_timer =
new TQTimer(
this,
"app_started_timer" );
639 connect( d->app_started_timer, TQ_SIGNAL( timeout()), TQ_SLOT( checkAppStartedSlot()));
641 if( !d->app_started_timer->isActive())
642 d->app_started_timer->start( 0,
true );
644 if( w->isTopLevel() && ( w->icon() == NULL || w->icon()->isNull()))
647 static TQPixmap* ic = NULL;
654 #if defined TQ_WS_X11
660 return TQApplication::notify(receiver, event);
663 void TDEApplication::checkAppStartedSlot()
665 #if defined TQ_WS_X11
666 TDEStartupInfo::handleAutoAppStartedSending();
671 static TQPtrList<KSessionManaged>* sessionClients()
673 static TQPtrList<KSessionManaged>* session_clients = 0L;
674 if ( !session_clients )
675 session_clients =
new TQPtrList<KSessionManaged>;
676 return session_clients;
684 TQString TDEApplication::sessionConfigName()
const
686 TQString sessKey = sessionKey();
687 if ( sessKey.isEmpty() && !d->sessionKey.isEmpty() )
688 sessKey = d->sessionKey;
689 return TQString(
"session/%1_%2_%3").arg(
name()).arg(sessionId()).arg(sessKey);
693 static SmcConn mySmcConnection = 0;
694 static SmcConn tmpSmcConnection = 0;
699 static TQTime* smModificationTime = 0;
702 bool allowStyles,
bool GUIenabled,
bool SMenabled ) :
703 TQApplication( argc, argv, GUIenabled, SMenabled ),
TDEInstance(rAppName),
708 d (new TDEApplicationPrivate())
710 aIconPixmap.pm.icon = 0L;
711 aIconPixmap.pm.miniIcon = 0L;
712 read_app_startup_id();
715 useStyles = allowStyles;
716 Q_ASSERT (!rAppName.isEmpty());
720 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
730 bool allowStyles,
bool GUIenabled ) :
731 TQApplication( argc, argv, GUIenabled ),
TDEInstance(rAppName),
736 d (new TDEApplicationPrivate())
738 aIconPixmap.pm.icon = 0L;
739 aIconPixmap.pm.miniIcon = 0L;
740 read_app_startup_id();
743 useStyles = allowStyles;
744 Q_ASSERT (!rAppName.isEmpty());
748 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
761 d (new TDEApplicationPrivate)
763 aIconPixmap.pm.icon = 0L;
764 aIconPixmap.pm.miniIcon = 0L;
765 read_app_startup_id();
768 useStyles = allowStyles;
787 d (new TDEApplicationPrivate)
789 aIconPixmap.pm.icon = 0L;
790 aIconPixmap.pm.miniIcon = 0L;
791 read_app_startup_id();
794 useStyles = allowStyles;
806 getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ),
809 aIconPixmap.pm.icon = 0L;
810 aIconPixmap.pm.miniIcon = 0L;
811 read_app_startup_id();
812 useStyles = allowStyles;
822 disable_argb?visual:getX11RGBAVisual(dpy), disable_argb?colormap:getX11RGBAColormap(dpy) ),
825 aIconPixmap.pm.icon = 0L;
826 aIconPixmap.pm.miniIcon = 0L;
827 read_app_startup_id();
828 useStyles = allowStyles;
829 if (disable_argb) argb_visual =
false;
840 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
843 if ((visual) && (colormap))
844 getX11RGBAInformation(dpy);
845 aIconPixmap.pm.icon = 0L;
846 aIconPixmap.pm.miniIcon = 0L;
847 read_app_startup_id();
848 useStyles = allowStyles;
859 visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ),
860 TDEInstance( _instance ), display(0L), d (new TDEApplicationPrivate)
862 if ((visual) && (colormap))
863 getX11RGBAInformation(dpy);
864 aIconPixmap.pm.icon = 0L;
865 aIconPixmap.pm.miniIcon = 0L;
866 read_app_startup_id();
867 useStyles = allowStyles;
884 d (new TDEApplicationPrivate)
886 aIconPixmap.pm.icon = 0L;
887 aIconPixmap.pm.miniIcon = 0L;
888 read_app_startup_id();
891 useStyles = allowStyles;
902 bool allowStyles,
bool GUIenabled ) :
906 d (new TDEApplicationPrivate())
908 aIconPixmap.pm.icon = 0L;
909 aIconPixmap.pm.miniIcon = 0L;
910 read_app_startup_id();
913 useStyles = allowStyles;
915 Q_ASSERT (!rAppName.isEmpty());
919 TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
926 int TDEApplication::xioErrhandler( Display* dpy )
932 d->oldXIOErrorHandler( dpy );
941 int TDEApplication::xErrhandler( Display* dpy,
void* err_ )
944 XErrorEvent* err =
static_cast< XErrorEvent*
>( err_ );
948 d->oldXErrorHandler( dpy, err );
954 void TDEApplication::iceIOErrorHandler( _IceConn *conn )
959 if ( d->oldIceIOErrorHandler != NULL )
960 (*d->oldIceIOErrorHandler)( conn );
965 class KDETranslator :
public TQTranslator
968 KDETranslator(TQObject *parent) : TQTranslator(parent,
"kdetranslator") {}
969 virtual TQTranslatorMessage findMessage(
const char* context,
970 const char *sourceText,
971 const char* message)
const
973 TQTranslatorMessage res;
974 res.setTranslation(
TDEGlobal::locale()->translateQt(context, sourceText, message));
979 void TDEApplication::init(
bool GUIenabled)
981 d->guiEnabled = GUIenabled;
982 if ((getuid() != geteuid()) ||
983 (getgid() != getegid()) )
987 struct group *man = getgrnam(
"man");
988 if ( !man || man->gr_gid != getegid() ){
989 fprintf(stderr,
"The TDE libraries are not designed to run with suid privileges.\n");
998 TQApplication::setDesktopSettingsAware(
false );
1009 Atom atoms_return[max];
1012 atoms[n] = &kipcCommAtom;
1013 names[n++] = (
char *)
"KIPC_COMM_ATOM";
1015 atoms[n] = &atom_DesktopWindow;
1016 names[n++] = (
char *)
"KDE_DESKTOP_WINDOW";
1018 atoms[n] = &atom_NetSupported;
1019 names[n++] = (
char *)
"_NET_SUPPORTED";
1021 XInternAtoms( tqt_xdisplay(), names, n,
false, atoms_return );
1023 for (
int i = 0; i < n; i++ )
1024 *atoms[i] = atoms_return[i];
1028 dcopAutoRegistration();
1029 dcopClientPostInit();
1034 #if defined TQ_WS_X11
1035 kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) |
1036 (1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged) |
1037 (1 << KIPC::ToolbarStyleChanged) | (1 << KIPC::SettingsChanged) |
1045 d->actionRestrictions =
config->
hasGroup(
"KDE Action Restrictions" ) && !kde_kiosk_exception;
1050 TQCString readOnly = getenv(
"TDE_HOME_READONLY");
1051 if (readOnly.isEmpty() && (qstrcmp(
name(),
"kdialog") != 0))
1062 fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, FD_CLOEXEC);
1064 d->oldXErrorHandler = XSetErrorHandler( kde_x_errhandler );
1065 d->oldXIOErrorHandler = XSetIOErrorHandler( kde_xio_errhandler );
1068 connect(
this, TQ_SIGNAL( aboutToQuit() ),
this, TQ_SIGNAL(
shutDown() ) );
1071 display = desktop()->x11Display();
1076 TQStringList::Iterator it = plugins.begin();
1077 while (it != plugins.end()) {
1078 addLibraryPath( *it );
1083 tdedisplaySetStyle();
1084 tdedisplaySetFont();
1086 propagateSettings(SETTINGS_QT);
1096 TQMimeSourceFactory* oldDefaultFactory = TQMimeSourceFactory::takeDefaultFactory();
1098 if ( oldDefaultFactory ) {
1099 TQMimeSourceFactory::addFactory( oldDefaultFactory );
1102 d->checkAccelerators =
new KCheckAccelerators(
this );
1109 if (!pixmap.isNull()) {
1110 TQImage i = pixmap.convertToImage().convertDepth(32).smoothScale(40, 40);
1111 for(
int y = 0; y < i.height(); y++) {
1112 uchar *l = i.scanLine(y);
1113 for(
int x = 0; x < i.width(); x+=4)
1116 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
1117 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL,
1118 i.bits(), i.numBytes(), NULL);
1119 CGImageRef ir = CGImageCreate(i.width(), i.height(), 8, 32, i.bytesPerLine(),
1120 cs, kCGImageAlphaNoneSkipFirst, dp,
1121 0, 0, kCGRenderingIntentDefault);
1123 SetApplicationDockTileImage(ir);
1125 CGColorSpaceRelease(cs);
1126 CGDataProviderRelease(dp);
1134 bool rtl = reverseLayout();
1135 installTranslator(
new KDETranslator(
this));
1136 setReverseLayout( rtl );
1137 if (i18n(
"_: Dear Translator! Translate this string to the string 'LTR' in "
1138 "left-to-right languages (as english) or to 'RTL' in right-to-left "
1139 "languages (such as Hebrew and Arabic) to get proper widget layout." ) ==
"RTL")
1140 setReverseLayout( !rtl );
1144 + TQString::fromLatin1(
name()) +
'/');
1145 pSessionConfig = 0L;
1146 bSessionManagement =
true;
1150 if (GUIenabled && kde_have_kipc )
1152 smw =
new TQWidget(0,0);
1154 XChangeProperty(tqt_xdisplay(), smw->winId(),
1155 atom_DesktopWindow, atom_DesktopWindow,
1156 32, PropModeReplace, (
unsigned char *)&data, 1);
1158 d->oldIceIOErrorHandler = IceSetIOErrorHandler( kde_ice_ioerrorhandler );
1159 #elif defined(TQ_WS_WIN)
1160 TDEApplication_init_windows(GUIenabled);
1166 static int my_system (
const char *command) {
1173 const char* shell =
"/bin/sh";
1174 execl(shell, shell,
"-c", command, (
void *)0);
1178 if (waitpid(pid, &status, 0) == -1) {
1190 return s_DCOPClient;
1194 if (args && args->
isSet(
"dcopserver"))
1199 connect(s_DCOPClient, TQ_SIGNAL(attachFailed(
const TQString &)),
1200 kapp, TQ_SLOT(dcopFailure(
const TQString &)));
1201 connect(s_DCOPClient, TQ_SIGNAL(blockUserInput(
bool) ),
1202 kapp, TQ_SLOT(dcopBlockUserInput(
bool)) );
1205 s_dcopClientNeedsPostInit =
true;
1208 return s_DCOPClient;
1211 void TDEApplication::dcopClientPostInit()
1213 if( s_dcopClientNeedsPostInit )
1215 s_dcopClientNeedsPostInit =
false;
1216 connect(s_DCOPClient, TQ_SIGNAL(blockUserInput(
bool) ),
1217 TQ_SLOT(dcopBlockUserInput(
bool)) );
1218 s_DCOPClient->bindToApp();
1222 void TDEApplication::dcopAutoRegistration()
1224 if (autoDcopRegistration)
1234 autoDcopRegistration =
false;
1240 return pSessionConfig;
1243 pSessionConfig =
new TDEConfig( sessionConfigName(),
false,
false);
1244 return pSessionConfig;
1257 if ( d->refCount <= 0 )
1261 KSessionManaged::KSessionManaged()
1263 sessionClients()->remove(
this );
1264 sessionClients()->append(
this );
1267 KSessionManaged::~KSessionManaged()
1269 sessionClients()->remove(
this );
1284 bSessionManagement =
false;
1288 bSessionManagement =
true;
1299 if( mySmcConnection ) {
1300 SmcRequestSaveYourself( mySmcConnection, SmSaveLocal, False,
1305 IceFlush(SmcGetIceConnection(mySmcConnection));
1315 TQApplication::syncX();
1322 TQDataStream arg(data, IO_WriteOnly);
1323 arg << (int)confirm << (
int)sdtype << (int)sdmode;
1325 "logout(int,int,int)", data );
1328 if ( mySmcConnection ) {
1330 SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True,
1335 IceFlush(SmcGetIceConnection(mySmcConnection));
1342 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1343 if (smEnv.isEmpty())
1346 if (! tmpSmcConnection) {
1351 tmpSmcConnection = SmcOpenConnection( 0, 0, 1, 0,
1358 if (!tmpSmcConnection )
1362 SmcRequestSaveYourself( tmpSmcConnection, SmSaveBoth, True,
1363 SmInteractStyleAny, False, True );
1366 IceFlush(SmcGetIceConnection(tmpSmcConnection));
1377 TQCString fName = TQFile::encodeName(locateLocal(
"socket",
"KSMserver"));
1378 TQCString display = ::getenv(DISPLAY);
1380 display.replace(TQRegExp(
"\\.[0-9]+$"),
"");
1382 while( (i = display.find(
':')) >= 0)
1385 fName +=
"_"+display;
1386 TQCString smEnv = ::getenv(
"SESSION_MANAGER");
1387 bool check = smEnv.isEmpty();
1388 if ( !check && smModificationTime ) {
1389 TQFileInfo info( fName );
1390 TQTime current = info.lastModified().time();
1391 check = current > *smModificationTime;
1394 delete smModificationTime;
1396 if ( !f.open( IO_ReadOnly ) )
1398 TQFileInfo info ( f );
1399 smModificationTime =
new TQTime( info.lastModified().time() );
1401 t.setEncoding( TQTextStream::Latin1 );
1402 TQString s = t.readLine();
1404 ::setenv(
"SESSION_MANAGER", s.latin1(),
true );
1411 d->session_save =
true;
1412 bool canceled =
false;
1415 it = sessionClients()->next() ) {
1416 canceled = !it->commitData( sm );
1421 if ( sm.allowsInteraction() ) {
1423 TQWidgetList *list = TQApplication::topLevelWidgets();
1424 bool canceled =
false;
1425 TQWidget* w = list->first();
1426 while ( !canceled && w ) {
1427 if ( !w->testWState( WState_ForceHide ) && !w->inherits(
"TDEMainWindow") ) {
1430 canceled = !e.isAccepted();
1434 list = TQApplication::topLevelWidgets();
1439 while ( w && done.containsRef( w ) )
1446 if ( !bSessionManagement )
1447 sm.setRestartHint( TQSessionManager::RestartNever );
1449 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1450 d->session_save =
false;
1453 static void checkRestartVersion( TQSessionManager& sm )
1455 Display* dpy = tqt_xdisplay();
1458 unsigned long nitems, after;
1459 unsigned char* data;
1460 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_FULL_SESSION", False ),
1461 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1464 if( type == XA_STRING && format == 8 ) {
1465 if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy,
"TDE_SESSION_VERSION", False ),
1466 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) {
1477 TQStringList restartCommand = sm.restartCommand();
1478 restartCommand.prepend( wrapper );
1479 sm.setRestartCommand( restartCommand );
1484 d->session_save =
true;
1486 static bool firstTime =
true;
1487 mySmcConnection = (SmcConn) sm.handle();
1489 if ( !bSessionManagement ) {
1490 sm.setRestartHint( TQSessionManager::RestartNever );
1491 d->session_save =
false;
1495 sm.setRestartHint( TQSessionManager::RestartIfRunning );
1499 d->session_save =
false;
1509 if ( pSessionConfig ) {
1510 delete pSessionConfig;
1515 TQStringList restartCommand = sm.restartCommand();
1517 TQCString multiHead = getenv(
"TDE_MULTIHEAD");
1518 if (multiHead.lower() ==
"true") {
1525 TQCString displayname = getenv(DISPLAY);
1526 if (! displayname.isNull()) {
1529 restartCommand.append(
"-display");
1530 restartCommand.append(displayname);
1532 sm.setRestartCommand( restartCommand );
1535 checkRestartVersion( sm );
1539 bool canceled =
false;
1542 it = sessionClients()->next() ) {
1543 canceled = !it->saveState( sm );
1547 if ( pSessionConfig ) {
1548 pSessionConfig->
sync();
1549 TQStringList discard;
1550 discard <<
"rm" << locateLocal(
"config", sessionConfigName());
1551 sm.setDiscardCommand( discard );
1553 sm.setDiscardCommand( TQStringList(
"") );
1561 d->session_save =
false;
1566 return d->session_save;
1569 void TDEApplication::startKdeinit()
1573 TDELockFile lock( locateLocal(
"tmp",
"starttdeinitlock", &inst ));
1586 if (kapp && (Tty != kapp->type()))
1587 setOverrideCursor( TQt::waitCursor );
1588 my_system(TQFile::encodeName(srv)+
" --suicide"+
" --new-startup");
1589 if (kapp && (Tty != kapp->type()))
1590 restoreOverrideCursor();
1594 void TDEApplication::dcopFailure(
const TQString &msg)
1596 static int failureCount = 0;
1598 if (failureCount == 1)
1603 if (failureCount == 2)
1610 TQString msgStr(i18n(
"There was an error setting up inter-process "
1611 "communications for TDE. The message returned "
1612 "by the system was:\n\n"));
1614 msgStr += i18n(
"\n\nPlease check that the \"dcopserver\" program is running!");
1616 if (Tty != kapp->type())
1618 TQMessageBox::critical
1621 i18n(
"DCOP communications error (%1)").arg(kapp->caption()),
1628 fprintf(stderr,
"%s\n", msgStr.local8Bit().data());
1639 {
"display <displayname>",
I18N_NOOP(
"Use the X-server display 'displayname'"), 0},
1641 {
"display <displayname>",
I18N_NOOP(
"Use the QWS display 'displayname'"), 0},
1643 {
"session <sessionId>",
I18N_NOOP(
"Restore the application for the given 'sessionId'"), 0},
1644 {
"cmap",
I18N_NOOP(
"Causes the application to install a private color\nmap on an 8-bit display"), 0},
1645 {
"ncols <count>",
I18N_NOOP(
"Limits the number of colors allocated in the color\ncube on an 8-bit display, if the application is\nusing the TQApplication::ManyColor color\nspecification"), 0},
1646 {
"nograb",
I18N_NOOP(
"tells TQt to never grab the mouse or the keyboard"), 0},
1647 {
"dograb",
I18N_NOOP(
"running under a debugger can cause an implicit\n-nograb, use -dograb to override"), 0},
1648 {
"sync",
I18N_NOOP(
"switches to synchronous mode for debugging"), 0},
1650 {
"font <fontname>",
I18N_NOOP(
"defines the application font"), 0},
1652 {
"background <color>",
I18N_NOOP(
"sets the default background color and an\napplication palette (light and dark shades are\ncalculated)"), 0},
1654 {
"foreground <color>",
I18N_NOOP(
"sets the default foreground color"), 0},
1656 {
"button <color>",
I18N_NOOP(
"sets the default button color"), 0},
1657 {
"name <name>",
I18N_NOOP(
"sets the application name"), 0},
1658 {
"title <title>",
I18N_NOOP(
"sets the application title (caption)"), 0},
1660 {
"visual TrueColor",
I18N_NOOP(
"forces the application to use a TrueColor visual on\nan 8-bit display"), 0},
1661 {
"inputstyle <inputstyle>",
I18N_NOOP(
"sets XIM (X Input Method) input style. Possible\nvalues are onthespot, overthespot, offthespot and\nroot"), 0 },
1662 {
"im <XIM server>",
I18N_NOOP(
"set XIM server"),0},
1663 {
"noxim",
I18N_NOOP(
"disable XIM"), 0 },
1666 {
"qws",
I18N_NOOP(
"forces the application to run as QWS Server"), 0},
1668 {
"reverse",
I18N_NOOP(
"mirrors the whole layout of widgets"), 0},
1669 TDECmdLineLastOption
1674 {
"caption <caption>",
I18N_NOOP(
"Use 'caption' as name in the titlebar"), 0},
1675 {
"icon <icon>",
I18N_NOOP(
"Use 'icon' as the application icon"), 0},
1676 {
"miniicon <icon>",
I18N_NOOP(
"Use 'icon' as the icon in the titlebar"), 0},
1677 {
"config <filename>",
I18N_NOOP(
"Use alternative configuration file"), 0},
1678 {
"dcopserver <server>",
I18N_NOOP(
"Use the DCOP Server specified by 'server'"), 0},
1679 {
"nocrashhandler",
I18N_NOOP(
"Disable crash handler, to get core dumps"), 0},
1680 {
"waitforwm",
I18N_NOOP(
"Waits for a WM_NET compatible windowmanager"), 0},
1681 {
"style <style>",
I18N_NOOP(
"sets the application GUI style"), 0},
1682 {
"geometry <geometry>",
I18N_NOOP(
"sets the client geometry of the main widget - see man X for the argument format"), 0},
1683 {
"smkey <sessionKey>", 0, 0},
1686 TDECmdLineLastOption
1696 void TDEApplication::parseCommandLine( )
1700 if ( !args )
return;
1702 if (args->
isSet(
"config"))
1708 if (args->
isSet(
"style"))
1712 TQStringList::Iterator itp = plugins.begin();
1713 while (itp != plugins.end()) {
1714 addLibraryPath( *itp );
1718 TQStringList styles = TQStyleFactory::keys();
1719 TQString reqStyle(args->
getOption(
"style").lower());
1721 TQStringList list = libraryPaths();
1722 TQStringList::Iterator it = list.begin();
1723 while( it != list.end() ) {
1727 for (TQStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it) {
1728 if ((*it).lower() == reqStyle)
1730 d->overrideStyle = *it;
1735 if (d->overrideStyle.isEmpty())
1736 fprintf(stderr,
"%s", TQString(i18n(
"The style %1 was not found\n").arg(reqStyle)).local8Bit().data());
1739 if (args->
isSet(
"caption"))
1741 aCaption = TQString::fromLocal8Bit(args->
getOption(
"caption"));
1744 if (args->
isSet(
"miniicon"))
1746 const char *tmp = args->
getOption(
"miniicon");
1747 if (!aIconPixmap.pm.miniIcon) {
1748 aIconPixmap.pm.miniIcon =
new TQPixmap;
1750 *aIconPixmap.pm.miniIcon = SmallIcon(tmp);
1751 aMiniIconName = tmp;
1754 if (args->
isSet(
"icon"))
1756 const char *tmp = args->
getOption(
"icon");
1757 if (!aIconPixmap.pm.icon) {
1758 aIconPixmap.pm.icon =
new TQPixmap;
1760 *aIconPixmap.pm.icon = DesktopIcon( tmp );
1762 if (!aIconPixmap.pm.miniIcon) {
1763 aIconPixmap.pm.miniIcon =
new TQPixmap;
1765 if (aIconPixmap.pm.miniIcon->isNull())
1767 *aIconPixmap.pm.miniIcon = SmallIcon( tmp );
1768 aMiniIconName = tmp;
1772 bool nocrashhandler = (getenv(
"TDE_DEBUG") != NULL);
1773 if (!nocrashhandler && args->
isSet(
"crashhandler"))
1783 if ( args->
isSet(
"waitforwm" ) ) {
1787 unsigned long length, after;
1788 unsigned char *data;
1789 while ( XGetWindowProperty( tqt_xdisplay(), tqt_xrootwin(), atom_NetSupported,
1790 0, 1,
false, AnyPropertyType, &type, &format,
1791 &length, &after, &data ) != Success || !length ) {
1795 XWindowEvent( tqt_xdisplay(), tqt_xrootwin(), PropertyChangeMask, &event );
1804 if (args->
isSet(
"geometry"))
1806 d->geometry_arg = args->
getOption(
"geometry");
1809 if (args->
isSet(
"smkey"))
1811 d->sessionKey = args->
getOption(
"smkey");
1818 return d->geometry_arg;
1821 TQPixmap TDEApplication::icon()
const
1823 if( !aIconPixmap.pm.icon) {
1824 aIconPixmap.pm.icon =
new TQPixmap;
1826 if( aIconPixmap.pm.icon->isNull()) {
1829 return *aIconPixmap.pm.icon;
1834 return aIconName.isNull() ? (TQString)
instanceName() : aIconName;
1837 TQPixmap TDEApplication::miniIcon()
const
1839 if (!aIconPixmap.pm.miniIcon) {
1840 aIconPixmap.pm.miniIcon =
new TQPixmap;
1842 if (aIconPixmap.pm.miniIcon->isNull()) {
1843 *aIconPixmap.pm.miniIcon = SmallIcon(
instanceName() );
1845 return *aIconPixmap.pm.miniIcon;
1850 return aMiniIconName.isNull() ? (TQString)
instanceName() : aMiniIconName;
1853 extern void kDebugCleanup();
1855 TDEApplication::~TDEApplication()
1857 delete aIconPixmap.pm.miniIcon;
1858 aIconPixmap.pm.miniIcon = 0L;
1859 delete aIconPixmap.pm.icon;
1860 aIconPixmap.pm.icon = 0L;
1861 delete d->m_TDEAppDCOPInterface;
1867 KLibLoader::cleanUp();
1872 delete s_DCOPClient;
1878 if ( d->oldXErrorHandler != NULL )
1879 XSetErrorHandler( d->oldXErrorHandler );
1880 if ( d->oldXIOErrorHandler != NULL )
1881 XSetIOErrorHandler( d->oldXIOErrorHandler );
1882 if ( d->oldIceIOErrorHandler != NULL )
1883 IceSetIOErrorHandler( d->oldIceIOErrorHandler );
1890 mySmcConnection = 0;
1891 delete smModificationTime;
1892 smModificationTime = 0;
1895 if (tmpSmcConnection) {
1896 SmcCloseConnection( tmpSmcConnection, 0, 0 );
1897 tmpSmcConnection = 0;
1906 class KAppX11HackWidget:
public TQWidget
1909 bool publicx11Event( XEvent * e) {
return x11Event( e ); }
1913 #if defined(TQ_WS_X11) && defined(COMPOSITE)
1915 bool have_manager =
false;
1918 const char *pidfile =
"compton-tde.available";
1919 char uidstr[
sizeof(uid_t)*8+1];
1920 sprintf(uidstr,
"%d", getuid());
1921 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1922 filename = (
char*)malloc(n*
sizeof(
char)+1);
1923 memset(filename,0,n);
1924 strcat(filename, P_tmpdir);
1925 strcat(filename,
"/.");
1926 strcat(filename, uidstr);
1927 strcat(filename,
"-");
1928 strcat(filename, pidfile);
1932 pFile = fopen(filename,
"r");
1934 have_manager =
true;
1941 return have_manager;
1945 bool compositing_manager_available;
1946 if (force_available) {
1947 compositing_manager_available = available;
1952 char *displayname = 0;
1953 if ( qtargs->
isSet(
"display"))
1954 displayname = qtargs->
getOption(
"display" ).data();
1956 Display *dpy = XOpenDisplay( displayname );
1958 x11_composite_error_generated =
false;
1959 compositing_manager_available =
false;
1960 XSetErrorHandler(x11_error);
1961 if (!XQueryExtension (dpy, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) {
1962 XSetErrorHandler(NULL);
1963 compositing_manager_available =
false;
1967 Window root_window = XDefaultRootWindow(dpy);
1968 XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual);
1970 if (x11_composite_error_generated ==
true) {
1971 compositing_manager_available =
true;
1974 XCompositeUnredirectSubwindows(dpy, root_window, CompositeRedirectManual);
1975 compositing_manager_available =
false;
1977 XSetErrorHandler(NULL);
1981 compositing_manager_available =
true;
1987 const char *pidfile =
"compton-tde.available";
1988 char uidstr[
sizeof(uid_t)*8+1];
1989 sprintf(uidstr,
"%d", getuid());
1990 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
1991 filename = (
char*)malloc(n*
sizeof(
char)+1);
1992 memset(filename,0,n);
1993 strcat(filename, P_tmpdir);
1994 strcat(filename,
"/.");
1995 strcat(filename, uidstr);
1996 strcat(filename,
"-");
1997 strcat(filename, pidfile);
2000 if (compositing_manager_available) {
2003 sprintf(buffer,
"available");
2004 pFile = fopen(filename,
"w");
2006 fwrite(buffer,1,strlen(buffer), pFile);
2017 return compositing_manager_available;
2020 Display* TDEApplication::openX11RGBADisplay() {
2023 if ( qtargs->
isSet(
"display"))
2024 display = qtargs->
getOption(
"display" ).data();
2026 Display *dpy = XOpenDisplay( display );
2028 kdError() <<
"cannot connect to X server " << display <<
endl;
2036 getX11RGBAInformation(dpy);
2038 return argb_x11_visual;
2041 return (TQt::HANDLE)NULL;
2046 getX11RGBAInformation(dpy);
2048 return argb_x11_colormap;
2051 return (TQt::HANDLE)NULL;
2059 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2061 argb_visual =
false;
2065 int screen = DefaultScreen( dpy );
2066 Colormap colormap = 0;
2068 int event_base, error_base;
2070 if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) {
2073 templ.screen = screen;
2075 templ.c_class = TrueColor;
2076 XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
2077 | VisualClassMask, &templ, &nvi );
2079 for (
int i = 0; i < nvi; i++ ) {
2080 XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual );
2081 if ( format->type == PictTypeDirect && format->direct.alphaMask ) {
2082 visual = xvi[i].visual;
2083 colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone );
2084 kdDebug() <<
"[tdecore-tdeapplication] Found visual with alpha support" <<
endl;
2092 argb_x11_visual = TQt::HANDLE( visual );
2093 argb_x11_colormap = TQt::HANDLE( colormap );
2097 argb_visual =
false;
2101 void TDEApplication::getX11RGBAInformation(Display *dpy) {
2110 const char *pidfile =
"compton-tde.available";
2111 char uidstr[
sizeof(uid_t)*8+1];
2112 sprintf(uidstr,
"%d", getuid());
2113 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
2114 filename = (
char*)malloc(n*
sizeof(
char)+1);
2115 memset(filename,0,n);
2116 strcat(filename, P_tmpdir);
2117 strcat(filename,
"/.");
2118 strcat(filename, uidstr);
2119 strcat(filename,
"-");
2120 strcat(filename, pidfile);
2123 if (force_available) {
2126 sprintf(buffer,
"available");
2127 pFile = fopen(filename,
"w");
2129 fwrite(buffer,1,strlen(buffer), pFile);
2143 Display* TDEApplication::openX11RGBADisplay() {
2160 static bool kapp_block_user_input =
false;
2162 void TDEApplication::dcopBlockUserInput(
bool b )
2164 kapp_block_user_input = b;
2168 bool TDEApplication::x11EventFilter( XEvent *_event )
2170 if ( kapp_block_user_input ) {
2171 switch ( _event->type ) {
2186 for (TQWidget *w=x11Filter->first(); w; w=x11Filter->next()) {
2187 if (((KAppX11HackWidget*) w)->publicx11Event(_event))
2192 if ((_event->type == ClientMessage) &&
2193 (_event->xclient.message_type == kipcCommAtom))
2195 XClientMessageEvent *cme = (XClientMessageEvent *) _event;
2197 int id = cme->data.l[0];
2198 int arg = cme->data.l[1];
2199 if ((
id < 32) && (kipcEventMask & (1 << id)))
2203 case KIPC::StyleChanged:
2205 tdedisplaySetStyle();
2208 case KIPC::ToolbarStyleChanged:
2214 case KIPC::PaletteChanged:
2216 tdedisplaySetPalette();
2219 case KIPC::FontChanged:
2221 TDEGlobalSettings::rereadFontSettings();
2222 tdedisplaySetFont();
2225 case KIPC::BackgroundChanged:
2229 case KIPC::SettingsChanged:
2231 if (arg == SETTINGS_PATHS)
2232 TDEGlobalSettings::rereadPathSettings();
2233 else if (arg == SETTINGS_MOUSE)
2234 TDEGlobalSettings::rereadMouseSettings();
2238 case KIPC::IconChanged:
2239 TQPixmapCache::clear();
2242 emit updateIconLoaders();
2246 case KIPC::ClipboardConfigChanged:
2247 TDEClipboardSynchronizer::newConfiguration(arg);
2251 TDEGlobalAccel::blockShortcuts(arg);
2268 #if defined TQ_WS_X11
2269 Display *display = tqt_xdisplay();
2275 Window w = XCreateSimpleWindow( display, tqt_xrootwin(), 0, 0, 1, 1, 0, 0, 0 );
2276 XSelectInput( tqt_xdisplay(), w, PropertyChangeMask );
2277 unsigned char data[ 1 ];
2278 XChangeProperty( display, w, XA_ATOM, XA_ATOM, 8, PropModeAppend, data, 1 );
2280 XWindowEvent( display, w, PropertyChangeMask, &ev );
2281 time = ev.xproperty.time;
2282 XDestroyWindow( display, w );
2284 if( get_tqt_x_user_time() == 0
2286 set_tqt_x_user_time(time);
2292 #if defined TQ_WS_X11
2293 return get_tqt_x_user_time();
2301 #if defined TQ_WS_X11
2303 time = get_tqt_x_user_time();
2304 DCOPRef( dcopId,
"MainApplication-Interface" ).
call(
"updateUserTimestamp", time );
2310 TQObject *
object = focusWidget();
2314 TQMetaObject *meta =
object->metaObject();
2316 int idx = meta->findSlot( slot + 1,
true );
2320 object->tqt_invoke( idx, 0 );
2327 kdDebug(101) <<
"[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2330 kipcEventMask |= (1 << id);
2337 kdDebug(101) <<
"[tdecore-tdeapplication] Cannot use KIPC event mask for message IDs >= 32\n";
2340 kipcEventMask &= ~(1 << id);
2357 void TDEApplication::applyGUIStyle()
2359 if ( !useStyles )
return;
2362 TQString defaultStyle = TDEStyle::defaultStyle();
2363 TQString styleStr = pConfig.readEntry(
"widgetStyle", defaultStyle);
2365 if (d->overrideStyle.isEmpty()) {
2369 TQStyle* sp = TQStyleFactory::create( styleStr );
2372 if ( !sp && styleStr != defaultStyle)
2373 sp = TQStyleFactory::create( defaultStyle );
2375 sp = TQStyleFactory::create( *(TQStyleFactory::keys().begin()) );
2379 setStyle(d->overrideStyle);
2381 tdedisplaySetPalette();
2387 if( !aCaption.isNull() )
2404 bool withAppName,
bool modified )
const
2406 TQString s = userCaption.isEmpty() ?
caption() : userCaption;
2410 s += TQString::fromUtf8(
" [") + i18n(
"modified") + TQString::fromUtf8(
"]");
2412 if ( !userCaption.isEmpty() ) {
2415 if ( withAppName && !
caption().isNull() && !userCaption.endsWith(
caption()) )
2416 s += TQString::fromUtf8(
" - ") +
caption();
2431 TQColor trinity4Background( 239, 239, 239 );
2432 TQColor trinity4Blue( 103,141,178 );
2434 TQColor trinity4Button;
2435 if ( TQPixmap::defaultDepth() > 8 )
2436 trinity4Button.setRgb( 221, 223, 228 );
2438 trinity4Button.setRgb( 220, 220, 220 );
2440 TQColor trinity4Link( 0, 0, 238 );
2441 TQColor trinity4VisitedLink( 82, 24, 139 );
2454 int highlightVal, lowlightVal;
2455 highlightVal = 100 + (2*contrast_+4)*16/10;
2456 lowlightVal = 100 + (2*contrast_+4)*10;
2458 TQColor disfg = foreground;
2461 disfg.hsv( &h, &s, &v );
2464 disfg = disfg.dark(lowlightVal);
2465 else if (disfg != TQt::black)
2467 disfg = disfg.light(highlightVal);
2470 disfg = TQt::darkGray;
2473 TQColorGroup disabledgrp(disfg, background,
2474 background.light(highlightVal),
2475 background.dark(lowlightVal),
2476 background.dark(120),
2477 background.dark(120), base);
2479 TQColorGroup colgrp(foreground, background, background.light(highlightVal),
2480 background.dark(lowlightVal),
2481 background.dark(120),
2484 int inlowlightVal = lowlightVal-25;
2485 if(inlowlightVal < 120)
2486 inlowlightVal = 120;
2488 colgrp.setColor(TQColorGroup::Highlight, highlight);
2489 colgrp.setColor(TQColorGroup::HighlightedText, highlightedText);
2490 colgrp.setColor(TQColorGroup::Button, button);
2491 colgrp.setColor(TQColorGroup::ButtonText, buttonText);
2492 colgrp.setColor(TQColorGroup::Midlight, background.light(110));
2493 colgrp.setColor(TQColorGroup::Link, link);
2494 colgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2496 disabledgrp.setColor(TQColorGroup::Button, button);
2498 TQColor disbtntext = buttonText;
2499 disbtntext.hsv( &h, &s, &v );
2502 disbtntext = disbtntext.dark(lowlightVal);
2503 else if (disbtntext != TQt::black)
2505 disbtntext = disbtntext.light(highlightVal);
2508 disbtntext = TQt::darkGray;
2510 disabledgrp.setColor(TQColorGroup::ButtonText, disbtntext);
2511 disabledgrp.setColor(TQColorGroup::Midlight, background.light(110));
2512 disabledgrp.setColor(TQColorGroup::Highlight, highlight.dark(120));
2513 disabledgrp.setColor(TQColorGroup::Link, link);
2514 disabledgrp.setColor(TQColorGroup::LinkVisited, visitedLink);
2516 return TQPalette(colgrp, disabledgrp, colgrp);
2520 void TDEApplication::tdedisplaySetPalette()
2527 bool do_not_set_palette = FALSE;
2538 void TDEApplication::tdedisplaySetFont()
2546 TQStyleSheet* sheet = TQStyleSheet::defaultSheet();
2556 void TDEApplication::tdedisplaySetStyle()
2567 void TDEApplication::propagateSettings(SettingsCategory arg)
2572 #ifdef QT_HAVE_MAX_IMAGE_SIZE
2573 TQSize maxImageSize(4096, 4096);
2575 TQImage::setMaxImageSize(maxImageSize);
2579 if ((num != 0) && (num < 200))
2583 TQApplication::setCursorFlashTime(num);
2584 num =
config->
readNumEntry(
"DoubleClickInterval", TQApplication::doubleClickInterval());
2585 TQApplication::setDoubleClickInterval(num);
2587 TQApplication::setStartDragTime(num);
2589 TQApplication::setStartDragDistance(num);
2591 TQApplication::setWheelScrollLines(num);
2594 TQApplication::setEffectEnabled( TQt::UI_AnimateMenu, b);
2596 TQApplication::setEffectEnabled( TQt::UI_FadeMenu, b);
2598 TQApplication::setEffectEnabled( TQt::UI_AnimateCombo, b);
2600 TQApplication::setEffectEnabled( TQt::UI_AnimateTooltip, b);
2602 TQApplication::setEffectEnabled( TQt::UI_FadeTooltip, b);
2604 TQToolTip::setGloballyEnabled( b );
2612 static bool installed =
false;
2613 if (installed)
return;
2622 TQSqlPropertyMap *kdeMap =
new TQSqlPropertyMap;
2623 kdeMap->insert(
"KColorButton",
"color" );
2624 kdeMap->insert(
"KComboBox",
"currentItem" );
2625 kdeMap->insert(
"KDatePicker",
"date" );
2626 kdeMap->insert(
"KDateWidget",
"date" );
2627 kdeMap->insert(
"KDateTimeWidget",
"dateTime" );
2628 kdeMap->insert(
"KEditListBox",
"items" );
2629 kdeMap->insert(
"TDEFontCombo",
"family" );
2630 kdeMap->insert(
"TDEFontRequester",
"font" );
2631 kdeMap->insert(
"TDEFontChooser",
"font" );
2632 kdeMap->insert(
"KHistoryCombo",
"currentItem" );
2633 kdeMap->insert(
"TDEListBox",
"currentItem" );
2634 kdeMap->insert(
"KLineEdit",
"text" );
2635 kdeMap->insert(
"KRestrictedLine",
"text" );
2636 kdeMap->insert(
"KSqueezedTextLabel",
"text" );
2637 kdeMap->insert(
"KTextBrowser",
"source" );
2638 kdeMap->insert(
"KTextEdit",
"text" );
2639 kdeMap->insert(
"KURLRequester",
"url" );
2640 kdeMap->insert(
"KPasswordEdit",
"password" );
2641 kdeMap->insert(
"KIntNumInput",
"value" );
2642 kdeMap->insert(
"KIntSpinBox",
"value" );
2643 kdeMap->insert(
"KDoubleNumInput",
"value" );
2645 kdeMap->insert(
"TQGroupBox",
"checked" );
2646 kdeMap->insert(
"TQTabWidget",
"currentPage" );
2647 TQSqlPropertyMap::installDefaultMap( kdeMap );
2652 const TQString& _appname)
const
2661 const TQString& _appname,
2662 const TQCString& startup_id )
const
2666 if (_appname.isEmpty())
2671 if (!anchor.isEmpty())
2672 url = TQString(
"help:/%1?anchor=%2").arg(appname).arg(anchor);
2674 url = TQString(
"help:/%1/index.html").arg(appname);
2677 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2681 if (Tty != kapp->type())
2682 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Help Center"),
2683 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2685 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2690 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url, startup_id );
2696 kdWarning() <<
"invoking HTML help is deprecated! use docbook and invokeHelp!\n";
2700 if( _filename.isEmpty() )
2701 filename = TQString(name()) +
"/index.html";
2703 filename = _filename;
2706 if (!topic.isEmpty())
2707 url = TQString(
"help:/%1#%2").arg(filename).arg(topic);
2709 url = TQString(
"help:/%1").arg(filename);
2712 if ( !
dcopClient()->isApplicationRegistered(
"khelpcenter") )
2716 if (Tty != kapp->type())
2717 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Help Center"),
2718 i18n(
"Could not launch the TDE Help Center:\n\n%1").arg(error), i18n(
"&OK"));
2720 kdWarning() <<
"Could not launch help:\n" << error <<
endl;
2725 DCOPRef(
"khelpcenter",
"KHelpCenterIface" ).
send(
"openUrl", url );
2736 invokeMailer(address, TQString::null, TQString::null, subject, TQString::null, TQString::null,
2737 TQStringList(), startup_id );
2753 TQStringList queries = TQStringList::split(
'&', mailtoURL.
query().mid(1));
2754 TQStringList attachURLs;
2755 for (TQStringList::Iterator it = queries.begin(); it != queries.end(); ++it)
2757 TQString q = (*it).lower();
2758 if (q.startsWith(
"subject="))
2761 if (q.startsWith(
"cc="))
2764 if (q.startsWith(
"bcc="))
2767 if (q.startsWith(
"body="))
2770 if (allowAttachments && q.startsWith(
"attach="))
2773 if (allowAttachments && q.startsWith(
"attachment="))
2776 if (q.startsWith(
"to="))
2780 invokeMailer( address, cc, bcc, subject, body, TQString::null, attachURLs, startup_id );
2784 const TQString &subject,
const TQString &body,
2785 const TQString & messageFile,
const TQStringList &attachURLs)
2787 return invokeMailer(to,cc,bcc,subject,body,messageFile,attachURLs,
"");
2794 static TQStringList splitEmailAddressList(
const TQString & aStr )
2812 int commentlevel = 0;
2813 bool insidequote =
false;
2815 for (uint index=0; index<aStr.length(); index++) {
2818 switch (aStr[index].latin1()) {
2820 if (commentlevel == 0)
2821 insidequote = !insidequote;
2829 if (commentlevel > 0)
2842 if (!insidequote && (commentlevel == 0)) {
2843 addr = aStr.mid(addrstart, index-addrstart);
2844 if (!addr.isEmpty())
2845 list += addr.simplifyWhiteSpace();
2846 addrstart = index+1;
2852 if (!insidequote && (commentlevel == 0)) {
2853 addr = aStr.mid(addrstart, aStr.length()-addrstart);
2854 if (!addr.isEmpty())
2855 list += addr.simplifyWhiteSpace();
2866 const TQString &subject,
const TQString &body,
2867 const TQString & ,
const TQStringList &attachURLs,
2868 const TQCString& startup_id )
2878 TQString to, cc, bcc;
2879 if (command.isEmpty() || command == TQString::fromLatin1(
"kmail")
2880 || command.endsWith(
"/kmail"))
2882 command = TQString::fromLatin1(
"kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t");
2883 if ( !_to.isEmpty() )
2887 to = TQString(
"=?utf8?b?%1?=" )
2890 if ( !_cc.isEmpty() )
2891 cc = TQString(
"=?utf8?b?%1?=" )
2893 if ( !_bcc.isEmpty() )
2894 bcc = TQString(
"=?utf8?b?%1?=" )
2900 if( !command.contains(
'%' ))
2907 TQString preferredTerminal = confGroup.readPathEntry(
"TerminalApplication",
"konsole");
2908 command = preferredTerminal +
" -e " + command;
2912 TQString cmd = cmdTokens[0];
2913 cmdTokens.remove(cmdTokens.begin());
2919 TQStringList tos = splitEmailAddressList( to );
2921 tos.remove( tos.begin() );
2922 for (TQStringList::ConstIterator it = tos.begin(); it != tos.end(); ++it)
2925 const TQStringList ccs = splitEmailAddressList( cc );
2926 for (TQStringList::ConstIterator it = ccs.begin(); it != ccs.end(); ++it)
2928 const TQStringList bccs = splitEmailAddressList( bcc );
2929 for (TQStringList::ConstIterator it = bccs.begin(); it != bccs.end(); ++it)
2931 for (TQStringList::ConstIterator it = attachURLs.begin(); it != attachURLs.end(); ++it)
2933 if (!subject.isEmpty())
2935 if (!body.isEmpty())
2938 if ( ! (to.isEmpty() && qry.isEmpty()) )
2941 TQMap<TQChar, TQString> keyMap;
2942 keyMap.insert(
't', to);
2943 keyMap.insert(
's', subject);
2944 keyMap.insert(
'c', cc);
2945 keyMap.insert(
'b', bcc);
2946 keyMap.insert(
'B', body);
2947 keyMap.insert(
'u', url.
url());
2949 TQString attachlist = attachURLs.join(
",");
2950 attachlist.prepend(
'\'');
2951 attachlist.append(
'\'');
2952 keyMap.insert(
'A', attachlist);
2954 for (TQStringList::Iterator it = cmdTokens.begin(); it != cmdTokens.end(); )
2958 if (it == cmdTokens.begin())
2960 TQStringList::ConstIterator urlit = attachURLs.begin();
2961 TQStringList::ConstIterator urlend = attachURLs.end();
2962 if ( urlit != urlend )
2964 TQStringList::Iterator previt = it;
2968 while ( ++urlit != urlend )
2970 cmdTokens.insert( it, *previt );
2971 cmdTokens.insert( it, *urlit );
2975 it = cmdTokens.remove( cmdTokens.remove( it ) );
2986 if (
tdeinitExec(cmd, cmdTokens, &error, NULL, startup_id )) {
2987 if (Tty != kapp->type()) {
2988 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Mail Client"),
2989 i18n(
"Could not launch the mail client:\n\n%1").arg(error), i18n(
"&OK"));
2992 kdWarning() <<
"Could not launch mail client:\n" << error <<
endl;
3012 if (Tty != kapp->type())
3013 TQMessageBox::critical(kapp->mainWidget(), i18n(
"Could not Launch Browser"),
3014 i18n(
"Could not launch the browser:\n\n%1").arg(error), i18n(
"&OK"));
3016 kdWarning() <<
"Could not launch browser:\n" << error <<
endl;
3049 emit coreFakeKeyPress(keyCode);
3055 return "tdelauncher";
3059 startServiceInternal(
const TQCString &
function,
3060 const TQString& _name,
const TQStringList &URLs,
3061 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3063 struct serviceResult
3074 dcopClient = kapp->dcopClient();
3080 if (!dcopClient->
attach())
3083 *error =
i18n(
"Could not register with DCOP.\n");
3091 TQDataStream stream(params, IO_WriteOnly);
3092 stream << _name << URLs;
3093 TQCString replyType;
3094 TQByteArray replyData;
3096 TQValueList<TQCString> envs;
3098 if (tqt_xdisplay()) {
3099 TQCString dpystring(XDisplayString(tqt_xdisplay()));
3100 envs.append( TQCString(
"DISPLAY=") + dpystring );
3101 }
else if( getenv(
"DISPLAY" )) {
3102 TQCString dpystring( getenv(
"DISPLAY" ));
3103 envs.append( TQCString(
"DISPLAY=") + dpystring );
3107 #if defined TQ_WS_X11
3109 stream << ( startup_id.isEmpty() ? TDEStartupInfo::createNewStartupId() : startup_id );
3111 if(
function.left( 12 ) !=
"tdeinit_exec" )
3114 if (!dcopClient->
call(_launcher, _launcher,
3115 function, params, replyType, replyData))
3118 *error =
i18n(
"TDELauncher could not be reached via DCOP.\n");
3129 TQDataStream stream2(replyData, IO_ReadOnly);
3130 serviceResult result;
3131 stream2 >> result.result >> result.dcopName >> result.error >> result.pid;
3133 *dcopService = result.dcopName;
3135 *error = result.error;
3138 return result.result;
3143 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3148 return startServiceInternal(
3149 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3150 _name, URLs, error, dcopService, pid, startup_id, noWait);
3155 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3157 return startServiceInternal(
3158 "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3159 _name, URLs, error, dcopService, pid, startup_id, noWait);
3164 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3169 return startServiceInternal(
3170 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3171 _name, URLs, error, dcopService, pid, startup_id, noWait);
3176 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3178 return startServiceInternal(
3179 "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3180 _name, URLs, error, dcopService, pid, startup_id, noWait);
3185 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3190 return startServiceInternal(
3191 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3192 _name, URLs, error, dcopService, pid, startup_id, noWait);
3197 TQString *error, TQCString *dcopService,
int *pid,
const TQCString& startup_id,
bool noWait )
3199 return startServiceInternal(
3200 "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)",
3201 _name, URLs, error, dcopService, pid, startup_id, noWait);
3206 TQString *error,
int *pid )
3213 TQString *error,
int *pid,
const TQCString& startup_id )
3215 return startServiceInternal(
"tdeinit_exec(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3216 name, args, error, 0, pid, startup_id,
false);
3221 TQString *error,
int *pid )
3228 TQString *error,
int *pid,
const TQCString& startup_id )
3230 return startServiceInternal(
"tdeinit_exec_wait(TQString,TQStringList,TQValueList<TQCString>,TQCString)",
3231 name, args, error, 0, pid, startup_id,
false);
3238 if( TQDir::isRelativePath(pFilename) )
3240 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3241 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3244 aFilename = pFilename;
3246 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3247 if( !aAutosaveDir.exists() )
3249 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3256 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3263 bool& bRecover )
const
3267 if( TQDir::isRelativePath(pFilename) )
3269 kdWarning(101) <<
"Relative filename passed to TDEApplication::tempSaveName" <<
endl;
3270 aFilename = TQFileInfo( TQDir(
"." ), pFilename ).absFilePath();
3273 aFilename = pFilename;
3275 TQDir aAutosaveDir( TQDir::homeDirPath() +
"/autosave/" );
3276 if( !aAutosaveDir.exists() )
3278 if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
3285 aFilename.replace(
"/",
"\\!" ).prepend(
"#" ).append(
"#" ).prepend(
"/" ).prepend( aAutosaveDir.absPath() );
3287 if( TQFile( aFilename ).exists() )
3302 int accessOK = access( TQFile::encodeName(pathname), mode );
3303 if ( accessOK == 0 )
3309 if ( (mode & W_OK) == 0 )
3313 if (!access( TQFile::encodeName(pathname), F_OK))
3317 TQString dirName(pathname);
3318 int pos = dirName.findRev(
'/');
3321 else if ( pos == 0 )
3324 dirName.truncate(pos);
3326 accessOK = access( TQFile::encodeName(dirName), W_OK );
3328 if ( accessOK == 0 )
3340 if ( !topWidget->inherits(
"TDEMainWindow") ) {
3341 topWidget->setCaption(
caption() );
3345 topWidget->setIcon( icon() );
3346 #if defined TQ_WS_X11
3351 TDEStartupInfo::setWindowStartupId( topWidget->winId(),
startupId());
3357 return d->startup_id;
3360 void TDEApplication::setStartupId(
const TQCString& startup_id )
3362 if( startup_id == d->startup_id )
3364 #if defined TQ_WS_X11
3365 TDEStartupInfo::handleAutoAppStartedSending();
3367 if( startup_id.isEmpty())
3368 d->startup_id =
"0";
3371 d->startup_id = startup_id;
3372 #if defined TQ_WS_X11
3373 TDEStartupInfoId id;
3374 id.initId( startup_id );
3375 long timestamp =
id.timestamp();
3376 if( timestamp != 0 )
3384 void TDEApplication::read_app_startup_id()
3386 #if defined TQ_WS_X11
3387 TDEStartupInfoId
id = TDEStartupInfo::currentStartupIdEnv();
3388 TDEStartupInfo::resetStartupEnv();
3389 d->startup_id =
id.id();
3395 static bool init =
false;
3400 int fd = open(
"/dev/urandom", O_RDONLY);
3401 if (fd < 0 || ::read(fd, &seed,
sizeof(seed)) !=
sizeof(seed))
3405 seed = rand()+time(0);
3407 if (fd >= 0) close(fd);
3415 if (length <=0 )
return TQString::null;
3417 TQString str; str.setLength( length );
3433 if (!d->actionRestrictions)
3443 if (!d->actionRestrictions || !action)
3448 return authorize(action_prefix + action);
3453 if (menuId.isEmpty() || kde_kiosk_exception)
3464 TQStringList result;
3465 for(TQStringList::ConstIterator it = menuIds.begin();
3466 it != menuIds.end(); ++it)
3474 void TDEApplication::initUrlActionRestrictions()
3476 d->urlActionRestrictions.setAutoDelete(
true);
3477 d->urlActionRestrictions.clear();
3478 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3479 (
"open", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3480 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3481 (
"list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3487 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3488 (
"link", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3489 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3490 (
"redirect", TQString::null, TQString::null, TQString::null,
":internet", TQString::null, TQString::null,
true));
3494 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3495 (
"redirect", TQString::null, TQString::null, TQString::null,
"file", TQString::null, TQString::null,
true));
3496 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3497 (
"redirect",
":internet", TQString::null, TQString::null,
"file", TQString::null, TQString::null,
false));
3500 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3501 (
"redirect",
":local", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null,
true));
3504 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3505 (
"redirect", TQString::null, TQString::null, TQString::null,
"about", TQString::null, TQString::null,
true));
3508 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3509 (
"redirect", TQString::null, TQString::null, TQString::null,
"=", TQString::null, TQString::null,
true));
3514 TQString keyFormat = TQString(
"rule_%1");
3515 for(
int i = 1; i <= count; i++)
3517 TQString key = keyFormat.arg(i);
3519 if (rule.count() != 8)
3521 TQString action = rule[0];
3522 TQString refProt = rule[1];
3523 TQString refHost = rule[2];
3524 TQString refPath = rule[3];
3525 TQString urlProt = rule[4];
3526 TQString urlHost = rule[5];
3527 TQString urlPath = rule[6];
3528 TQString strEnabled = rule[7].lower();
3530 bool bEnabled = (strEnabled ==
"true");
3532 if (refPath.startsWith(
"$HOME"))
3533 refPath.replace(0, 5, TQDir::homeDirPath());
3534 else if (refPath.startsWith(
"~"))
3535 refPath.replace(0, 1, TQDir::homeDirPath());
3536 if (urlPath.startsWith(
"$HOME"))
3537 urlPath.replace(0, 5, TQDir::homeDirPath());
3538 else if (urlPath.startsWith(
"~"))
3539 urlPath.replace(0, 1, TQDir::homeDirPath());
3541 if (refPath.startsWith(
"$TMP"))
3543 if (urlPath.startsWith(
"$TMP"))
3546 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3547 ( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
3556 d->urlActionRestrictions.append(
new TDEApplicationPrivate::URLActionRule
3566 bool result =
false;
3567 if (d->urlActionRestrictions.isEmpty())
3568 initUrlActionRestrictions();
3570 KURL baseURL(_baseURL);
3571 baseURL.
setPath(TQDir::cleanDirPath(baseURL.
path()));
3572 TQString baseClass = KProtocolInfo::protocolClass(baseURL.
protocol());
3573 KURL destURL(_destURL);
3574 destURL.
setPath(TQDir::cleanDirPath(destURL.
path()));
3575 TQString destClass = KProtocolInfo::protocolClass(destURL.
protocol());
3577 for(TDEApplicationPrivate::URLActionRule *rule = d->urlActionRestrictions.first();
3578 rule; rule = d->urlActionRestrictions.next())
3580 if ((result != rule->permission) &&
3581 (action == rule->action) &&
3582 rule->baseMatch(baseURL, baseClass) &&
3583 rule->destMatch(destURL, destClass, baseURL, baseClass))
3585 result = rule->permission;
3597 int root_x, root_y, win_x, win_y;
3599 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3600 &root_x, &root_y, &win_x, &win_y, &keybstate );
3601 return keybstate & 0x00ff;
3602 #elif defined W_WS_MACX
3603 return GetCurrentEventKeyModifiers() & 0x00ff;
3616 int root_x, root_y, win_x, win_y;
3617 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3618 &root_x, &root_y, &win_x, &win_y, &mousestate );
3619 #elif defined(TQ_WS_WIN)
3620 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3621 if (GetAsyncKeyState(VK_LBUTTON))
3622 mousestate |= (mousebtn_swapped ? Button3Mask : Button1Mask);
3623 if (GetAsyncKeyState(VK_MBUTTON))
3624 mousestate |= Button2Mask;
3625 if (GetAsyncKeyState(VK_RBUTTON))
3626 mousestate |= (mousebtn_swapped ? Button1Mask : Button3Mask);
3627 #elif defined(TQ_WS_MACX)
3628 mousestate = GetCurrentEventButtonState();
3632 return mousestate & 0xff00;
3641 int root_x, root_y, win_x, win_y;
3643 XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
3644 &root_x, &root_y, &win_x, &win_y, &state );
3646 if( state & Button1Mask )
3648 if( state & Button2Mask )
3650 if( state & Button3Mask )
3652 if( state & ShiftMask )
3654 if( state & ControlMask )
3655 ret |= ControlButton;
3656 if( state & KKeyNative::modX( KKey::ALT ))
3658 if( state & KKeyNative::modX( KKey::WIN ))
3660 #elif defined(TQ_WS_WIN)
3661 const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON);
3662 if (GetAsyncKeyState(VK_LBUTTON))
3663 ret |= (mousebtn_swapped ? RightButton : LeftButton);
3664 if (GetAsyncKeyState(VK_MBUTTON))
3666 if (GetAsyncKeyState(VK_RBUTTON))
3667 ret |= (mousebtn_swapped ? LeftButton : RightButton);
3668 if (GetAsyncKeyState(VK_SHIFT))
3670 if (GetAsyncKeyState(VK_CONTROL))
3671 ret |= ControlButton;
3672 if (GetAsyncKeyState(VK_MENU))
3674 if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN))
3679 return static_cast< ButtonState
>( ret );
3682 #if defined TQ_WS_X11
3685 return get_x_vtnum(TQPaintDevice::x11AppDisplay());
3697 struct sigaction act;
3698 act.sa_handler = SIG_IGN;
3699 sigemptyset( &act.sa_mask );
3701 sigaction( SIGPIPE, &act, 0 );
3705 void TDEApplication::sigpipeHandler(
int)
3707 int saved_errno = errno;
3711 sprintf(msg,
"*** SIGPIPE *** (ignored, pid = %ld)\n", (
long) getpid());
3712 if (write(2, msg, strlen(msg)) < 0) {
3718 errno = saved_errno;
3721 bool TDEApplication::guiEnabled()
3723 return kapp && kapp->d->guiEnabled;
3726 void TDEApplication::virtual_hook(
int id,
void* data )
3727 { TDEInstance::virtual_hook(
id, data ); }
3729 void KSessionManaged::virtual_hook(
int,
void* )
3732 #include "tdeapplication.moc"
bool send(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data)
bool call(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, bool useEventLoop, int timeout, bool forceRemote)
static void setMainClient(DCOPClient *mainClient)
static void setServerAddress(const TQCString &addr)
TQCString registerAs(const TQCString &appId, bool addPID=true)
DCOPReply call(const TQCString &fun)
bool send(const TQCString &fun)
static TQCString base64Encode(const TQByteArray &in, bool insertLFs=false)
Encodes the given data using the base64 algorithm.
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Provides highlevel access to session management on a per-object base.
virtual bool saveState(TQSessionManager &sm)
See TQApplication::saveState() for documentation.
virtual bool commitData(TQSessionManager &sm)
See TQApplication::commitData() for documentation.
Represents and parses a URL.
TQString path() const
Returns the current decoded path.
TQString query() const
Returns the encoded query of the URL.
static TQString encode_string(const TQString &str, int encoding_hint=0)
Encodes a string for use in URLs.
void setPath(const TQString &path)
Sets the decoded path of the URL.
TQString protocol() const
Returns the protocol for the URL.
bool isEmpty() const
Tests if the KURL is empty.
void setQuery(const TQString &_txt, int encoding_hint=0)
Sets the encoded query of the URL.
TQString url(int _trailing=0, int encoding_hint=0) const
Returns the URL as string, with all escape sequences intact, encoded in a given charset.
TQString host() const
Returns the decoded hostname included in the URL.
static TQString decode_string(const TQString &str, int encoding_hint=0)
Decodes a string as used in URLs.
void setProtocol(const TQString &_txt)
Sets the protocol for the URL.
static void setIcons(WId win, const TQPixmap &icon, const TQPixmap &miniIcon)
Sets an icon and a miniIcon on window win.
static int timestampCompare(unsigned long time1, unsigned long time2)
Compares two X timestamps, taking into account wrapping and 64bit architectures.
TQString programName() const
Returns the translated program name.
This is the main interface to the TDEApplication.
Controls and provides information to all KDE applications.
static TDEApplication * KApp
Current application object.
TQt::HANDLE getX11RGBAVisual(Display *dpy)
Returns the X11 display visual.
void invokeHTMLHelp(const TQString &aFilename, const TQString &aTopic=TQString::null) const TDE_DEPRECATED
bool authorize(const TQString &genericAction)
Returns whether a certain action is authorized.
TQString caption() const
Returns a text for the window caption.
void appearanceChanged()
Emitted when TDEApplication has changed either its GUI style, its font or its palette in response to ...
void copy()
If the widget with focus provides a copy() slot, call that slot.
void settingsChanged(int category)
Emitted when the global settings have been changed - see TDEGlobalSettings TDEApplication takes care ...
static int startServiceByName(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
Starts a service based on the (translated) name of the service.
static void installSigpipeHandler()
Installs a handler for the SIGPIPE signal.
ShutdownType
The possible values for the sdtype parameter of requestShutDown().
@ ShutdownTypeDefault
Select previous action or the default if it's the first time.
void addKipcEventMask(int id)
Adds a message type to the KIPC event mask.
void tdedisplayStyleChanged()
Emitted when TDEApplication has changed its GUI style in response to a KControl request.
TQCString startupId() const
Returns the app startup notification identifier for this running application.
void removeX11EventFilter(const TQWidget *filter)
Removes global X11 event filter previously installed by installX11EventFilter().
ShutdownMode
The possible values for the sdmode parameter of requestShutDown().
@ ShutdownModeDefault
Select previous mode or the default if it's the first time.
TDEApplication(bool allowStyles=true, bool GUIenabled=true, bool SMenabled=true)
This constructor takes aboutData and command line arguments from TDECmdLineArgs.
void installX11EventFilter(TQWidget *filter)
Installs widget filter as global X11 event filter.
void propagateSessionManager()
Propagates the network address of the session manager in the SESSION_MANAGER environment variable so ...
static uint mouseState() TDE_DEPRECATED
static int tdeinitExec(const TQString &name, const TQStringList &args, TQString *error, int *pid, const TQCString &startup_id)
Starts a program via tdeinit.
bool detectCompositionManagerAvailable(bool force_available=false, bool available=true)
Detects the availability of a composition manager such as kompmgr Note that calling this method will ...
bool authorizeURLAction(const TQString &action, const KURL &baseURL, const KURL &destURL)
Returns whether a certain URL related action is authorized.
void toolbarAppearanceChanged(int)
Emitted when the settings for toolbars have been changed.
static TQCString launcher()
Returns the DCOP name of the service launcher.
void tdedisplayPaletteChanged()
Emitted when TDEApplication has changed its palette due to a KControl request.
bool isX11CompositionAvailable()
Returns whether or not X11 composition is available.
void disableSessionManagement()
Disables session management for this application.
static int random()
Generates a uniform random number.
void shutDown()
Your application is killed.
void invokeBrowser(const TQString &url, const TQCString &startup_id)
Invokes the standard browser.
static uint keyboardModifiers() TDE_DEPRECATED
TQString makeStdCaption(const TQString &userCaption, bool withAppName=true, bool modified=false) const
Builds a caption that contains the application name along with the userCaption using a standard layou...
void broadcastKeyCode(unsigned int keyCode)
Broadcast a received keycode to all listening KDE applications The primary use for this feature is to...
void invokeMailer(const TQString &address, const TQString &subject, const TQCString &startup_id)
Convenience method; invokes the standard email application.
void enableSessionManagement()
Enables again session management for this application, formerly disabled by calling disableSessionMan...
void installKDEPropertyMap()
Install a Qt SQL property map with entries for all KDE widgets Call this in any application using KDE...
void paste()
If the widget with focus provides a paste() slot, call that slot.
void commitData(TQSessionManager &sm)
Reimplemented for internal purposes, mainly the highlevel handling of session management with KSessio...
static TQString randomString(int length)
Generates a random string.
static ButtonState keyboardMouseState()
Returns the state of the currently pressed keyboard modifiers (e.g.
void allowURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL)
Allow a certain URL action.
TQStringList authorizeControlModules(const TQStringList &menuIds)
Returns whether access to a certain control modules is authorized.
static int startServiceByDesktopPath(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
Starts a service based on the desktop path of the service.
TQString iconName() const
Returns the name of the application icon.
void tdedisplayFontChanged()
Emitted when TDEApplication has changed its font in response to a KControl request.
void invokeHelp(const TQString &anchor, const TQString &appname, const TQCString &startup_id) const
Invokes the KHelpCenter HTML help viewer from docbook sources.
static int currentX11VT()
Returns the VT that the current X server is running on, or -1 if this information is unavailable.
void deref()
Tells TDEApplication that one operation such as those described in ref() just finished.
bool sessionSaving() const
Returns true if the application is currently saving its session data (most probably before KDE logout...
void ref()
Tells TDEApplication about one more operation that should be finished before the application exits.
bool authorizeControlModule(const TQString &menuId)
Returns whether access to a certain control module is authorized.
void kipcMessage(int id, int data)
Emitted when a KIPC user message has been received.
void backgroundChanged(int desk)
Emitted when the desktop background has been changed by kcmdisplay.
void updateUserTimestamp(unsigned long time=0)
Updates the last user action timestamp to the given time, or to the current time, if 0 is given.
TQString checkRecoverFile(const TQString &pFilename, bool &bRecover) const
Check whether an auto-save file exists for the document you want to open.
TDEConfig * sessionConfig()
Returns the application session config object.
void clear()
If the widget with focus provides a clear() slot, call that slot.
TQString miniIconName() const
Returns the name of the mini-icon for the application.
void setTopWidget(TQWidget *topWidget)
Sets the top widget of the application.
static TQPalette createApplicationPalette()
Used to obtain the TQPalette that will be used to set the application palette.
bool authorizeTDEAction(const char *action)
Returns whether a certain TDEAction is authorized.
TQString geometryArgument() const
Returns the argument to –geometry if any, so the geometry can be set wherever necessary.
void saveState(TQSessionManager &sm)
Reimplemented for internal purposes, mainly the highlevel handling of session management with KSessio...
void invokeEditSlot(const char *slot)
This method is used internally to determine which edit slots are implemented by the widget that has t...
void cut()
If the widget with focus provides a cut() slot, call that slot.
SettingsCategory
Valid values for the settingsChanged signal.
void updateRemoteUserTimestamp(const TQCString &dcopId, unsigned long time=0)
Updates the last user action timestamp in the application registered to DCOP with dcopId to the given...
void iconChanged(int group)
Emitted when the global icon settings have been changed.
void disableStyles()
Disables style plugins.
void selectAll()
If the widget with focus provides a selectAll() slot, call that slot.
ShutdownConfirm
The possible values for the confirm parameter of requestShutDown().
@ ShutdownConfirmYes
Always confirm, ask even if the user turned it off.
@ ShutdownConfirmNo
Don't confirm, shutdown without asking.
static int tdeinitExecWait(const TQString &name, const TQStringList &args, TQString *error, int *pid, const TQCString &startup_id)
Starts a program via tdeinit and wait for it to finish.
static void addCmdLineOptions()
Add Qt and KDE command line options to TDECmdLineArgs.
static int startServiceByDesktopName(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
Starts a service based on the desktop name of the service.
unsigned long userTimestamp() const
Returns the last user action timestamp or 0 if no user activity has taken place yet.
TQt::HANDLE getX11RGBAColormap(Display *dpy)
Returns the X11 display colormap.
void removeKipcEventMask(int id)
Removes a message type from the KIPC event mask.
static bool isCompositionManagerAvailable()
Gets the availability of a composition manager such as kompmgr Note that at least one application mus...
static void disableAutoDcopRegistration()
Disable automatic dcop registration Must be called before creating a TDEApplication instance to have ...
void enableStyles()
Enables style plugins.
TQString tempSaveName(const TQString &pFilename) const
Get a file name in order to make a temporary copy of your document.
bool requestShutDown(ShutdownConfirm confirm=ShutdownConfirmDefault, ShutdownType sdtype=ShutdownTypeDefault, ShutdownMode sdmode=ShutdownModeDefault)
Asks the session manager to shut the session down.
static DCOPClient * dcopClient()
Returns a pointer to a DCOPClient for the application.
static TDEClipboardSynchronizer * self()
Returns the TDEClipboardSynchronizer singleton object.
A class for command-line argument handling.
bool isSet(const char *option) const
Read out a boolean option or check for the presence of string option.
static const char * appName()
Get the appname according to argv[0].
static TDECmdLineArgs * parsedArgs(const char *id=0)
Access parsed arguments.
static void addCmdLineOptions(const TDECmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
Add options to your application.
TQCString getOption(const char *option) const
Read out a string option.
KDE Configuration Management abstract base class.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
Reads a list of strings.
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
Helper class to facilitate working with TDEConfig / KSimpleConfig groups.
A TDEConfigBase derived class for one specific group in a TDEConfig object.
Access KDE Configuration entries.
virtual void reparseConfiguration()
Clears all internal data structures and then reread configuration information from disk.
static void setEmergencySaveFunction(HandlerType saveFunction=(HandlerType) 0)
Installs a function which should try to save the applications data.
static void defaultCrashHandler(int signal)
The default crash handler.
static void setCrashHandler(HandlerType handler=defaultCrashHandler)
Install a function to be called in case a SIGSEGV is caught.
static void setApplicationName(TQString name)
Sets the application name name which should be passed to Dr.
static TQFont menuFont()
Returns the default menu font.
static TQFont generalFont()
Returns the default general font.
static int contrast()
Returns the contrast for borders.
static TQFont fixedFont()
Returns the default fixed font.
static TDEIconLoader * iconLoader()
Returns an iconloader object.
static TDEConfig * config()
Returns the general config object.
static TDEStandardDirs * dirs()
Returns the application standard dirs object.
static TDEInstance * instance()
Returns the global instance.
bool checkAccess(const TQString &pathname, int mode)
Check, if a file may be accessed in a given mode.
static TDELocale * locale()
Returns the global locale object.
static void deleteStaticDeleters()
Calls KStaticDeleterBase::destructObject() on all registered static deleters and unregisters them all...
static const TQString & staticQString(const char *str)
Creates a static TQString.
TQPixmap loadIcon(const TQString &name, TDEIcon::Group group, int size=0, int state=TDEIcon::DefaultState, TQString *path_store=0L, bool canReturnNull=false) const
Loads an icon.
@ DefaultState
The default state.
@ SizeLarge
large sized icons for the panel
Access to KDE global objects for use in shared libraries.
TQCString instanceName() const
Returns the name of the instance.
TDEConfig * config() const
Returns the general config object ("appnamerc").
KMimeSourceFactory * mimeSourceFactory() const
Returns the KMimeSourceFactory of the instance.
void newIconLoader() const
Re-allocate the global iconloader.
const TDEAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
void setConfigName(const TQString &name)
Set name of default config file.
TQString i18n(const char *text)
i18n is the function that does everything you need to translate a string.
#define I18N_NOOP(x)
I18N_NOOP marks a string to be translated without translating it.
The TDELockFile class provides NFS safe lockfiles.
@ LockOK
Lock was acquired successfully.
@ LockNoBlock
Return immediately, do not wait for the lock to become available.
static void deref()
Destroy the instance if one exists and it is not referenced any more.
static void ref()
Create an instance if none exists yet.
The TDEShortcut class is used to represent a keyboard shortcut to an action.
bool contains(const KKey &key) const
Checks whether this shortcut contains a sequence that starts with the given key.
TQString saveLocation(const char *type, const TQString &suffix=TQString::null, bool create=true) const
Finds a location to save files into for the given type in the user's home directory.
TQStringList resourceDirs(const char *type) const
This function is used internally by almost all other function as it serves and fills the directories ...
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)
Finds the executable in the system path.
bool addResourceType(const char *type, const TQString &relativename)
Adds suffixes for types.
static TQString kde_default(const char *type)
This returns a default relative path for the standard KDE resource types.
kndbgstream & endl(kndbgstream &s)
Does nothing.
TQString expandMacros(const TQString &ostr, const TQMap< TQChar, TQString > &map, TQChar c)
Perform safe macro expansion (substitution) on a string.
int event(const TQString &message, const TQString &text=TQString::null) TDE_DEPRECATED
TQStringList splitArgs(const TQString &cmd, int flags=0, int *err=0)
Splits cmd according to POSIX shell word splitting and quoting rules.
TDEAction * action(StdAction act_enum, const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0L)
const char * name(StdAction id)
const TDEShortcut & selectAll()
Reload.
Structure that holds command line options.