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

A widget for displaying if no documents are open. This will display in the MDI area. More...

#include <KisWelcomePageWidget.h>

+ Inheritance diagram for KisWelcomePageWidget:

Public Slots

void showDropAreaIndicator (bool show)
 
void slotUpdateThemeColors ()
 

Public Member Functions

 KisWelcomePageWidget (QWidget *parent)
 
void setMainWindow (KisMainWindow *m_mainWindow)
 
 ~KisWelcomePageWidget () override
 

Protected Member Functions

void changeEvent (QEvent *event) override
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dragMoveEvent (QDragMoveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
bool eventFilter (QObject *watched, QEvent *event) override
 

Private Slots

bool isDevelopmentBuild ()
 
QFont largerFont ()
 
void newsStateChanged (bool hasNews)
 
void recentDocumentClicked (QModelIndex index)
 
void recentFilesResized ()
 
void slotCheckNews ()
 
void slotNewFileClicked ()
 
void slotOpenFileClicked ()
 
void slotPaste ()
 
void slotRecentDocContextMenuRequest (const QPoint &pos)
 
void slotRecentFilesModelIsUpToDate ()
 
void slotScrollerStateChanged (QScroller::State state)
 
void slotSetNewsEnabled (bool newsEnabled)
 

Private Member Functions

void setupNewsLangSelection (QMenu *newsOptionMenu)
 
void showDevVersionHighlight ()
 

Static Private Member Functions

static void updateShortcutLink (QToolButton *button, QLabel *label, QAction *action)
 

Private Attributes

const QString analyticsString = "pk_campaign=startup-sceen&pk_kwd="
 
QColor backgroundColor
 
QColor blendedColor
 
QString blendedStyle
 
QAction * m_enableNewsAction
 
KisMainWindow * m_mainWindow {nullptr}
 
QScopedPointer< RecentItemDelegate > recentItemDelegate
 
QColor textColor
 

Detailed Description

A widget for displaying if no documents are open. This will display in the MDI area.

Definition at line 27 of file KisWelcomePageWidget.h.

Constructor & Destructor Documentation

◆ KisWelcomePageWidget()

KisWelcomePageWidget::KisWelcomePageWidget ( QWidget * parent)
explicit

Definition at line 116 of file KisWelcomePageWidget.cpp.

117 : QWidget(parent)
118{
119 setupUi(this);
120
121 // URLs that go to web browser...
122 devBuildIcon->setIcon(KisIconUtils::loadIcon("warning"));
123 devBuildLabel->setVisible(false);
124 updaterFrame->setVisible(false);
125 versionNotificationLabel->setVisible(false);
126 bnVersionUpdate->setVisible(false);
127 bnErrorDetails->setVisible(false);
128
129 // Recent docs...
130 recentDocumentsListView->setDragEnabled(false);
131 recentDocumentsListView->viewport()->setAutoFillBackground(false);
132 recentDocumentsListView->setSpacing(2);
133 recentDocumentsListView->installEventFilter(this);
134 recentDocumentsListView->setViewMode(QListView::IconMode);
135 recentDocumentsListView->setSelectionMode(QAbstractItemView::NoSelection);
136 recentDocumentsListView->setVerticalScrollMode(QListView::ScrollPerPixel);
137 recentDocumentsListView->verticalScrollBar()->setSingleStep(50);
138 {
139 QScroller* scroller = KisKineticScroller::createPreconfiguredScroller(recentDocumentsListView);
140 if (scroller) {
141 connect(scroller, SIGNAL(stateChanged(QScroller::State)), this, SLOT(slotScrollerStateChanged(QScroller::State)));
142 }
143 }
144 recentDocumentsListView->setContextMenuPolicy(Qt::CustomContextMenu);
145 connect(recentDocumentsListView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotRecentDocContextMenuRequest(QPoint)));
147
148 // News widget...
149 QMenu *newsOptionsMenu = new QMenu(this);
150 newsOptionsMenu->setToolTipsVisible(true);
151 m_enableNewsAction = newsOptionsMenu->addAction(i18n("Automatically check for updates"));
152 m_enableNewsAction->setToolTip(i18n("Show news about Krita: this needs internet to retrieve information from the krita.org website"));
153 m_enableNewsAction->setCheckable(true);
154
155 newsOptionsMenu->addSection(i18n("Language"));
156 QAction *newsInfoAction = newsOptionsMenu->addAction(i18n("English news is always up to date."));
157 newsInfoAction->setEnabled(false);
158
159 setupNewsLangSelection(newsOptionsMenu);
160 btnNewsOptions->setMenu(newsOptionsMenu);
161
162 checkNowButton->setIcon(KisIconUtils::loadIcon(QStringLiteral("view-refresh")));
163
164 labelSupportText->setFont(largerFont());
165
166 connect(btnDismisAll, SIGNAL(clicked()), newsWidget, SLOT(dismissAll()));
167 connect(newsWidget, SIGNAL(newsStateChanged(bool)), this, SLOT(newsStateChanged(bool)));
168 newsStateChanged(false);
169
170 connect(m_enableNewsAction, SIGNAL(triggered(bool)), this, SLOT(slotSetNewsEnabled(bool)));
171 connect(enableNewsBox, SIGNAL(clicked(bool)), this, SLOT(slotSetNewsEnabled(bool)));
172 connect(checkNowButton, SIGNAL(clicked()), this, SLOT(slotCheckNews()));
173
174 supporterBadge->hide();
175 wdgAndroidSupportBanner->hide();
176#ifdef Q_OS_ANDROID
177 initDonations();
178#endif
179
180 // We want to enable updates by default, but allow the user the chance to
181 // disable them before making a network connection when they see the option
182 // the first time.
183 bool newsCheckEnabled, newsFirstStartup;
184 {
185 KisConfig cfg(false);
186 newsCheckEnabled = cfg.newsCheckEnabled();
187 newsFirstStartup = cfg.newsFirstStartup();
188 cfg.setNewsFirstStartup(false);
189 }
190
191 m_enableNewsAction->setChecked(newsCheckEnabled);
192 enableNewsBox->setChecked(newsCheckEnabled);
193
194#ifdef ENABLE_UPDATERS
195#ifndef Q_OS_ANDROID
196 // Setup version updater, but do not check for them, unless the user explicitly
197 // wants to check for updates.
198 // * No updater is created for Linux/Steam, Windows/Steam and Windows/Store distributions,
199 // as those stores have their own updating mechanism.
200 // * STEAMAPPID(Windows)/SteamAppId(Linux) environment variable is set when Krita is run from Steam.
201 // The environment variables are not public API.
202 // * MS Store version runs as a package (though we cannot know if it was
203 // installed from the Store or manually with the .msix package)
204#if defined Q_OS_LINUX
205 if (!qEnvironmentVariableIsSet("SteamAppId")) { // do not create updater for linux/steam
206 if (qEnvironmentVariableIsSet("APPIMAGE")) {
207 m_versionUpdater.reset(new KisAppimageUpdater());
208 }
209 // Fall back to the manual updater if the AppImage one doesn't work.
210 if (m_versionUpdater.isNull() || !m_versionUpdater->hasUpdateCapability()) {
211 m_versionUpdater.reset(new KisManualUpdater());
212 }
213 }
214#elif defined Q_OS_WIN
215 if (!KisWindowsPackageUtils::isRunningInPackage() && !qEnvironmentVariableIsSet("STEAMAPPID")) {
216 m_versionUpdater.reset(new KisManualUpdater());
217 KisUsageLogger::log("Non-store package - creating updater");
218 } else {
219 KisUsageLogger::log("detected appx or steam package - not creating the updater");
220 }
221#else
222 // always create updater for MacOS
223 m_versionUpdater.reset(new KisManualUpdater());
224#endif // Q_OS_*
225 if (!m_versionUpdater.isNull()) {
226 connect(bnVersionUpdate, SIGNAL(clicked()), this, SLOT(slotRunVersionUpdate()));
227 connect(bnErrorDetails, SIGNAL(clicked()), this, SLOT(slotShowUpdaterErrorDetails()));
228 connect(m_versionUpdater.data(), SIGNAL(sigUpdateCheckStateChange(KisUpdaterStatus)),
229 this, SLOT(slotSetUpdateStatus(const KisUpdaterStatus&)));
230 }
231#endif // ifndef Q_OS_ANDROID
232#endif // ENABLE_UPDATERS
233
234 if (newsCheckEnabled && !newsFirstStartup) {
236 } else {
237 newsWidget->hide();
238 }
239
240 // Drop area..
241 setAcceptDrops(true);
242}
static void log(const QString &message)
Logs with date/time.
void slotSetNewsEnabled(bool newsEnabled)
void setupNewsLangSelection(QMenu *newsOptionMenu)
void slotScrollerStateChanged(QScroller::State state)
void newsStateChanged(bool hasNews)
void slotRecentDocContextMenuRequest(const QPoint &pos)
QIcon loadIcon(const QString &name)
KRITAWIDGETUTILS_EXPORT QScroller * createPreconfiguredScroller(QAbstractScrollArea *target)

References KisKineticScroller::createPreconfiguredScroller(), KisWindowsPackageUtils::isRunningInPackage(), largerFont(), KisIconUtils::loadIcon(), KisUsageLogger::log(), m_enableNewsAction, KisConfig::newsCheckEnabled(), KisConfig::newsFirstStartup(), newsStateChanged(), recentFilesResized(), KisConfig::setNewsFirstStartup(), setupNewsLangSelection(), slotCheckNews(), slotRecentDocContextMenuRequest(), slotScrollerStateChanged(), and slotSetNewsEnabled().

◆ ~KisWelcomePageWidget()

KisWelcomePageWidget::~KisWelcomePageWidget ( )
override

Definition at line 244 of file KisWelcomePageWidget.cpp.

245{
246}

Member Function Documentation

◆ changeEvent()

void KisWelcomePageWidget::changeEvent ( QEvent * event)
overrideprotected

Definition at line 460 of file KisWelcomePageWidget.cpp.

461{
462 if (event->type() == QEvent::FontChange) {
463 labelSupportText->setFont(largerFont());
464 }
465}

References largerFont().

◆ dragEnterEvent()

void KisWelcomePageWidget::dragEnterEvent ( QDragEnterEvent * event)
overrideprotected

Definition at line 398 of file KisWelcomePageWidget.cpp.

399{
401 if (event->mimeData()->hasUrls() ||
402 event->mimeData()->hasFormat("application/x-krita-node-internal-pointer") ||
403 event->mimeData()->hasFormat("application/x-qt-image")) {
404 return event->accept();
405 }
406
407 return event->ignore();
408}
void showDropAreaIndicator(bool show)

References showDropAreaIndicator().

◆ dragLeaveEvent()

void KisWelcomePageWidget::dragLeaveEvent ( QDragLeaveEvent * event)
overrideprotected

◆ dragMoveEvent()

void KisWelcomePageWidget::dragMoveEvent ( QDragMoveEvent * event)
overrideprotected

Definition at line 441 of file KisWelcomePageWidget.cpp.

442{
444
445 if (event->mimeData()->hasUrls() ||
446 event->mimeData()->hasFormat("application/x-krita-node-internal-pointer") ||
447 event->mimeData()->hasFormat("application/x-qt-image")) {
448 return event->accept();
449 }
450
451 return event->ignore();
452}
void dragMoveEvent(QDragMoveEvent *event) override

References KisMainWindow::dragMoveEvent(), and m_mainWindow.

◆ dropEvent()

void KisWelcomePageWidget::dropEvent ( QDropEvent * event)
overrideprotected

Definition at line 410 of file KisWelcomePageWidget.cpp.

411{
413
414 if (event->mimeData()->hasUrls() && !event->mimeData()->urls().empty()) {
415 Q_FOREACH (const QUrl &url, event->mimeData()->urls()) {
416 if (url.toLocalFile().endsWith(".bundle", Qt::CaseInsensitive)) {
417 bool r = m_mainWindow->installBundle(url.toLocalFile());
418 if (!r) {
419 qWarning() << "Could not install bundle" << url.toLocalFile();
420 }
421 } else if (!url.isLocalFile()) {
422 QScopedPointer<QTemporaryFile> tmp(new QTemporaryFile());
423 tmp->setFileName(url.fileName());
424
425 KisRemoteFileFetcher fetcher;
426
427 if (!fetcher.fetchFile(url, tmp.data())) {
428 qWarning() << "Fetching" << url << "failed";
429 continue;
430 }
431 const auto localUrl = QUrl::fromLocalFile(tmp->fileName());
432
433 m_mainWindow->openDocument(localUrl.toLocalFile(), KisMainWindow::None);
434 } else {
436 }
437 }
438 }
439}
bool installBundle(const QString &fileName) const
Copy the given file into the bundle directory.
bool openDocument(const QString &path, OpenFlags flags)
The KisRemoteFileFetcher class can fetch a remote file and blocks until the file is downloaded.
bool fetchFile(const QUrl &remote, QIODevice *io)
fetch the image. Shows a progress dialog

References KisRemoteFileFetcher::fetchFile(), KisMainWindow::installBundle(), m_mainWindow, KisMainWindow::None, KisMainWindow::openDocument(), and showDropAreaIndicator().

◆ eventFilter()

bool KisWelcomePageWidget::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

Definition at line 467 of file KisWelcomePageWidget.cpp.

468{
469 if (watched == recentDocumentsListView && event->type() == QEvent::Leave) {
470 recentDocumentsListView->clearSelection();
471 }else if (watched == recentDocumentsListView && event->type() == QEvent::Resize) {
473 }
474 return QWidget::eventFilter(watched, event);
475}

References recentFilesResized().

◆ isDevelopmentBuild

bool KisWelcomePageWidget::isDevelopmentBuild ( )
privateslot

Definition at line 645 of file KisWelcomePageWidget.cpp.

646{
648}
KRITAVERSION_EXPORT bool isDevelopersBuild()

References KritaVersionWrapper::isDevelopersBuild().

◆ largerFont

QFont KisWelcomePageWidget::largerFont ( )
privateslot

Definition at line 999 of file KisWelcomePageWidget.cpp.

1000{
1001 QFont larger = font();
1002 // Font size may be in pixels (on Android) or points (everywhere else.)
1003 qreal ratio = 1.1;
1004 if (larger.pixelSize() == -1) {
1005 larger.setPointSizeF(larger.pointSizeF() * ratio);
1006 } else {
1007 larger.setPixelSize(qRound(larger.pixelSize() * ratio));
1008 }
1009 return larger;
1010}

◆ newsStateChanged

void KisWelcomePageWidget::newsStateChanged ( bool hasNews)
privateslot

Definition at line 1026 of file KisWelcomePageWidget.cpp.

1027{
1028 btnDismisAll->setVisible(hasNews);
1029 notifyIcon->setVisible(hasNews);
1030
1031
1032 //colapse or expand notifyIcon and btnDismisAll
1033
1034 QSizePolicy sizePolicy = notifyIcon->sizePolicy();
1035 if (hasNews) {
1036 sizePolicy.setHorizontalPolicy(QSizePolicy::Preferred);
1037 } else {
1038 sizePolicy.setHorizontalPolicy(QSizePolicy::Ignored);
1039 }
1040 notifyIcon->setSizePolicy(sizePolicy);
1041
1042 //notifyIcon and btnDismisAll should both have the same size policy
1043 btnDismisAll->setSizePolicy(sizePolicy);
1044}

◆ recentDocumentClicked

void KisWelcomePageWidget::recentDocumentClicked ( QModelIndex index)
privateslot

Definition at line 623 of file KisWelcomePageWidget.cpp.

624{
625 QString fileUrl = index.data(Qt::ToolTipRole).toString();
627}

References m_mainWindow, KisMainWindow::None, and KisMainWindow::openDocument().

◆ recentFilesResized

void KisWelcomePageWidget::recentFilesResized ( )
privateslot

Definition at line 1012 of file KisWelcomePageWidget.cpp.

1013{
1014 int scrollSize = qApp->style()->pixelMetric(QStyle::PM_SliderThickness);
1015 int spacing = 8;
1016
1018
1019 int currentSize = recentDocumentsListView->size().width()-scrollSize-2;
1020 int iconAmount = floor(currentSize/iconLength);
1021 int length = floor(currentSize / iconAmount)-spacing;
1022
1023 recentDocumentsListView->setIconSize(QSize(length,length));
1024}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
static constexpr const int DEFALT_ICON_SIZE_LENGTH

References KisRecentDocumentsModelWrapper::DEFALT_ICON_SIZE_LENGTH, and length().

◆ setMainWindow()

void KisWelcomePageWidget::setMainWindow ( KisMainWindow * m_mainWindow)

Definition at line 248 of file KisWelcomePageWidget.cpp.

249{
250 if (mainWin) {
251 m_mainWindow = mainWin;
252
253 // set the shortcut links from actions (only if a shortcut exists)
254 KisActionManager *actionManager = mainWin->viewManager()->actionManager();
255 updateShortcutLink(newFileLink, newFileLinkShortcut, actionManager->actionByName(QStringLiteral("file_new")));
256 updateShortcutLink(openFileLink, openFileShortcut, actionManager->actionByName(QStringLiteral("file_open")));
257 connect(recentDocumentsListView, SIGNAL(clicked(QModelIndex)), this, SLOT(recentDocumentClicked(QModelIndex)));
258 // we need the view manager to actually call actions, so don't create the connections
259 // until after the view manager is set
260 connect(newFileLink, SIGNAL(clicked(bool)), this, SLOT(slotNewFileClicked()));
261 connect(openFileLink, SIGNAL(clicked(bool)), this, SLOT(slotOpenFileClicked()));
262 connect(clearRecentFilesLink, SIGNAL(clicked(bool)), mainWin, SLOT(clearRecentFiles()));
263
264 KisAction *pasteAction = mainWin->viewManager()->actionManager()->actionByName("edit_paste");
265 connect(pasteAction, SIGNAL(triggered()), this, SLOT(slotPaste()));
266
268
269 // allows RSS news items to apply analytics tracking.
270 Q_EMIT newsWidget->setAnalyticsTracking("?" + analyticsString);
271
273 connect(recentFilesModel, SIGNAL(sigModelIsUpToDate()), this, SLOT(slotRecentFilesModelIsUpToDate()));
274 recentDocumentsListView->setModel(&recentFilesModel->model());
276 }
277}
A KisActionManager class keeps track of KisActions. These actions are always associated with the GUI....
KisAction * actionByName(const QString &name) const
KisViewManager * viewManager
KisActionManager * actionManager
static KisRecentDocumentsModelWrapper * instance()
KisActionManager * actionManager() const
void recentDocumentClicked(QModelIndex index)
static void updateShortcutLink(QToolButton *button, QLabel *label, QAction *action)

References KisActionManager::actionByName(), KisViewManager::actionManager(), analyticsString, KisRecentDocumentsModelWrapper::instance(), m_mainWindow, KisRecentDocumentsModelWrapper::model(), recentDocumentClicked(), slotNewFileClicked(), slotOpenFileClicked(), slotPaste(), slotRecentFilesModelIsUpToDate(), slotUpdateThemeColors(), updateShortcutLink(), and KisMainWindow::viewManager.

◆ setupNewsLangSelection()

void KisWelcomePageWidget::setupNewsLangSelection ( QMenu * newsOptionMenu)
private

Definition at line 504 of file KisWelcomePageWidget.cpp.

505{
506 // Hard-coded news language data:
507 // These are languages in which the news items should be regularly
508 // translated into as of 04-09-2024.
509 // The language display names should not be translated. This reflects
510 // the language selection box on the Krita website.
511 struct Lang {
512 const QString siteCode;
513 const QString name;
514 };
515 static const std::array<Lang, 22> newsLangs = {{
516 {QString("en"), QStringLiteral("English")},
517 {QString("ja"), QStringLiteral("日本語")},
518 {QString("zh-cn"), QStringLiteral("中文 (简体)")},
519 {QString("zh-tw"), QStringLiteral("中文 (台灣正體)")},
520 {QString("zh-hk"), QStringLiteral("廣東話 (香港)")},
521 {QString("ca"), QStringLiteral("Català")},
522 {QString("ca@valencia"), QStringLiteral("Català de Valencia")},
523 {QString("cs"), QStringLiteral("Čeština")},
524 {QString("de"), QStringLiteral("Deutsch")},
525 {QString("eo"), QStringLiteral("Esperanto")},
526 {QString("es"), QStringLiteral("Español")},
527 {QString("eu"), QStringLiteral("Euskara")},
528 {QString("fr"), QStringLiteral("Français")},
529 {QString("it"), QStringLiteral("Italiano")},
530 {QString("lt"), QStringLiteral("lietuvių")},
531 {QString("nl"), QStringLiteral("Nederlands")},
532 {QString("pt"), QStringLiteral("Português")},
533 {QString("sk"), QStringLiteral("Slovenský")},
534 {QString("sl"), QStringLiteral("Slovenski")},
535 {QString("sv"), QStringLiteral("Svenska")},
536 {QString("tr"), QStringLiteral("Türkçe")},
537 {QString("uk"), QStringLiteral("Українська")}
538 }};
539
540 static const QString newsLangConfigName = QStringLiteral("FetchNewsLanguages");
541
542 QSharedPointer<QSet<QString>> enabledNewsLangs = QSharedPointer<QSet<QString>>::create();
543 {
544 // Initialize with the config.
545 KisConfig cfg(true);
546 auto languagesList = cfg.readList<QString>(newsLangConfigName);
547 *enabledNewsLangs = QSet(languagesList.begin(), languagesList.end());
548 }
549
550 // If no languages are selected in the config, use the automatic selection.
551 if (enabledNewsLangs->isEmpty()) {
552 enabledNewsLangs->insert(QString(getAutoNewsLang()));
553 }
554
555 for (const auto &lang : newsLangs) {
556 QAction *langItem = newsOptionsMenu->addAction(lang.name);
557 langItem->setCheckable(true);
558 // We can copy `code` into the lambda because its backing string is a
559 // static string literal.
560 const QString code = lang.siteCode;
561 connect(langItem, &QAction::toggled, newsWidget, [=](bool checked) {
562 newsWidget->toggleNewsLanguage(code, checked);
563 });
564
565 // Set the initial checked state.
566 if (enabledNewsLangs->contains(code)) {
567 langItem->setChecked(true);
568 }
569
570 // Connect this lambda after setting the initial checked state because
571 // we don't want to overwrite the config when doing the initial setup.
572 connect(langItem, &QAction::toggled, qApp, [=](bool checked) {
573 KisConfig cfg(false);
574 // It is safe to modify `enabledNewsLangs` here, because the slots
575 // are called synchronously on the UI thread so there is no need
576 // for explicit synchronization.
577 if (checked) {
578 enabledNewsLangs->insert(QString(code));
579 } else {
580 enabledNewsLangs->remove(QString(code));
581 }
582 cfg.writeList(newsLangConfigName, enabledNewsLangs->values());
583 });
584 }
585}
const char * name(StandardAction id)

References KisConfig::readList(), and KisConfig::writeList().

◆ showDevVersionHighlight()

void KisWelcomePageWidget::showDevVersionHighlight ( )
private

Definition at line 587 of file KisWelcomePageWidget.cpp.

588{
589 // always flag development version
590 if (isDevelopmentBuild()) {
591 QString devBuildLabelText = QString("<a style=\"color: " +
592 blendedColor.name() +
593 " \" href=\"https://docs.krita.org/en/untranslatable_pages/triaging_bugs.html?"
594 + analyticsString + "dev-build" + "\">")
595 .append(i18n("DEV BUILD")).append("</a>");
596
597 devBuildLabel->setText(devBuildLabelText);
598 devBuildIcon->setVisible(true);
599 devBuildLabel->setVisible(true);
600 } else {
601 devBuildIcon->setVisible(false);
602 devBuildLabel->setVisible(false);
603 }
604}

References analyticsString, blendedColor, and isDevelopmentBuild().

◆ showDropAreaIndicator

void KisWelcomePageWidget::showDropAreaIndicator ( bool show)
slot

if a document is placed over this area, a dotted line will appear as an indicator that it is a droppable area. KisMainwindow is what triggers this

Definition at line 280 of file KisWelcomePageWidget.cpp.

281{
282 if (!show) {
283 QString dropFrameStyle = QStringLiteral("QFrame#dropAreaIndicator { border: 2px solid transparent }");
284 dropFrameBorder->setStyleSheet(dropFrameStyle);
285 } else {
286 QColor textColor = qApp->palette().color(QPalette::Text);
287 QColor backgroundColor = qApp->palette().color(QPalette::Window);
289
290 // QColor.name() turns it into a hex/web format
291 QString dropFrameStyle = QString("QFrame#dropAreaIndicator { border: 2px dotted ").append(blendedColor.name()).append(" }") ;
292 dropFrameBorder->setStyleSheet(dropFrameStyle);
293 }
294}
QColor blendColors(const QColor &c1, const QColor &c2, qreal r1)

References backgroundColor, KisPaintingTweaks::blendColors(), blendedColor, and textColor.

◆ slotCheckNews

void KisWelcomePageWidget::slotCheckNews ( )
privateslot

Definition at line 696 of file KisWelcomePageWidget.cpp.

697{
698 checkNowButton->setEnabled(false);
699 noNewsWidget->hide();
700 newsWidget->show();
701 newsWidget->toggleNews(true);
702#ifdef ENABLE_UPDATERS
703 if (m_versionUpdater) {
704 m_versionUpdater->checkForUpdate();
705 updateVersionUpdaterFrame();
706 }
707#endif
708}

◆ slotNewFileClicked

void KisWelcomePageWidget::slotNewFileClicked ( )
privateslot

Definition at line 650 of file KisWelcomePageWidget.cpp.

651{
653}

References m_mainWindow, and KisMainWindow::slotFileNew().

◆ slotOpenFileClicked

void KisWelcomePageWidget::slotOpenFileClicked ( )
privateslot

Definition at line 655 of file KisWelcomePageWidget.cpp.

656{
658}
void slotFileOpen(bool isImporting=false)

References m_mainWindow, and KisMainWindow::slotFileOpen().

◆ slotPaste

void KisWelcomePageWidget::slotPaste ( )
privateslot

Definition at line 660 of file KisWelcomePageWidget.cpp.

661{
662 if (!this->isVisible())
663 return;
664
665 // Don't do anything if there's no image in the clipboard
666 if (!KisClipboard::instance()->hasImage())
667 return;
668
670
672 dlg->exec();
673 dlg->deleteLater();
674}
static KisClipboard * instance()

References KisDlgCreateNewDocument::CreateFromClipboard, KisClipboard::instance(), and KisDlgCreateNewDocument::SelectPage().

◆ slotRecentDocContextMenuRequest

void KisWelcomePageWidget::slotRecentDocContextMenuRequest ( const QPoint & pos)
privateslot

Definition at line 629 of file KisWelcomePageWidget.cpp.

630{
631 QMenu contextMenu;
632 QModelIndex index = recentDocumentsListView->indexAt(pos);
633 QAction *actionForget = 0;
634 if (index.isValid()) {
635 actionForget = new QAction(i18n("Forget \"%1\"", index.data(Qt::DisplayRole).toString()), &contextMenu);
636 contextMenu.addAction(actionForget);
637 }
638 QAction *triggered = contextMenu.exec(recentDocumentsListView->mapToGlobal(pos));
639
640 if (index.isValid() && triggered == actionForget) {
641 m_mainWindow->removeRecentFile(index.data(Qt::ToolTipRole).toString());
642 }
643}
void removeRecentFile(QString url)

References m_mainWindow, and KisMainWindow::removeRecentFile().

◆ slotRecentFilesModelIsUpToDate

void KisWelcomePageWidget::slotRecentFilesModelIsUpToDate ( )
privateslot

Once all files in the recent documents model are checked, cleanup the UI if the model is empty

Definition at line 676 of file KisWelcomePageWidget.cpp.

677{
679 const bool modelIsEmpty = recentFilesModel->model().rowCount() == 0;
680
681 if (modelIsEmpty) {
682 recentDocsStackedWidget->setCurrentWidget(labelNoRecentDocs);
683 } else {
684 recentDocsStackedWidget->setCurrentWidget(recentDocumentsListView);
685 }
686 clearRecentFilesLink->setVisible(!modelIsEmpty);
687}

References KisRecentDocumentsModelWrapper::instance(), and KisRecentDocumentsModelWrapper::model().

◆ slotScrollerStateChanged

void KisWelcomePageWidget::slotScrollerStateChanged ( QScroller::State state)
inlineprivateslot

Definition at line 66 of file KisWelcomePageWidget.h.

KRITAWIDGETUTILS_EXPORT void updateCursor(QWidget *source, QScroller::State state)

References KisKineticScroller::updateCursor().

◆ slotSetNewsEnabled

void KisWelcomePageWidget::slotSetNewsEnabled ( bool newsEnabled)
privateslot

Definition at line 689 of file KisWelcomePageWidget.cpp.

690{
691 enableNewsBox->setChecked(newsEnabled);
692 m_enableNewsAction->setChecked(newsEnabled);
693 KisConfig(false).setNewsCheckEnabled(newsEnabled);
694}
void setNewsCheckEnabled(bool value)

References m_enableNewsAction, and KisConfig::setNewsCheckEnabled().

◆ slotUpdateThemeColors

void KisWelcomePageWidget::slotUpdateThemeColors ( )
slot

Definition at line 296 of file KisWelcomePageWidget.cpp.

297{
298 textColor = qApp->palette().color(QPalette::Text);
299 backgroundColor = qApp->palette().color(QPalette::Window);
300
301 // make the welcome screen labels a subtle color so it doesn't clash with the main UI elements
303 // only apply color to the widget itself, not to the tooltip or something
304 blendedStyle = "QWidget{color: " + blendedColor.name() + "}";
305
306 // what labels to change the color...
307 startTitleLabel->setStyleSheet(blendedStyle);
308 recentDocumentsLabel->setStyleSheet(blendedStyle);
309 helpTitleLabel->setStyleSheet(blendedStyle);
310 newsTitleLabel->setStyleSheet(blendedStyle);
311 newFileLinkShortcut->setStyleSheet(blendedStyle);
312 openFileShortcut->setStyleSheet(blendedStyle);
313 clearRecentFilesLink->setStyleSheet(blendedStyle);
314 recentDocumentsListView->setStyleSheet(blendedStyle);
315 newsWidget->setStyleSheet(blendedStyle);
316
317#ifdef Q_OS_ANDROID
318 blendedStyle = blendedStyle + "\nQPushButton { padding: 10px }";
319#endif
320
321 newFileLink->setStyleSheet(blendedStyle);
322 openFileLink->setStyleSheet(blendedStyle);
323
324 // make drop area QFrame have a dotted line
325 dropFrameBorder->setObjectName("dropAreaIndicator");
326 QString dropFrameStyle = QString("QFrame#dropAreaIndicator { border: 4px dotted ").append(blendedColor.name()).append("}");
327 dropFrameBorder->setStyleSheet(dropFrameStyle);
328
329 // only show drop area when we have a document over the empty area
331
332 // add icons for new and open settings to make them stand out a bit more
333 openFileLink->setIconSize(QSize(48, 48));
334 newFileLink->setIconSize(QSize(48, 48));
335
336 openFileLink->setIcon(KisIconUtils::loadIcon("document-open"));
337 newFileLink->setIcon(KisIconUtils::loadIcon("document-new"));
338
339 btnNewsOptions->setIcon(KisIconUtils::loadIcon("view-choose"));
340 btnNewsOptions->setFlat(true);
341
342 notifyIcon->setIcon(KisIconUtils::loadIcon("notification-dot"));
343
344 supportKritaIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("support-krita")));
345 userManualIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("help-contents")));
346 gettingStartedIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("get_started")));
347 userCommunityIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("comunity")));
348 kritaWebsiteIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("website")));
349 sourceCodeIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("code")));
350 kdeIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("kde")));
351
352 // HTML links seem to be a bit more stubborn with theme changes... setting inline styles to help with color change
353 userCommunityLink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://krita-artists.org\">")
354 .append(i18n("User Community")).append("</a>"));
355
356 gettingStartedLink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://docs.krita.org/user_manual/getting_started.html\">")
357 .append(i18n("Getting Started")).append("</a>"));
358
359 manualLink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://docs.krita.org\">")
360 .append(i18n("User Manual")).append("</a>"));
361
362 supportKritaLink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://krita.org/support-us/donations?" + analyticsString + "donations" + "\">")
363 .append(i18n("Support Krita")).append("</a>"));
364
365 kritaWebsiteLink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://www.krita.org?" + analyticsString + "marketing-site" + "\">")
366 .append(i18n("Krita Website")).append("</a>"));
367
368 sourceCodeLink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://invent.kde.org/graphics/krita\">")
369 .append(i18n("Source Code")).append("</a>"));
370
371 poweredByKDELink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://userbase.kde.org/What_is_KDE\">")
372 .append(i18n("Powered by KDE")).append("</a>"));
373
374 const QColor frameColor = KisPaintingTweaks::blendColors(textColor, backgroundColor, 0.1);
375 const QString &frameQss = "{border: 1px solid " + frameColor.name() + "}";
376 recentDocsStackedWidget->setStyleSheet("QStackedWidget#recentDocsStackedWidget" + frameQss);
377 newsFrame->setStyleSheet("QFrame#newsFrame" + frameQss);
378
379 // show the dev version labels, if dev version is detected
381
382#ifdef ENABLE_UPDATERS
383 updateVersionUpdaterFrame(); // updater frame
384#endif
385
386#ifdef Q_OS_MACOS
387 // macOS store version should not contain external links containing donation buttons or forms
388 if (KisMacosEntitlements().sandbox()) {
389 supportKritaLink->hide();
390 supportKritaIcon->hide();
391 labelSupportText->hide();
392 kritaWebsiteLink->hide();
393 kritaWebsiteIcon->hide();
394 }
395#endif
396}

References analyticsString, backgroundColor, KisPaintingTweaks::blendColors(), blendedColor, blendedStyle, KisIconUtils::loadIcon(), showDevVersionHighlight(), showDropAreaIndicator(), and textColor.

◆ updateShortcutLink()

void KisWelcomePageWidget::updateShortcutLink ( QToolButton * button,
QLabel * label,
QAction * action )
staticprivate

Definition at line 606 of file KisWelcomePageWidget.cpp.

607{
608 if (action) {
609 QString shortcutText = action->shortcut().toString(QKeySequence::NativeText);
610 if (shortcutText.isEmpty()) {
611 label->setText(QString());
612 } else {
613 label->setText(QStringLiteral("(%1)").arg(shortcutText));
614 }
615 button->show();
616 label->show();
617 } else {
618 button->hide();
619 label->hide();
620 }
621}
QString button(const QWheelEvent &ev)

References button().

Member Data Documentation

◆ analyticsString

const QString KisWelcomePageWidget::analyticsString = "pk_campaign=startup-sceen&pk_kwd="
private

help us see how many people are clicking startup screen links you can see the results in Matomo (stats.kde.org) this will be listed in the "Acquisition" section of Matomo just append some text to this to associate it with an event/page

Definition at line 115 of file KisWelcomePageWidget.h.

◆ backgroundColor

QColor KisWelcomePageWidget::backgroundColor
private

Definition at line 120 of file KisWelcomePageWidget.h.

◆ blendedColor

QColor KisWelcomePageWidget::blendedColor
private

Definition at line 121 of file KisWelcomePageWidget.h.

◆ blendedStyle

QString KisWelcomePageWidget::blendedStyle
private

Definition at line 122 of file KisWelcomePageWidget.h.

◆ m_enableNewsAction

QAction* KisWelcomePageWidget::m_enableNewsAction
private

Definition at line 124 of file KisWelcomePageWidget.h.

◆ m_mainWindow

KisMainWindow* KisWelcomePageWidget::m_mainWindow {nullptr}
private

Definition at line 109 of file KisWelcomePageWidget.h.

109{nullptr};

◆ recentItemDelegate

QScopedPointer<RecentItemDelegate> KisWelcomePageWidget::recentItemDelegate
private

Definition at line 130 of file KisWelcomePageWidget.h.

◆ textColor

QColor KisWelcomePageWidget::textColor
private

Definition at line 119 of file KisWelcomePageWidget.h.


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