kapplication.h
/* This file is part of the KDE libraries
Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
Copyright (c) 1998, 1999 KDE Team
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KAPP_H
#define _KAPP_H
// Version macros. Never put this further down.
#include "kdeversion.h"
#include "kdelibs_export.h"
class KConfig;
class KCharsets;
class DCOPClient;
class DCOPObject;
typedef unsigned long Atom;
#if !defined(Q_WS_X11)
typedef void Display;
#endif
#include <qapplication.h>
#include <qpixmap.h>
#include <kinstance.h>
struct _IceConn;
class QPopupMenu;
class QStrList;
class KSessionManaged;
class KStyle;
class KURL;
#define kapp KApplication::kApplication()
class KApplicationPrivate;
class KDECORE_EXPORT KApplication : public QApplication, public KInstance
{
Q_OBJECT
public:
enum CaptionLayout {
CaptionAppLast=1 ,
CaptionAppFirst ,
CaptionNoApp
};
KApplication( bool allowStyles=true, bool GUIenabled=true);
#ifdef Q_WS_X11
KApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0,
bool allowStyles=true);
KApplication(Display *display, int& argc, char** argv, const QCString& rAppName,
bool allowStyles=true, bool GUIenabled=true);
#endif
// REMOVE FOR KDE 4.0 - using it only gives crashing applications because
// KCmdLineArgs::init isn't called
KApplication(int& argc, char** argv,
const QCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED;
static void addCmdLineOptions();
virtual ~KApplication();
static KApplication* kApplication() { return KApp; }
KConfig* sessionConfig();
bool isRestored() const { return QApplication::isSessionRestored(); }
void disableSessionManagement();
void enableSessionManagement();
enum ShutdownConfirm {
ShutdownConfirmDefault = -1,
ShutdownConfirmNo = 0,
ShutdownConfirmYes = 1
};
enum ShutdownType {
ShutdownTypeDefault = -1,
ShutdownTypeNone = 0,
ShutdownTypeReboot = 1,
ShutdownTypeHalt = 2
};
enum ShutdownMode {
ShutdownModeDefault = -1,
ShutdownModeSchedule = 0,
ShutdownModeTryNow = 1,
ShutdownModeForceNow = 2,
ShutdownModeInteractive = 3
};
bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
ShutdownType sdtype = ShutdownTypeDefault,
ShutdownMode sdmode = ShutdownModeDefault );
void propagateSessionManager();
void commitData( QSessionManager& sm );
void saveState( QSessionManager& sm );
bool sessionSaving() const;
static DCOPClient *dcopClient();
static void disableAutoDcopRegistration();
QPixmap icon() const;
QString iconName() const;
QPixmap miniIcon() const;
QString miniIconName() const;
void setTopWidget( QWidget *topWidget );
void invokeHelp( const QString& anchor,
const QString& appname,
const QCString& startup_id ) const;
// KDE4 merge with above with startup_id = ""
void invokeHelp( const QString& anchor = QString::null,
const QString& appname = QString::null ) const;
void invokeHTMLHelp( const QString& aFilename, const QString& aTopic = QString::null ) const KDE_DEPRECATED;
void invokeMailer( const QString &address, const QString &subject, const QCString& startup_id );
// KDE4 merge with above with startup_id = ""
void invokeMailer( const QString &address, const QString &subject );
void invokeMailer( const KURL &mailtoURL, const QCString& startup_id, bool allowAttachments );
// KDE4 merge with above with allowAttachments = false
void invokeMailer( const KURL &mailtoURL, const QCString& startup_id );
// KDE4 merge with above with startup_id = ""
void invokeMailer( const KURL &mailtoURL );
void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
const QString &subject, const QString &body,
const QString &messageFile, const QStringList &attachURLs,
const QCString& startup_id );
// KDE4 merge with above with startup_id = ""
void invokeMailer(const QString &to, const QString &cc, const QString &bcc,
const QString &subject, const QString &body,
const QString &messageFile = QString::null, const QStringList &attachURLs = QStringList());
public slots:
void invokeBrowser( const QString &url, const QCString& startup_id );
// KDE4 merge with above with startup_id = ""
void invokeBrowser( const QString &url );
void cut();
void copy();
void paste();
void clear();
void selectAll();
public:
static QCString launcher();
static int startServiceByName( const QString& _name, const QString &URL,
QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
static int startServiceByName( const QString& _name, const QStringList &URLs=QStringList(),
QString *error=0, QCString *dcopService=0, int *pid=0, const QCString &startup_id = "", bool noWait = false );
static int startServiceByDesktopPath( const QString& _name, const QString &URL,
QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
static int startServiceByDesktopPath( const QString& _name, const QStringList &URLs=QStringList(),
QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
static int startServiceByDesktopName( const QString& _name, const QString &URL,
QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
static int startServiceByDesktopName( const QString& _name, const QStringList &URLs=QStringList(),
QString *error=0, QCString *dcopService=0, int *pid = 0, const QCString &startup_id = "", bool noWait = false );
static int kdeinitExec( const QString& name, const QStringList &args,
QString *error, int *pid, const QCString& startup_id );
// KDE4 merge with above with startup_id = ""
static int kdeinitExec( const QString& name, const QStringList &args=QStringList(),
QString *error=0, int *pid = 0 );
static int kdeinitExecWait( const QString& name, const QStringList &args,
QString *error, int *pid, const QCString& startup_id );
// KDE4 merge with above with startup_id = ""
static int kdeinitExecWait( const QString& name, const QStringList &args=QStringList(),
QString *error=0, int *pid = 0 );
QString caption() const;
KDE_DEPRECATED KStyle* kstyle() const { return 0; }
QString makeStdCaption( const QString &userCaption,
bool withAppName=true, bool modified=false ) const;
QString tempSaveName( const QString& pFilename ) const;
QString checkRecoverFile( const QString& pFilename, bool& bRecover ) const;
#ifdef Q_WS_X11
Display *getDisplay() { return display; }
#endif
void enableStyles();
void disableStyles();
void installX11EventFilter( QWidget* filter );
void removeX11EventFilter( const QWidget* filter );
static int random();
static QString randomString(int length);
void addKipcEventMask(int id);
void removeKipcEventMask(int id);
QCString startupId() const;
void setStartupId( const QCString& startup_id );
void updateUserTimestamp( unsigned long time = 0 );
unsigned long userTimestamp() const;
void updateRemoteUserTimestamp( const QCString& dcopId, unsigned long time = 0 );
QString geometryArgument() const;
void installKDEPropertyMap();
bool authorize(const QString &genericAction);
bool authorizeKAction(const char *action);
bool authorizeURLAction(const QString &action, const KURL &baseURL, const KURL &destURL);
void allowURLAction(const QString &action, const KURL &_baseURL, const KURL &_destURL);
bool authorizeControlModule(const QString &menuId);
QStringList authorizeControlModules(const QStringList &menuIds);
static ButtonState keyboardMouseState();
// Same values as ShiftMask etc. in X.h
enum { ShiftModifier = 1<<0,
LockModifier = 1<<1,
ControlModifier = 1<<2,
Modifier1 = 1<<3,
Modifier2 = 1<<4,
Modifier3 = 1<<5,
Modifier4 = 1<<6,
Modifier5 = 1<<7 };
static uint keyboardModifiers() KDE_DEPRECATED;
enum { Button1Pressed = 1<<8,
Button2Pressed = 1<<9,
Button3Pressed = 1<<10,
Button4Pressed = 1<<11,
Button5Pressed = 1<<12 };
static uint mouseState() KDE_DEPRECATED;
public slots:
void ref();
void deref();
protected:
KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance );
#ifdef Q_WS_X11
KApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap,
bool allowStyles, KInstance* _instance );
bool x11EventFilter( XEvent * );
Display *display;
#endif
Atom kipcCommAtom;
int kipcEventMask;
static KApplication *KApp;
int pArgc;
void invokeEditSlot( const char *slot );
private slots:
void dcopFailure(const QString &);
void dcopBlockUserInput( bool );
void x11FilterDestroyed();
void checkAppStartedSlot();
private:
QString sessionConfigName() const;
KConfig* pSessionConfig; //instance specific application config object
static DCOPClient *s_DCOPClient; // app specific application communication client
static bool s_dcopClientNeedsPostInit;
QString aCaption; // the name for the window title
bool bSessionManagement;
struct oldPixmapType { QPixmap a, b; };
mutable union {
struct {
QPixmap *icon, *miniIcon;
} pm;
char unused[sizeof(oldPixmapType)];
} aIconPixmap; // KDE4: remove me
QString aIconName;
QString aMiniIconName;
bool useStyles;
QWidget *smw;
void init( bool GUIenabled );
void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs)
void read_app_startup_id();
void dcopAutoRegistration();
void dcopClientPostInit();
void initUrlActionRestrictions();
public:
bool notify(QObject *receiver, QEvent *event);
int xErrhandler( Display*, void* );
int xioErrhandler( Display* );
void iceIOErrorHandler( _IceConn *conn );
static bool loadedByKdeinit;
static void startKdeinit();
enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS };
static QPalette createApplicationPalette();
static QPalette createApplicationPalette( KConfig *config, int contrast );
static void installSigpipeHandler();
static bool guiEnabled();
signals:
void kdisplayPaletteChanged();
void kdisplayStyleChanged();
void kdisplayFontChanged();
void appearanceChanged();
void toolbarAppearanceChanged(int);
void backgroundChanged(int desk);
void settingsChanged(int category);
void iconChanged(int group);
void kipcMessage(int id, int data);
void saveYourself();
void shutDown();
void updateIconLoaders();
private:
void propagateSettings(SettingsCategory category);
void kdisplaySetPalette();
void kdisplaySetStyle();
void kdisplaySetFont();
void applyGUIStyle();
static void sigpipeHandler(int);
int captionLayout;
KApplication(const KApplication&);
KApplication& operator=(const KApplication&);
protected:
virtual void virtual_hook( int id, void* data );
private:
KApplicationPrivate* d;
};
KDECORE_EXPORT bool checkAccess(const QString& pathname, int mode);
class KSessionManagedPrivate;
class KDECORE_EXPORT KSessionManaged
{
public:
KSessionManaged();
virtual ~KSessionManaged();
virtual bool saveState( QSessionManager& sm );
virtual bool commitData( QSessionManager& sm );
protected:
virtual void virtual_hook( int id, void* data );
private:
KSessionManagedPrivate *d;
};
#endif
KURL
Represents and parses a URL.
Definition: kurl.h:127
KApplication
Controls and provides information to all KDE applications.
Definition: kapplication.h:94
KApplication::ShutdownConfirm
ShutdownConfirm
The possible values for the confirm parameter of requestShutDown().
Definition: kapplication.h:264
KApplication::ShutdownType
ShutdownType
The possible values for the sdtype parameter of requestShutDown().
Definition: kapplication.h:282
KCharsets
Charset font and encoder/decoder handling.
Definition: kcharsets.h:43
KApplication::SettingsCategory
SettingsCategory
Valid values for the settingsChanged signal.
Definition: kapplication.h:1228
KApplication::KApp
static KApplication * KApp
Current application object.
Definition: kapplication.h:1123
DCOPClient
KInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:43
KApplication::isRestored
bool isRestored() const
Is the application restored from the session manager?
Definition: kapplication.h:243
KConfig
Access KDE Configuration entries.
Definition: kconfig.h:43
KApplication::CaptionLayout
CaptionLayout
Position of the caption (presumably in the application window's title bar).
Definition: kapplication.h:104
DCOPObject
KGlobal::checkAccess
bool checkAccess(const QString &pathname, int mode)
Definition: kapplication.cpp:2854
KSessionManaged
Provides highlevel access to session management on a per-object base.
Definition: kapplication.h:1441
KApplication::ShutdownMode
ShutdownMode
The possible values for the sdmode parameter of requestShutDown().
Definition: kapplication.h:304

KDE Home | KDE Accessibility Home | Description of Access Keys