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 recentDocumentClicked (QModelIndex index)
 
void slotNewFileClicked ()
 
void slotOpenFileClicked ()
 
void slotPaste ()
 
void slotRecentDocContextMenuRequest (const QPoint &pos)
 
void slotRecentFilesModelIsUpToDate ()
 
void slotScrollerStateChanged (QScroller::State state)
 

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
 
KisMainWindowm_mainWindow {nullptr}
 
bool m_networkIsAllowed {false}
 
QScopedPointer< RecentItemDelegaterecentItemDelegate
 
QColor textColor
 

Detailed Description

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

Definition at line 37 of file KisWelcomePageWidget.h.

Constructor & Destructor Documentation

◆ KisWelcomePageWidget()

KisWelcomePageWidget::KisWelcomePageWidget ( QWidget * parent)
explicit

Definition at line 123 of file KisWelcomePageWidget.cpp.

124 : QWidget(parent)
125{
126 setupUi(this);
127
128 // URLs that go to web browser...
129 devBuildIcon->setIcon(KisIconUtils::loadIcon("warning"));
130 devBuildLabel->setVisible(false);
131 updaterFrame->setVisible(false);
132 versionNotificationLabel->setVisible(false);
133 bnVersionUpdate->setVisible(false);
134 bnErrorDetails->setVisible(false);
135
136 // Recent docs...
137 recentDocumentsListView->setDragEnabled(false);
138 recentDocumentsListView->viewport()->setAutoFillBackground(false);
139 recentDocumentsListView->setSpacing(2);
140 recentDocumentsListView->installEventFilter(this);
141 recentDocumentsListView->setViewMode(QListView::IconMode);
142 recentDocumentsListView->setSelectionMode(QAbstractItemView::NoSelection);
143
144// m_recentItemDelegate.reset(new RecentItemDelegate(this));
145// m_recentItemDelegate->setItemHeight(KisRecentDocumentsModelWrapper::ICON_SIZE_LENGTH);
146// recentDocumentsListView->setItemDelegate(m_recentItemDelegate.data());
148 recentDocumentsListView->setVerticalScrollMode(QListView::ScrollPerPixel);
149 recentDocumentsListView->verticalScrollBar()->setSingleStep(50);
150 {
151 QScroller* scroller = KisKineticScroller::createPreconfiguredScroller(recentDocumentsListView);
152 if (scroller) {
153 connect(scroller, SIGNAL(stateChanged(QScroller::State)), this, SLOT(slotScrollerStateChanged(QScroller::State)));
154 }
155 }
156 recentDocumentsListView->setContextMenuPolicy(Qt::CustomContextMenu);
157 connect(recentDocumentsListView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotRecentDocContextMenuRequest(QPoint)));
158
159 // News widget...
160 QMenu *newsOptionsMenu = new QMenu(this);
161 newsOptionsMenu->setToolTipsVisible(true);
162 ShowNewsAction *showNewsAction = new ShowNewsAction(i18n("Enable news and check for new releases"), newsOptionsMenu);
163 newsOptionsMenu->addAction(showNewsAction);
164 showNewsAction->setToolTip(i18n("Show news about Krita: this needs internet to retrieve information from the krita.org website"));
165 showNewsAction->setCheckable(true);
166
167 newsOptionsMenu->addSection(i18n("Language"));
168 QAction *newsInfoAction = newsOptionsMenu->addAction(i18n("English news is always up to date."));
169 newsInfoAction->setEnabled(false);
170
171 setupNewsLangSelection(newsOptionsMenu);
172 btnNewsOptions->setMenu(newsOptionsMenu);
173
174 labelSupportText->setFont(largerFont());
175
176 connect(showNewsAction, SIGNAL(toggled(bool)), newsWidget, SLOT(setVisible(bool)));
177 connect(showNewsAction, SIGNAL(toggled(bool)), labelNoFeed, SLOT(setHidden(bool)));
178 connect(showNewsAction, SIGNAL(toggled(bool)), newsWidget, SLOT(toggleNews(bool)));
179 connect(labelNoFeed, SIGNAL(linkActivated(QString)), showNewsAction, SLOT(enableFromLink(QString)));
180
181#ifdef ENABLE_UPDATERS
182 connect(showNewsAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleUpdateChecks(bool)));
183#endif
184
185 supporterBadge->hide();
186 wdgAndroidSupportBanner->hide();
187#ifdef Q_OS_ANDROID
188 initDonations();
189#endif
190
191 // configure the News area
192 KisConfig cfg(true);
193 m_networkIsAllowed = cfg.readEntry<bool>("FetchNews", false);
194
195
196#ifdef ENABLE_UPDATERS
197#ifndef Q_OS_ANDROID
198 // Setup version updater, but do not check for them, unless the user explicitly
199 // wants to check for updates.
200 // * No updater is created for Linux/Steam, Windows/Steam and Windows/Store distributions,
201 // as those stores have their own updating mechanism.
202 // * STEAMAPPID(Windows)/SteamAppId(Linux) environment variable is set when Krita is run from Steam.
203 // The environment variables are not public API.
204 // * MS Store version runs as a package (though we cannot know if it was
205 // installed from the Store or manually with the .msix package)
206#if defined Q_OS_LINUX
207 if (!qEnvironmentVariableIsSet("SteamAppId")) { // do not create updater for linux/steam
208 if (qEnvironmentVariableIsSet("APPIMAGE")) {
209 m_versionUpdater.reset(new KisAppimageUpdater());
210 } else {
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 if (m_networkIsAllowed) { // only if the user wants them
232 m_versionUpdater->checkForUpdate();
233 }
234 }
235#endif // ifndef Q_OS_ANDROID
236#endif // ENABLE_UPDATERS
237
238
239 showNewsAction->setChecked(m_networkIsAllowed);
240 newsWidget->setVisible(m_networkIsAllowed);
241 versionNotificationLabel->setEnabled(m_networkIsAllowed);
242
243 // Drop area..
244 setAcceptDrops(true);
245}
static void log(const QString &message)
Logs with date/time.
void setupNewsLangSelection(QMenu *newsOptionMenu)
void slotScrollerStateChanged(QScroller::State state)
void slotRecentDocContextMenuRequest(const QPoint &pos)
QIcon loadIcon(const QString &name)
KRITAWIDGETUTILS_EXPORT QScroller * createPreconfiguredScroller(QAbstractScrollArea *target)

References KisKineticScroller::createPreconfiguredScroller(), KisRecentDocumentsModelWrapper::ICON_SIZE_LENGTH, KisWindowsPackageUtils::isRunningInPackage(), largerFont(), KisIconUtils::loadIcon(), KisUsageLogger::log(), m_networkIsAllowed, KisConfig::readEntry(), setupNewsLangSelection(), slotRecentDocContextMenuRequest(), and slotScrollerStateChanged().

◆ ~KisWelcomePageWidget()

KisWelcomePageWidget::~KisWelcomePageWidget ( )
override

Definition at line 247 of file KisWelcomePageWidget.cpp.

248{
249}

Member Function Documentation

◆ changeEvent()

void KisWelcomePageWidget::changeEvent ( QEvent * event)
overrideprotected

Definition at line 469 of file KisWelcomePageWidget.cpp.

470{
471 if (event->type() == QEvent::FontChange) {
472 labelSupportText->setFont(largerFont());
473 }
474}

References largerFont().

◆ dragEnterEvent()

void KisWelcomePageWidget::dragEnterEvent ( QDragEnterEvent * event)
overrideprotected

Definition at line 407 of file KisWelcomePageWidget.cpp.

408{
410 if (event->mimeData()->hasUrls() ||
411 event->mimeData()->hasFormat("application/x-krita-node-internal-pointer") ||
412 event->mimeData()->hasFormat("application/x-qt-image")) {
413 return event->accept();
414 }
415
416 return event->ignore();
417}
void showDropAreaIndicator(bool show)

References showDropAreaIndicator().

◆ dragLeaveEvent()

void KisWelcomePageWidget::dragLeaveEvent ( QDragLeaveEvent * event)
overrideprotected

◆ dragMoveEvent()

void KisWelcomePageWidget::dragMoveEvent ( QDragMoveEvent * event)
overrideprotected

Definition at line 450 of file KisWelcomePageWidget.cpp.

451{
453
454 if (event->mimeData()->hasUrls() ||
455 event->mimeData()->hasFormat("application/x-krita-node-internal-pointer") ||
456 event->mimeData()->hasFormat("application/x-qt-image")) {
457 return event->accept();
458 }
459
460 return event->ignore();
461}
void dragMoveEvent(QDragMoveEvent *event) override

References KisMainWindow::dragMoveEvent(), and m_mainWindow.

◆ dropEvent()

void KisWelcomePageWidget::dropEvent ( QDropEvent * event)
overrideprotected

Definition at line 419 of file KisWelcomePageWidget.cpp.

420{
422
423 if (event->mimeData()->hasUrls() && !event->mimeData()->urls().empty()) {
424 Q_FOREACH (const QUrl &url, event->mimeData()->urls()) {
425 if (url.toLocalFile().endsWith(".bundle", Qt::CaseInsensitive)) {
426 bool r = m_mainWindow->installBundle(url.toLocalFile());
427 if (!r) {
428 qWarning() << "Could not install bundle" << url.toLocalFile();
429 }
430 } else if (!url.isLocalFile()) {
431 QScopedPointer<QTemporaryFile> tmp(new QTemporaryFile());
432 tmp->setFileName(url.fileName());
433
434 KisRemoteFileFetcher fetcher;
435
436 if (!fetcher.fetchFile(url, tmp.data())) {
437 qWarning() << "Fetching" << url << "failed";
438 continue;
439 }
440 const auto localUrl = QUrl::fromLocalFile(tmp->fileName());
441
442 m_mainWindow->openDocument(localUrl.toLocalFile(), KisMainWindow::None);
443 } else {
445 }
446 }
447 }
448}
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 476 of file KisWelcomePageWidget.cpp.

477{
478 if (watched == recentDocumentsListView && event->type() == QEvent::Leave) {
479 recentDocumentsListView->clearSelection();
480 }
481 return QWidget::eventFilter(watched, event);
482}

◆ isDevelopmentBuild

bool KisWelcomePageWidget::isDevelopmentBuild ( )
privateslot

Definition at line 652 of file KisWelcomePageWidget.cpp.

653{
655}
KRITAVERSION_EXPORT bool isDevelopersBuild()

References KritaVersionWrapper::isDevelopersBuild().

◆ largerFont

QFont KisWelcomePageWidget::largerFont ( )
privateslot

Definition at line 998 of file KisWelcomePageWidget.cpp.

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

◆ recentDocumentClicked

void KisWelcomePageWidget::recentDocumentClicked ( QModelIndex index)
privateslot

Definition at line 630 of file KisWelcomePageWidget.cpp.

631{
632 QString fileUrl = index.data(Qt::ToolTipRole).toString();
634}

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

◆ setMainWindow()

void KisWelcomePageWidget::setMainWindow ( KisMainWindow * m_mainWindow)

Definition at line 251 of file KisWelcomePageWidget.cpp.

252{
253 if (mainWin) {
254 m_mainWindow = mainWin;
255
256 // set the shortcut links from actions (only if a shortcut exists)
257 KisActionManager *actionManager = mainWin->viewManager()->actionManager();
258 updateShortcutLink(newFileLink, newFileLinkShortcut, actionManager->actionByName(QStringLiteral("file_new")));
259 updateShortcutLink(openFileLink, openFileShortcut, actionManager->actionByName(QStringLiteral("file_open")));
260 connect(recentDocumentsListView, SIGNAL(clicked(QModelIndex)), this, SLOT(recentDocumentClicked(QModelIndex)));
261 // we need the view manager to actually call actions, so don't create the connections
262 // until after the view manager is set
263 connect(newFileLink, SIGNAL(clicked(bool)), this, SLOT(slotNewFileClicked()));
264 connect(openFileLink, SIGNAL(clicked(bool)), this, SLOT(slotOpenFileClicked()));
265 connect(clearRecentFilesLink, SIGNAL(clicked(bool)), mainWin, SLOT(clearRecentFiles()));
266
267 KisAction *pasteAction = mainWin->viewManager()->actionManager()->actionByName("edit_paste");
268 connect(pasteAction, SIGNAL(triggered()), this, SLOT(slotPaste()));
269
271
272 // allows RSS news items to apply analytics tracking.
273 newsWidget->setAnalyticsTracking("?" + analyticsString);
274
276 connect(recentFilesModel, SIGNAL(sigModelIsUpToDate()), this, SLOT(slotRecentFilesModelIsUpToDate()));
277 recentDocumentsListView->setModel(&recentFilesModel->model());
279 }
280}
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 511 of file KisWelcomePageWidget.cpp.

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

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

◆ showDevVersionHighlight()

void KisWelcomePageWidget::showDevVersionHighlight ( )
private

Definition at line 594 of file KisWelcomePageWidget.cpp.

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

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 283 of file KisWelcomePageWidget.cpp.

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

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

◆ slotNewFileClicked

void KisWelcomePageWidget::slotNewFileClicked ( )
privateslot

Definition at line 657 of file KisWelcomePageWidget.cpp.

658{
660}

References m_mainWindow, and KisMainWindow::slotFileNew().

◆ slotOpenFileClicked

void KisWelcomePageWidget::slotOpenFileClicked ( )
privateslot

Definition at line 662 of file KisWelcomePageWidget.cpp.

663{
665}
void slotFileOpen(bool isImporting=false)

References m_mainWindow, and KisMainWindow::slotFileOpen().

◆ slotPaste

void KisWelcomePageWidget::slotPaste ( )
privateslot

Definition at line 667 of file KisWelcomePageWidget.cpp.

668{
669 if (!this->isVisible())
670 return;
671
672 // Don't do anything if there's no image in the clipboard
673 if (!KisClipboard::instance()->hasImage())
674 return;
675
677
679 dlg->exec();
680 dlg->deleteLater();
681}
static KisClipboard * instance()

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

◆ slotRecentDocContextMenuRequest

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

Definition at line 636 of file KisWelcomePageWidget.cpp.

637{
638 QMenu contextMenu;
639 QModelIndex index = recentDocumentsListView->indexAt(pos);
640 QAction *actionForget = 0;
641 if (index.isValid()) {
642 actionForget = new QAction(i18n("Forget \"%1\"", index.data(Qt::DisplayRole).toString()), &contextMenu);
643 contextMenu.addAction(actionForget);
644 }
645 QAction *triggered = contextMenu.exec(recentDocumentsListView->mapToGlobal(pos));
646
647 if (index.isValid() && triggered == actionForget) {
648 m_mainWindow->removeRecentFile(index.data(Qt::ToolTipRole).toString());
649 }
650}
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 683 of file KisWelcomePageWidget.cpp.

684{
686 const bool modelIsEmpty = recentFilesModel->model().rowCount() == 0;
687
688 if (modelIsEmpty) {
689 recentDocsStackedWidget->setCurrentWidget(labelNoRecentDocs);
690 } else {
691 recentDocsStackedWidget->setCurrentWidget(recentDocumentsListView);
692 }
693 clearRecentFilesLink->setVisible(!modelIsEmpty);
694}

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

◆ slotScrollerStateChanged

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

Definition at line 72 of file KisWelcomePageWidget.h.

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

References KisKineticScroller::updateCursor().

◆ slotUpdateThemeColors

void KisWelcomePageWidget::slotUpdateThemeColors ( )
slot

Definition at line 299 of file KisWelcomePageWidget.cpp.

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

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 613 of file KisWelcomePageWidget.cpp.

614{
615 if (action) {
616 QString shortcutText = action->shortcut().toString(QKeySequence::NativeText);
617 if (shortcutText.isEmpty()) {
618 label->setText(QString());
619 } else {
620 label->setText(QStringLiteral("(%1)").arg(shortcutText));
621 }
622 button->show();
623 label->show();
624 } else {
625 button->hide();
626 label->hide();
627 }
628}
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 119 of file KisWelcomePageWidget.h.

◆ backgroundColor

QColor KisWelcomePageWidget::backgroundColor
private

Definition at line 124 of file KisWelcomePageWidget.h.

◆ blendedColor

QColor KisWelcomePageWidget::blendedColor
private

Definition at line 125 of file KisWelcomePageWidget.h.

◆ blendedStyle

QString KisWelcomePageWidget::blendedStyle
private

Definition at line 126 of file KisWelcomePageWidget.h.

◆ m_mainWindow

KisMainWindow* KisWelcomePageWidget::m_mainWindow {nullptr}
private

Definition at line 113 of file KisWelcomePageWidget.h.

113{nullptr};

◆ m_networkIsAllowed

bool KisWelcomePageWidget::m_networkIsAllowed {false}
private

Definition at line 132 of file KisWelcomePageWidget.h.

132{false};

◆ recentItemDelegate

QScopedPointer<RecentItemDelegate> KisWelcomePageWidget::recentItemDelegate
private

Definition at line 134 of file KisWelcomePageWidget.h.

◆ textColor

QColor KisWelcomePageWidget::textColor
private

Definition at line 123 of file KisWelcomePageWidget.h.


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