Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Add "professional" splash screen for paying users

Carsten Hartenfelsee0da5bd21df
diff --git a/krita/data/splash/corpo1.jpg b/krita/data/splash/corpo1.jpg
new file mode 100644
index 0000000000..19bba1bcfd
Binary files /dev/null and b/krita/data/splash/corpo1.jpg differ
diff --git a/krita/data/splash/splash-android.qrc b/krita/data/splash/splash-android.qrc
index d7147ad4ee..8f7ac9e955 100644
--- a/krita/data/splash/splash-android.qrc
+++ b/krita/data/splash/splash-android.qrc
@@ -7,6 +7,7 @@
<qresource prefix="/splash">
<file>banner.svg</file>
<file alias="hd.jpg">electrichearts_20250824A_kiki_HD.jpg</file>
+ <file alias="corpo1.jpg">corpo1.jpg</file>
</qresource>
</RCC>
diff --git a/krita/data/splash/splash.qrc b/krita/data/splash/splash.qrc
index 9d2eaac368..1a310282e3 100644
--- a/krita/data/splash/splash.qrc
+++ b/krita/data/splash/splash.qrc
@@ -8,5 +8,6 @@
<file>banner.svg</file>
<file alias="0.png">electrichearts_20250824A_kiki_4K.png</file>
<file alias="1.png">splash_holidays_dummy.png</file>
+ <file alias="corpo1.jpg">corpo1.jpg</file>
</qresource>
</RCC>
diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt
index fc4419e655..928b634b52 100644
--- a/libs/ui/CMakeLists.txt
+++ b/libs/ui/CMakeLists.txt
@@ -73,6 +73,7 @@ set(kritaui_LIB_SRCS
dialogs/KisRecoverNamedAutosaveDialog.cpp
dialogs/KisDlgSavePreset.cpp
dialogs/kis_dlg_missing_color_profile.cpp
+ dialogs/KisSplashSourceDialog.cpp
dialogs/KisDlgConfigureCumulativeUndo.cpp
dialogs/KisCumulativeUndoModel.cpp
@@ -340,6 +341,7 @@ set(kritaui_LIB_SRCS
widgets/KisNewsItem.cpp
widgets/KisGamutMaskToolbar.cpp
widgets/KisColorSamplerPreviewPreview.cpp
+ widgets/KisSplashPreview.cpp
utils/kis_document_aware_spin_box_unit_manager.cpp
utils/KisSpinBoxSplineUnitConverter.cpp
@@ -653,6 +655,7 @@ ki18n_wrap_ui(kritaui_LIB_SRCS
widgets/KisDlgListPicker.ui
dialogs/kis_delayed_save_dialog.ui
dialogs/KisRecoverNamedAutosaveDialog.ui
+ dialogs/KisSplashSourceDialog.ui
input/config/kis_input_configuration_page.ui
input/config/kis_edit_profiles_dialog.ui
input/config/kis_input_configuration_page_item.ui
diff --git a/libs/ui/KisAndroidDonations.cpp b/libs/ui/KisAndroidDonations.cpp
index e1841b5148..d65f897303 100644
--- a/libs/ui/KisAndroidDonations.cpp
+++ b/libs/ui/KisAndroidDonations.cpp
@@ -4,6 +4,7 @@
#include "KisAndroidDonations.h"
#include "KisApplication.h"
+#include "kis_config.h"
#include "kis_splash_screen.h"
#include <QAndroidJniEnvironment>
@@ -99,8 +100,8 @@ void KisAndroidDonations::showDonationDialog(bool splash)
jbyteArray splashBytes = nullptr;
QString splashArtist;
if (splash) {
- KisSplashScreen::Source source = KisSplashScreen::getImageSource();
- splashArtist = source.artistCredit;
+ KisSplashScreen::Source source = KisSplashScreen::getCurrentSource();
+ splashArtist = source.artistCredit();
QFile f(source.resourcePath);
if (f.open(QIODevice::ReadOnly)) {
QByteArray buf = f.readAll();
@@ -206,6 +207,11 @@ void KisAndroidDonations::slotUpdateState(int state, long long ownedProductFlags
if (int(m_state) != state || m_ownedProductFlags != ownedProductFlags) {
m_state = State(state);
m_ownedProductFlags = ownedProductFlags;
+ // Reset the splash screen setting if we're definitely not a supporter.
+ if (!isMaybeSupporter()) {
+ KisConfig cfg(false);
+ cfg.setSplashScreenImage(cfg.splashScreenImage(true));
+ }
Q_EMIT sigStateChanged();
}
}
diff --git a/libs/ui/KisAndroidDonations.h b/libs/ui/KisAndroidDonations.h
index 6dba85085c..daf7cd4aaa 100644
--- a/libs/ui/KisAndroidDonations.h
+++ b/libs/ui/KisAndroidDonations.h
@@ -39,6 +39,19 @@ public:
State state() const { return m_state; }
+ bool isMaybeSupporter()
+ {
+ // Only returns false if we're sure the user is *not* a supporter.
+ // If we're not sure (yet), returns true.
+ switch (m_state) {
+ case State::Unavailable:
+ case State::NoSupport:
+ return false;
+ default:
+ return true;
+ }
+ }
+
bool shouldShowSupporterBadge() const;
bool isShowDonationManagementDialogPending() const
diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index 6bf08aa997..f032391406 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -965,20 +965,34 @@ void KisApplication::processPostponedSynchronizationEvents()
}
}
+#ifndef Q_OS_ANDROID
bool KisApplication::isStoreApplication()
{
- if (qEnvironmentVariableIsSet("STEAMAPPID") || qEnvironmentVariableIsSet("SteamAppId")) {
+ if (qEnvironmentVariableIsSet("STEAMAPPID") || qEnvironmentVariableIsSet("SteamAppId")
+ || qEnvironmentVariableIsSet("STEAMGAMEID") || qEnvironmentVariableIsSet("SteamGameId")) {
return true;
}
- if (applicationDirPath().toLower().contains("steam")) {
+ for (const QString &arg : arguments()) {
+ if (arg.startsWith("-epicapp=", Qt::CaseInsensitive) || arg.compare("-EpicPortal", Qt::CaseInsensitive) == 0) {
+ return true;
+ }
+ }
+
+ if (QDir(applicationDirPath()).exists(".egstore")) {
+ return true;
+ }
+
+ if (QRegularExpression(QStringLiteral("[/\\\\](?:steam|steamapps|epic\\s*games)[/\\\\]"),
+ QRegularExpression::CaseInsensitiveOption)
+ .match(applicationDirPath())
+ .hasMatch()) {
return true;
}
#ifdef Q_OS_WIN
// This is also true for user-installed MSIX, but that's
- // likely only true in institutional situations, where
- // we don't want to show the beginning banner either.
+ // likely only true in institutional situations, so whatever.
if (KisWindowsPackageUtils::isRunningInPackage()) {
return true;
}
@@ -993,6 +1007,7 @@ bool KisApplication::isStoreApplication()
return false;
}
+#endif
void KisApplication::verifyMetatypeRegistration()
{
diff --git a/libs/ui/KisApplication.h b/libs/ui/KisApplication.h
index 5d8c001fc4..42d4b31493 100644
--- a/libs/ui/KisApplication.h
+++ b/libs/ui/KisApplication.h
@@ -90,8 +90,15 @@ public:
void initializeGlobals(const KisApplicationArguments &args);
void processPostponedSynchronizationEvents();
- /// @return true if Krita has been acquired through an app store
- bool isStoreApplication();
+#ifndef Q_OS_ANDROID
+ /**
+ * Tries to detect if Krita has been bought on a store. The user can
+ * definitely fake this and it's probably also not 100% reliable, but
+ * should be good enough for what we're doing with it. On Android, check
+ * KisAndroidDonations for an in-app purchase instead.
+ */
+ static bool isStoreApplication();
+#endif
static void verifyMetatypeRegistration();
diff --git a/libs/ui/dialogs/KisSplashSourceDialog.cpp b/libs/ui/dialogs/KisSplashSourceDialog.cpp
new file mode 100644
index 0000000000..90aff72a66
--- /dev/null
+++ b/libs/ui/dialogs/KisSplashSourceDialog.cpp
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#include "KisSplashSourceDialog.h"
+#include <QPixmap>
+#include <QPushButton>
+#include <QSignalBlocker>
+#include <kis_signal_compressor.h>
+#ifdef Q_OS_ANDROID
+#include <KisAndroidDonations.h>
+#endif
+
+KisSplashSourceDialog::KisSplashSourceDialog(const QString &key, QWidget *parent)
+ : QDialog(parent)
+ , m_sources(KisSplashScreen::getSources())
+ , m_updatePreviewCompressor(
+ new KisSignalCompressor(100, KisSignalCompressor::POSTPONE, KisSignalCompressor::ADDITIVE_INTERVAL, this))
+{
+ setupUi(this);
+
+#ifdef Q_OS_ANDROID
+ KisAndroidDonations *androidDonations = KisAndroidDonations::instance();
+ if (androidDonations && androidDonations->state() == KisAndroidDonations::State::NoSupport) {
+ m_explanationLabel->setText(
+ QStringLiteral("%1 <a href=\"#\">%2</a>")
+ .arg(i18n("Become a supporter to change the splash screen.").toHtmlEscaped(), i18n("Support Krita")));
+
+ connect(m_explanationLabel, &QLabel::linkActivated, this, &KisSplashSourceDialog::slotShowDonationDialog);
+
+ connect(androidDonations,
+ &KisAndroidDonations::sigStateChanged,
+ this,
+ &KisSplashSourceDialog::slotRefreshSources);
+ } else {
+ m_explanationLabel->setText(
+ i18n("Changing the splash screen is only available for supporters through the Play Store."));
+ }
+#else
+ QString explanationText = i18n("Purchase Krita to change the splash screen and receive automatic updates.");
+
+ QStringList purchaseOptions = {
+ makePurchaseOption(QStringLiteral("steam"), i18n("Get Krita on Steam")),
+#ifdef Q_OS_WINDOWS
+ makePurchaseOption(QStringLiteral("epicgamesstore"), i18n("Get Krita on the Epic Games Store")),
+ makePurchaseOption(QStringLiteral("microsoftstore"), i18n("Get Krita on the Microsoft Store")),
+#endif
+#ifdef Q_OS_MACOS
+ makePurchaseOption(QStringLiteral("appleappstore"), i18n("Get Krita on the App Store")),
+#endif
+ };
+
+ m_explanationLabel->setOpenExternalLinks(true);
+ m_explanationLabel->setText(
+ QStringLiteral("%1<ul>%2</ul>").arg(explanationText.toHtmlEscaped(), purchaseOptions.join(QString())));
+#endif
+
+ connect(m_sourceCombo,
+ QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this,
+ &KisSplashSourceDialog::slotSourceSelected);
+ connect(m_updatePreviewCompressor, &KisSignalCompressor::timeout, this, &KisSplashSourceDialog::slotUpdatePreview);
+ connect(m_buttons, &QDialogButtonBox::accepted, this, &KisSplashSourceDialog::accept);
+ connect(m_buttons, &QDialogButtonBox::rejected, this, &KisSplashSourceDialog::reject);
+
+ initSources(key);
+}
+
+QString KisSplashSourceDialog::selectedKey() const
+{
+ const KisSplashScreen::Source *source = currentSource();
+ if (source && source->isAvailable) {
+ return source->key;
+ } else {
+ return QString();
+ }
+}
+
+void KisSplashSourceDialog::slotSourceSelected()
+{
+ const KisSplashScreen::Source *source = currentSource();
+ m_buttons->button(QDialogButtonBox::Ok)->setEnabled(source && source->isAvailable);
+ m_previewWidget->setPixmap(QPixmap());
+ m_updatePreviewCompressor->start();
+}
+
+void KisSplashSourceDialog::slotUpdatePreview()
+{
+ const KisSplashScreen::Source *source = currentSource();
+ if (source) {
+ QPixmap img(source->resourcePath);
+ m_previewWidget->setPixmap(img);
+ }
+}
+
+void KisSplashSourceDialog::slotRefreshSources()
+{
+ initSources(selectedKey());
+}
+
+#ifdef Q_OS_ANDROID
+void KisSplashSourceDialog::slotShowDonationDialog()
+{
+ KisAndroidDonations::showDonationDialog(false);
+}
+#endif
+
+void KisSplashSourceDialog::initSources(const QString &key)
+{
+ QSignalBlocker blocker(m_sourceCombo);
+ m_explanationLabel->setVisible(!KisSplashScreen::canChooseSplashScreen());
+ m_sources = KisSplashScreen::getSources();
+ m_sourceCombo->clear();
+ for (const KisSplashScreen::Source &source : m_sources) {
+ m_sourceCombo->addItem(source.description());
+ if (key == source.key) {
+ m_sourceCombo->setCurrentIndex(m_sourceCombo->count() - 1);
+ }
+ }
+ slotSourceSelected();
+}
+
+const KisSplashScreen::Source *KisSplashSourceDialog::currentSource() const
+{
+ int index = m_sourceCombo->currentIndex();
+ if (index >= 0 && index < m_sources.size()) {
+ return &m_sources[index];
+ } else {
+ return nullptr;
+ }
+}
+
+QString KisSplashSourceDialog::makePurchaseOption(const QString &key, const QString &text)
+{
+ return QStringLiteral("<li><a href=\"https://krita.org/%1\">%2</a></li>")
+ .arg(key.toHtmlEscaped(), text.toHtmlEscaped());
+}
diff --git a/libs/ui/dialogs/KisSplashSourceDialog.h b/libs/ui/dialogs/KisSplashSourceDialog.h
new file mode 100644
index 0000000000..c38d9fd08e
--- /dev/null
+++ b/libs/ui/dialogs/KisSplashSourceDialog.h
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#ifndef KIS_SPLASH_SOURCE_DIALOG_H
+#define KIS_SPLASH_SOURCE_DIALOG_H
+#include "ui_KisSplashSourceDialog.h"
+#include <QDialog>
+#include <QVector>
+#include <kis_splash_screen.h>
+
+class KisSignalCompressor;
+
+class KisSplashSourceDialog : public QDialog, public Ui::KisSplashSourceDialog
+{
+ Q_OBJECT
+public:
+ explicit KisSplashSourceDialog(const QString &key, QWidget *parent = nullptr);
+
+ QString selectedKey() const;
+
+private Q_SLOTS:
+ void slotSourceSelected();
+ void slotUpdatePreview();
+ void slotRefreshSources();
+#ifdef Q_OS_ANDROID
+ void slotShowDonationDialog();
+#endif
+
+private:
+ void initSources(const QString &key);
+ const KisSplashScreen::Source *currentSource() const;
+
+ static QString makePurchaseOption(const QString &key, const QString &text);
+
+ QVector<KisSplashScreen::Source> m_sources;
+ KisSignalCompressor *m_updatePreviewCompressor;
+};
+
+#endif
diff --git a/libs/ui/dialogs/KisSplashSourceDialog.ui b/libs/ui/dialogs/KisSplashSourceDialog.ui
new file mode 100644
index 0000000000..777064353d
--- /dev/null
+++ b/libs/ui/dialogs/KisSplashSourceDialog.ui
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>KisSplashSourceDialog</class>
+ <widget class="QDialog" name="KisSplashSourceDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>500</width>
+ <height>350</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Change Splash Screen</string>
+ </property>
+ <layout class="QVBoxLayout" name="formLayout">
+ <item>
+ <widget class="QComboBox" name="m_sourceCombo"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="m_explanationLabel">
+ <property name="text">
+ <string>Explanation goes here.</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KisSplashPreview" name="m_previewWidget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="m_buttons">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KisSplashPreview</class>
+ <extends>QWidget</extends>
+ <header location="global">KisSplashPreview.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.cc
index a27073d9ba..9129552e12 100644
--- a/libs/ui/dialogs/kis_dlg_preferences.cc
+++ b/libs/ui/dialogs/kis_dlg_preferences.cc
@@ -86,6 +86,7 @@
#include "KisMainWindow.h"
#include "KisMimeDatabase.h"
#include "kis_file_name_requester.h"
+#include "KisSplashSourceDialog.h"
#include <KisWidgetConnectionUtils.h>
#include <dialogs/KisFrameRateLimitModel.h>
#include <KisPlatformPluginInterfaceFactory.h>
@@ -523,6 +524,10 @@ GeneralTab::GeneralTab(QWidget *_parent, const char *_name)
m_chkConvertOnImport->setChecked(cfg.convertToImageColorspaceOnImport());
+ m_splashScreenImage = cfg.splashScreenImage();
+ slotUpdateCurrentSplashScreenTitle();
+ connect(m_btnChangeSplash, &QPushButton::clicked, this, &GeneralTab::slotChangeSplashScreen);
+
m_undoStackSize->setValue(cfg.undoStackLimit());
chkCumulativeUndo->setChecked(cfg.useCumulativeUndoRedo());
connect(chkCumulativeUndo, SIGNAL(toggled(bool)), btnAdvancedCumulativeUndo, SLOT(setEnabled(bool)));
@@ -811,6 +816,9 @@ void GeneralTab::setDefault()
m_autosaveSpinBox->setValue(cfg.autoSaveInterval(true) / 60);
chkHideAutosaveFiles->setChecked(true);
+ m_splashScreenImage = cfg.splashScreenImage(true);
+ slotUpdateCurrentSplashScreenTitle();
+
m_undoStackSize->setValue(cfg.undoStackLimit(true));
chkCumulativeUndo->setChecked(cfg.useCumulativeUndoRedo(true));
m_cumulativeUndoData = cfg.cumulativeUndoData(true);
@@ -932,6 +940,20 @@ void GeneralTab::colorSamplePreviewOutlineEnabledChanged(int value)
m_lblColorSamplerPreviewSizePreview->setOutlineEnabled(value);
}
+void GeneralTab::slotUpdateCurrentSplashScreenTitle()
+{
+ m_lblCurrentSplash->setText(KisSplashScreen::getAvailableSource(m_splashScreenImage).description());
+}
+
+void GeneralTab::slotChangeSplashScreen()
+{
+ KisSplashSourceDialog dlg(m_splashScreenImage, this);
+ if (dlg.exec() == QDialog::Accepted) {
+ m_splashScreenImage = dlg.selectedKey();
+ slotUpdateCurrentSplashScreenTitle();
+ }
+}
+
void GeneralTab::setButtonGroupEnabled(const QButtonGroup &buttonGroup, bool value)
{
Q_FOREACH(QAbstractButton* button, buttonGroup.buttons()) {
@@ -1028,6 +1050,11 @@ int GeneralTab::autoSaveInterval()
return m_autosaveCheckBox->isChecked() ? m_autosaveSpinBox->value() * 60 : 0;
}
+QString GeneralTab::splashScreenImage() const
+{
+ return m_splashScreenImage;
+}
+
int GeneralTab::undoStackSize()
{
return m_undoStackSize->value();
@@ -3129,6 +3156,7 @@ bool KisDlgPreferences::editPreferences(std::optional<PageDesc>page)
cfg.setSelectionActionBar(m_general->chkEnableSelectionActionBar->isChecked());
cfg.setConvertToImageColorspaceOnImport(m_general->convertToImageColorspaceOnImport());
+ cfg.setSplashScreenImage(m_general->splashScreenImage());
cfg.setUndoStackLimit(m_general->undoStackSize());
cfg.setCumulativeUndoRedo(m_general->chkCumulativeUndo->isChecked());
cfg.setCumulativeUndoData(m_general->m_cumulativeUndoData);
diff --git a/libs/ui/dialogs/kis_dlg_preferences.h b/libs/ui/dialogs/kis_dlg_preferences.h
index b19c89b6d4..65a14bd835 100644
--- a/libs/ui/dialogs/kis_dlg_preferences.h
+++ b/libs/ui/dialogs/kis_dlg_preferences.h
@@ -84,6 +84,7 @@ public:
bool showRootLayer();
int autoSaveInterval();
void setDefault();
+ QString splashScreenImage() const;
int undoStackSize();
bool showOutlineWhilePainting();
bool showEraserOutlineWhilePainting();
@@ -132,11 +133,15 @@ private Q_SLOTS:
void colorSamplePreviewThicknessChanged(qreal value);
void colorSamplePreviewOutlineEnabledChanged(int value);
+ void slotUpdateCurrentSplashScreenTitle();
+ void slotChangeSplashScreen();
+
static void setButtonGroupEnabled(const QButtonGroup& buttonGroup, bool value);
public:
QButtonGroup m_pasteFormatGroup;
KisCumulativeUndoData m_cumulativeUndoData;
+ QString m_splashScreenImage;
};
diff --git a/libs/ui/forms/wdggeneralsettings.ui b/libs/ui/forms/wdggeneralsettings.ui
index d242157e60..6cd1953a64 100644
--- a/libs/ui/forms/wdggeneralsettings.ui
+++ b/libs/ui/forms/wdggeneralsettings.ui
@@ -42,7 +42,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>5</number>
+ <number>0</number>
</property>
<property name="movable">
<bool>false</bool>
@@ -697,7 +697,7 @@
<x>0</x>
<y>0</y>
<width>1669</width>
- <height>781</height>
+ <height>778</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_19">
@@ -1396,7 +1396,7 @@
<x>0</x>
<y>0</y>
<width>1689</width>
- <height>801</height>
+ <height>798</height>
</rect>
</property>
<property name="sizePolicy">
@@ -1443,7 +1443,7 @@
</property>
</widget>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@@ -1459,7 +1459,7 @@
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="KisIntParseSpinBox" name="m_undoStackSize">
<property name="toolTip">
<string>Only applies to new or newly opened images.</string>
@@ -1478,7 +1478,7 @@
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="chkCumulativeUndo">
@@ -1509,14 +1509,14 @@
</item>
</layout>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<widget class="QCheckBox" name="chkShowRootLayer">
<property name="text">
<string>Show root layer</string>
</property>
</widget>
</item>
- <item row="6" column="1">
+ <item row="7" column="1">
<widget class="QCheckBox" name="chkUsageLogging">
<property name="text">
<string>Enable Logging for bug reports</string>
@@ -1526,7 +1526,7 @@
</property>
</widget>
</item>
- <item row="7" column="1">
+ <item row="8" column="1">
<widget class="QFrame" name="frame_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@@ -1583,14 +1583,24 @@
</layout>
</widget>
</item>
- <item row="10" column="0">
+ <item row="10" column="1">
+ <widget class="QCheckBox" name="chkIgnoreHighFunctionKeys">
+ <property name="toolTip">
+ <string>Some applications may emulate presses of function keys with high numbers (e.g. F22) to bring themselves to the foreground. This may break Krita's shortcuts and actions system. If you have a keyboard with F13 or higher function keys, and you wish to use them, try disabling this option, but take this potential problem into account.</string>
+ </property>
+ <property name="text">
+ <string>Ignore high function keys (F13-F24)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="11" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Maximum brush size:</string>
</property>
</widget>
</item>
- <item row="10" column="1">
+ <item row="11" column="1">
<widget class="QFrame" name="frame">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
@@ -1659,7 +1669,7 @@
</layout>
</widget>
</item>
- <item row="11" column="0" colspan="2">
+ <item row="12" column="0" colspan="2">
<widget class="QGroupBox" name="chkForcedFontDPI">
<property name="title">
<string>Font DPI Workaround</string>
@@ -1699,7 +1709,7 @@ To restore the old behavior you can force Krita to use Display DPI for fonts by
</layout>
</widget>
</item>
- <item row="12" column="0" colspan="2">
+ <item row="13" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_51">
<property name="title">
<string>Automatic layer naming</string>
@@ -1729,14 +1739,14 @@ To restore the old behavior you can force Krita to use Display DPI for fonts by
</layout>
</widget>
</item>
- <item row="13" column="0" colspan="2">
+ <item row="14" column="0" colspan="2">
<widget class="QCheckBox" name="chkEnableLongPress">
<property name="text">
<string>Long-press to open context menus</string>
</property>
</widget>
</item>
- <item row="14" column="0" colspan="2">
+ <item row="15" column="0" colspan="2">
<widget class="QGroupBox" name="m_groupBoxKineticScrollingSettings">
<property name="title">
<string>Kinetic Scrolling (needs restart)</string>
@@ -1815,7 +1825,7 @@ To restore the old behavior you can force Krita to use Display DPI for fonts by
</layout>
</widget>
</item>
- <item row="15" column="0" colspan="2">
+ <item row="16" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -1828,13 +1838,44 @@ To restore the old behavior you can force Krita to use Display DPI for fonts by
</property>
</spacer>
</item>
- <item row="9" column="1">
- <widget class="QCheckBox" name="chkIgnoreHighFunctionKeys">
- <property name="toolTip">
- <string>Some applications may emulate presses of function keys with high numbers (e.g. F22) to bring themselves to the foreground. This may break Krita's shortcuts and actions system. If you have a keyboard with F13 or higher function keys, and you wish to use them, try disabling this option, but take this potential problem into account.</string>
- </property>
+ <item row="3" column="1">
+ <layout class="QHBoxLayout" name="m_lytSplash">
+ <item>
+ <widget class="QLabel" name="m_lblCurrentSplash">
+ <property name="text">
+ <string notr="true">splash image title goes here</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_btnChangeSplash">
+ <property name="text">
+ <string>Change…</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="m_spcSplash">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="m_lblSplashTitle">
<property name="text">
- <string>Ignore high function keys (F13-F24)</string>
+ <string>Splash screen:</string>
</property>
</widget>
</item>
diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.cc
index e6d2ef3a0e..7f949c7a89 100644
--- a/libs/ui/kis_config.cc
+++ b/libs/ui/kis_config.cc
@@ -1816,6 +1816,20 @@ void KisConfig::setFirstRun(const bool first) const
m_cfg.writeEntry("firstRun", first);
}
+QString KisConfig::splashScreenImage(bool defaultValue) const
+{
+ if (defaultValue) {
+ return QString();
+ } else {
+ return m_cfg.readEntry(QStringLiteral("splashScreenImage"), QString());
+ }
+}
+
+void KisConfig::setSplashScreenImage(const QString &value)
+{
+ m_cfg.writeEntry(QStringLiteral("splashScreenImage"), value);
+}
+
int KisConfig::horizontalSplitLines(bool defaultValue) const
{
return (defaultValue ? 1 : m_cfg.readEntry("horizontalSplitLines", 1));
diff --git a/libs/ui/kis_config.h b/libs/ui/kis_config.h
index 3587fd89c5..5cb41b24c8 100644
--- a/libs/ui/kis_config.h
+++ b/libs/ui/kis_config.h
@@ -483,6 +483,9 @@ public:
bool firstRun(bool defaultValue = false) const;
void setFirstRun(const bool firstRun) const;
+ QString splashScreenImage(bool defaultValue = false) const;
+ void setSplashScreenImage(const QString &value);
+
bool clicklessSpacePan(bool defaultValue = false) const;
void setClicklessSpacePan(const bool toggle) const;
diff --git a/libs/ui/kis_splash_screen.cpp b/libs/ui/kis_splash_screen.cpp
index 4065915614..1c897ea03b 100644
--- a/libs/ui/kis_splash_screen.cpp
+++ b/libs/ui/kis_splash_screen.cpp
@@ -14,7 +14,6 @@
#include <QCheckBox>
#include <kis_debug.h>
#include <QFile>
-#include <QScreen>
#include <QWindow>
#include <QSvgWidget>
#include <QVBoxLayout>
@@ -24,11 +23,13 @@
#include <KisApplication.h>
#include <kis_icon.h>
+#include <kis_config.h>
#include <klocalizedstring.h>
-#include <kconfig.h>
-#include <ksharedconfig.h>
-#include <kconfiggroup.h>
+
+#ifdef Q_OS_ANDROID
+#include <KisAndroidDonations.h>
+#endif
static void addDropShadow(QWidget *widget)
{
@@ -39,6 +40,35 @@ static void addDropShadow(QWidget *widget)
widget->setGraphicsEffect(effect);
}
+QString KisSplashScreen::Source::description() const
+{
+ QString text;
+ if (artistName.isEmpty()) {
+ text = title;
+ } else {
+ text = i18nc("Splash image by artist", "%1 by %2", title, artistName);
+ }
+
+ if (isAvailable) {
+ if (isDefault) {
+ return i18nc("Splash image default", "%1 (default)", text);
+ } else {
+ return text;
+ }
+ } else {
+ return i18nc("Splash image unavailable", "%1 (not available)", text);
+ }
+}
+
+QString KisSplashScreen::Source::artistCredit() const
+{
+ if (artistName.isEmpty()) {
+ return QString();
+ } else {
+ return i18nc("splash image credit", "Artwork by: %1", artistName);
+ }
+}
+
KisSplashScreen::KisSplashScreen(int height, QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
, m_versionHtml(qApp->applicationVersion().toHtmlEscaped())
@@ -85,7 +115,7 @@ void KisSplashScreen::updateSplashImage(const int height)
const int marginTop = height * 0.05;
const int marginRight = height * 0.1;
- Source source = getImageSource();
+ Source source = getCurrentSource();
QPixmap img(source.resourcePath);
if (img.isNull() || img.height() == 0) return;
@@ -114,7 +144,7 @@ void KisSplashScreen::updateSplashImage(const int height)
m_loadingTextLabel->setFixedWidth(m_bannerSvg->geometry().right() - marginRight);
// Place credits text on bottom right with similar margins.
- m_artCreditsLabel->setText(source.artistCredit);
+ m_artCreditsLabel->setText(source.artistCredit());
m_artCreditsLabel->setFixedWidth(m_loadingTextLabel->width());
m_artCreditsLabel->setFixedHeight(20);
m_artCreditsLabel->move(m_loadingTextLabel->x(), height - marginTop - m_artCreditsLabel->height());
@@ -129,32 +159,74 @@ void KisSplashScreen::setLoadingText(QString text)
m_loadingTextLabel->setText(htmlText);
}
-KisSplashScreen::Source KisSplashScreen::getImageSource()
+KisSplashScreen::Source KisSplashScreen::getCurrentSource()
+{
+ return getAvailableSource(KisConfig(true).splashScreenImage());
+}
+
+KisSplashScreen::Source KisSplashScreen::getAvailableSource(const QString &key)
+{
+ QVector<Source> sources = getSources();
+ for (const Source &source : sources) {
+ if (source.isAvailable && source.key == key) {
+ return source;
+ }
+ }
+ return sources[0];
+}
+
+bool KisSplashScreen::canChooseSplashScreen()
+{
+ // The "professional" splash screen is available on purchased versions of
+ // Krita, since professionals can pay for their tools. On Android, we'll
+ // err on the side of allowing changing the splash screen unless we have
+ // evidence to the contrary, otherwise a bad internet connection could
+ // show the user the wrong splash screen. KisAndroidDonations will reset
+ // the splash screen setting if it sees the user is not a supporter.
+#ifdef Q_OS_ANDROID
+ KisAndroidDonations *donations = KisAndroidDonations::instance();
+ return !donations || donations->isMaybeSupporter();
+#else
+ return KisApplication::isStoreApplication();
+#endif
+}
+
+QVector<KisSplashScreen::Source> KisSplashScreen::getSources()
+{
+ bool canChoose = canChooseSplashScreen();
+ return {
+ // First entry is used as the default.
+ {
+ QString(),
+ i18nc("Normal splash artwork title, consider leaving it English", "Electric Hearts"),
+ defaultSplashResourcePath(),
+ i18nc("Normal splash artist name", "Tyson Tan"),
+ true,
+ true,
+ },
+ {
+ QStringLiteral("corpo1"),
+ i18n("Professional"),
+ QStringLiteral(":/splash/corpo1.jpg"),
+ QString(),
+ canChoose,
+ false,
+ },
+ };
+}
+
+QString KisSplashScreen::defaultSplashResourcePath()
{
- QString artistCredit = i18nc("Normal splash artist name", "Tyson Tan");
// Loading the ginormous 4K PNG splash image increases the startup time on
// Android by several seconds and at the same time looks really bad when
// scaled down to a dinky size. Instead of overengineering this into an
// Enterprise Splash Screen Solution where we choose the image based on
// screen size or something, we'll just use a HD JPEG instead. It's fine.
#ifdef Q_OS_ANDROID
- QString resourcePath = QStringLiteral(":/splash/hd.jpg");
+ return QStringLiteral(":/splash/hd.jpg");
#else
- QString resourcePath = QStringLiteral(":/splash/0.png");
- // TODO: Re-add the holiday splash...
-#if 0
- QDate currentDate = QDate::currentDate();
- if (currentDate > QDate(currentDate.year(), 12, 4) ||
- currentDate < QDate(currentDate.year(), 1, 9)) {
- resourcePath = QStringLiteral(":/splash/1.png");
- artistCredit = QStringLiteral("???")};
- }
+ return QStringLiteral(":/splash/0.png");
#endif
-#endif
- if (!artistCredit.isEmpty()) {
- artistCredit = i18nc("splash image credit", "Artwork by: %1", artistCredit);
- }
- return Source{resourcePath, artistCredit};
}
void KisSplashScreen::repaint()
diff --git a/libs/ui/kis_splash_screen.h b/libs/ui/kis_splash_screen.h
index 8a26cff1b7..60260e7adb 100644
--- a/libs/ui/kis_splash_screen.h
+++ b/libs/ui/kis_splash_screen.h
@@ -9,6 +9,7 @@
#include <QWidget>
#include <QTimer>
+#include <QVector>
class QPixmap;
class QSvgWidget;
@@ -21,8 +22,15 @@ class KRITAUI_EXPORT KisSplashScreen : public QWidget
Q_OBJECT
public:
struct Source {
+ QString key;
+ QString title;
QString resourcePath;
- QString artistCredit;
+ QString artistName;
+ bool isAvailable;
+ bool isDefault;
+
+ QString description() const;
+ QString artistCredit() const;
};
explicit KisSplashScreen(int height, QWidget *parent = 0,
@@ -34,12 +42,15 @@ public:
void setLoadingText(QString text);
- static Source getImageSource();
+ static Source getCurrentSource();
+ static Source getAvailableSource(const QString &key);
+ static bool canChooseSplashScreen();
+ static QVector<Source> getSources();
private:
void updateSplashImage(const int height);
-private:
+ static QString defaultSplashResourcePath();
QTimer m_timer;
bool m_displayLinks { false };
diff --git a/libs/ui/widgets/KisSplashPreview.cpp b/libs/ui/widgets/KisSplashPreview.cpp
new file mode 100644
index 0000000000..4a83909f73
--- /dev/null
+++ b/libs/ui/widgets/KisSplashPreview.cpp
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#include "KisSplashPreview.h"
+#include <QPainter>
+
+KisSplashPreview::KisSplashPreview(QWidget *parent)
+ : QWidget(parent)
+{
+}
+
+void KisSplashPreview::setPixmap(const QPixmap &pixmap)
+{
+ if (pixmap.cacheKey() != m_originalPixmap.cacheKey()) {
+ m_originalPixmap = pixmap;
+ m_scaledPixmap = QPixmap();
+ update();
+ }
+}
+
+void KisSplashPreview::paintEvent(QPaintEvent *event)
+{
+ QWidget::paintEvent(event);
+
+ if (!m_originalPixmap.isNull()) {
+ qreal dpr = qMax(1.0, devicePixelRatioF());
+ int w = width();
+ int h = height();
+
+ if (m_scaledPixmap.isNull()) {
+ m_scaledPixmap = m_originalPixmap.scaled(qRound(qreal(w) * dpr),
+ qRound(qreal(h) * dpr),
+ Qt::KeepAspectRatio,
+ Qt::SmoothTransformation);
+ }
+
+ int pw = qRound(qreal(m_scaledPixmap.width()) / dpr);
+ int ph = qRound(qreal(m_scaledPixmap.height()) / dpr);
+ int x = (w - pw) / 2;
+ int y = (h - ph) / 2;
+
+ QPainter painter(this);
+ painter.drawPixmap(QRect(x, y, pw, ph), m_scaledPixmap);
+ }
+}
+
+void KisSplashPreview::resizeEvent(QResizeEvent *event)
+{
+ QWidget::resizeEvent(event);
+ m_scaledPixmap = QPixmap();
+}
diff --git a/libs/ui/widgets/KisSplashPreview.h b/libs/ui/widgets/KisSplashPreview.h
new file mode 100644
index 0000000000..cc30898a07
--- /dev/null
+++ b/libs/ui/widgets/KisSplashPreview.h
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#ifndef KIS_SPLASH_PREVIEW_H
+#define KIS_SPLASH_PREVIEW_H
+#include <QPixmap>
+#include <QWidget>
+
+class KisSplashPreview : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit KisSplashPreview(QWidget *parent = nullptr);
+
+ void setPixmap(const QPixmap &pixmap);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+
+private:
+ QPixmap m_originalPixmap;
+ QPixmap m_scaledPixmap;
+};
+
+#endif