Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KApplication (./kdelibs/kdecore/kapp.h:75)
class KApplication : public QApplication, public KInstance
{
friend QTDispatcher;
Q_OBJECT
public:
enum CaptionLayout { CaptionAppLast=1, CaptionAppFirst, CaptionNoApp };
/**
* Constructor. Parses command-line arguments.
*
* @param rAppName application name. Will be used for finding the
* associated message files and icon files, and as the default
* registration name for DCOP. This is a mandatory parameter.
*
* @param allowStyles Set to false to disable the loading on plugin based
* styles. This is only useful to applications that do not display a GUI
* normally. If you do create an application with @p allowStyles set to false
* that normally runs in the background but under special circumstances
* displays widgets call @ref enableStyles() before displaying any widgets.
*
* @param GUIenabled Set to false to disable all GUI stuff. This implies
* no styles either.
*/
KApplication(int& argc, char** argv,
const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true);
/**
* This constructor takes aboutData and command line
* arguments from @ref KCmdLineArgs.
*
* @param allowStyles Set to false to disable the loading on plugin based
* styles. This is only useful to applications that do not display a GUI
* normally. If you do create an application with @p allowStyles set to false
* it normally runs in the background but under special circumstances
* displays widgets. Call @ref enableStyles() before displaying any widgets.
*
* @param GUIenabled Set to false to disable all GUI stuff. This implies
* no styles either.
*/
KApplication( bool allowStyles=true, bool GUIenabled=true);
/**
* Constructor. Parses command-line arguments. Use this constructor to use KApplication
* in a Motif or Xt program.
*
* @param display Will be passed to Qt as the X display. The display must be valid and already
* opened.
*
* @param rAppName application name. Will be used for finding the
* associated message files and icon files, and as the default
* registration name for DCOP. This is a mandatory parameter.
*
* @param allowStyles Set to false to disable the loading on plugin based
* styles. This is only useful to applications that do not display a GUI
* normally. If you do create an application with @p allowStyles set to false
* that normally runs in the background but under special circumstances
* displays widgets call @ref enableStyles() before displaying any widgets.
*
* @param GUIenabled Set to false to disable all GUI stuff. This implies
* no styles either.
*/
KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
bool allowStyles=true, bool GUIenabled=true);
/**
* Add Qt and KDE command line options to KCmdLineArgs.
*/
static void addCmdLineOptions();
virtual ~KApplication();
/** Retrieve the number of command line arguments, i. e. the length
* of the array @ref KApplication::argv().
*
* In this array, the arguments
* handled by @ref KApplication itself (eg. '-icon') are already removed
*/
int argc() const { return pArgc; }
/**
* Retrieve the current application object.
*
* This is similar to the global @ref QApplication pointer @ref qApp. It
* allows access to the single global @ref KApplication object, since
* more than one cannot be created in the same application. It
* saves you the trouble of having to pass the pointer explicitly
* to every function that may require it.
*/
static KApplication* kApplication() { return KApp; }
/**
* Retrieve the application session config object.
*
* @return A pointer to the application's instance specific
* @ref KConfig object.
* @see KConfig
*/
KConfig* sessionConfig();
/**
* Is the application restored from the session manager?
*
* @return If @p true, this application was restored by the session manager.
* Note that this may mean the config object returned by
* @ref sessionConfig() contains data saved by a session closedown.
* @see sessionConfig()
*/
bool isRestored() const { return QApplication::isSessionRestored(); }
/**
* Disable session management for this application.
*
* Useful in case your application is started by the
* inital "startkde" script.
*/
void disableSessionManagement();
/**
* Asks the session manager to shut the session down.
*
* Returns TRUE on sucess, FALSE if the session manager could not be
* contacted.
*/
bool requestShutDown();
/**
* Propagates the network address of the session manager in the
* SESSION_MANAGER environment variable so that child processes can
* pick it up.
*
* If SESSION_MANAGER isn't defined yet, the address is searched in
* $HOME/.KSMserver.
*
* This function is called by clients that are started outside the
* session ( i.e. before ksmserver is started), but want to launch
* other processes that should participate in the session. Examples
* are kdesktop or kicker.
*/
void propagateSessionManager();
/*
* Reimplemented for internal purposes, mainly the highlevel
* handling of session management with @ref KSessionManaged.
* @internal
*/
void commitData( QSessionManager& sm );
/*
* Reimplemented for internal purposes, mainly the highlevel
* handling of session management with KSessionManaged.
* @internal
*/
void saveState( QSessionManager& sm );
/**
* Retrieve a pointer to a @ref DCOPClient for the application.
*/
virtual DCOPClient *dcopClient();
// See kapp.cpp for explanation
/*
QPopupMenu* helpMenu( bool bAboutQtMenu,
const QString& appAboutText );
*/
/**
* Get the application icon.
* @return a @ref QPixmap with the icon.
* @see QPixmap
*/
QPixmap icon() const;
/**
* Get the mini-icon for the application.
* @return a @ref QPixmap with the icon.
* @see QPixmap
*/
QPixmap miniIcon() const;
/**
* Set the top widget of the application.
*
* @param topWidget A top widget of the application.
*
* This means bascially applying the right window caption and
* icon. An application may have several top widgets. You don't
* need to call this function manually when using @ref KTMainWindow.
*
* @see icon(), caption()
**/
void setTopWidget( QWidget *topWidget );
/**
* Invoke the khelpcenter HTML help viewer.
*
* @param aFilename The filename that is to be loaded. Its
* location is computed automatically
* according to the KFSSTND. If @p aFilename
* is empty, the logical appname with .html
* appended to it is used.
* @param aTopic This allows context-sensitive help. Its
* value will be appended to the filename,
* prefixed with a "#" (hash) character.
*/
void invokeHTMLHelp( QString aFilename, QString aTopic ) const;
/**
* Invoke the standard email application.
*
* @param address The destination address
* @param subject Subject string. Can be QString::null.
*/
void invokeMailer( const QString &address, const QString &subject );
/**
* Invoke the standard browser.
*
* @param url The destination address
*/
void invokeBrowser( const QString &url );
/**
* Get the DCOP name of the service launcher. This will be something like
* klaucher_$host_$uid.
* @return The DCOP name of the launcher.
*/
static QCString launcher();
/**
* Starts a service based on the (translated) name of the service.
* E.g. "Web Browser"
*
* @param URL - if not empty this URL is passed to the service
*
* @return an error code indicating success (== 0) or failure (> 0).
* @return On success, 'dcopService' contains the DCOP name under which
* this service is available. If empty, the service does
* not provide DCOP services.
* @return On failure, 'error' contains a description of the error
* that occured.
*/
static int startServiceByName( const QString& _name, const QString &URL,
QCString &dcopService, QString &error );
/**
* Starts a service based on the desktop path of the service.
* E.g. "Applications/konqueror.desktop" or "/home/user/bla/myfile.desktop"
*
* @param URL - if not empty this URL is passed to the service
*
* @return an error code indicating success (== 0) or failure (> 0).
* @return On success, 'dcopService' contains the DCOP name under which
* this service is available. If empty, the service does
* not provide DCOP services.
* @return On failure, 'error' contains a description of the error
* that occured.
*/
static int startServiceByDesktopPath( const QString& _name,
const QString &URL, QCString &dcopService, QString &error );
/**
* Starts a service based on the desktop name of the service.
* E.g. "konqueror"
*
* @param URL - if not empty this URL is passed to the service
*
* @return an error code indicating success (== 0) or failure (> 0).
* @return On success, 'dcopService' contains the DCOP name under which
* this service is available. If empty, the service does
* not provide DCOP services.
* @return On failure, 'error' contains a description of the error
* that occured.
*/
static int startServiceByDesktopName( const QString& _name,
const QString &URL, QCString &dcopService, QString &error );
/**
* Retrieve the current KDE style object if a plugin is in use,
* or else NULL if a Qt internal style is being used.
*
*/
KStyle* kstyle() const {return pKStyle;}
/**
* Get the KDE font list.
*
* This method allows you to get the KDE font list which was
* composed by the user with kfontmanager. Usually you should
* work only with those fonts in your KDE application.
*
* @param fontlist A reference to a list to fill with fonts.
* @return true on success.
*/
bool kdeFonts(QStringList &fontlist) const;
/**
* Return a text for the window caption.
*
* This may be set by
* "-caption", otherwise it will be equivalent to the name of the
* executable.
*/
QString caption() const;
/**
* Build a caption that contains the application name along with the
* @ref userCaption() using a standard layout.
*
* To make a compliant caption
* for your window, simply do: @p setCaption(kapp->makeStdCaption(yourCaption));
*
* @param userCaption The caption string you want to display in the
* window caption area. Do not include the application name!
* @param withAppName Indicates that the method shall include or ignore
* the application name when making the caption string. You are not
* compliant if you set this to @p false.
* @param modified If true, a 'modified' sign will be included in the
* returned string. This is useful when indicating that a file is
* modified, i.e., contains data the has not been saved.
*/
QString makeStdCaption( const QString &userCaption,
bool withAppName=true, bool modified=false ) const;
/**
* Get a file name in order to make a temporary copy of your document.
*
* @param pFilename The full path to the current file of your
* document.
* @return A new filename for auto-saving.
*/
QString tempSaveName( const QString& pFilename ) const;
/**
* Check if there is an auto-save file for the document you want to
* open.
*
* @param pFilename The full path to the document you want to open.
* @param bRecover This gets set to true if there was a recover
* file.
* @return The full path of the file to open.
*/
QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
/**
* Get the X11 display
*/
Display *getDisplay() { return display; }
/**
* Enable style plugins.
*
* This is useful only to applications that normally
* do not display a GUI and create the @ref KApplication with @p allowStyles = @pfalse.
*/
void enableStyles();
/**
* Install widget filter as global X11 event filter.
*
* The widget
* filter receives XEvents in its standard @ref QWidget::x11Event() function.
*
* Warning: Only do this when absolutely necessary. An installed X11 filter
* can slow things down.
**/
void installX11EventFilter( QWidget* filter );
/**
* Generate a uniform random number.
* @return A truly unpredictable number in the range [0, MAX_RAND)
*/
static int random();
/**
* Generate a random string. It operates in the range [A-Za-z0-9]
* @param length Generate a string of this length. If negative, the
* length will be random as well (from 0 to MAX_RAND)
*/
static QString randomString(int length=-1);
/**
* Add a message type to the KIPC event mask. You can only add "system
* messages" to the event mask. These are the messages with id < 32.
* Messages with id >= 32 are user messages.
* @param id The message id. See @ref #KIPC::Message.
*/
void addKipcEventMask(int id);
/**
* Remove a message type from the KIPC event mask. This message will not
* be handled anymore.
* @param id The message id.
*/
void removeKipcEventMask(int id);
protected:
/**
* Used to catch X11 events
*/
bool x11EventFilter( XEvent * );
Display *display;
Atom kipcCommAtom;
int kipcEventMask;
/// Current application object.
static KApplication *KApp;
int pArgc;
public slots:
// See kapp.cpp for explanation
//void aboutKDE();
//void aboutApp();
//void aboutQt();
protected slots:
// See kapp.cpp for explanation
//void appHelpActivated();
private slots:
void dcopFailure(const QString &);
void x11FilterDestroyed();
private:
KApplicationPrivate* pAppData;
KConfig* pSessionConfig; //instance specific application config object
DCOPClient *pDCOPClient; // instance specific application communication client
QString aCaption; // the name for the window title
QString aAppAboutString; // The text for the about box
QString aDummyString2; // do not touch
QString aDummyString3; // do not touch
QString aDummyString4; // do not touch
bool bSessionManagement;
QPixmap aIconPixmap;
QPixmap aMiniIconPixmap;
KStyle *pKStyle; // A KDE style object if available (mosfet)
bool useStyles;
void* styleHandle; // A KDE style dlopen handle, if used
QWidget *smw;
void init( bool GUIenabled );
void parseCommandLine( int&, char** ); // search for special KDE arguments
void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs)
virtual void kdisplaySetPalette();
virtual void kdisplaySetStyle();
virtual void kdisplaySetFont();
virtual void applyGUIStyle(GUIStyle);
QColor inactiveTitleColor_;
QColor inactiveTextColor_;
QColor activeTitleColor_;
QColor activeTextColor_;
int contrast_;
int captionLayout;
public:
QColor inactiveTitleColor() const;
QColor inactiveTextColor() const;
QColor activeTitleColor() const;
QColor activeTextColor() const;
int contrast() const;
/**
@internal
*/
int xioErrhandler();
/**
* Valid values for the settingsChanged signal
*/
enum { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS };
signals:
/**
* KApplication has changed its Palette due to a KDisplay request.
*
* Normally, widgets will update their palettes automatically, but you
* should connect to this to program special behaviour.
*/
void kdisplayPaletteChanged();
/**
* KApplication has changed its GUI Style due to a KDisplay request.
*
* Normally, widgets will update their styles automatically (as they would
* respond to an explicit setGUIStyle() call), but you should connect to
* this to program special behaviour.
*/
void kdisplayStyleChanged();
/**
* KApplication has changed its Font due to a KDisplay request.
*
* Normally widgets will update their fonts automatically, but you should
* connect to this to monitor global font changes, especially if you are
* using explicit fonts.
*/
void kdisplayFontChanged();
/**
* KApplication has changed either its GUI style, its font or its palette
* due to a kdisplay request. Normally, widgets will update their styles
* automatically, but you should connect to this to program special
* behavior. */
void appearanceChanged();
/**
* The desktop background has been changed by kcmdisplay.
*
* @param desk The desktop whose background has changed.
*/
void backgroundChanged(int desk);
/**
* The global settings have been changed - see KGlobalSettings
* KApplication takes care of calling reparseConfiguration on KGlobal::config()
* so that applications/classes using this only have to re-read the configuration
* @param category the category among the enum above
*/
void settingsChanged(int category);
/**
* Emitted when a KIPC user message has been received.
*/
void kipcMessage(int id, int data);
/**
Session management asks you to save the state of your application.
This signal is provided for compatibility only. For new
appliations, simply use KTMainWindow. By reimplementing @ref
KTMainWindow::queryClose, @ref KTMainWindow::saveProperties and
@ref KTMainWindow::readProperties you can simply handle session
management for applications with multiple toplevel windows.
For purposes without KTMainWindow, create an instance of
KSessionManaged and reimplement the functions @ref
KSessionManaged::commitData and/or @ref
KSessionManaged::saveState
If you still want to use this signal, here is what you should do:
Connect to this signal in order to save your data. Do NOT
manipulate the UI in that slot, it is blocked by the session
manager.
Use the @ref ::getSessionConfig KConfig object to store all your
instance specific datas.
Do not do any closing at this point! The user may still select
"cancel" and then he wants to continue working with your
application. Cleanups could be done after shutDown() (see below)
*/
void saveYourself();
/** Your application is killed. Either by your program itself, kwm's
killwindow function, xkill or (the usual case) by KDE's logout.
The signal is particularly useful if your application has to do some
last-second cleanups. Note that no user interaction is possible at
this state.
*/
void shutDown();
private:
KApplication(const KApplication&);
KApplication& operator=(const KApplication&);
};
/** Check, if a file may be accessed in a given mode.
* This is a wrapper around the access() system call.
* checkAccess() calls access() with the given parameters.
* If this is OK, checkAccess() returns true. If not, and W_OK
* is part of mode, it is checked if there is write access to
* the directory. If yes, checkAccess() returns true.
* In all other cases checkAccess() returns false.
*
* Other than access() this function EXPLICITELY ignores non-existant
* files if checking for write access.
*
* @param pathname The full path of the file you want to test
* @param mode The access mode, as in the access() system call.
* @return Whether the access is allowed, true = Access allowed
*/
kdelibs'KApplication::installX11EventFilter() (./kdelibs/kdecore/kapp.cpp:136)
void KApplication::installX11EventFilter( QWidget* filter )
{
if ( !filter )
return;
if (!x11Filter)
x11Filter = new QList<QWidget>;
connect ( filter, SIGNAL( destroyed() ), this, SLOT( x11FilterDestroyed() ) );
x11Filter->append( filter );
}
kdelibs'KApplication::x11FilterDestroyed() (./kdelibs/kdecore/kapp.cpp:146)
void KApplication::x11FilterDestroyed()
{
if ( !x11Filter || !sender() )
return;
QWidget* w = (QWidget*) sender();
x11Filter->removeRef( w );
if ( x11Filter->isEmpty() ) {
delete x11Filter;
x11Filter = 0;
}
}
// the help class for session management communication
kdelibs'KApplication::KApplication() (./kdelibs/kdecore/kapp.cpp:185)
KApplication::KApplication( int& argc, char** argv, const QCString& rAppName,
bool allowStyles, bool GUIenabled ) :
QApplication( argc, argv, GUIenabled ), KInstance(rAppName)
{
if (!GUIenabled)
allowStyles = false;
useStyles = allowStyles;
ASSERT (!rAppName.isEmpty());
setName(rAppName);
pAppData = new KApplicationPrivate;
init(GUIenabled);
parseCommandLine( argc, argv );
}
kdelibs'KApplication::KApplication() (./kdelibs/kdecore/kapp.cpp:200)
KApplication::KApplication( bool allowStyles, bool GUIenabled ) :
QApplication( *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(),
GUIenabled ),
KInstance( KCmdLineArgs::about)
{
if (!GUIenabled)
allowStyles = false;
useStyles = allowStyles;
setName( instanceName() );
pAppData = new KApplicationPrivate;
init(GUIenabled);
parseCommandLine( );
}
kdelibs'KApplication::KApplication() (./kdelibs/kdecore/kapp.cpp:215)
KApplication::KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
bool allowStyles, bool GUIenabled ) :
QApplication( display ), KInstance(rAppName)
{
if (!GUIenabled)
allowStyles = false;
useStyles = allowStyles;
ASSERT (!rAppName.isEmpty());
setName(rAppName);
pAppData = new KApplicationPrivate;
init(GUIenabled);
parseCommandLine( argc, argv );
}
kdelibs'KApplication::xioErrhandler() (./kdelibs/kdecore/kapp.cpp:231)
int KApplication::xioErrhandler()
{
emit shutDown();
exit( 1 );
return 0;
}
kdelibs'KApplication::init() (./kdelibs/kdecore/kapp.cpp:247)
void KApplication::init(bool GUIenabled)
{
QApplication::setDesktopSettingsAware( false );
KApp = this;
styleHandle = 0;
pKStyle = 0;
smw = 0;
// Initial KIPC event mask.
kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) |
(1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged);
if (GUIenabled)
{
// this is important since we fork() to launch the help (Matthias)
fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1);
// set up the fancy (=robust and error ignoring ) KDE xio error handlers (Matthias)
XSetErrorHandler( kde_x_errhandler );
XSetIOErrorHandler( kde_xio_errhandler );
connect( this, SIGNAL( aboutToQuit() ), this, SIGNAL( shutDown() ) );
display = desktop()->x11Display();
kipcCommAtom = XInternAtom(display, "KIPC_COMM_ATOM", false);
// GJ: Work around a bug in kconfig or kinstance.
KGlobal::config()->reparseConfiguration();
kdisplaySetStyle();
kdisplaySetFont();
kdisplaySetPalette();
}
installTranslator(new KDETranslator(this));
// install appdata resource type
KGlobal::dirs()->addResourceType("appdata", KStandardDirs::kde_default("data")
+ QString::fromLatin1(name()) + '/');
pSessionConfig = 0L;
pDCOPClient = 0L; // don't instantiate until asked to do so.
bSessionManagement = true;
// register a communication window for desktop changes (Matthias)
if (GUIenabled)
{
Atom a = XInternAtom(qt_xdisplay(), "KDE_DESKTOP_WINDOW", false);
smw = new QWidget(0,0);
long data = 1;
XChangeProperty(qt_xdisplay(), smw->winId(), a, a, 32,
PropModeReplace, (unsigned char *)&data, 1);
}
captionLayout = CaptionAppLast;
}
kdelibs'KApplication::dcopClient() (./kdelibs/kdecore/kapp.cpp:303)
DCOPClient *KApplication::dcopClient()
{
if (pDCOPClient)
return pDCOPClient;
// create an instance specific DCOP client object
// if dcopserver lockfile not present, start the server.
QCString fName(::getenv("HOME"));
fName += "/.DCOPserver";
if (::access(fName.data(), R_OK) == -1) {
QString srv = KStandardDirs::findExe(QString::fromLatin1("dcopserver"));
QApplication::flushX();
if (fork() == 0) {
execl(srv.latin1(), srv.latin1(), 0);
_exit(1);
} else {
sleep(1); // give server some startup time. Race condition, I know...
}
}
pDCOPClient = new DCOPClient();
connect(pDCOPClient, SIGNAL(attachFailed(const QString &)),
SLOT(dcopFailure(const QString &)));
return pDCOPClient;
}
kdelibs'KApplication::sessionConfig() (./kdelibs/kdecore/kapp.cpp:330)
KConfig* KApplication::sessionConfig()
{
if (pSessionConfig)
return pSessionConfig;
// create an instance specific config object
pSessionConfig = new KConfig( sessionConfigName(), false, false);
return pSessionConfig;
}
kdelibs'KApplication::disableSessionManagement() (./kdelibs/kdecore/kapp.cpp:364)
void KApplication::disableSessionManagement() {
bSessionManagement = false;
}
kdelibs'KApplication::requestShutDown() (./kdelibs/kdecore/kapp.cpp:369)
bool KApplication::requestShutDown()
{
if ( mySmcConnection ) {
// we already have a connection to the session manager, use it.
SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True, SmInteractStyleAny, False, True );
return TRUE;
}
// open a temporary connection, if possible
propagateSessionManager();
if (!::getenv("SESSION_MANAGER") )
return FALSE;
char cerror[256];
char* myId = 0;
char* prevId = 0;
SmcCallbacks cb;
SmcConn smcConnection = SmcOpenConnection( 0, 0, 1, 0,
0, &cb,
prevId,
&myId,
255,
cerror );
::free( myId ); // it was allocated by C
if (!smcConnection )
return FALSE;
SmcRequestSaveYourself( smcConnection, SmSaveBoth, True, SmInteractStyleAny, False, True );
SmcCloseConnection( smcConnection, 0, 0 );
return TRUE;
}
kdelibs'KApplication::propagateSessionManager() (./kdelibs/kdecore/kapp.cpp:402)
void KApplication::propagateSessionManager()
{
QCString fName = ::getenv("HOME");
fName += "/.KSMserver";
bool check = !::getenv("SESSION_MANAGER");
if ( !check && smModificationTime ) {
QFileInfo info( fName );
QTime current = info.lastModified().time();
check = current > *smModificationTime;
}
if ( check ) {
delete smModificationTime;
QFile f( fName );
if ( !f.open( IO_ReadOnly ) )
return;
QFileInfo info ( f );
smModificationTime = new QTime( info.lastModified().time() );
QTextStream t(&f);
QString s = t.readLine();
f.close();
::setenv( "SESSION_MANAGER", s.latin1(), TRUE );
}
}
kdelibs'KApplication::commitData() (./kdelibs/kdecore/kapp.cpp:426)
void KApplication::commitData( QSessionManager& sm )
{
bool cancelled = false;
for (KSessionManaged* it = sessionClients()->first();
it && !cancelled;
it = sessionClients()->next() ) {
cancelled = !it->commitData( sm );
}
if ( cancelled )
sm.cancel();
if ( sm.allowsInteraction() ) {
QWidgetList done;
QWidgetList *list = QApplication::topLevelWidgets();
bool cancelled = FALSE;
QWidget* w = list->first();
while ( !cancelled && w ) {
if ( !w->testWState( WState_ForceHide ) && !w->inherits("KTMainWindow") ) {
QCloseEvent e;
sendEvent( w, &e );
cancelled = !e.isAccepted();
if ( !cancelled )
done.append( w );
delete list; // one never knows...
list = QApplication::topLevelWidgets();
w = list->first();
} else {
w = list->next();
}
while ( w && done.containsRef( w ) )
w = list->next();
}
delete list;
}
if ( !bSessionManagement ) {
sm.setRestartHint( QSessionManager::RestartNever );
return;
}
}
kdelibs'KApplication::saveState() (./kdelibs/kdecore/kapp.cpp:468)
void KApplication::saveState( QSessionManager& sm )
{
static bool firstTime = false;
mySmcConnection = (SmcConn) sm.handle();
if ( !bSessionManagement ) {
sm.setRestartHint( QSessionManager::RestartNever );
return;
}
if ( firstTime ) {
firstTime = false;
return; // no need to save the state.
}
QString aLocalFileName = KGlobal::dirs()->saveLocation("config") +
sessionConfigName();
// remove former session config if still existing, we want a new and fresh one
if ( pSessionConfig ) {
delete pSessionConfig;
pSessionConfig = 0;
QFile f ( aLocalFileName );
if ( f.exists() )
f.remove();
}
// tell the session manager about our new lifecycle
QStringList restartCommand = sm.restartCommand();
sm.setRestartCommand( restartCommand );
// finally: do session management
emit saveYourself(); // for compatiblity
bool cancelled = false;
for (KSessionManaged* it = sessionClients()->first();
it && !cancelled;
it = sessionClients()->next() ) {
cancelled = !it->saveState( sm );
}
// if we created a new session config object, register a proper discard command
if ( pSessionConfig ) {
pSessionConfig->sync();
QStringList discard;
discard << ( "rm "+aLocalFileName ); // only one argument due to broken xsm
sm.setDiscardCommand( discard );
}
if ( cancelled )
sm.cancel();
}
#if 0
//
// 1999-10-21 Espen Sand:
// The functionality is moved to ktmainwindow. I have decided that I will
// not remove the code from kapp yet. You should only uncomment this is you
// really need to do so. In 99% of the cases it is simpler to modify the
// code that depend on this See KDE2PORTING
//
// This code WILL be delected quite soon.
//
QPopupMenu* KApplication::helpMenu( bool /*bAboutQtMenu*/,
const QString& aboutAppText )
{
int id = 0;
QPopupMenu* pMenu = new QPopupMenu();
id = pMenu->insertItem( i18n( "&Contents" ) );
pMenu->connectItem( id, this, SLOT( appHelpActivated() ) );
pMenu->setAccel( Key_F1, id );
pMenu->insertSeparator();
id = pMenu->insertItem(i18n("&About %1...").arg(aAppName));
if( !aboutAppText.isNull() )
{
pMenu->connectItem( id, this, SLOT( aboutApp() ) );
aAppAboutString = aboutAppText;
}
id = pMenu->insertItem( i18n( "About &KDE..." ) );
pMenu->connectItem( id, this, SLOT( aboutKDE() ) );
/*
if( bAboutQtMenu )
{
id = pMenu->insertItem( i18n( "About Qt" ) );
pMenu->connectItem( id, this, SLOT( aboutQt() ) );
}
*/
return pMenu;
}
void KApplication::appHelpActivated()
{
invokeHTMLHelp( QString(name()) + "/" + "index.html", "" );
}
void KApplication::aboutKDE()
{
QMessageBox about(i18n( "About KDE" ),
i18n(
"\nThe KDE Desktop Environment was written by the KDE Team,\n"
"a world-wide network of software engineers committed to\n"
"free software development.\n\n"
"Visit http://www.kde.org for more information on the KDE\n"
"Project. Please consider joining and supporting KDE.\n\n"
"Please report bugs at http://bugs.kde.org.\n"),
QMessageBox::Information,
QMessageBox::Ok + QMessageBox::Default, 0, 0,
0, "aboutkde");
about.setButtonText(0, i18n("&OK"));
about.exec();
}
void KApplication::aboutApp()
{
QWidget* w = activeWindow();
QString caption = i18n("About %1").arg(kapp->caption());
QMessageBox about(caption, aAppAboutString, QMessageBox::Information,
QMessageBox::Ok + QMessageBox::Default, 0, 0, w, "aboutapp");
about.setButtonText(0, i18n("&OK"));
about.setIconPixmap(icon());
about.exec();
}
void KApplication::aboutQt(){
// QWidget* w = activeWindow();
// QMessageBox::aboutQt( w, caption() );
}
kdelibs'KApplication::dcopFailure() (./kdelibs/kdecore/kapp.cpp:604)
void KApplication::dcopFailure(const QString &msg)
{
QString msgStr(i18n("There was some error setting up inter-process\n"
"communications for KDE. The message returned\n"
"by the system was:\n\n"));
msgStr += msg;
msgStr += i18n("\n\nPlease check that the \"dcopserver\" program is running!");
QMessageBox::critical(kapp->mainWidget(),
i18n("DCOP communications error (%1)").arg(kapp->caption()),
msgStr, i18n("OK"));
}
kdelibs'KApplication::parseCommandLine() (./kdelibs/kdecore/kapp.cpp:617)
void KApplication::parseCommandLine( int& argc, char** argv )
{
enum parameter_code { unknown = 0, caption, icon, miniicon, dcopserver };
const char* parameter_strings[] = { "-caption", "-icon", "-miniicon", "-dcopserver", 0 };
aDummyString2 = " ";
int i = 1;
parameter_code parameter;
while( i < argc ) {
parameter = unknown;
for ( int p = 0 ; parameter_strings[p]; p++)
if ( !strcmp( argv[i], parameter_strings[p]) ) {
parameter = static_cast<parameter_code>(p + 1);
break;
}
if ( parameter != unknown && argc < i +2 ) { // last argument without parameters
argc -= 1;
break; // jump out of the while loop
}
switch (parameter) {
case caption:
aCaption = argv[i+1];
aDummyString2 += parameter_strings[caption-1];
aDummyString2 += " \"";
aDummyString2 += argv[i+1];
aDummyString2 += "\" ";
break;
case icon:
if (argv[i+1][0] == '/')
aIconPixmap = QPixmap(argv[i+1]);
else
aIconPixmap = DesktopIcon(argv[i+1]);
if (aMiniIconPixmap.isNull())
aMiniIconPixmap = SmallIcon(argv[i+1]);
aDummyString2 += parameter_strings[icon-1];
aDummyString2 += " ";
aDummyString2 += argv[i+1];
aDummyString2 += " ";
break;
case miniicon:
aMiniIconPixmap = SmallIcon(argv[i+1]);
aDummyString2 += parameter_strings[miniicon-1];
aDummyString2 += " ";
aDummyString2 += argv[i+1];
aDummyString2 += " ";
break;
case dcopserver:
dcopClient()->setServerAddress(argv[i+1]);
break;
case unknown:
i++;
}
if ( parameter != unknown ) { // remove arguments
for( int j = i; j < argc-2; j++ )
argv[j] = argv[j+2];
argc -=2 ;
}
}
pArgc = argc;
}
kdelibs'KApplication::addCmdLineOptions() (./kdelibs/kdecore/kapp.cpp:704)
KApplication::addCmdLineOptions()
{
KCmdLineArgs::addCmdLineOptions(qt_options, "Qt", "qt");
KCmdLineArgs::addCmdLineOptions(kde_options, "KDE", "kde");
}
kdelibs'KApplication::parseCommandLine() (./kdelibs/kdecore/kapp.cpp:710)
void KApplication::parseCommandLine( )
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde");
if (args->isSet("caption"))
{
aCaption = args->getOption("caption");
}
if (args->isSet("miniicon"))
{
const char *tmp = args->getOption("miniicon");
aMiniIconPixmap = SmallIcon(tmp);
}
if (args->isSet("icon"))
{
const char *tmp = args->getOption("icon");
aIconPixmap = DesktopIcon( tmp );
if (aMiniIconPixmap.isNull())
aMiniIconPixmap = SmallIcon( tmp );
}
if (args->isSet("dcopserver"))
{
dcopClient()->setServerAddress( args->getOption("dcopserver"));
}
bool nocrashhandler = (getenv("KDE_DEBUG") != NULL);
if (!nocrashhandler && args->isSet("crashhandler"))
{
// set default crash handler / set emergency save function to nothing
KCrash::setCrashHandler(KCrash::defaultCrashHandler);
KCrash::setEmergencySaveFunction(NULL);
// WABA: What's the use of a path if you can't guarantee that
// it is the right one?
// KCrash::setApplicationPath(KStandardDirs::findExe(QCString(args->appName()),NULL,0));
KCrash::setApplicationName(QString(args->appName()));
}
delete args; // Throw away
}
kdelibs'KApplication::icon() (./kdelibs/kdecore/kapp.cpp:755)
QPixmap KApplication::icon() const
{
if( aIconPixmap.isNull()) {
KApplication *that = const_cast<KApplication*>(this);
that->aIconPixmap = DesktopIcon( instanceName() );
}
return aIconPixmap;
}
kdelibs'KApplication::miniIcon() (./kdelibs/kdecore/kapp.cpp:764)
QPixmap KApplication::miniIcon() const
{
if (aMiniIconPixmap.isNull()) {
KApplication *that = const_cast<KApplication*>(this);
that->aMiniIconPixmap = SmallIcon( instanceName() );
}
return aMiniIconPixmap;
}
kdelibs'KApplication::~KApplication() (./kdelibs/kdecore/kapp.cpp:772)
KApplication::~KApplication()
{
delete smw;
// close down IPC
delete pDCOPClient;
// Carefully shut down the process controller: It is very likely
// that we receive a SIGCHLD while the destructor is running
// (since we are in the process of shutting down, an opportunity
// at which child process are being killed). So we first mark
// the controller deleted (so that the SIGCHLD handler thinks it
// is already gone) before we actually delete it.
KProcessController* ctrl = KProcessController::theKProcessController;
KProcessController::theKProcessController = 0;
delete ctrl; // Stephan: "there can be only one" ;)
delete pAppData;
KApp = 0;
mySmcConnection = 0;
delete smModificationTime;
smModificationTime = 0;
}
kdelibs'KApplication::x11EventFilter() (./kdelibs/kdecore/kapp.cpp:805)
bool KApplication::x11EventFilter( XEvent *_event )
{
if (x11Filter)
{
for (QWidget* w=x11Filter->first(); w; w=x11Filter->next())
{
if (((KAppX11HackWidget*) w)->publicx11Event(_event))
return true;
}
}
if ((_event->type == ClientMessage) &&
(_event->xclient.message_type == kipcCommAtom))
{
XClientMessageEvent *cme = (XClientMessageEvent *) _event;
int id = cme->data.l[0];
int arg = cme->data.l[1];
if ((id < 32) && (kipcEventMask & (1 << id)))
{
switch (id)
{
case KIPC::StyleChanged:
KGlobal::config()->reparseConfiguration();
kdisplaySetStyle();
break;
case KIPC::PaletteChanged:
KGlobal::config()->reparseConfiguration();
kdisplaySetPalette();
break;
case KIPC::FontChanged:
KGlobal::config()->reparseConfiguration();
kdisplaySetFont();
break;
case KIPC::BackgroundChanged:
emit backgroundChanged(arg);
break;
case KIPC::SettingsChanged:
KGlobal::config()->reparseConfiguration();
emit settingsChanged(arg);
break;
}
}
else if (id >= 32)
{
emit kipcMessage(id, arg);
}
return true;
}
return false;
}
kdelibs'KApplication::addKipcEventMask() (./kdelibs/kdecore/kapp.cpp:862)
void KApplication::addKipcEventMask(int id)
{
if (id >= 32)
{
kdDebug(101) << "Cannot use KIPC event mask for message IDs >= 32\n";
return;
}
kipcEventMask |= (1 << id);
}
kdelibs'KApplication::removeKipcEventMask() (./kdelibs/kdecore/kapp.cpp:872)
void KApplication::removeKipcEventMask(int id)
{
if (id >= 32)
{
kdDebug(101) << "Cannot use KIPC event mask for message IDs >= 32\n";
return;
}
kipcEventMask &= ~(1 << id);
}
kdelibs'KApplication::enableStyles() (./kdelibs/kdecore/kapp.cpp:882)
void KApplication::enableStyles()
{
if (!useStyles)
{
useStyles = true;
applyGUIStyle(Qt::WindowsStyle);
}
}
kdelibs'KApplication::applyGUIStyle() (./kdelibs/kdecore/kapp.cpp:891)
void KApplication::applyGUIStyle(GUIStyle /* pointless */) {
/* Hey, we actually do stuff here now :)
* The widgetStyle key is used as a style string. If it matches a
* Qt internal style that is used, otherwise it is checked to see
* if it matches a lib name in either $(KDEDIR)/lib or
* ~/.kde/share/apps/kstyle/modules. If it does we assume it's a style
* plugin and try to dlopen and allocate a KStyle. If libtool dlopen
* isn't supported that's no problem, plugins just won't work and you'll
* be restricted to the internal styles.
*
* mosfet@jorsm.com
*/
static bool dlregistered = false;
KSimpleConfig pConfig( "kstylerc", true );
QString oldGroup = pConfig.group();
pConfig.setGroup("KDE");
QString styleStr = pConfig.readEntry("widgetStyle", "Platinum");
void *oldHandle = styleHandle;
if(styleStr == "Platinum"){
pKStyle=0;
styleHandle=0;
setStyle(new QPlatinumStyle);
}
else if(styleStr == "Windows 95"){
pKStyle=0;
styleHandle=0;
setStyle(new QWindowsStyle);
}
else if(styleStr == "CDE"){
pKStyle=0;
styleHandle=0;
setStyle(new QCDEStyle);
}
else if(styleStr == "Motif"){
pKStyle=0;
styleHandle=0;
setStyle(new QMotifStyle);
}
else if(useStyles){
if(!dlregistered){
dlregistered = true;
lt_dlinit();
}
if(!locate("lib", styleStr).isNull()) {
styleStr = locate("lib", styleStr);
styleHandle = lt_dlopen(QFile::encodeName(styleStr));
}
else {
warning("KApp: Unable to find style plugin %s.", styleStr.local8Bit().data());
pKStyle = 0;
styleHandle=0;
setStyle(new QPlatinumStyle);
return;
}
if(!styleHandle){
warning("KApp: Unable to open style plugin %s (%s).",
styleStr.local8Bit().data(), lt_dlerror());
pKStyle = 0;
setStyle(new QPlatinumStyle);
}
else{
lt_ptr_t alloc_func = lt_dlsym(styleHandle,
"allocate");
if(!alloc_func){
warning("KApp: Unable to init style plugin %s (%s).",
styleStr.local8Bit().data(), lt_dlerror());
pKStyle = 0;
lt_dlclose(styleHandle);
styleHandle = 0;
setStyle(new QPlatinumStyle);
}
else{
KStyle* (*alloc_ptr)();
alloc_ptr = (KStyle* (*)())(alloc_func);
pKStyle = alloc_ptr();
if(pKStyle){
setStyle(pKStyle);
}
else{
warning("KApp: Style plugin unable to allocate style.");
pKStyle = 0;
setStyle(new QPlatinumStyle);
lt_dlclose(styleHandle);
styleHandle = 0;
}
}
}
}
else{
pKStyle=0;
styleHandle=0;
setStyle(new QPlatinumStyle);
}
if(oldHandle){
lt_dlclose((lt_dlhandle*)oldHandle);
}
}
kdelibs'KApplication::caption() (./kdelibs/kdecore/kapp.cpp:998)
QString KApplication::caption() const
{
// Caption set from command line ?
if( !aCaption.isNull() )
return aCaption;
else
// We have some about data ?
if ( KGlobal::instance()->aboutData() )
return KGlobal::instance()->aboutData()->programName();
else
// Last resort : application name
return name();
}
//
// 1999-09-20: Espen Sand
// An attempt to simplify consistent captions.
//
kdelibs'KApplication::makeStdCaption() (./kdelibs/kdecore/kapp.cpp:1017)
QString KApplication::makeStdCaption( const QString &userCaption,
bool withAppName, bool modified ) const
{
if( userCaption.isNull() == true )
{
return( caption() );
}
//
// This string should be collected from a global object.
//
QString modString = i18n("**");
if( modified == true )
{
modified = modString.isNull() == true ? false : true;
}
if( withAppName == true )
{
if( captionLayout == CaptionAppLast )
{
if( modified == true )
{
return( QString("%1 %2 - %3").arg(modString).arg(userCaption).
arg(caption()));
}
else
{
return( QString("%1 - %2").arg(userCaption).arg(caption()));
}
}
else if( captionLayout == CaptionAppFirst )
{
if( modified == true )
{
return( QString("%1: %2 %3").arg(caption()).arg(modString).
arg(userCaption) );
}
else
{
return( QString("%1: %2").arg(caption()).arg(userCaption) );
}
}
}
if( modified == true )
{
return( QString("%1 %2").arg(modString).arg(userCaption) );
}
else
{
return( userCaption );
}
}
kdelibs'KApplication::kdisplaySetPalette() (./kdelibs/kdecore/kapp.cpp:1072)
void KApplication::kdisplaySetPalette()
{
// the following is temporary and will soon dissappear (Matthias, 3.August 1999 )
KConfigBase* config = KGlobal::config();
KConfigGroupSaver saver( config, "General" );
QColor buttonFallback = config->readColorEntry( "background", &lightGray );
QColor button = config->readColorEntry( "buttonBackground", &buttonFallback );
QColor buttonTextFallback = config->readColorEntry( "foreground", &black );
QColor buttonText = config->readColorEntry( "buttonForeground", &buttonTextFallback );
QColor background = config->readColorEntry( "background", &lightGray );
QColor highlight = config->readColorEntry( "selectBackground", &darkBlue);
QColor highlightedText = config->readColorEntry( "selectForeground", &white );
QColor base = config->readColorEntry( "windowBackground", &white );
QColor foreground = config->readColorEntry( "windowForeground", &black );
config->setGroup( "WM");
inactiveTitleColor_ = config->readColorEntry( "inactiveBackground", &lightGray );
inactiveTextColor_ = config->readColorEntry( "inactiveForeground", &darkGray );
activeTitleColor_ = config->readColorEntry( "activeBackground", &darkBlue );
activeTextColor_ = config->readColorEntry( "activeForeground", &white );
config->setGroup( "KDE");
contrast_ = config->readNumEntry( "contrast", 7 );
int highlightVal, lowlightVal;
highlightVal = 100 + (2*contrast_+4)*16/10;
lowlightVal = 100 + (2*contrast_+4)*10;
QColorGroup disabledgrp(foreground, background,
background.light(highlightVal),
background.dark(lowlightVal),
background.dark(120),
background.dark(120), base);
QColorGroup colgrp(foreground, background, background.light(highlightVal),
background.dark(lowlightVal),
background.dark(120),
foreground, base);
int inlowlightVal = lowlightVal-25;
if(inlowlightVal < 120)
inlowlightVal = 120;
/*
QColorGroup inactivegrp(foreground, button.light(110),
background.light(highlightVal),
background.dark(inlowlightVal), background,
foreground, highlightedText, base,
background);*/
/*
QColorGroup disabledgrp( textColor, backgroundColor,
backgroundColor.light(highlightVal),
backgroundColor.dark(lowlightVal),
backgroundColor.dark(120),
backgroundColor.dark(120), windowColor );
QColorGroup colgrp( textColor, backgroundColor,
backgroundColor.light(highlightVal),
backgroundColor.dark(lowlightVal),
backgroundColor.dark(120),
textColor, windowColor );*/
colgrp.setColor(QColorGroup::Highlight, highlight);
colgrp.setColor(QColorGroup::HighlightedText, highlightedText);
colgrp.setColor(QColorGroup::Button, button);
colgrp.setColor(QColorGroup::ButtonText, buttonText);
colgrp.setColor(QColorGroup::Midlight, background.light(110));
disabledgrp.setColor(QColorGroup::Button, button);
disabledgrp.setColor(QColorGroup::ButtonText, buttonText);
disabledgrp.setColor(QColorGroup::Midlight, background.light(110));
QPalette newPal;
newPal.setActive(colgrp);
newPal.setDisabled(disabledgrp);
newPal.setInactive(colgrp);
/*
if(QPixmap::defaultDepth() > 8){
QColorGroup iGrp(colgrp);
iGrp.setColor(QColorGroup::Button, colgrp.button().light(115));
iGrp.setColor(QColorGroup::ButtonText, colgrp.buttonText().light(115));
iGrp.setColor(QColorGroup::Text, colgrp.text().light(115));
iGrp.setColor(QColorGroup::Dark, colgrp.dark().light(115));
iGrp.setColor(QColorGroup::Mid, colgrp.mid().light(115));
iGrp.setColor(QColorGroup::Midlight, colgrp.midlight().light(115));
iGrp.setColor(QColorGroup::Light, colgrp.light().light(115));
newPal.setInactive(iGrp);
}
*/
setPalette(newPal, true);
// GJ: The cursor blink rate doesn't belong here. It should get it's own
// change message but it doesn't really matter because it isn't set.
int num = config->readNumEntry("cursorBlinkRate", cursorFlashTime());
if (num < 200)
num = 200;
if (num > 2000)
num = 2000;
setCursorFlashTime(num);
style().polish(newPal);
emit kdisplayPaletteChanged();
emit appearanceChanged();
}
kdelibs'KApplication::kdisplaySetFont() (./kdelibs/kdecore/kapp.cpp:1177)
void KApplication::kdisplaySetFont()
{
delete KGlobal::_generalFont;
KGlobal::_generalFont = 0L;
delete KGlobal::_fixedFont;
KGlobal::_fixedFont = 0L;
delete KGlobal::_menuFont;
KGlobal::_menuFont = 0L;
delete KGlobal::_toolBarFont;
KGlobal::_toolBarFont = 0L;
QApplication::setFont(KGlobal::generalFont(), true);
emit kdisplayFontChanged();
emit appearanceChanged();
}
kdelibs'KApplication::kdisplaySetStyle() (./kdelibs/kdecore/kapp.cpp:1194)
void KApplication::kdisplaySetStyle()
{
applyGUIStyle(WindowsStyle);
emit kdisplayStyleChanged();
emit appearanceChanged();
}
kdelibs'KApplication::invokeHTMLHelp() (./kdelibs/kdecore/kapp.cpp:1202)
void KApplication::invokeHTMLHelp( QString filename, QString topic ) const
{
QApplication::flushX();
if ( fork() == 0 )
{
if( filename.isEmpty() )
filename = QString(name()) + "/index.html";
// first try the locale setting
QString file = locate("html", KGlobal::locale()->language() + '/' + filename);
if (file.isNull())
file = locate("html", "default/" + filename);
if (file.isNull()) {
warning("no help file %s found\n", filename.local8Bit().data());
_exit( 1 );
}
if( !topic.isEmpty() ) {
file.append( "#" );
file.append(topic);
}
/* Since this is a library, we must conside the possibilty that
* we are being used by a suid root program. These next two
* lines drop all privileges.
*/
setuid( getuid() );
setgid( getgid() );
const char* shell = "/bin/sh";
if (getenv("SHELL"))
shell = getenv("SHELL");
file.prepend("khelpcenter ");
execl(shell, shell, "-c", QFile::encodeName(file).data(), 0L);
_exit( 1 );
}
}
kdelibs'KApplication::invokeMailer() (./kdelibs/kdecore/kapp.cpp:1241)
void KApplication::invokeMailer(const QString &address,const QString &subject )
{
QApplication::flushX();
if( fork() == 0 )
{
QString mailClient( "kmail");
QString exec = QString("%1 %2 -s %3").arg(mailClient).arg(address).
arg(subject);
setuid( getuid() ); // Make sure a set-user-id prog. is not root anymore
setgid( getgid() );
const char* shell = "/bin/sh";
if( getenv("SHELL") )
{
shell = getenv("SHELL");
}
execl( shell, shell, "-c", QFile::encodeName(exec).data(), 0L );
_exit( 1 );
}
}
kdelibs'KApplication::invokeBrowser() (./kdelibs/kdecore/kapp.cpp:1264)
void KApplication::invokeBrowser( const QString &url )
{
QApplication::flushX();
if( fork() == 0 )
{
setuid( getuid() ); // Make sure a set-user-id prog. is not root anymore
setgid( getgid() );
QString browser, exec;
//
// 1999-10-05 Espen Sand
//
// The code below is inspired by the work of Markus Goetz <guruz@gmx.de>
// It should not be here at all. We should rather just use a method
// that returns the correct browser exec string:
// exec = KSomeGlobalObject::browser( url ):
// and it must be done before the fork() above I'll guess. Is that OK
// with Qt/QString?
//
#if 0
if( 0 )
{
browser = "lynx";
exec = QString("konsole -e %1 %2").arg(browser).arg(url);
}
else if(0)
{
browser = "netscape";
QString lockFile = QString("%1/.netscape/lock").arg(getenv("HOME"));
struct stat statInfo;
if( lstat(QFile::encodeName(lockFile), &statInfo) != -1 )
{
exec = QString("%1 -remote 'openURL(%2,new-window)'").arg(browser).
arg(url);
}
else
{
exec = QString("%1 %2").arg(browser).arg(url);
}
}
else
{
browser = "kfmclient";
exec = QString("%1 openURL %2").arg(browser).arg(url);
}
#endif
//
// This is what we use now.
//
browser = "kfmclient";
exec = QString("%1 openURL %2").arg(browser).arg(url);
const char* shell = "/bin/sh";
if( getenv("SHELL") )
{
shell = getenv("SHELL");
}
execl( shell, shell, "-c", QFile::encodeName(exec).data(), 0L );
_exit( 1 );
}
}
QCString
kdelibs'KApplication::launcher() (./kdelibs/kdecore/kapp.cpp:1332)
KApplication::launcher()
{
char host[200];
if (gethostname(host, 200) == -1) {
kdDebug(101) << "gethostname(): " << strerror(errno) << "\n";
return 0;
}
// Try to resolve to FQDN
struct hostent *h = gethostbyname(host);
if (h == 0L) {
kdDebug(101) << "gethostbyname() returned with an error!\n";
} else {
if (strlen(h->h_name) < 200)
strcpy(host, h->h_name);
else
kdDebug(101) << "host name too long\n";
}
QCString name;
name.sprintf("klauncher_%s_%d", host, getuid());
return name;
}
static int
kdelibs'KApplication::startServiceByName() (./kdelibs/kdecore/kapp.cpp:1407)
KApplication::startServiceByName( const QString& _name, const QString &URL,
QCString &dcopService, QString &error )
{
return startServiceInternal(
"start_service_by_name(QString,QString)",
_name, URL, dcopService, error);
}
int
kdelibs'KApplication::startServiceByDesktopPath() (./kdelibs/kdecore/kapp.cpp:1416)
KApplication::startServiceByDesktopPath( const QString& _name, const QString &URL,
QCString &dcopService, QString &error )
{
return startServiceInternal(
"start_service_by_desktop_path(QString,QString)",
_name, URL, dcopService, error);
}
int
kdelibs'KApplication::startServiceByDesktopName() (./kdelibs/kdecore/kapp.cpp:1425)
KApplication::startServiceByDesktopName( const QString& _name, const QString &URL,
QCString &dcopService, QString &error )
{
return startServiceInternal(
"start_service_by_desktop_name(QString,QString)",
_name, URL, dcopService, error);
}
kdelibs'KApplication::kdeFonts() (./kdelibs/kdecore/kapp.cpp:1434)
bool KApplication::kdeFonts(QStringList &fontlist) const
{
QString fontfilename = KGlobal::dirs()->saveLocation("config") + "kdefonts";
QFile fontfile(fontfilename);
if (!fontfile.exists())
return false;
if(!fontfile.open(IO_ReadOnly)){
return false;
}
QTextStream t(&fontfile);
while ( !t.eof() ) {
QString s = t.readLine();
if(!s.isEmpty())
fontlist.append( s );
}
fontfile.close();
return true;
}
kdelibs'KApplication::tempSaveName() (./kdelibs/kdecore/kapp.cpp:1461)
QString KApplication::tempSaveName( const QString& pFilename ) const
{
QString aFilename;
if( pFilename[0] != '/' )
{
kdWarning(101) << "Relative filename passed to KApplication::tempSaveName" << endl;
aFilename = QFileInfo( QDir( "." ), pFilename ).absFilePath();
}
else
aFilename = pFilename;
QDir aAutosaveDir( QDir::homeDirPath() + "/autosave/" );
if( !aAutosaveDir.exists() )
{
if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
{
// Last chance: use _PATH_TMP
aAutosaveDir.setPath( _PATH_TMP );
}
}
aFilename.replace( QRegExp( "/" ),"\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() );
return aFilename;
}
kdelibs'KApplication::checkRecoverFile() (./kdelibs/kdecore/kapp.cpp:1489)
QString KApplication::checkRecoverFile( const QString& pFilename,
bool& bRecover ) const
{
QString aFilename;
if( pFilename[0] != '/' )
{
kdWarning(101) << "Relative filename passed to KApplication::tempSaveName" << endl;
aFilename = QFileInfo( QDir( "." ), pFilename ).absFilePath();
}
else
aFilename = pFilename;
QDir aAutosaveDir( QDir::homeDirPath() + "/autosave/" );
if( !aAutosaveDir.exists() )
{
if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) )
{
// Last chance: use _PATH_TMP
aAutosaveDir.setPath( _PATH_TMP );
}
}
aFilename.replace( QRegExp( "/" ), "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() );
if( QFile( aFilename ).exists() )
{
bRecover = true;
return aFilename;
}
else
{
bRecover = false;
return pFilename;
}
}
kdelibs'KApplication::setTopWidget() (./kdelibs/kdecore/kapp.cpp:1560)
void KApplication::setTopWidget( QWidget *topWidget )
{
if( topWidget != 0 )
{
Window leader = topWidget->winId();
QCString string_buffer = instanceName().data(); // copies it
char * argv = string_buffer.data();
XSetCommand(display, leader, &argv, 1);
XClassHint hint;
hint.res_name = string_buffer.data();
hint.res_class = const_cast<char*>("toplevel");
XSetClassHint(display, leader, &hint);
XWMHints * hints = XAllocWMHints();
hints->window_group = leader;
hints->flags = WindowGroupHint;
XSetWMHints(display, leader, hints);
XFree( (char*)hints);
// set the specified caption
topWidget->setCaption( caption() );
// set the specified icons
KWM::setIcon(topWidget->winId(), icon());
KWM::setMiniIcon(topWidget->winId(), miniIcon());
// set a short icon text
// TODO: perhaps using .ascii() isn't right here as this may be seen by
// a user?
XSetIconName( qt_xdisplay(), topWidget->winId(), caption().ascii() );
}
}
kdelibs'KApplication::inactiveTitleColor() (./kdelibs/kdecore/kapp.cpp:1594)
QColor KApplication::inactiveTitleColor() const
{
return inactiveTitleColor_;
}
kdelibs'KApplication::inactiveTextColor() (./kdelibs/kdecore/kapp.cpp:1600)
QColor KApplication::inactiveTextColor() const
{
return inactiveTextColor_;
}
kdelibs'KApplication::activeTitleColor() (./kdelibs/kdecore/kapp.cpp:1606)
QColor KApplication::activeTitleColor() const
{
return activeTitleColor_;
}
kdelibs'KApplication::activeTextColor() (./kdelibs/kdecore/kapp.cpp:1612)
QColor KApplication::activeTextColor() const
{
return activeTextColor_;
}
kdelibs'KApplication::contrast() (./kdelibs/kdecore/kapp.cpp:1617)
int KApplication::contrast() const
{
return contrast_;
}
kdelibs'KApplication::random() (./kdelibs/kdecore/kapp.cpp:1622)
int KApplication::random()
{
static int init = false;
if (!init)
{
unsigned int seed;
init = true;
int fd = open("/dev/urandom", O_RDONLY);
if (fd <= 0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed))
{
// No /dev/urandom... try something else.
srand(getpid());
seed = rand()+time(0);
}
if (fd >= 0) close(fd);
srand(seed);
}
return rand();
}
kdelibs'KApplication::randomString() (./kdelibs/kdecore/kapp.cpp:1642)
QString KApplication::randomString(int length)
{
if (!length) return QString::null;
if (length<0)
length=random();
char *string=new char[length+1];
while (length--)
{
int r=random() % 62;
r+=48;
if (r>57) r+=7;
if (r>90) r+=6;
string[length]=(char)r;
// so what if I work backwards?
}
QString str(string);
delete [] string;
return str;
}