Application.h 3.17 KB
Newer Older
1
/*
2
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA.
*/

20 21
#ifndef APPLICATION_H
#define APPLICATION_H
22

23 24
// Qt
#include <QCommandLineParser>
25

26
// Konsole
27
#include "widgets/ViewSplitter.h"
28

Kurt Hindenburg's avatar
Kurt Hindenburg committed
29
namespace Konsole {
30
class MainWindow;
31
class Session;
32
class Profile;
33 34

/**
35 36
 * The Konsole Application.
 *
Kurt Hindenburg's avatar
Kurt Hindenburg committed
37 38
 * The application consists of one or more main windows and a set of
 * factories to create new sessions and views.
39
 *
Kurt Hindenburg's avatar
Kurt Hindenburg committed
40 41
 * To create a new main window with a default terminal session, call
 * the newInstance(). Empty main windows can be created using newMainWindow().
42
 *
Kurt Hindenburg's avatar
Kurt Hindenburg committed
43 44
 * The factory used to create new terminal sessions can be retrieved using
 * the sessionManager() accessor.
45
 */
46
class Application : public QObject
47
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
48
    Q_OBJECT
49

50 51
public:
    /** Constructs a new Konsole application. */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
52 53
    explicit Application(QSharedPointer<QCommandLineParser> parser,
                         const QStringList &customCommand);
54 55

    static void populateCommandLineParser(QCommandLineParser *parser);
56
    static QStringList getCustomCommand(QStringList &args);
57

58
    ~Application() override;
59

60
    /** Creates a new main window and opens a default terminal session */
61
    int newInstance();
62

Jekyll Wu's avatar
Jekyll Wu committed
63
    /**
64 65
     * Creates a new, empty main window and connects to its newSessionRequest()
     * and newWindowRequest() signals to trigger creation of new sessions or
Jekyll Wu's avatar
Jekyll Wu committed
66
     * windows when then they are emitted.
67
     */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
68
    MainWindow *newMainWindow();
69

70
private Q_SLOTS:
71
    void createWindow(const QExplicitlySharedDataPointer<Profile> &profile, const QString &directory);
Tomaz  Canabrava's avatar
Tomaz Canabrava committed
72
    void detachTerminals(ViewSplitter *splitter, const QHash<TerminalDisplay*, Session*>& sessionsMap);
73

Kurt Hindenburg's avatar
Kurt Hindenburg committed
74 75
    void toggleBackgroundInstance();

76
public Q_SLOTS:
Kurt Hindenburg's avatar
Kurt Hindenburg committed
77
    void slotActivateRequested(QStringList args, const QString &workingDir);
78

79
private:
80 81
    Q_DISABLE_COPY(Application)

82
    void listAvailableProfiles();
83
    void listProfilePropertyInfo();
Kurt Hindenburg's avatar
Kurt Hindenburg committed
84
    void startBackgroundMode(MainWindow *window);
85
    bool processHelpArgs();
Kurt Hindenburg's avatar
Kurt Hindenburg committed
86
    MainWindow *processWindowArgs(bool &createdNewMainWindow);
87 88
    QExplicitlySharedDataPointer<Profile> processProfileSelectArgs();
    QExplicitlySharedDataPointer<Profile> processProfileChangeArgs(QExplicitlySharedDataPointer<Profile> baseProfile);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
89 90
    bool processTabsFromFileArgs(MainWindow *window);
    void createTabFromArgs(MainWindow *window, const QHash<QString, QString> &);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
91

Kurt Hindenburg's avatar
Kurt Hindenburg committed
92
    MainWindow *_backgroundInstance;
93
    QSharedPointer<QCommandLineParser> m_parser;
94
    QStringList m_customCommand;
95
};
Stephan Binner's avatar
Stephan Binner committed
96
}
97
#endif  // APPLICATION_H