📄 kapp.cpp
字号:
/* This file is part of the KDE libraries Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */// $Id: kapp.cpp,v 1.1 2003/09/08 19:42:03 jasonk Exp $//// $Log: kapp.cpp,v $// Revision 1.1 2003/09/08 19:42:03 jasonk// Addition of packages directory and associated files.//// Revision 1.1.1.1 2003/08/07 21:18:32 jasonk// Initial import of PIXIL into new cvs repository.//// Revision 1.1.1.1 2003/06/23 22:04:23 jasonk////// Revision 1.1.1.1 2000/07/07 16:10:58 jasonk// Initial import of ViewML//// Revision 1.122.4.3 1999/06/14 10:37:47 porten// const char* for string constant//// Revision 1.122.4.2 1999/04/22 23:04:13 pfeiffer// I think http://buglist.kde.org is deprecated, so I changed it (in the// about-box) to http://bugs.kde.org, as in the HEAD-Branch.//// Revision 1.122.4.1 1999/04/13 00:20:22 dmuell// don't create /.kde/share/config for kdm.//// Revision 1.122 1999/01/18 10:56:12 kulow// .moc files are back in kdelibs. Built fine here using automake 1.3//// Revision 1.121 1999/01/15 09:30:30 kulow// it's official - kdelibs builds with srcdir != builddir. For this I// automocifized it, the generated rules are easier to maintain than// selfwritten rules. I have to fight with some bugs of this tool, but// generally it's better than keeping them updated by hand.//// Revision 1.120 1999/01/10 14:48:47 ettrich// fixed default widget style//// Revision 1.119 1998/12/13 20:32:57 ettrich// reverted some of the previous changes//// Revision 1.118 1998/12/13 20:04:16 ettrich// yet another fix for user defined SM//// Revision 1.117 1998/12/13 18:03:54 ettrich// bugfix for user defined session management//// Revision 1.116 1998/12/05 01:32:59 ettrich// support for icon text//// Revision 1.115 1998/11/08 19:06:43 esken// Several security fixes by adding checkAccess() tests before the creation// of files and directorys. This is neccesary for SUID programs. Added// checkAccess(), which checks if the user may write a file.//// checkAccess() is a global function, perhaps it should be moved to some// KTools class as static member funtion later.//// Revision 1.114 1998/10/12 13:22:54 ettrich// Matthias: small fix//// Revision 1.113 1998/10/12 00:17:09 ettrich// Matthias: automatic removal of session management temp-files//// Revision 1.112 1998/09/28 07:54:23 garbanzo// Remove some unneeded/unused kdebug gunk.//// Revision 1.111 1998/09/21 18:33:30 bieker// Use paths.h if we can.//// Revision 1.110 1998/09/10 23:47:29 markus// //$markus: replaced NULL with 0L in aboutKDE(). This caused trouble on// the netwinder.//// Revision 1.109 1998/09/01 20:21:14 kulow// I renamed all old qt header files to the new versions. I think, this looks// nicer (and gives the change in configure a sense :)//// Revision 1.108 1998/08/23 15:58:31 kulow// fixed some more advanced warnings//// Revision 1.107 1998/08/11 00:24:57 steffen// KProcess stuff removed//// Revision 1.106 1998/07/23 20:55:11 ettrich// Matthias: new configurable keybindings//// Revision 1.105 1998/07/02 15:42:42 ettrich// Matthias: Added a new signal//// void shutDown();//// which is emitted when the client is killed (for example via// kwm's logout)//// Revision 1.104 1998/06/21 15:03:37 konold//// Martin K.: Fixed typo Coolo does this affect the translations?? Please check.//// Revision 1.103 1998/06/15 12:49:29 kulow// applied patch to replace .kde with localkdedir()//// Revision 1.102 1998/05/28 21:43:52 kulow// removed TESTDIR. Since kdedir() is protected, it shouldn't happen anymore :)//// Revision 1.101 1998/04/12 08:52:36 jacek//// * Updtated KCharset class documentation.//// * Chnged font entry in config files to store charset as string, not numerical// id (which worked only for iso-8859-* charsets)//// * added KCharset::xCharset method for getting charset name to use for X font// names.//// Revision 1.100 1998/04/03 14:25:59 kulow// fixed a memory leak//// Revision 1.99 1998/03/27 17:27:31 mark// MD:// - Added call to setWinStyleHighlightColor()// - changed disabled text color from darkGray to colorGroup().mid()// - changed config keys and groups to read color scheme and fonts// - used readFontEntry for reading generalFont and fixedFont//// Revision 1.98 1998/03/21 23:05:12 mark// MD: Addition of a new font, a fixed font, for general use in applications.// Unfortunately, I think this is a BINARY INCOMPATIBLE change. (Cleared with Kalle.)//// Revision 1.97 1998/03/12 21:17:01 wuebben// Bernd: updated 'about KDE' text. It is now more in line with KDE goals//// Revision 1.96 1998/03/11 11:22:24 kulow// use readColorEntry instead of the old way. This is more consistent//// Revision 1.95 1998/03/09 20:20:11 kulow// - set KApp to 0, after the destructor has run. After that, nothing is for sure// - remove widgetList given by QApplication::topLevelWidgets. You can see this// in the documentation//// Revision 1.94 1998/02/24 21:36:04 kulow// fix for invokeHTMLHelp: missing / behind the path//// Revision 1.93 1998/02/24 21:16:22 kulow// remove kde_minidir, since this is somehow stupid (I hard coded it in the// Makefiles as icondir/mini now) and added kde_sounddir// This is even source incompatible, but it hasn't been used, so it should// work after some little changes I will make//// Revision 1.92 1998/02/24 20:07:45 kalle// Added F1 accelerator to standard help menu//// Revision 1.91 1998/02/24 15:54:29 kulow// replaced some hard coded paths with the kapp->kde_ methodes.// I'm not sure, if kde_datadir() is optimal for /share/apps ;)//// Revision 1.90 1998/02/20 06:21:18 kalle// Don't connect the Help/About slot when there is no text for an about box//// Revision 1.89 1998/02/19 05:58:22 rwilliam// Modified getHelpMenu()// Now displays Content instead of Help...//// Revision 1.88 1998/02/07 20:44:05 kulow// good news: KDE is relocatable again. kdelibs's configure is now inserting KDEDIR in the directories name and the kde_dir functions check for this.// This way we can have the advantages of both sides. It's relocatable with $KDEDIR// and you can hardcode specific directories, if you don't use relative paths.// All, that is needed now is to patch the applications to use the kapp::kde_ functions//// Revision 1.87 1998/01/27 20:17:01 kulow// applied patch by Kalle to make invokeHTMLHelp use the locale setting.//// Revision 1.86 1998/01/25 20:35:48 kulow// corrected order of signal and action (a party for the four-eyes-strategy ;)//// Revision 1.85 1998/01/25 20:09:43 kulow// patch created by me after Mario told me, what to do ;)// applyGUIStyle does not work exactly like QApplication::setStyle//// Revision 1.84 1998/01/22 16:29:45 jacek// Default locale's charset support added//// Revision 1.83 1998/01/17 07:35:16 kalle// Uh-oh...//// Revision 1.82 1998/01/16 21:29:30 kalle// mention the new bug site in the about dialog//// Revision 1.81 1998/01/03 15:24:33 kulow// added accelerators and ... to the returned Help - Menu//// Revision 1.80 1997/12/31 14:12:25 kulow// corrected grammar and added one more .copy()//// Revision 1.79 1997/12/29 14:36:46 kulow// kdedir() does no longer return a deep copy, but a shallow copy.// I inserted a test against a deep copy to take care of changes. But this// is just to find problems and can be removed by undefining TEST_KDEDIR in// Makefile.am//// Revision 1.78 1997/12/28 21:32:14 kulow// last time I forgot two functions kde_mimedir() and kde_confdir()// I will move this functions very soon to static functions of a new// class KPaths. Kapplication is not the optimal class to contain this// functions, since I need a DISPLAY to find out the paths. But I think,// we can create some inline methods in kapp then//// Revision 1.77 1997/12/13 15:08:56 jacek// KCharsets support added// WARNING: kderc file format has changed. Since now charset name// instead of id is stored.////// Revision 1.76 1997/11/27 20:21:20 kulow// safer deletion of theKProcessController by Johannes Sixt.// Read the comments for details//// Revision 1.75 1997/11/21 11:22:29 kulow// make a deep copy of kdedir before returning it. I still don't get it,// why this is necessary.//// Revision 1.74 1997/11/20 22:41:32 kalle// Small bug fix in kapp.cpp (I hope this does not break anything...)// First element of search was $HOME./kde and is now $HOME/.kde// New version looks way more correct to me...//// Revision 1.73 1997/11/20 22:24:30 kalle// new static methods for the various directories//// Revision 1.72 1997/11/18 21:40:41 kalle// KApplication::localconfigdir()// KApplication::localkdedir()// KConfig searches in $KDEDIR/share/config/kderc//// Revision 1.71 1997/11/11 05:41:53 wuebben// Bernd: implemented iso charset support//// Revision 1.70 1997/11/09 04:08:54 wuebben// Bernd: iso charset changes (minimal and harmless )//// Revision 1.69 1997/11/03 14:41:28 ettrich// Matthias: tiny fix for command line arguments: "-icon" will also be used// for the miniicon if "-miniicon" is not defined.//// Revision 1.68 1997/11/03 13:50:15 kulow// delete theKProcessController in the destructor//// Revision 1.67 1997/10/30 13:30:15 ettrich// Matthias: fix for setWmCommand: now setWmCommand can also be used for// PseudoSessionManagement (this is the default when session management// was not enabled with enableSessionManagement).// Now KApplication should work as promised in kapp.h :-)//// Revision 1.66 1997/10/25 22:27:40 kalle// Fixed bug with default help menu (Thanks, Bernd! This one was just in time!)//// Revision 1.65 1997/10/24 16:58:55 ettrich// Matthias: bugfixes for session management.//// Revision 1.64 1997/10/22 20:42:52 kalle// Help menu works as advertised//// Revision 1.63 1997/10/21 20:44:41 kulow// removed all NULLs and replaced it with 0L or "".// There are some left in mediatool, but this is not C++//// Revision 1.62 1997/10/17 15:46:22 stefan// Moved the include of stdlib.h -- otherwise gcc-2.7.2.1 has an internal// compiler bug. I know - I should upgrade gcc, but for all the// poor folks that still have the old one ;-)//// Revision 1.61 1997/10/17 13:30:16 ettrich// Matthias: registerTopWidget/unregisterTopWidget are obsolete and empty now.// Introduced new registration model//// Revision 1.60 1997/10/16 11:35:24 kulow// readded my yesterday bugfixes. I hope, I have not forgotten one.// I'm not sure, why this have been removed, but I'm sure, they are// needed.//// Revision 1.59 1997/10/16 11:14:27 torben// Kalle: Copyright headers// kdoctoolbar removed//// Revision 1.57 1997/10/14 13:31:57 kulow// removed one more default value from the implementation//// Revision 1.56 1997/10/13 14:31:03 ettrich// Matthias: fixed the caption bug (AGAIN THESE WEIRD SHALLOW QSTRING COPIES...)//// Revision 1.55 1997/10/13 11:00:04 ettrich// Matthias: fix to generation of SM command//// Revision 1.54 1997/10/12 14:36:34 kalle// KApplication::tempSaveName() and KApplication::checkRecoverFile()// now implemented as documented.// The change in kapp.h is only in the documentation and thus *-compatible.//// Revision 1.53 1997/10/11 22:39:27 ettrich// Matthias: BINARY INCOMPATIBLE CHANGES// - removed senseless method setUnsavedData//// Revision 1.52 1997/10/11 19:25:32 ettrich// Matthias: mainWidget -> topWidget for SM//// Revision 1.51 1997/10/10 22:36:21 ettrich// Matthias: fixed an async reply problem with invokeHTMLHelp//// Revision 1.50 1997/10/10 22:09:17 ettrich// Matthias: BINARY INCOMPATIBLE CHANGES: extended session management support#include <qdir.h> // must be at the front#include <kapp.h>#include <kiconloader.h>#include <klocale.h>#include <kcharsets.h>#include <kdebug.h>#include "kwm.h"#include <kdebugdialog.h>#include <unistd.h>#include <fcntl.h>#include <X11/Xlib.h>#include <X11/Xatom.h>#include <qobjcoll.h>#include <qstrlist.h>#include <qfile.h>#include <qmessagebox.h>#include <qtextstream.h>#include <qregexp.h>#include <qkeycode.h>#ifdef HAVE_SYS_STAT_H#include <sys/stat.h>#endif#include <sys/types.h>#include <sys/wait.h>#include <stdlib.h> // getenv()#include <signal.h>#include <qwidcoll.h>#include "kprocctrl.h"#ifdef HAVE_PATHS_H#include <paths.h>#endif#ifndef _PATH_TMP#define _PATH_TMP "/tmp/"#endifKCharsets* KApplication::pCharsets = 0L;KApplication* KApplication::KApp = 0L;QStrList* KApplication::pSearchPaths;//extern bool bAreaCalculated;static int kde_xio_errhandler( Display * ){ return kapp->xioErrhandler();}KApplication::KApplication( int& argc, char** argv ) : QApplication( argc, argv ){ QString aArgv0 = argv[0]; int nSlashPos = aArgv0.findRev( '/' ); if( nSlashPos != -1 ) aAppName = aArgv0.remove( 0, nSlashPos+1 ); else aAppName = aArgv0; init(); parseCommandLine( argc, argv );}KApplication::KApplication( int& argc, char** argv, const QString& rAppName ) : QApplication( argc, argv ){ aAppName = rAppName; init(); parseCommandLine( argc, argv );}int KApplication::xioErrhandler(){ emit shutDown(); exit( 1 ); return 0;}void KApplication::init(){ // this is important since we fork() to launch the help (Matthias) fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); // set up the fance KDE xio error handler (Matthias) XSetIOErrorHandler( kde_xio_errhandler ); rootDropZone = 0L; // CC: install KProcess' signal handler // by creating the KProcController instance (if its not already existing) // This is handled be KProcess (stefh) /* if ( theKProcessController == 0L) theKProcessController = new KProcessController(); */ KApp = this; bLocaleConstructed = false; // no work around mutual dependencies pIconLoader = 0L; // create the config directory ~/.kde/share/config QString configPath = KApplication::localkdedir(); // We should check if mkdir() succeeds, but since we cannot do much anyway... // But we'll check at least for access permissions (for SUID case) // Don't access if ~/ is unknown (as in kdm). if ( (QDir::home() != QDir::root()) && checkAccess(configPath, W_OK) ) { if ( mkdir (configPath.data(), 0755) == 0) { // make it public(?) chown(configPath.data(), getuid(), getgid()); configPath += "/share"; if ( checkAccess(configPath, W_OK) ) { if ( mkdir (configPath.data(), 0755) == 0 ) { // make it public chown(configPath.data(), getuid(), getgid());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -