bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) { new ActionManager(this); Theme::initialPalette(); // Initialize palette before setting it qsrand(QDateTime::currentDateTime().toTime_t()); parseArguments(arguments); const bool success = m_mainWindow->init(errorMessage); if (success) { InfoBar::initializeGloballySuppressed(); } // Make sure we respect the process's umask when creating new files SaveFile::initializeUmask(); MacroExpander *expander = Utils::globalMacroExpander(); expander->registerVariable("CurrentDate:ISO", tr("The current date (ISO)."), []() { return QDate::currentDate().toString(Qt::ISODate); }); expander->registerVariable("CurrentTime:ISO", tr("The current time (ISO)."), []() { return QTime::currentTime().toString(Qt::ISODate); }); expander->registerVariable("CurrentDate:RFC", tr("The current date (RFC2822)."), []() { return QDate::currentDate().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentTime:RFC", tr("The current time (RFC2822)."), []() { return QTime::currentTime().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentDate:Locale", tr("The current date (Locale)."), []() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); }); expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."), []() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); }); expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."), [](const QString &fmt) { return QDate::currentDate().toString(fmt); }); expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."), [](const QString &fmt) { return QTime::currentTime().toString(fmt); }); return success; }
bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) { // register all mime types from all plugins for (ExtensionSystem::PluginSpec *plugin : ExtensionSystem::PluginManager::plugins()) { if (!plugin->isEffectivelyEnabled()) continue; const QJsonObject metaData = plugin->metaData(); const QJsonValue mimetypes = metaData.value("Mimetypes"); QString mimetypeString; if (Utils::readMultiLineString(mimetypes, &mimetypeString)) Utils::addMimeTypes(plugin->name() + ".mimetypes", mimetypeString.trimmed().toUtf8()); } if (ThemeEntry::availableThemes().isEmpty()) { *errorMessage = tr("No themes found in installation."); return false; } const CoreArguments args = parseArguments(arguments); Theme::initialPalette(); // Initialize palette before setting it Theme *themeFromArg = ThemeEntry::createTheme(args.themeId); setCreatorTheme(themeFromArg ? themeFromArg : ThemeEntry::createTheme(ThemeEntry::themeSetting())); new ActionManager(this); ActionManager::setPresentationModeEnabled(args.presentationMode); m_mainWindow = new MainWindow; if (args.overrideColor.isValid()) m_mainWindow->setOverrideColor(args.overrideColor); m_locator = new Locator; std::srand(unsigned(QDateTime::currentDateTime().toSecsSinceEpoch())); m_mainWindow->init(); m_editMode = new EditMode; ModeManager::activateMode(m_editMode->id()); InfoBar::initialize(ICore::settings(), creatorTheme()); IWizardFactory::initialize(); // Make sure we respect the process's umask when creating new files SaveFile::initializeUmask(); Find::initialize(); m_locator->initialize(); MacroExpander *expander = Utils::globalMacroExpander(); expander->registerVariable("CurrentDate:ISO", tr("The current date (ISO)."), []() { return QDate::currentDate().toString(Qt::ISODate); }); expander->registerVariable("CurrentTime:ISO", tr("The current time (ISO)."), []() { return QTime::currentTime().toString(Qt::ISODate); }); expander->registerVariable("CurrentDate:RFC", tr("The current date (RFC2822)."), []() { return QDate::currentDate().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentTime:RFC", tr("The current time (RFC2822)."), []() { return QTime::currentTime().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentDate:Locale", tr("The current date (Locale)."), []() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); }); expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."), []() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); }); expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."), []() { return DocumentManager::projectsDirectory().toString(); }); expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."), []() { return DocumentManager::fileDialogLastVisitedDirectory(); }); expander->registerVariable("HostOs:isWindows", tr("Is %1 running on Windows?").arg(Constants::IDE_DISPLAY_NAME), []() { return QVariant(Utils::HostOsInfo::isWindowsHost()).toString(); }); expander->registerVariable("HostOs:isOSX", tr("Is %1 running on OS X?").arg(Constants::IDE_DISPLAY_NAME), []() { return QVariant(Utils::HostOsInfo::isMacHost()).toString(); }); expander->registerVariable("HostOs:isLinux", tr("Is %1 running on Linux?").arg(Constants::IDE_DISPLAY_NAME), []() { return QVariant(Utils::HostOsInfo::isLinuxHost()).toString(); }); expander->registerVariable("HostOs:isUnix", tr("Is %1 running on any unix-based platform?") .arg(Constants::IDE_DISPLAY_NAME), []() { return QVariant(Utils::HostOsInfo::isAnyUnixHost()).toString(); }); expander->registerVariable("HostOs:PathListSeparator", tr("The path list separator for the platform."), []() { return QString(Utils::HostOsInfo::pathListSeparator()); }); expander->registerVariable("HostOs:ExecutableSuffix", tr("The platform executable suffix."), []() { return QString(Utils::HostOsInfo::withExecutableSuffix("")); }); expander->registerVariable("IDE:ResourcePath", tr("The directory where %1 finds its pre-installed resources.") .arg(Constants::IDE_DISPLAY_NAME), []() { return ICore::resourcePath(); }); expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."), [](const QString &fmt) { return QDate::currentDate().toString(fmt); }); expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."), [](const QString &fmt) { return QTime::currentTime().toString(fmt); }); expander->registerVariable("UUID", tr("Generate a new UUID."), []() { return QUuid::createUuid().toString(); }); expander->registerPrefix("#:", tr("A comment."), [](const QString &) { return QString(); }); Utils::PathChooser::setAboutToShowContextMenuHandler(&CorePlugin::addToPathChooserContextMenu); return true; }
bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) { if (ThemeEntry::availableThemes().isEmpty()) { *errorMessage = tr("No themes found in installation."); return false; } new ActionManager(this); Theme::initialPalette(); // Initialize palette before setting it qsrand(QDateTime::currentDateTime().toTime_t()); parseArguments(arguments); const bool success = m_mainWindow->init(errorMessage); if (success) { m_editMode = new EditMode; addObject(m_editMode); ModeManager::activateMode(m_editMode->id()); m_designMode = new DesignMode; InfoBar::initializeGloballySuppressed(); } IWizardFactory::initialize(); // Make sure we respect the process's umask when creating new files SaveFile::initializeUmask(); m_findPlugin->initialize(arguments, errorMessage); m_locator->initialize(this, arguments, errorMessage); MacroExpander *expander = Utils::globalMacroExpander(); expander->registerVariable("CurrentDate:ISO", tr("The current date (ISO)."), []() { return QDate::currentDate().toString(Qt::ISODate); }); expander->registerVariable("CurrentTime:ISO", tr("The current time (ISO)."), []() { return QTime::currentTime().toString(Qt::ISODate); }); expander->registerVariable("CurrentDate:RFC", tr("The current date (RFC2822)."), []() { return QDate::currentDate().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentTime:RFC", tr("The current time (RFC2822)."), []() { return QTime::currentTime().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentDate:Locale", tr("The current date (Locale)."), []() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); }); expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."), []() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); }); expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."), []() { return DocumentManager::projectsDirectory(); }); expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."), []() { return DocumentManager::fileDialogLastVisitedDirectory(); }); expander->registerVariable("HostOs:isWindows", tr("Is Qt Creator running on Windows?"), []() { return QVariant(Utils::HostOsInfo::isWindowsHost()).toString(); }); expander->registerVariable("HostOs:isOSX", tr("Is Qt Creator running on OS X?"), []() { return QVariant(Utils::HostOsInfo::isMacHost()).toString(); }); expander->registerVariable("HostOs:isLinux", tr("Is Qt Creator running on Linux?"), []() { return QVariant(Utils::HostOsInfo::isLinuxHost()).toString(); }); expander->registerVariable("HostOs:isUnix", tr("Is Qt Creator running on any unix-based platform?"), []() { return QVariant(Utils::HostOsInfo::isAnyUnixHost()).toString(); }); expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."), [](const QString &fmt) { return QDate::currentDate().toString(fmt); }); expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."), [](const QString &fmt) { return QTime::currentTime().toString(fmt); }); expander->registerVariable("UUID", tr("Generate a new UUID."), []() { return QUuid::createUuid().toString(); }); expander->registerPrefix("#:", tr("A comment."), [](const QString &) { return QStringLiteral(""); }); // Make sure all wizards are there when the user might access the keyboard shortcuts: connect(ICore::instance(), &ICore::optionsDialogRequested, []() { IWizardFactory::allWizardFactories(); }); Utils::PathChooser::setAboutToShowContextMenuHandler(&CorePlugin::addToPathChooserContextMenu); return success; }