icore.h 5.05 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
Eike Ziller's avatar
Eike Ziller committed
3
4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
Eike Ziller's avatar
Eike Ziller committed
12
13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** use the contact form at http://www.qt.io/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18
19
20
21
22
23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
Eike Ziller's avatar
Eike Ziller committed
25
26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
con's avatar
con committed
27
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
con's avatar
con committed
30
31
32
33
34

#ifndef ICORE_H
#define ICORE_H

#include "core_global.h"
35
#include "id.h"
36

37
38
#include <QObject>
#include <QSettings>
con's avatar
con committed
39
40
41

QT_BEGIN_NAMESPACE
class QPrinter;
42
class QStatusBar;
43
class QWidget;
44
template <class T> class QList;
con's avatar
con committed
45
46
47
QT_END_NAMESPACE

namespace Core {
Tobias Hunger's avatar
Tobias Hunger committed
48
class IWizardFactory;
49
class Context;
50
class IContext;
51
class ProgressManager;
52
class SettingsDatabase;
hjk's avatar
hjk committed
53
class VcsManager;
con's avatar
con committed
54

hjk's avatar
hjk committed
55
56
namespace Internal { class MainWindow; }

con's avatar
con committed
57
58
59
60
class CORE_EXPORT ICore : public QObject
{
    Q_OBJECT

hjk's avatar
hjk committed
61
62
63
    friend class Internal::MainWindow;
    explicit ICore(Internal::MainWindow *mw);
    ~ICore();
con's avatar
con committed
64

hjk's avatar
hjk committed
65
public:
hjk's avatar
hjk committed
66
67
68
    // This should only be used to acccess the signals, so it could
    // theoretically return an QObject *. For source compatibility
    // it returns a ICore.
69
70
    static ICore *instance();

71
    static bool isNewItemDialogRunning();
hjk's avatar
hjk committed
72
    static void showNewItemDialog(const QString &title,
Tobias Hunger's avatar
Tobias Hunger committed
73
                                  const QList<IWizardFactory *> &factories,
74
75
                                  const QString &defaultLocation = QString(),
                                  const QVariantMap &extraVariables = QVariantMap());
con's avatar
con committed
76

77
    static bool showOptionsDialog(Id page, QWidget *parent = 0);
78
    static QString msgShowOptionsDialog();
79
    static QString msgShowOptionsDialogToolTip();
con's avatar
con committed
80

hjk's avatar
hjk committed
81
    static bool showWarningWithOptions(const QString &title, const QString &text,
82
                                       const QString &details = QString(),
hjk's avatar
hjk committed
83
                                       Id settingsId = Id(),
hjk's avatar
hjk committed
84
85
86
87
88
89
90
91
92
                                       QWidget *parent = 0);

    static QSettings *settings(QSettings::Scope scope = QSettings::UserScope);
    static SettingsDatabase *settingsDatabase();
    static QPrinter *printer();
    static QString userInterfaceLanguage();

    static QString resourcePath();
    static QString userResourcePath();
93
    static QString documentationPath();
94
    static QString libexecPath();
hjk's avatar
hjk committed
95

96
97
98
    static QString versionString();
    static QString buildCompatibilityString();

99
    static QWidget *mainWindow();
100
    static QWidget *dialogParent();
hjk's avatar
hjk committed
101
    static QStatusBar *statusBar();
102
103
    /* Raises and activates the window for the widget. This contains workarounds for X11. */
    static void raiseWindow(QWidget *widget);
hjk's avatar
hjk committed
104
105

    static IContext *currentContextObject();
106
107
    // Adds and removes additional active contexts, these contexts are appended
    // to the currently active contexts.
hjk's avatar
hjk committed
108
    static void updateAdditionalContexts(const Context &remove, const Context &add);
109
110
    static void addAdditionalContext(const Context &context);
    static void removeAdditionalContext(const Context &context);
hjk's avatar
hjk committed
111
112
    static void addContextObject(IContext *context);
    static void removeContextObject(IContext *context);
con's avatar
con committed
113

114
115
116
    // manages the minimize, zoom and fullscreen actions for the window
    static void registerWindow(QWidget *window, const Context &context);

117
118
119
    enum OpenFilesFlags {
        None = 0,
        SwitchMode = 1,
120
        CanContainLineAndColumnNumbers = 2,
121
122
123
         /// Stop loading once the first file fails to load
        StopOnLoadFail = 4
    };
hjk's avatar
hjk committed
124
125
    static void openFiles(const QStringList &fileNames, OpenFilesFlags flags = None);

Eike Ziller's avatar
Eike Ziller committed
126
public slots:
Tobias Hunger's avatar
Tobias Hunger committed
127
128
    static void saveSettings();

con's avatar
con committed
129
signals:
130
    void coreAboutToOpen();
con's avatar
con committed
131
    void coreOpened();
132
    void newItemDialogRunningChanged();
con's avatar
con committed
133
    void saveSettingsRequested();
con's avatar
con committed
134
    void optionsDialogRequested();
con's avatar
con committed
135
    void coreAboutToClose();
136
137
    void contextAboutToChange(const QList<Core::IContext *> &context);
    void contextChanged(const QList<Core::IContext *> &context, const Core::Context &additionalContexts);
138
    void themeChanged();
con's avatar
con committed
139
140
141
142
};

} // namespace Core

hjk's avatar
hjk committed
143
#endif // ICORE_H