KoApplication.h 4.09 KB
Newer Older
Casper Boemann's avatar
Casper Boemann committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/* This file is part of the KDE project
   Copyright (C) 1998, 1999 Torben Weis <weis@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., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef __ko_app_h__
#define __ko_app_h__

#include <kapplication.h>
24
#include "komain_export.h"
Casper Boemann's avatar
Casper Boemann committed
25

26 27
class KoPart;

Casper Boemann's avatar
Casper Boemann committed
28
class KoApplicationPrivate;
29

30
class QWidget;
31 32 33 34 35
class QStringList;

#include <KoFilterManager.h>

#define koApp KoApplication::koApplication()
Casper Boemann's avatar
Casper Boemann committed
36 37

/**
Halla Rempt's avatar
Halla Rempt committed
38
 *  @brief Base class for all %Calligra apps
Casper Boemann's avatar
Casper Boemann committed
39 40
 *
 *  This class handles arguments given on the command line and
Halla Rempt's avatar
Halla Rempt committed
41
 *  shows a generic about dialog for all Calligra apps.
Casper Boemann's avatar
Casper Boemann committed
42
 *
Halla Rempt's avatar
Halla Rempt committed
43
 *  In addition it adds the standard directories where Calligra applications
Casper Boemann's avatar
Casper Boemann committed
44 45 46 47 48 49 50 51 52 53 54 55 56
 *  can find their images etc.
 *
 *  If the last mainwindow becomes closed, KoApplication automatically
 *  calls QApplication::quit.
 */
class KOMAIN_EXPORT KoApplication : public KApplication
{
    Q_OBJECT

public:
    /**
     * Creates an application object, adds some standard directories and
     * initializes kimgio.
57 58
     *
     * @param nativeMimeType: the nativeMimeType of the calligra application
Casper Boemann's avatar
Casper Boemann committed
59
     */
60
    explicit KoApplication(const QByteArray &nativeMimeType);
Casper Boemann's avatar
Casper Boemann committed
61 62 63 64 65 66 67 68 69

    /**
     *  Destructor.
     */
    virtual ~KoApplication();

    /**
     * Call this to start the application.
     *
70
     * Parses command line arguments and creates the initial main windowss and docs
Casper Boemann's avatar
Casper Boemann committed
71 72 73 74 75 76 77 78 79
     * from them (or an empty doc if no cmd-line argument is specified ).
     *
     * You must call this method directly before calling QApplication::exec.
     *
     * It is valid behaviour not to call this method at all. In this case you
     * have to process your command line parameters by yourself.
     */
    virtual bool start();

80 81 82 83 84
    /**
     * Tell KoApplication to show this splashscreen when you call start();
     * when start returns, the splashscreen is hidden. Use KSplashScreen
     * to have the splash show correctly on Xinerama displays. 
     */
85
    void setSplashScreen(QWidget *splash);
86

87 88 89

    QList<KoPart*> partList() const;

90 91 92 93 94
    /**
     * Remove the splash dialog
     */
    void removeSplash();

95 96 97 98
    /**
     * return a list of mimetypes this application supports.
     */
    QStringList mimeFilter(KoFilterManager::Direction direction) const;
99

100 101 102
    // Overridden to handle exceptions from event handlers.
    bool notify(QObject *receiver, QEvent *event);

103 104 105 106 107 108 109 110 111 112 113 114
    /**
     * Returns the current application object.
     *
     * This is similar to the global QApplication pointer qApp. It
     * allows access to the single global KoApplication 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.
     * @return the current application object
     */
    static KoApplication* koApplication();

115 116
signals:

117 118 119
    /// KoPart needs to be able to emit document signals from here. These
    /// signals are used for the dbus interface of stage, see commit
    /// d102d9beef80cc93fc9c130b0ad5fe1caf238267
120
    friend class KoPart;
121

122 123 124 125 126 127 128 129 130 131
    /**
     * emitted when a new document is opened.
     */
    void documentOpened(const QString &ref);

    /**
     * emitted when an old document is closed.
     */
    void documentClosed(const QString &ref);

132 133 134 135 136
protected:

    // Current application object.
    static KoApplication *KoApp;

Casper Boemann's avatar
Casper Boemann committed
137 138 139 140 141 142 143 144
private:
    bool initHack();
    KoApplicationPrivate * const d;
    class ResetStarting;
    friend class ResetStarting;
};

#endif