2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "core_global.h"
|
2020-06-19 16:12:42 +02:00
|
|
|
#include "icontext.h"
|
2010-01-14 14:14:39 +01:00
|
|
|
|
2022-07-22 13:07:53 +02:00
|
|
|
#include <utils/filepath.h>
|
2020-11-19 15:34:59 +01:00
|
|
|
#include <utils/qtcsettings.h>
|
|
|
|
|
|
2019-11-12 10:26:38 +01:00
|
|
|
#include <QList>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2016-12-20 11:19:22 +01:00
|
|
|
#include <QRect>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-08-26 14:39:15 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
2022-07-22 13:27:19 +02:00
|
|
|
class QMainWindow;
|
2008-12-02 12:01:29 +01:00
|
|
|
class QPrinter;
|
2010-01-21 21:12:40 +01:00
|
|
|
class QStatusBar;
|
2012-07-19 15:31:22 +04:00
|
|
|
class QWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2022-07-22 13:07:53 +02:00
|
|
|
namespace Utils { class InfoBar; }
|
2020-06-17 12:23:44 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Core {
|
2010-06-25 12:56:16 +02:00
|
|
|
class Context;
|
2019-08-07 12:44:40 +02:00
|
|
|
class IWizardFactory;
|
2009-05-19 19:20:53 +02:00
|
|
|
class SettingsDatabase;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-01-18 23:25:34 +01:00
|
|
|
namespace Internal { class MainWindow; }
|
|
|
|
|
|
2021-08-26 20:02:55 +03:00
|
|
|
class NewDialog;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class CORE_EXPORT ICore : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2012-01-18 23:25:34 +01:00
|
|
|
friend class Internal::MainWindow;
|
2015-05-29 15:55:49 +02:00
|
|
|
friend class IWizardFactory;
|
|
|
|
|
|
2012-01-18 23:25:34 +01:00
|
|
|
explicit ICore(Internal::MainWindow *mw);
|
2018-05-07 15:00:03 +02:00
|
|
|
~ICore() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-01-18 23:25:34 +01:00
|
|
|
public:
|
2015-08-07 17:21:38 +02:00
|
|
|
enum class ContextPriority {
|
|
|
|
|
High,
|
|
|
|
|
Low
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
static ICore *instance();
|
|
|
|
|
|
2014-06-27 15:15:09 +02:00
|
|
|
static bool isNewItemDialogRunning();
|
2016-09-26 16:39:49 +02:00
|
|
|
static QWidget *newItemDialog();
|
2012-01-18 23:25:34 +01:00
|
|
|
static void showNewItemDialog(const QString &title,
|
2014-05-02 17:38:42 +02:00
|
|
|
const QList<IWizardFactory *> &factories,
|
2021-07-26 17:20:03 +02:00
|
|
|
const Utils::FilePath &defaultLocation = {},
|
|
|
|
|
const QVariantMap &extraVariables = {});
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
static bool showOptionsDialog(const Utils::Id page, QWidget *parent = nullptr);
|
2014-02-20 14:52:10 +01:00
|
|
|
static QString msgShowOptionsDialog();
|
2014-06-23 10:39:01 +02:00
|
|
|
static QString msgShowOptionsDialogToolTip();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-01-18 23:25:34 +01:00
|
|
|
static bool showWarningWithOptions(const QString &title, const QString &text,
|
2009-10-08 17:23:27 +02:00
|
|
|
const QString &details = QString(),
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id settingsId = {},
|
2018-05-07 17:34:42 +02:00
|
|
|
QWidget *parent = nullptr);
|
2012-01-18 23:25:34 +01:00
|
|
|
|
2020-11-19 15:34:59 +01:00
|
|
|
static Utils::QtcSettings *settings(QSettings::Scope scope = QSettings::UserScope);
|
2012-01-18 23:25:34 +01:00
|
|
|
static SettingsDatabase *settingsDatabase();
|
|
|
|
|
static QPrinter *printer();
|
|
|
|
|
static QString userInterfaceLanguage();
|
|
|
|
|
|
2021-04-26 15:46:09 +02:00
|
|
|
static Utils::FilePath resourcePath(const QString &rel = {});
|
|
|
|
|
static Utils::FilePath userResourcePath(const QString &rel = {});
|
|
|
|
|
static Utils::FilePath cacheResourcePath(const QString &rel = {});
|
|
|
|
|
static Utils::FilePath installerResourcePath(const QString &rel = {});
|
|
|
|
|
static Utils::FilePath libexecPath(const QString &rel = {});
|
2021-04-22 16:15:26 +02:00
|
|
|
static Utils::FilePath crashReportsPath();
|
2012-01-18 23:25:34 +01:00
|
|
|
|
2021-01-29 10:01:03 +01:00
|
|
|
static QString ideDisplayName();
|
|
|
|
|
|
2013-05-24 16:45:49 +02:00
|
|
|
static QString versionString();
|
|
|
|
|
|
2018-01-10 10:23:18 +01:00
|
|
|
static QMainWindow *mainWindow();
|
2014-01-06 10:36:40 +01:00
|
|
|
static QWidget *dialogParent();
|
2020-06-17 12:23:44 +02:00
|
|
|
static Utils::InfoBar *infoBar();
|
2019-08-07 12:44:40 +02:00
|
|
|
|
2013-04-15 12:53:34 +02:00
|
|
|
static void raiseWindow(QWidget *widget);
|
2012-01-18 23:25:34 +01:00
|
|
|
|
|
|
|
|
static IContext *currentContextObject();
|
2017-11-30 16:32:55 +01:00
|
|
|
static QWidget *currentContextWidget();
|
2018-07-10 15:49:50 +02:00
|
|
|
static IContext *contextObject(QWidget *widget);
|
2015-08-07 17:21:38 +02:00
|
|
|
static void updateAdditionalContexts(const Context &remove, const Context &add,
|
|
|
|
|
ContextPriority priority = ContextPriority::Low);
|
|
|
|
|
static void addAdditionalContext(const Context &context,
|
|
|
|
|
ContextPriority priority = ContextPriority::Low);
|
2014-11-16 11:47:18 +02:00
|
|
|
static void removeAdditionalContext(const Context &context);
|
2012-01-18 23:25:34 +01:00
|
|
|
static void addContextObject(IContext *context);
|
|
|
|
|
static void removeContextObject(IContext *context);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-07-17 17:04:02 +02:00
|
|
|
static void registerWindow(QWidget *window, const Context &context);
|
|
|
|
|
|
2010-10-19 13:07:19 +02:00
|
|
|
enum OpenFilesFlags {
|
|
|
|
|
None = 0,
|
|
|
|
|
SwitchMode = 1,
|
2015-03-05 17:43:11 -07:00
|
|
|
CanContainLineAndColumnNumbers = 2,
|
2010-10-19 13:07:19 +02:00
|
|
|
/// Stop loading once the first file fails to load
|
2018-06-14 13:37:09 +04:30
|
|
|
StopOnLoadFail = 4,
|
|
|
|
|
SwitchSplitIfAlreadyVisible = 8
|
2010-10-19 13:07:19 +02:00
|
|
|
};
|
2021-07-23 10:33:02 +02:00
|
|
|
static void openFiles(const Utils::FilePaths &filePaths, OpenFilesFlags flags = None);
|
2012-01-18 23:25:34 +01:00
|
|
|
|
2015-08-26 14:39:15 +02:00
|
|
|
static void addPreCloseListener(const std::function<bool()> &listener);
|
|
|
|
|
|
2020-05-28 16:26:01 +02:00
|
|
|
static void restart();
|
2016-08-31 15:39:52 +02:00
|
|
|
|
2019-06-03 09:32:15 +02:00
|
|
|
enum SaveSettingsReason {
|
|
|
|
|
InitializationDone,
|
|
|
|
|
SettingsDialogDone,
|
|
|
|
|
ModeChanged,
|
|
|
|
|
MainWindowClosing,
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
2009-06-12 18:06:34 +02:00
|
|
|
void coreAboutToOpen();
|
2008-12-02 12:01:29 +01:00
|
|
|
void coreOpened();
|
2016-09-26 16:39:49 +02:00
|
|
|
void newItemDialogStateChanged();
|
2019-06-03 09:32:15 +02:00
|
|
|
void saveSettingsRequested(SaveSettingsReason reason);
|
2008-12-02 12:01:29 +01:00
|
|
|
void coreAboutToClose();
|
2013-05-07 19:03:22 +02:00
|
|
|
void contextAboutToChange(const QList<Core::IContext *> &context);
|
2015-09-22 09:17:59 +02:00
|
|
|
void contextChanged(const Core::Context &context);
|
2020-11-16 16:40:12 +01:00
|
|
|
void systemEnvironmentChanged();
|
2015-05-29 13:24:02 +02:00
|
|
|
|
2015-10-02 15:15:38 +02:00
|
|
|
public:
|
|
|
|
|
/* internal use */
|
|
|
|
|
static QStringList additionalAboutInformation();
|
|
|
|
|
static void appendAboutInformation(const QString &line);
|
2020-05-28 16:26:01 +02:00
|
|
|
static QString systemInformation();
|
|
|
|
|
static void setupScreenShooter(const QString &name, QWidget *w, const QRect &rc = QRect());
|
|
|
|
|
static QString pluginPath();
|
|
|
|
|
static QString userPluginPath();
|
2021-08-12 09:19:55 +02:00
|
|
|
static Utils::FilePath clangExecutable(const Utils::FilePath &clangBinDirectory);
|
|
|
|
|
static Utils::FilePath clangdExecutable(const Utils::FilePath &clangBinDirectory);
|
|
|
|
|
static Utils::FilePath clangTidyExecutable(const Utils::FilePath &clangBinDirectory);
|
|
|
|
|
static Utils::FilePath clazyStandaloneExecutable(const Utils::FilePath &clangBinDirectory);
|
|
|
|
|
static Utils::FilePath clangIncludeDirectory(const QString &clangVersion,
|
|
|
|
|
const Utils::FilePath &clangFallbackIncludeDir);
|
2020-05-28 16:26:01 +02:00
|
|
|
static QString buildCompatibilityString();
|
|
|
|
|
static QStatusBar *statusBar();
|
|
|
|
|
|
|
|
|
|
static void saveSettings(SaveSettingsReason reason);
|
2021-08-26 20:02:55 +03:00
|
|
|
static void setNewDialogFactory(const std::function<NewDialog *(QWidget *)> &newFactory);
|
2015-10-02 15:15:38 +02:00
|
|
|
|
2015-05-29 13:24:02 +02:00
|
|
|
private:
|
2016-09-26 16:39:49 +02:00
|
|
|
static void updateNewItemDialogState();
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|