Krita Source Code Documentation
Loading...
Searching...
No Matches
KisApplication Class Reference

Base class for the Krita app. More...

#include <KisApplication.h>

+ Inheritance diagram for KisApplication:

Classes

class  Private
 
class  ResetStarting
 

Public Slots

void executeRemoteArguments (QByteArray message, KisMainWindow *mainWindow)
 
void fileOpenRequested (const QString &url)
 
void remoteArguments (const QString &message)
 
void setSplashScreenLoadingText (const QString &)
 
- Public Slots inherited from QtSingleApplication
void activateWindow ()
 
bool sendMessage (const QString &message, int timeout=5000)
 

Public Member Functions

void addResourceTypes ()
 
void askResetConfig ()
 
bool event (QEvent *event) override
 
KisExtendedModifiersMapperPluginInterfaceextendedModifiersPluginInterface ()
 
void hideSplashScreen ()
 
void initializeGlobals (const KisApplicationArguments &args)
 
bool isStoreApplication ()
 
 KisApplication (const QString &key, int &argc, char **argv)
 
void loadPlugins ()
 
bool notify (QObject *receiver, QEvent *event) override
 Overridden to handle exceptions from event handlers.
 
void processPostponedSynchronizationEvents ()
 
bool registerResources ()
 
void setSplashScreen (QWidget *splash)
 
virtual bool start (const KisApplicationArguments &args)
 
 ~KisApplication () override
 
- Public Member Functions inherited from QtSingleApplication
QWidget * activationWindow () const
 
QString id () const
 
void initialize (bool dummy=true)
 
bool isRunning ()
 
 QtSingleApplication (const QString &id, int &argc, char **argv)
 
 QtSingleApplication (int &argc, char **argv, bool GUIenabled=true)
 
 QtSingleApplication (int &argc, char **argv, Type type)
 
void setActivationWindow (QWidget *aw, bool activateOnMessage=true)
 

Static Public Member Functions

static void verifyMetatypeRegistration ()
 

Private Slots

void slotSetLongPress (bool enabled)
 

Private Member Functions

void checkAutosaveFiles ()
 
bool createNewDocFromTemplate (const QString &fileName, KisMainWindow *m_mainWindow)
 
void resetConfig ()
 

Private Attributes

QScopedPointer< Privated
 

Friends

class ResetStarting
 

Additional Inherited Members

- Signals inherited from QtSingleApplication
void messageReceived (const QString &message)
 

Detailed Description

Base class for the Krita app.

This class handles arguments given on the command line and shows a generic about dialog for the Krita app.

In addition it adds the standard directories where Krita can find its images etc.

If the last mainwindow becomes closed, KisApplication automatically calls QApplication::quit.

Definition at line 37 of file KisApplication.h.

Constructor & Destructor Documentation

◆ KisApplication()

KisApplication::KisApplication ( const QString & key,
int & argc,
char ** argv )
explicit

Creates an application object, adds some standard directories and initializes kimgio.

Load platform plugin for modifiers fetching

Definition at line 218 of file KisApplication.cpp.

219 : QtSingleApplication(key, argc, argv)
220 , d(new Private)
221{
222#ifdef Q_OS_MACOS
224#endif
225
226 QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
227
228 setApplicationDisplayName("Krita");
229 setApplicationName("krita");
230 // Note: Qt docs suggest we set this, but if we do, we get resource paths of the form of krita/krita, which is weird.
231 // setOrganizationName("krita");
232 setOrganizationDomain("krita.org");
233
234 QString version = KritaVersionWrapper::versionString(true);
235 setApplicationVersion(version);
236 setWindowIcon(KisIconUtils::loadIcon("krita-branding"));
237
238 if (qgetenv("KRITA_NO_STYLE_OVERRIDE").isEmpty()) {
239
240#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
241 QStringList styles = QStringList() << "haiku" << "macintosh" << "breeze" << "fusion";
242#else
243 QStringList styles = QStringList() << "haiku" << "macos" << "breeze" << "fusion";
244#endif
245 if (!styles.contains(style()->objectName().toLower())) {
246 Q_FOREACH (const QString & style, styles) {
247 if (!setStyle(style)) {
248 qDebug() << "No" << style << "available.";
249 }
250 else {
251 qDebug() << "Set style" << style;
252 break;
253 }
254 }
255 }
256
257 // if style is set from config, try to load that
258 KisConfig cfg(true);
259 QString widgetStyleFromConfig = cfg.widgetStyle();
260 if(widgetStyleFromConfig != "") {
261 qApp->setStyle(widgetStyleFromConfig);
262#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
263 } else if (style()->objectName().toLower() == "macintosh") {
264 // if no configured style on macOS, default to Fusion
265 qApp->setStyle("fusion");
266 }
267#else
268 } else if (style()->objectName().toLower() == "macos") {
269 // if no configured style on macOS, default to Fusion
270 qApp->setStyle("fusion");
271 }
272#endif
273
274 }
275 else {
276 qDebug() << "Style override disabled, using" << style()->objectName();
277 }
278
282 {
283 d->extendedModifiersPluginInterface.reset(KisPlatformPluginInterfaceFactory::instance()->createExtendedModifiersMapper());
284 }
285
286 // store the style name
287 qApp->setProperty(currentUnderlyingStyleNameProperty, style()->objectName());
289
290
291#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
292
297 struct PlatformWindowCreationFilter : QObject
298 {
299 using QObject::QObject;
300
301 bool eventFilter(QObject *watched, QEvent *event) override {
302 if (event->type() == QEvent::PlatformSurface) {
303 QWidget *widget = qobject_cast<QWidget*>(watched);
304 if (!widget) return false;
305
310 if (watched->property("krita_skip_srgb_surface_manager_assignment").toBool()) {
311 return false;
312 }
313
314 QPlatformSurfaceEvent *surfaceEvent = static_cast<QPlatformSurfaceEvent*>(event);
315 if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
316 QWindow *nativeWindow = widget->windowHandle();
317 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(widget->windowHandle(), false);
318
319 if (!nativeWindow->findChild<KisSRGBSurfaceColorSpaceManager*>()) {
321 }
322 }
323 }
324
325 return false;
326 }
327 };
328
329 this->installEventFilter(new PlatformWindowCreationFilter(this));
330#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
331}
QList< QString > QStringList
QScopedPointer< Private > d
void processPostponedSynchronizationEvents()
static KisPlatformPluginInterfaceFactory * instance()
static KisSRGBSurfaceColorSpaceManager * tryCreateForCurrentPlatform(QWidget *widget)
static void registerSynchronizedEventBarrier(std::function< void()> callback)
QtSingleApplication(int &argc, char **argv, bool GUIenabled=true)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
constexpr const char * currentUnderlyingStyleNameProperty
Definition kis_global.h:116
QIcon loadIcon(const QString &name)
KRITAVERSION_EXPORT QString versionString(bool checkGit=false)
void setMouseCoalescingEnabled(bool enabled)
Definition osx.mm:17

References KisIconUtils::loadIcon(), setMouseCoalescingEnabled(), KritaVersionWrapper::versionString(), and KisConfig::widgetStyle().

◆ ~KisApplication()

KisApplication::~KisApplication ( )
override

Destructor.

Definition at line 821 of file KisApplication.cpp.

822{
823 if (!isRunning()) {
826 }
827}
static void performHouseKeepingOnExit()
perform optimize and vacuum when necessary
static void deleteTemporaryResources()
Delete all storages that are Unknown or Memory and all resources that are marked temporary or belong ...

References KisResourceCacheDb::deleteTemporaryResources(), QtSingleApplication::isRunning(), and KisResourceCacheDb::performHouseKeepingOnExit().

Member Function Documentation

◆ addResourceTypes()

void KisApplication::addResourceTypes ( )

Definition at line 367 of file KisApplication.cpp.

368{
369 // All Krita's resource types
370 KoResourcePaths::addAssetType("markers", "data", "/styles/");
371 KoResourcePaths::addAssetType("kis_pics", "data", "/pics/");
372 KoResourcePaths::addAssetType("kis_images", "data", "/images/");
373 KoResourcePaths::addAssetType("metadata_schema", "data", "/metadata/schemas/");
374 KoResourcePaths::addAssetType("gmic_definitions", "data", "/gmic/");
375 KoResourcePaths::addAssetType("kis_shortcuts", "data", "/shortcuts/");
376 KoResourcePaths::addAssetType("kis_actions", "data", "/actions");
377 KoResourcePaths::addAssetType("kis_actions", "data", "/pykrita");
378 KoResourcePaths::addAssetType("icc_profiles", "data", "/color/icc");
379 KoResourcePaths::addAssetType("icc_profiles", "data", "/profiles/");
381 KoResourcePaths::addAssetType("tags", "data", "/tags/");
382 KoResourcePaths::addAssetType("templates", "data", "/templates");
383 KoResourcePaths::addAssetType("pythonscripts", "data", "/pykrita");
384 KoResourcePaths::addAssetType("preset_icons", "data", "/preset_icons");
385#if defined HAVE_SEEXPR
386 KoResourcePaths::addAssetType(ResourceType::SeExprScripts, "data", "/seexpr_scripts/", true);
387#endif
388
389 // Make directories for all resources we can save, and tags
390 KoResourcePaths::saveLocation("data", "/asl/", true);
391 KoResourcePaths::saveLocation("data", "/css_styles/", true);
392 KoResourcePaths::saveLocation("data", "/input/", true);
393 KoResourcePaths::saveLocation("data", "/pykrita/", true);
394 KoResourcePaths::saveLocation("data", "/color-schemes/", true);
395 KoResourcePaths::saveLocation("data", "/preset_icons/", true);
396 KoResourcePaths::saveLocation("data", "/preset_icons/tool_icons/", true);
397 KoResourcePaths::saveLocation("data", "/preset_icons/emblem_icons/", true);
398}
static void addAssetType(const QString &type, const char *basetype, const QString &relativeName, bool priority=true)
static QString saveLocation(const QString &type, const QString &suffix=QString(), bool create=true)
const QString FilterEffects
const QString SeExprScripts

References KoResourcePaths::addAssetType(), ResourceType::FilterEffects, KoResourcePaths::saveLocation(), and ResourceType::SeExprScripts.

◆ askResetConfig()

void KisApplication::askResetConfig ( )

Checks if user is holding ctrl+alt+shift keys and asks if the settings file should be cleared.

Typically called during startup before reading the config.

Definition at line 1273 of file KisApplication.cpp.

1274{
1275 bool ok = QMessageBox::question(qApp->activeWindow(),
1276 i18nc("@title:window", "Krita"),
1277 i18n("Do you want to clear the settings file?"),
1278 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes;
1279 if (ok) {
1280 resetConfig();
1281 }
1282}

References resetConfig().

◆ checkAutosaveFiles()

void KisApplication::checkAutosaveFiles ( )
private
Returns
the number of autosavefiles opened

Definition at line 1105 of file KisApplication.cpp.

1106{
1107 if (d->batchRun) return;
1108
1110
1111 // Check for autosave files from a previous run. There can be several, and
1112 // we want to offer a restore for every one. Including a nice thumbnail!
1113
1114 // Hidden autosave files
1115 QStringList filters = QStringList() << QString(".krita-*-*-autosave.kra");
1116
1117 // all autosave files for our application
1118 QStringList autosaveFiles = dir.entryList(filters, QDir::Files | QDir::Hidden);
1119
1120 // Visible autosave files
1121 filters = QStringList() << QString("krita-*-*-autosave.kra");
1122 autosaveFiles += dir.entryList(filters, QDir::Files);
1123
1124 // Allow the user to make their selection
1125 if (autosaveFiles.size() > 0) {
1126 if (d->splashScreen) {
1127 // hide the splashscreen to see the dialog
1128 d->splashScreen->hide();
1129 }
1130 d->autosaveDialog = new KisAutoSaveRecoveryDialog(autosaveFiles, activeWindow());
1131 QDialog::DialogCode result = (QDialog::DialogCode) d->autosaveDialog->exec();
1132
1133 if (result == QDialog::Accepted) {
1134 QStringList filesToRecover = d->autosaveDialog->recoverableFiles();
1135 Q_FOREACH (const QString &autosaveFile, autosaveFiles) {
1136 if (!filesToRecover.contains(autosaveFile)) {
1137 KisUsageLogger::log(QString("Removing autosave file %1").arg(dir.absolutePath() + "/" + autosaveFile));
1138 QFile::remove(dir.absolutePath() + "/" + autosaveFile);
1139 }
1140 }
1141 autosaveFiles = filesToRecover;
1142 } else {
1143 autosaveFiles.clear();
1144 }
1145
1146 if (autosaveFiles.size() > 0) {
1147 QList<QString> autosavePaths;
1148 Q_FOREACH (const QString &autoSaveFile, autosaveFiles) {
1149 const QString path = dir.absolutePath() + QLatin1Char('/') + autoSaveFile;
1150 autosavePaths << path;
1151 }
1152 if (d->mainWindow) {
1153 Q_FOREACH (const QString &path, autosavePaths) {
1154 KisMainWindow::OpenFlags flags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
1155 d->mainWindow->openDocument(path, flags | KisMainWindow::RecoveryFile);
1156 }
1157 }
1158 }
1159 // cleanup
1160 delete d->autosaveDialog;
1161 d->autosaveDialog = nullptr;
1162 }
1163}
static void log(const QString &message)
Logs with date/time.

References KisAutoSaveRecoveryDialog::autoSaveLocation(), KisMainWindow::BatchMode, d, KisUsageLogger::log(), KisMainWindow::None, and KisMainWindow::RecoveryFile.

◆ createNewDocFromTemplate()

bool KisApplication::createNewDocFromTemplate ( const QString & fileName,
KisMainWindow * m_mainWindow )
private

Definition at line 1165 of file KisApplication.cpp.

1166{
1167 QString templatePath;
1168
1169 if (QFile::exists(fileName)) {
1170 templatePath = fileName;
1171 dbgUI << "using full path...";
1172 }
1173 else {
1174 QString desktopName(fileName);
1175 const QString templatesResourcePath = QStringLiteral("templates/");
1176
1177 QStringList paths = KoResourcePaths::findAllAssets("data", templatesResourcePath + "*/" + desktopName);
1178 if (paths.isEmpty()) {
1179 paths = KoResourcePaths::findAllAssets("data", templatesResourcePath + desktopName);
1180 }
1181
1182 if (paths.isEmpty()) {
1183 QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita"),
1184 i18n("No template found for: %1", desktopName));
1185 } else if (paths.count() > 1) {
1186 QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita"),
1187 i18n("Too many templates found for: %1", desktopName));
1188 } else {
1189 templatePath = paths.at(0);
1190 }
1191 }
1192
1193 if (!templatePath.isEmpty()) {
1194 KDesktopFile templateInfo(templatePath);
1195
1196 KisMainWindow::OpenFlags batchFlags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
1197 if (mainWindow->openDocument(templatePath, KisMainWindow::Import | batchFlags)) {
1198 dbgUI << "Template loaded...";
1199 return true;
1200 }
1201 else {
1202 QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita"),
1203 i18n("Template %1 failed to load.", fileName));
1204 }
1205 }
1206
1207 return false;
1208}
static QStringList findAllAssets(const QString &type, const QString &filter=QString(), SearchOptions options=NoSearchOptions)
#define dbgUI
Definition kis_debug.h:52

References KisMainWindow::BatchMode, d, dbgUI, KoResourcePaths::findAllAssets(), KisMainWindow::Import, KisMainWindow::None, and KisMainWindow::openDocument().

◆ event()

bool KisApplication::event ( QEvent * event)
override

Definition at line 401 of file KisApplication.cpp.

402{
403
404 #ifdef Q_OS_MACOS
405 if (event->type() == QEvent::FileOpen) {
406 QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
407 fileOpenRequested(openEvent->file());
408 return true;
409 }
410 #endif
411 return QApplication::event(event);
412}
bool event(QEvent *event) override
void fileOpenRequested(const QString &url)

References event(), and fileOpenRequested().

◆ executeRemoteArguments

void KisApplication::executeRemoteArguments ( QByteArray message,
KisMainWindow * mainWindow )
slot

Definition at line 1001 of file KisApplication.cpp.

1002{
1004 const bool doTemplate = args.doTemplate();
1005 const bool doNewImage = args.doNewImage();
1006 const int argsCount = args.filenames().count();
1007 bool documentCreated = false;
1008
1009 // Create a new image, if needed
1010 if (doNewImage) {
1012 if (doc) {
1014 d->mainWindow->addViewAndNotifyLoadingCompleted(doc);
1015 }
1016 }
1017 if (argsCount > 0) {
1018 // Loop through arguments
1019 for (int argNumber = 0; argNumber < argsCount; ++argNumber) {
1020 QString filename = args.filenames().at(argNumber);
1021 // are we just trying to open a template?
1022 if (doTemplate) {
1023 documentCreated |= createNewDocFromTemplate(filename, mainWindow);
1024 }
1025 else if (QFile(filename).exists()) {
1026 KisMainWindow::OpenFlags flags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
1027 documentCreated |= mainWindow->openDocument(filename, flags);
1028 }
1029 }
1030 }
1031
1032 //add an image as file-layer if called in another process and singleApplication is enabled
1033 if (!args.fileLayer().isEmpty()){
1034 if (argsCount > 0 && !documentCreated){
1035 //arg was passed but document was not created so don't add the file layer.
1036 QMessageBox::warning(mainWindow, i18nc("@title:window", "Krita:Warning"),
1037 i18n("Couldn't open file %1",args.filenames().at(argsCount - 1)));
1038 }
1039 else if (mainWindow->viewManager()->image()){
1040 KisFileLayer *fileLayer = new KisFileLayer(mainWindow->viewManager()->image(), "",
1041 args.fileLayer(), KisFileLayer::None, "Bicubic",
1042 mainWindow->viewManager()->image()->nextLayerName(i18n("File layer")), OPACITY_OPAQUE_U8);
1043 QFileInfo fi(fileLayer->path());
1044 if (fi.exists()){
1045 KisNodeCommandsAdapter adapter(d->mainWindow->viewManager());
1046 adapter.addNode(fileLayer, d->mainWindow->viewManager()->activeNode()->parent(),
1047 d->mainWindow->viewManager()->activeNode());
1048 }
1049 else{
1050 QMessageBox::warning(mainWindow, i18nc("@title:window", "Krita:Warning"),
1051 i18n("Cannot add %1 as a file layer: the file does not exist.", fileLayer->path()));
1052 }
1053 }
1054 else {
1055 QMessageBox::warning(mainWindow, i18nc("@title:window", "Krita:Warning"),
1056 i18n("Cannot add the file layer: no document is open."));
1057 }
1058 }
1059}
const quint8 OPACITY_OPAQUE_U8
bool createNewDocFromTemplate(const QString &fileName, KisMainWindow *m_mainWindow)
The KisFileLayer class loads a particular file as a layer into the layer stack.
QString path() const
QString nextLayerName(const QString &baseName="") const
Definition kis_image.cc:715
bool openDocument(const QString &path, OpenFlags flags)
KisViewManager * viewManager
static KisPart * instance()
Definition KisPart.cpp:131
void addDocument(KisDocument *document, bool notify=true)
Definition KisPart.cpp:211
KisImageWSP image() const
Return the image this view is displaying.
static KisApplicationArguments deserialize(QByteArray &serialized)
KisDocument * createDocumentFromArguments() const

References KisPart::addDocument(), KisNodeCommandsAdapter::addNode(), KisMainWindow::BatchMode, KisApplicationArguments::createDocumentFromArguments(), createNewDocFromTemplate(), d, KisApplicationArguments::deserialize(), KisApplicationArguments::doNewImage(), KisApplicationArguments::doTemplate, KisApplicationArguments::fileLayer, KisApplicationArguments::filenames, KisViewManager::image(), KisPart::instance(), KisImage::nextLayerName(), KisFileLayer::None, KisMainWindow::None, OPACITY_OPAQUE_U8, KisMainWindow::openDocument(), KisNode::parent, KisFileLayer::path(), and KisMainWindow::viewManager.

◆ extendedModifiersPluginInterface()

KisExtendedModifiersMapperPluginInterface * KisApplication::extendedModifiersPluginInterface ( )

Definition at line 1284 of file KisApplication.cpp.

1285{
1286 return d->extendedModifiersPluginInterface.data();
1287}

References d.

◆ fileOpenRequested

void KisApplication::fileOpenRequested ( const QString & url)
slot

Definition at line 1081 of file KisApplication.cpp.

1082{
1083 if (!d->mainWindow) {
1084 d->earlyFileOpenEvents.append(url);
1085 return;
1086 }
1087
1088 KisMainWindow::OpenFlags flags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
1089 d->mainWindow->openDocument(url, flags);
1090}

References KisMainWindow::BatchMode, d, and KisMainWindow::None.

◆ hideSplashScreen()

void KisApplication::hideSplashScreen ( )

Definition at line 842 of file KisApplication.cpp.

843{
844 if (d->splashScreen) {
845 // hide the splashscreen to see the dialog
846 d->splashScreen->hide();
847 }
848}

References d.

◆ initializeGlobals()

void KisApplication::initializeGlobals ( const KisApplicationArguments & args)

Definition at line 360 of file KisApplication.cpp.

361{
362 Q_UNUSED(args)
363 // There are no globals to initialize from the arguments now. There used
364 // to be the `dpi` argument, but it doesn't do anything anymore.
365}

◆ isStoreApplication()

bool KisApplication::isStoreApplication ( )
Returns
true if Krita has been acquired through an app store

Definition at line 921 of file KisApplication.cpp.

922{
923 if (qEnvironmentVariableIsSet("STEAMAPPID") || qEnvironmentVariableIsSet("SteamAppId")) {
924 return true;
925 }
926
927 if (applicationDirPath().toLower().contains("steam")) {
928 return true;
929 }
930
931#ifdef Q_OS_WIN
932 // This is also true for user-installed MSIX, but that's
933 // likely only true in institutional situations, where
934 // we don't want to show the beginning banner either.
936 return true;
937 }
938#endif
939
940#ifdef Q_OS_MACOS
941 KisMacosEntitlements entitlements;
942 if (entitlements.sandbox()) {
943 return true;
944 }
945#endif
946
947 return false;
948}

References KisWindowsPackageUtils::isRunningInPackage(), and KisMacosEntitlements::sandbox().

◆ loadPlugins()

void KisApplication::loadPlugins ( )

Definition at line 481 of file KisApplication.cpp.

482{
483 // qDebug() << "loadPlugins();";
484
486 r->add(new KisShapeSelectionFactory());
495}
static KisActionRegistry * instance()
static KisFilterRegistry * instance()
static KisGeneratorRegistry * instance()
static KisMetadataBackendRegistry * instance()
static KisPaintOpRegistry * instance()
static KoDockRegistry * instance()
static KoShapeRegistry * instance()
static KoToolRegistry * instance()
static KoColorSpaceRegistry * instance()

References KoDockRegistry::instance(), KoShapeRegistry::instance(), KoToolRegistry::instance(), KisPaintOpRegistry::instance(), KisFilterRegistry::instance(), KisGeneratorRegistry::instance(), KisMetadataBackendRegistry::instance(), KoColorSpaceRegistry::instance(), and KisActionRegistry::instance().

◆ notify()

bool KisApplication::notify ( QObject * receiver,
QEvent * event )
override

Overridden to handle exceptions from event handlers.

KisApplication::notify() is called for every event loop processed in any thread, so we need to make sure our counters and postponed events queues are stored in a per-thread way.

Definition at line 851 of file KisApplication.cpp.

852{
853 try {
854 bool result = true;
855
861 AppRecursionInfo &info = s_recursionInfo->localData();
862
863 {
864 // QApplication::notify() can throw, so use RAII for counters
865 AppRecursionGuard guard(&info);
866
868
869 if (info.eventRecursionCount > 1) {
871 KIS_SAFE_ASSERT_RECOVER_NOOP(typedEvent->destination == receiver);
872
873 info.postponedSynchronizationEvents.emplace(KisSynchronizedConnectionEvent(*typedEvent));
874 } else {
875 result = QApplication::notify(receiver, event);
876 }
877 } else {
878 result = QApplication::notify(receiver, event);
879 }
880 }
881
882 if (!info.eventRecursionCount) {
884
885 }
886
887 return result;
888
889 } catch (std::exception &e) {
890 qWarning("Error %s sending event %i to object %s",
891 e.what(), event->type(), qPrintable(receiver->objectName()));
892 } catch (...) {
893 qWarning("Error <unknown> sending event %i to object %s",
894 event->type(), qPrintable(receiver->objectName()));
895 }
896 return false;
897}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
Event type used for synchronizing connection in KisSynchronizedConnection.

References KisSynchronizedConnectionEvent::destination, event(), KisSynchronizedConnectionBase::eventType(), KIS_SAFE_ASSERT_RECOVER_NOOP, and processPostponedSynchronizationEvents().

◆ processPostponedSynchronizationEvents()

void KisApplication::processPostponedSynchronizationEvents ( )

We must pop event from the queue before we call QApplication::notify(), because it can throw!

Definition at line 899 of file KisApplication.cpp.

900{
901 AppRecursionInfo &info = s_recursionInfo->localData();
902
903 while (!info.postponedSynchronizationEvents.empty()) {
904 // QApplication::notify() can throw, so use RAII for counters
905 AppRecursionGuard guard(&info);
906
909 KisSynchronizedConnectionEvent typedEvent = info.postponedSynchronizationEvents.front();
910 info.postponedSynchronizationEvents.pop();
911
912 if (!typedEvent.destination) {
913 qWarning() << "WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery";
914 continue;
915 }
916
917 QApplication::notify(typedEvent.destination, &typedEvent);
918 }
919}

References KisSynchronizedConnectionEvent::destination.

◆ registerResources()

bool KisApplication::registerResources ( )

Definition at line 415 of file KisApplication.cpp.

416{
418
420 QStringList() << "application/x-krita-paintoppreset"));
421
422 reg->add(new KisResourceLoader<KisGbrBrush>(ResourceSubType::GbrBrushes, ResourceType::Brushes, i18n("Brush tips"), QStringList() << "image/x-gimp-brush"));
423 reg->add(new KisResourceLoader<KisImagePipeBrush>(ResourceSubType::GihBrushes, ResourceType::Brushes, i18n("Brush tips"), QStringList() << "image/x-gimp-brush-animated"));
424 reg->add(new KisResourceLoader<KisSvgBrush>(ResourceSubType::SvgBrushes, ResourceType::Brushes, i18n("Brush tips"), QStringList() << "image/svg+xml"));
426
427 reg->add(new KisResourceLoader<KoSegmentGradient>(ResourceSubType::SegmentedGradients, ResourceType::Gradients, i18n("Gradients"), QStringList() << "application/x-gimp-gradient"));
429
440
441
442 reg->add(new KisResourceLoader<KoPattern>(ResourceType::Patterns, ResourceType::Patterns, i18n("Patterns"), {"application/x-gimp-pattern", "image/x-gimp-pat", "application/x-gimp-pattern", "image/bmp", "image/jpeg", "image/png", "image/tiff"}));
443 reg->add(new KisResourceLoader<KisWorkspaceResource>(ResourceType::Workspaces, ResourceType::Workspaces, i18n("Workspaces"), QStringList() << "application/x-krita-workspace"));
444 reg->add(new KisResourceLoader<KoSvgSymbolCollectionResource>(ResourceType::Symbols, ResourceType::Symbols, i18n("SVG symbol libraries"), QStringList() << "image/svg+xml"));
445 reg->add(new KisResourceLoader<KisWindowLayoutResource>(ResourceType::WindowLayouts, ResourceType::WindowLayouts, i18n("Window layouts"), QStringList() << "application/x-krita-windowlayout"));
446 reg->add(new KisResourceLoader<KisSessionResource>(ResourceType::Sessions, ResourceType::Sessions, i18n("Sessions"), QStringList() << "application/x-krita-session"));
447 reg->add(new KisResourceLoader<KoGamutMask>(ResourceType::GamutMasks, ResourceType::GamutMasks, i18n("Gamut masks"), QStringList() << "application/x-krita-gamutmasks"));
448#if defined HAVE_SEEXPR
449 reg->add(new KisResourceLoader<KisSeExprScript>(ResourceType::SeExprScripts, ResourceType::SeExprScripts, i18n("SeExpr Scripts"), QStringList() << "application/x-krita-seexpr-script"));
450#endif
451 // XXX: this covers only individual styles, not the library itself!
454 i18nc("Resource type name", "Layer styles"),
455 QStringList() << "application/x-photoshop-style"));
456
457 reg->add(new KisResourceLoader<KoCssStylePreset>(ResourceType::CssStyles, ResourceType::CssStyles, i18n("Style Presets"), QStringList() << "image/svg+xml"));
458
460
461#ifndef Q_OS_ANDROID
462 QString databaseLocation = KoResourcePaths::getAppDataLocation();
463#else
464 // Sqlite doesn't support content URIs (obviously). So, we make database location unconfigurable on android.
465 QString databaseLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
466#endif
467
468 if (!KisResourceCacheDb::initialize(databaseLocation)) {
469 QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita: Fatal error"), i18n("%1\n\nKrita will quit now.", KisResourceCacheDb::lastError()));
470 }
471
473 connect(KisResourceLocator::instance(), SIGNAL(progressMessage(const QString&)), this, SLOT(setSplashScreenLoadingText(const QString&)));
474 if (r != KisResourceLocator::LocatorError::Ok && qApp->inherits("KisApplication")) {
475 QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita: Fatal error"), KisResourceLocator::instance()->errorMessages().join('\n') + i18n("\n\nKrita will quit now."));
476 return false;
477 }
478 return true;
479}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setSplashScreenLoadingText(const QString &)
static QString mimeTypeForSuffix(const QString &suffix)
Find the mimetype for a given extension. The extension may have the form "*.xxx" or "xxx".
static bool initialize(const QString &location)
initializes the database and updates the scheme if necessary. Does not actually fill the database wit...
static QString lastError()
lastError returns the last SQL error.
The KisResourceLoaderRegistry class manages the loader plugins for resources. Every resource can be l...
static KisResourceLoaderRegistry * instance()
void registerFixup(int priority, ResourceCacheFixup *fixup)
LocatorError initialize(const QString &installationResourcesLocation)
initialize Setup the resource locator for use.
static KisResourceLocator * instance()
static QString getAppDataLocation()
static QString getApplicationRoot()
const QString GbrBrushes
const QString PngBrushes
const QString GihBrushes
const QString SvgBrushes
const QString StopGradients
const QString KritaPaintOpPresets
const QString SegmentedGradients
const QString Palettes
const QString Symbols
const QString CssStyles
const QString LayerStyles
const QString Brushes
const QString GamutMasks
const QString Patterns
const QString Gradients
const QString Workspaces
const QString WindowLayouts
const QString Sessions
const QString PaintOpPresets

References KoGenericRegistry< T >::add(), ResourceType::Brushes, connect(), ResourceType::CssStyles, ResourceType::GamutMasks, ResourceSubType::GbrBrushes, KoResourcePaths::getAppDataLocation(), KoResourcePaths::getApplicationRoot(), ResourceSubType::GihBrushes, ResourceType::Gradients, KisResourceLocator::initialize(), KisResourceCacheDb::initialize(), KisResourceLoaderRegistry::instance(), KisResourceLocator::instance(), ResourceSubType::KritaPaintOpPresets, KisResourceCacheDb::lastError(), ResourceType::LayerStyles, KisMimeDatabase::mimeTypeForSuffix(), KisResourceLocator::Ok, ResourceType::PaintOpPresets, ResourceType::Palettes, ResourceType::Patterns, ResourceSubType::PngBrushes, KisResourceLoaderRegistry::registerFixup(), ResourceType::SeExprScripts, ResourceSubType::SegmentedGradients, ResourceType::Sessions, setSplashScreenLoadingText(), ResourceSubType::StopGradients, ResourceSubType::SvgBrushes, ResourceType::Symbols, ResourceType::WindowLayouts, and ResourceType::Workspaces.

◆ remoteArguments

void KisApplication::remoteArguments ( const QString & message)
slot

Definition at line 1062 of file KisApplication.cpp.

1063{
1064 // check if we have any mainwindow
1065 KisMainWindow *mw = qobject_cast<KisMainWindow*>(qApp->activeWindow());
1066
1067 if (!mw && KisPart::instance()->mainWindows().size() > 0) {
1068 mw = KisPart::instance()->mainWindows().first();
1069 }
1070
1071 const QByteArray unpackedMessage =
1072 QByteArray::fromBase64(message.toLatin1());
1073
1074 if (!mw) {
1075 d->earlyRemoteArguments << unpackedMessage;
1076 return;
1077 }
1078 executeRemoteArguments(unpackedMessage, mw);
1079}
void executeRemoteArguments(QByteArray message, KisMainWindow *mainWindow)
Main window for Krita.
QList< QPointer< KisMainWindow > > mainWindows
Definition KisPart.cpp:107
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References d, executeRemoteArguments(), KisPart::instance(), and KisPart::mainWindows.

◆ resetConfig()

void KisApplication::resetConfig ( )
private

Definition at line 1210 of file KisApplication.cpp.

1211{
1212 KIS_ASSERT_RECOVER_RETURN(qApp->thread() == QThread::currentThread());
1213
1214 KSharedConfigPtr config = KSharedConfig::openConfig();
1215 config->markAsClean();
1216
1217 // find user settings file
1218 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
1219 QString kritarcPath = configPath + QStringLiteral("/kritarc");
1220
1221 QFile kritarcFile(kritarcPath);
1222
1223 if (kritarcFile.exists()) {
1224 if (kritarcFile.open(QFile::ReadWrite)) {
1225 QString backupKritarcPath = kritarcPath + QStringLiteral(".backup");
1226
1227 QFile backupKritarcFile(backupKritarcPath);
1228
1229 if (backupKritarcFile.exists()) {
1230 backupKritarcFile.remove();
1231 }
1232
1233 QMessageBox::information(qApp->activeWindow(),
1234 i18nc("@title:window", "Krita"),
1235 i18n("Krita configurations reset!\n\n"
1236 "Backup file was created at: %1\n\n"
1237 "Restart Krita for changes to take effect.",
1238 backupKritarcPath),
1239 QMessageBox::Ok, QMessageBox::Ok);
1240
1241 // clear file
1242 kritarcFile.rename(backupKritarcPath);
1243
1244 kritarcFile.close();
1245 }
1246 else {
1247 QMessageBox::warning(qApp->activeWindow(),
1248 i18nc("@title:window", "Krita"),
1249 i18n("Failed to clear %1\n\n"
1250 "Please make sure no other program is using the file and try again.",
1251 kritarcPath),
1252 QMessageBox::Ok, QMessageBox::Ok);
1253 }
1254 }
1255
1256 // reload from disk; with the user file settings cleared,
1257 // this should load any default configuration files shipping with the program
1258 config->reparseConfiguration();
1259 config->sync();
1260
1261 // Restore to default workspace
1262 KConfigGroup cfg = KSharedConfig::openConfig()->group("MainWindow");
1263
1264 QString currentWorkspace = cfg.readEntry<QString>("CurrentWorkspace", "Default");
1266 KisWorkspaceResourceSP workspace = rserver->resource("", "", currentWorkspace);
1267
1268 if (workspace) {
1269 d->mainWindow->restoreWorkspace(workspace);
1270 }
1271}
static KisResourceServerProvider * instance()
KoResourceServer< KisWorkspaceResource > * workspaceServer()
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References d, KisResourceServerProvider::instance(), KIS_ASSERT_RECOVER_RETURN, and KisResourceServerProvider::workspaceServer().

◆ setSplashScreen()

void KisApplication::setSplashScreen ( QWidget * splash)

Tell KisApplication to show this splashscreen when you call start(); when start returns, the splashscreen is hidden. Use KSplashScreen to have the splash show correctly on Xinerama displays.

Definition at line 829 of file KisApplication.cpp.

830{
831 d->splashScreen = qobject_cast<KisSplashScreen*>(splashScreen);
832}

References d.

◆ setSplashScreenLoadingText

void KisApplication::setSplashScreenLoadingText ( const QString & textToLoad)
slot

Definition at line 834 of file KisApplication.cpp.

835{
836 if (d->splashScreen) {
837 d->splashScreen->setLoadingText(textToLoad);
838 d->splashScreen->repaint();
839 }
840}

References d.

◆ slotSetLongPress

void KisApplication::slotSetLongPress ( bool enabled)
privateslot

Definition at line 1093 of file KisApplication.cpp.

1094{
1095 if (enabled && !d->longPressEventFilter) {
1096 d->longPressEventFilter = new KisLongPressEventFilter(this);
1097 installEventFilter(d->longPressEventFilter);
1098 } else if (!enabled && d->longPressEventFilter) {
1099 removeEventFilter(d->longPressEventFilter);
1100 d->longPressEventFilter->deleteLater();
1101 d->longPressEventFilter = nullptr;
1102 }
1103}

References d.

◆ start()

bool KisApplication::start ( const KisApplicationArguments & args)
virtual

Call this to start the application.

Parses command line arguments and creates the initial main windows and docs from them (or an empty doc if no cmd-line argument is specified ).

You must call this method directly before calling QApplication::exec.

It is valid behaviour not to call this method at all. In this case you have to process your command line parameters by yourself.

Definition at line 497 of file KisApplication.cpp.

498{
499 KisConfig cfg(false);
500
501#if defined(Q_OS_WIN)
502#ifdef ENV32BIT
503
504 if (isWow64() && !cfg.readEntry("WarnedAbout32Bits", false)) {
505 QMessageBox::information(qApp->activeWindow(),
506 i18nc("@title:window", "Krita: Warning"),
507 i18n("You are running a 32 bits build on a 64 bits Windows.\n"
508 "This is not recommended.\n"
509 "Please download and install the x64 build instead."));
510 cfg.writeEntry("WarnedAbout32Bits", true);
511
512 }
513#endif
514#endif
515
516 QString opengl = cfg.canvasState();
517 if (opengl == "OPENGL_NOT_TRIED" ) {
518 cfg.setCanvasState("TRY_OPENGL");
519 }
520 else if (opengl != "OPENGL_SUCCESS" && opengl != "TRY_OPENGL") {
521 cfg.setCanvasState("OPENGL_FAILED");
522 }
523
524 setSplashScreenLoadingText(i18n("Initializing Globals..."));
525 processEvents();
526 initializeGlobals(args);
527
528 const bool doNewImage = args.doNewImage();
529 const bool doTemplate = args.doTemplate();
530 const bool exportAs = args.exportAs();
531 const bool exportSequence = args.exportSequence();
532 const QString exportFileName = args.exportFileName();
533
534 d->batchRun = (exportAs || exportSequence || !exportFileName.isEmpty());
535 const bool needsMainWindow = (!exportAs && !exportSequence);
536 // only show the mainWindow when no command-line mode option is passed
537 bool showmainWindow = (!exportAs && !exportSequence); // would be !batchRun;
538
539 const bool showSplashScreen = !d->batchRun && qEnvironmentVariableIsEmpty("NOSPLASH");
540 if (showSplashScreen && d->splashScreen) {
541 d->splashScreen->show();
542 d->splashScreen->repaint();
543 processEvents();
544 }
545
546 KConfigGroup group(KSharedConfig::openConfig(), "theme");
547#ifndef Q_OS_HAIKU
548 Digikam::ThemeManager themeManager;
549 themeManager.setCurrentTheme(group.readEntry("Theme", "Krita dark"));
550#endif
551
552 ResetStarting resetStarting(d->splashScreen, args.filenames().count()); // remove the splash when done
553 Q_UNUSED(resetStarting);
554
555 // Make sure we can save resources and tags
556 setSplashScreenLoadingText(i18n("Adding resource types..."));
557 processEvents();
559
560 setSplashScreenLoadingText(i18n("Loading plugins..."));
561 processEvents();
562 // Load the plugins
563 loadPlugins();
564
565 // Load all resources
566 setSplashScreenLoadingText(i18n("Loading resources..."));
567 processEvents();
568 if (!registerResources()) {
569 return false;
570 }
571
572 KisPart *kisPart = KisPart::instance();
573 if (needsMainWindow) {
574 // show a mainWindow asap, if we want that
575 setSplashScreenLoadingText(i18n("Loading Main Window..."));
576 processEvents();
577
578
579 bool sessionNeeded = true;
580 auto sessionMode = cfg.sessionOnStartup();
581
582 if (!args.session().isEmpty()) {
583 sessionNeeded = !kisPart->restoreSession(args.session());
584 } else if (sessionMode == KisConfig::SOS_ShowSessionManager) {
585 showmainWindow = false;
586 sessionNeeded = false;
587 kisPart->showSessionManager();
588 } else if (sessionMode == KisConfig::SOS_PreviousSession) {
589 KConfigGroup sessionCfg = KSharedConfig::openConfig()->group("session");
590 const QString &sessionName = sessionCfg.readEntry("previousSession");
591
592 sessionNeeded = !kisPart->restoreSession(sessionName);
593 }
594
595 if (sessionNeeded) {
596 kisPart->startBlankSession();
597 }
598
599 if (!args.windowLayout().isEmpty()) {
601 KisWindowLayoutResourceSP windowLayout = rserver->resource("", "", args.windowLayout());
602 if (windowLayout) {
603 windowLayout->applyLayout();
604 }
605 }
606
607 setSplashScreenLoadingText(i18n("Launching..."));
608
609 if (showmainWindow) {
610 d->mainWindow = kisPart->currentMainwindow();
611
612 if (!args.workspace().isEmpty()) {
614 KisWorkspaceResourceSP workspace = rserver->resource("", "", args.workspace());
615 if (workspace) {
616 d->mainWindow->restoreWorkspace(workspace);
617 }
618 }
619
620 if (args.canvasOnly()) {
621 d->mainWindow->viewManager()->switchCanvasOnly(true);
622 }
623
624 if (args.fullScreen()) {
625 d->mainWindow->showFullScreen();
626 }
627 } else {
628 d->mainWindow = kisPart->createMainWindow();
629 }
630 }
631 short int numberOfOpenDocuments = 0; // number of documents open
632
633 // Check for autosave files that can be restored, if we're not running a batch run (test)
634 if (!d->batchRun) {
636 }
637
638 setSplashScreenLoadingText(QString()); // done loading, so clear out label
639 processEvents();
640
641 //configure the unit manager
643 connect(this, &KisApplication::aboutToQuit, &KisSpinBoxUnitManagerFactory::clearUnitManagerBuilder); //ensure the builder is destroyed when the application leave.
644 //the new syntax slot syntax allow to connect to a non q_object static method.
645
646 // Long-press emulation.
648 slotSetLongPress(cfg.longPressEnabled());
649
650 // Create a new image, if needed
651 if (doNewImage) {
653 if (doc) {
654 kisPart->addDocument(doc);
655 d->mainWindow->addViewAndNotifyLoadingCompleted(doc);
656 }
657 }
658
659 // Get the command line arguments which we have to parse
660 int argsCount = args.filenames().count();
661 if (argsCount > 0) {
662 // Loop through arguments
663 for (int argNumber = 0; argNumber < argsCount; argNumber++) {
664 QString fileName = args.filenames().at(argNumber);
665 // are we just trying to open a template?
666 if (doTemplate) {
667 // called in mix with batch options? ignore and silently skip
668 if (d->batchRun) {
669 continue;
670 }
671 if (createNewDocFromTemplate(fileName, d->mainWindow)) {
672 ++numberOfOpenDocuments;
673 }
674 // now try to load
675 }
676 else {
677 if (exportAs) {
678 QString outputMimetype = KisMimeDatabase::mimeTypeForFile(exportFileName, false);
679 if (outputMimetype == "application/octetstream") {
680 dbgKrita << i18n("Mimetype not found, try using the -mimetype option") << Qt::endl;
681 return false;
682 }
683
684 KisDocument *doc = kisPart->createDocument();
685 doc->setFileBatchMode(d->batchRun);
686 bool result = doc->openPath(fileName);
687
688 if (!result) {
689 errKrita << "Could not load " << fileName << ":" << doc->errorMessage();
690 QTimer::singleShot(0, this, SLOT(quit()));
691 return false;
692 }
693
694 if (exportFileName.isEmpty()) {
695 errKrita << "Export destination is not specified for" << fileName << "Please specify export destination with --export-filename option";
696 QTimer::singleShot(0, this, SLOT(quit()));
697 return false;
698 }
699
700 qApp->processEvents(); // For vector layers to be updated
701
702 doc->setFileBatchMode(true);
703 doc->image()->waitForDone();
704
705 if (!doc->exportDocumentSync(exportFileName, outputMimetype.toLatin1())) {
706 errKrita << "Could not export " << fileName << "to" << exportFileName << ":" << doc->errorMessage();
707 }
708 QTimer::singleShot(0, this, SLOT(quit()));
709 return true;
710 }
711 else if (exportSequence) {
712 KisDocument *doc = kisPart->createDocument();
713 doc->setFileBatchMode(d->batchRun);
714 doc->openPath(fileName);
715 qApp->processEvents(); // For vector layers to be updated
716
717 if (!doc->image()->animationInterface()->hasAnimation()) {
718 errKrita << "This file has no animation." << Qt::endl;
719 QTimer::singleShot(0, this, SLOT(quit()));
720 return false;
721 }
722
723 doc->setFileBatchMode(true);
724 int sequenceStart = 0;
725
726
727 qDebug() << ppVar(exportFileName);
730 exportFileName,
731 sequenceStart,
732 false,
733 0);
734
735 exporter.setBatchMode(d->batchRun);
736
737 KisAsyncAnimationFramesSaveDialog::Result result = exporter.regenerateRange(nullptr);
738 qDebug() << ppVar(result);
739
741 errKrita << i18n("Failed to render animation frames!") << Qt::endl;
742 }
743
744 QTimer::singleShot(0, this, SLOT(quit()));
745 return true;
746 }
747 else if (d->mainWindow) {
748 if (QFileInfo(fileName).fileName().endsWith(".bundle", Qt::CaseInsensitive)) {
749 d->mainWindow->installBundle(fileName);
750 }
751 else {
752 KisMainWindow::OpenFlags flags = d->batchRun ? KisMainWindow::BatchMode : KisMainWindow::None;
753
754 if (d->mainWindow->openDocument(fileName, flags)) {
755 // Normal case, success
756 numberOfOpenDocuments++;
757 }
758 }
759 }
760 }
761 }
762 }
763
764 //add an image as file-layer
765 if (!args.fileLayer().isEmpty()){
766 if (d->mainWindow->viewManager()->image()){
767 KisFileLayer *fileLayer = new KisFileLayer(d->mainWindow->viewManager()->image(), "",
768 args.fileLayer(), KisFileLayer::None, "Bicubic",
769 d->mainWindow->viewManager()->image()->nextLayerName(i18n("File layer")), OPACITY_OPAQUE_U8);
770 QFileInfo fi(fileLayer->path());
771 if (fi.exists()){
772 KisNodeCommandsAdapter adapter(d->mainWindow->viewManager());
773 adapter.addNode(fileLayer, d->mainWindow->viewManager()->activeNode()->parent(),
774 d->mainWindow->viewManager()->activeNode());
775 }
776 else{
777 QMessageBox::warning(qApp->activeWindow(), i18nc("@title:window", "Krita:Warning"),
778 i18n("Cannot add %1 as a file layer: the file does not exist.", fileLayer->path()));
779 }
780 }
781 else if (this->isRunning()){
782 QMessageBox::warning(qApp->activeWindow(), i18nc("@title:window", "Krita:Warning"),
783 i18n("Cannot add the file layer: no document is open.\n\n"
784"You can create a new document using the --new-image option, or you can open an existing file.\n\n"
785"If you instead want to add the file layer to a document in an already running instance of Krita, check the \"Allow only one instance of Krita\" checkbox in the settings (Settings -> General -> Window)."));
786 }
787 else {
788 QMessageBox::warning(qApp->activeWindow(), i18nc("@title:window", "Krita: Warning"),
789 i18n("Cannot add the file layer: no document is open.\n"
790 "You can either create a new file using the --new-image option, or you can open an existing file."));
791 }
792 }
793
794 // fixes BUG:369308 - Krita crashing on splash screen when loading.
795 // trying to open a file before Krita has loaded can cause it to hang and crash
796 if (d->splashScreen) {
797 d->splashScreen->displayLinks(true);
798 d->splashScreen->displayRecentFiles(true);
799 }
800
801 Q_FOREACH(const QByteArray &message, d->earlyRemoteArguments) {
802 executeRemoteArguments(message, d->mainWindow);
803 }
804
806
807 // process File open event files
808 if (!d->earlyFileOpenEvents.isEmpty()) {
810 Q_FOREACH(QString fileName, d->earlyFileOpenEvents) {
811 d->mainWindow->openDocument(fileName, QFlags<KisMainWindow::OpenFlag>());
812 }
813 }
814
816
817 // not calling this before since the program will quit there.
818 return true;
819}
void setCurrentTheme(const QString &name)
friend class ResetStarting
void slotSetLongPress(bool enabled)
void initializeGlobals(const KisApplicationArguments &args)
static void verifyMetatypeRegistration()
void sigLongPressChanged(bool enabled)
static KisConfigNotifier * instance()
@ SOS_PreviousSession
Definition kis_config.h:345
@ SOS_ShowSessionManager
Definition kis_config.h:346
void setFileBatchMode(const bool batchMode)
KisImageSP image
QString errorMessage() const
bool exportDocumentSync(const QString &path, const QByteArray &mimeType, KisPropertiesConfigurationSP exportConfiguration=0)
bool openPath(const QString &path, OpenFlags flags=None)
openPath Open a Path
const KisTimeSpan & documentPlaybackRange() const
documentPlaybackRange
void waitForDone()
KisImageAnimationInterface * animationInterface() const
static QString mimeTypeForFile(const QString &file, bool checkExistingFiles=true)
Find the mimetype for the given filename. The filename must include a suffix.
bool restoreSession(const QString &sessionName)
Definition KisPart.cpp:668
KisMainWindow * currentMainwindow() const
Definition KisPart.cpp:483
void startBlankSession()
Definition KisPart.cpp:660
KisDocument * createDocument() const
Definition KisPart.cpp:230
void showSessionManager()
Definition KisPart.cpp:650
KisMainWindow * createMainWindow(QUuid id=QUuid())
Definition KisPart.cpp:260
KoResourceServer< KisWindowLayoutResource > * windowLayoutServer()
static void setDefaultUnitManagerBuilder(KisSpinBoxUnitManagerBuilder *pBuilder)
set a builder the factory can use. The factory should take on the lifecycle of the builder,...
static QString screenInformation()
Returns information about all available screens.
static void writeSysInfo(const QString &message)
Writes to the system information file and Krita log.
QSharedPointer< T > resource(const QString &md5, const QString &fileName, const QString &name)
resource retrieves a resource. If the md5sum is not empty, the resource will only be retrieved if a r...
#define dbgKrita
Definition kis_debug.h:45
#define errKrita
Definition kis_debug.h:107
#define ppVar(var)
Definition kis_debug.h:155
QAction * quit(const QObject *recvr, const char *slot, QObject *parent)

References KisPart::addDocument(), KisNodeCommandsAdapter::addNode(), addResourceTypes(), KisImage::animationInterface(), KisMainWindow::BatchMode, KisApplicationArguments::canvasOnly, KisConfig::canvasState(), checkAutosaveFiles(), KisSpinBoxUnitManagerFactory::clearUnitManagerBuilder(), connect(), KisPart::createDocument(), KisApplicationArguments::createDocumentFromArguments(), KisPart::createMainWindow(), createNewDocFromTemplate(), KisPart::currentMainwindow(), d, dbgKrita, KisImageAnimationInterface::documentPlaybackRange(), KisApplicationArguments::doNewImage(), KisApplicationArguments::doTemplate, errKrita, KisDocument::errorMessage(), executeRemoteArguments(), KisApplicationArguments::exportAs, KisDocument::exportDocumentSync(), KisApplicationArguments::exportFileName, KisApplicationArguments::exportSequence, KisApplicationArguments::fileLayer, KisApplicationArguments::filenames, KisApplicationArguments::fullScreen, KisImageAnimationInterface::hasAnimation(), hideSplashScreen(), KisDocument::image, initializeGlobals(), KisConfigNotifier::instance(), KisPart::instance(), KisResourceServerProvider::instance(), QtSingleApplication::isRunning(), loadPlugins(), KisConfig::longPressEnabled(), KisMimeDatabase::mimeTypeForFile(), KisFileLayer::None, KisMainWindow::None, OPACITY_OPAQUE_U8, KisDocument::openPath(), KisNode::parent, KisFileLayer::path(), ppVar, KisConfig::readEntry(), KisAsyncAnimationFramesSaveDialog::regenerateRange(), registerResources(), KisAsyncAnimationRenderDialogBase::RenderComplete, KoResourceServer< T >::resource(), KisPart::restoreSession(), KisUsageLogger::screenInformation(), KisApplicationArguments::session, KisConfig::sessionOnStartup(), KisAsyncAnimationRenderDialogBase::setBatchMode(), KisConfig::setCanvasState(), Digikam::ThemeManager::setCurrentTheme(), KisSpinBoxUnitManagerFactory::setDefaultUnitManagerBuilder(), KisDocument::setFileBatchMode(), setSplashScreenLoadingText(), KisPart::showSessionManager(), KisConfigNotifier::sigLongPressChanged(), slotSetLongPress(), KisConfig::SOS_PreviousSession, KisConfig::SOS_ShowSessionManager, KisPart::startBlankSession(), verifyMetatypeRegistration(), KisImage::waitForDone(), KisApplicationArguments::windowLayout, KisResourceServerProvider::windowLayoutServer(), KisApplicationArguments::workspace, KisResourceServerProvider::workspaceServer(), KisConfig::writeEntry(), and KisUsageLogger::writeSysInfo().

◆ verifyMetatypeRegistration()

void KisApplication::verifyMetatypeRegistration ( )
static

Verify that all our statically registered types are actually registered. This check is skipped in release builds, when HIDE_SAFE_ASSERTS is defined

Definition at line 950 of file KisApplication.cpp.

951{
956#if !defined(HIDE_SAFE_ASSERTS) || defined(CRASH_ON_SAFE_ASSERTS)
957
958 auto verifyTypeRegistered = [] (const char *type) {
959 const int typeId = QMetaType::type(type);
960
961 if (typeId <= 0) {
962 qFatal("ERROR: type-id for metatype %s is not found", type);
963 }
964
965 if (!QMetaType::isRegistered(typeId)) {
966 qFatal("ERROR: metatype %s is not registered", type);
967 }
968 };
969
970 verifyTypeRegistered("KisBrushSP");
971 verifyTypeRegistered("KoSvgText::AutoValue");
972 verifyTypeRegistered("KoSvgText::BackgroundProperty");
973 verifyTypeRegistered("KoSvgText::StrokeProperty");
974 verifyTypeRegistered("KoSvgText::TextTransformInfo");
975 verifyTypeRegistered("KoSvgText::TextIndentInfo");
976 verifyTypeRegistered("KoSvgText::TabSizeInfo");
977 verifyTypeRegistered("KoSvgText::LineHeightInfo");
978 verifyTypeRegistered("KisPaintopLodLimitations");
979 verifyTypeRegistered("KisImageSP");
980 verifyTypeRegistered("KisImageSignalType");
981 verifyTypeRegistered("KisNodeSP");
982 verifyTypeRegistered("KisNodeList");
983 verifyTypeRegistered("KisPaintDeviceSP");
984 verifyTypeRegistered("KisTimeSpan");
985 verifyTypeRegistered("KoColor");
986 verifyTypeRegistered("KoResourceSP");
987 verifyTypeRegistered("KoResourceCacheInterfaceSP");
988 verifyTypeRegistered("KisAsyncAnimationRendererBase::CancelReason");
989 verifyTypeRegistered("KisGridConfig");
990 verifyTypeRegistered("KisGuidesConfig");
991 verifyTypeRegistered("KisUpdateInfoSP");
992 verifyTypeRegistered("KisToolChangesTrackerDataSP");
993 verifyTypeRegistered("QVector<QImage>");
994 verifyTypeRegistered("SnapshotDirInfoList");
995 verifyTypeRegistered("TransformTransactionProperties");
996 verifyTypeRegistered("ToolTransformArgs");
997 verifyTypeRegistered("QPainterPath");
998#endif
999}

Friends And Related Symbol Documentation

◆ ResetStarting

friend class ResetStarting
friend

Definition at line 123 of file KisApplication.h.

Member Data Documentation

◆ d

QScopedPointer<Private> KisApplication::d
private

Definition at line 121 of file KisApplication.h.


The documentation for this class was generated from the following files: