ICore Class
(Core::ICore)The ICore class allows access to the different parts that make up the basic functionality of Qt Creator. More...
Header: | #include <ICore> |
Signals
void | contextAboutToChange(const QList<Core::IContext *> &context) |
void | contextChanged(const Core::Context &context) |
void | coreAboutToClose() |
void | coreOpened() |
void | saveSettingsRequested(Core::ICore::SaveSettingsReason reason) |
Static Public Members
void | addAdditionalContext(const Core::Context &context, Core::ICore::ContextPriority priority = ContextPriority::Low) |
void | addContextObject(Core::IContext *context) |
void | addPreCloseListener(const std::function<bool ()> &listener) |
Core::IContext * | currentContextObject() |
QWidget * | dialogParent() |
QString | libexecPath() |
QMainWindow * | mainWindow() |
void | openFiles(const QStringList &arguments, Core::ICore::OpenFilesFlags flags = None) |
QPrinter * | printer() |
void | removeContextObject(Core::IContext *context) |
QString | resourcePath() |
QSettings * | settings(QSettings::Scope scope = QSettings::UserScope) |
Core::SettingsDatabase * | settingsDatabase() |
void | showNewItemDialog(const QString &title, const QList<Core::IWizardFactory *> &factories, const QString &defaultLocation = QString(), const QVariantMap &extraVariables = QVariantMap()) |
bool | showWarningWithOptions(const QString &title, const QString &text, const QString &details = QString(), Core::Id settingsId = Id(), QWidget *parent = nullptr) |
void | updateAdditionalContexts(const Core::Context &remove, const Core::Context &add, Core::ICore::ContextPriority priority = ContextPriority::Low) |
QString | userResourcePath() |
Detailed Description
You should never create a subclass of this interface. The one and only instance is created by the Core plugin. You can access this instance from your plugin through instance().
Member Function Documentation
[signal]
void ICore::contextAboutToChange(const QList<Core::IContext *> &context)
Indicates that a new context will shortly become the current context (meaning that its widget got focus).
[signal]
void ICore::contextChanged(const Core::Context &context)
Indicates that a new context just became the current context. This includes the context from the focus object as well as the additional context.
[signal]
void ICore::coreAboutToClose()
Enables plugins to perform some pre-end-of-life actions.
The application is guaranteed to shut down after this signal is emitted. It is there as an addition to the usual plugin lifecycle functions, namely IPlugin::aboutToShutdown()
, just for convenience.
[signal]
void ICore::coreOpened()
Indicates that all plugins have been loaded and the main window is shown.
[signal]
void ICore::saveSettingsRequested(Core::ICore::SaveSettingsReason reason)
Signals that the user has requested that the global settings should be saved to disk for a reason.
At the moment that happens when the application is closed, and on Save All.
[static]
void ICore::addAdditionalContext(const Core::Context &context, Core::ICore::ContextPriority priority = ContextPriority::Low)
Adds context with priority.
[static]
void ICore::addContextObject(Core::IContext *context)
After registration, this context object automatically becomes the current context object, context, whenever its widget gets focus.
See also removeContextObject(), updateAdditionalContexts(), and currentContextObject().
[static]
void ICore::addPreCloseListener(const std::function<bool ()> &listener)
Provides a hook for plugins to veto on closing the application.
When the application window requests a close, all listeners are called. If one of the listener calls returns false
, the process is aborted and the event is ignored. If all calls return true
, coreAboutToClose() is emitted and the event is accepted or performed.
[static]
Core::IContext *ICore::currentContextObject()
Returns the context object of the current main context.
See also updateAdditionalContexts() and addContextObject().
[static]
QWidget *ICore::dialogParent()
Returns a widget pointer suitable to use as parent for QDialogs.
[static]
QString ICore::libexecPath()
Returns the path to the command line tools that are shipped with Qt Creator (corresponding to the IDE_LIBEXEC_PATH qmake variable).
[static]
QMainWindow *ICore::mainWindow()
Returns the main window of the application.
For dialog parents use dialogParent().
[static]
void ICore::openFiles(const QStringList &arguments, Core::ICore::OpenFilesFlags flags = None)
Opens files using arguments and flags like it would be done if they were given to Qt Creator on the command line, or they were opened via File > Open.
[static]
QPrinter *ICore::printer()
Returns the application's printer object.
Always use this printer object for printing, so the different parts of the application re-use its settings.
[static]
void ICore::removeContextObject(Core::IContext *context)
Unregisters a context object from the list of know contexts.
See also addContextObject(), updateAdditionalContexts(), and currentContextObject().
[static]
QString ICore::resourcePath()
Returns the absolute path that is used for resources like project templates and the debugger macros.
This abstraction is needed to avoid platform-specific code all over the place, since on macOS, for example, the resources are part of the application bundle.
[static]
QSettings *ICore::settings(QSettings::Scope scope = QSettings::UserScope)
Returns the application's main settings object.
You can use it to retrieve or set application-wide settings (in contrast to session or project specific settings).
If scope is QSettings::UserScope
(the default), the settings will be read from the user's settings, with a fallback to global settings provided with Qt Creator.
If scope is QSettings::SystemScope
, only the system settings shipped with the current version of Qt Creator will be read. This functionality exists for internal purposes only.
See also settingsDatabase().
[static]
Core::SettingsDatabase *ICore::settingsDatabase()
Returns the application's settings database.
The settings database is meant as an alternative to the regular settings object. It is more suitable for storing large amounts of data. The settings are application wide.
See also SettingsDatabase.
[static]
void ICore::showNewItemDialog(const QString &title, const QList<Core::IWizardFactory *> &factories, const QString &defaultLocation = QString(), const QVariantMap &extraVariables = QVariantMap())
Opens a dialog where the user can choose from a set of factories that create new files or projects.
The title argument is shown as the dialog title. The path where the files will be created (if the user does not change it) is set in defaultLocation. Defaults to DocumentManager::projectsDirectory() or DocumentManager::fileDialogLastVisitedDirectory(), depending on wizard kind.
Additional variables for the wizards are set in extraVariables.
See also Core::DocumentManager.
[static]
bool ICore::showWarningWithOptions(const QString &title, const QString &text, const QString &details = QString(), Core::Id settingsId = Id(), QWidget *parent = nullptr)
Creates a message box with parent that contains a Settings button for opening the settings page specified by settingsId.
The dialog has title and displays the message text and detailed information specified by details.
Use this function to display configuration errors and to point users to the setting they should fix.
Returns true
if the user accepted the settings dialog.
[static]
void ICore::updateAdditionalContexts(const Core::Context &remove, const Core::Context &add, Core::ICore::ContextPriority priority = ContextPriority::Low)
Changes the currently active additional contexts.
Removes the list of additional contexts specified by remove and adds the list of additional contexts specified by add with priority.
[static]
QString ICore::userResourcePath()
Returns the absolute path in the users directory that is used for resources like project templates.
Use this function for finding the place for resources that the user may write to, for example, to allow for custom palettes or templates.