KisApplication.h 3.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* 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 KIS_APPLICATION_H
#define KIS_APPLICATION_H

23
#include <qtsingleapplication/qtsingleapplication.h>
24
#include "kritaui_export.h"
25 26 27 28

class KisMainWindow;
class KisApplicationPrivate;
class QWidget;
29
class KisApplicationArguments;
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

#include <KisImportExportManager.h>

/**
 *  @brief Base class for all %Calligra apps
 *
 *  This class handles arguments given on the command line and
 *  shows a generic about dialog for all Calligra apps.
 *
 *  In addition it adds the standard directories where Calligra applications
 *  can find their images etc.
 *
 *  If the last mainwindow becomes closed, KisApplication automatically
 *  calls QApplication::quit.
 */
45
class KRITAUI_EXPORT KisApplication : public QtSingleApplication
46 47 48 49 50 51 52 53
{
    Q_OBJECT

public:
    /**
     * Creates an application object, adds some standard directories and
     * initializes kimgio.
     */
54
    explicit KisApplication(const QString &key, int &argc, char **argv);
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

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

    /**
     * Call this to start the application.
     *
     * Parses command line arguments and creates the initial main windowss and docs
     * 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.
     */
72
    virtual bool start(const KisApplicationArguments &args);
73

74 75 76 77 78 79 80
    /**
     * Checks if user is holding ctrl+alt+shift keys and asks if the settings file should be cleared.
     *
     * Typically called during startup before reading the config.
     */
    void askClearConfig();

81 82 83 84 85 86 87 88 89 90
    /**
     * Tell KisApplication 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. 
     */
    void setSplashScreen(QWidget *splash);

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

91
public Q_SLOTS:
92

93
    void remoteArguments(QByteArray message, QObject*socket);
94 95
    void fileOpenRequested(const QString & url);

96 97
private:
    /// @return the number of autosavefiles opened
Boudewijn Rempt's avatar
Boudewijn Rempt committed
98
    QList<QUrl> checkAutosaveFiles();
99
    bool createNewDocFromTemplate(const QString &fileName, KisMainWindow *mainWindow);
100
    void clearConfig();
101

102
private:
103 104 105 106 107 108
    KisApplicationPrivate * const d;
    class ResetStarting;
    friend class ResetStarting;
};

#endif