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 ()
 

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

119 : QWidget(parent)
120{
121 setupUi(this);
122
123 // URLs that go to web browser...
124 devBuildIcon->setIcon(KisIconUtils::loadIcon("warning"));
125 devBuildLabel->setVisible(false);
126 updaterFrame->setVisible(false);
127 versionNotificationLabel->setVisible(false);
128 bnVersionUpdate->setVisible(false);
129 bnErrorDetails->setVisible(false);
130
131 // Recent docs...
132 recentDocumentsListView->setDragEnabled(false);
133 recentDocumentsListView->viewport()->setAutoFillBackground(false);
134 recentDocumentsListView->setSpacing(2);
135 recentDocumentsListView->installEventFilter(this);
136 recentDocumentsListView->setViewMode(QListView::IconMode);
137 recentDocumentsListView->setSelectionMode(QAbstractItemView::NoSelection);
138
139// m_recentItemDelegate.reset(new RecentItemDelegate(this));
140// m_recentItemDelegate->setItemHeight(KisRecentDocumentsModelWrapper::ICON_SIZE_LENGTH);
141// recentDocumentsListView->setItemDelegate(m_recentItemDelegate.data());
143 recentDocumentsListView->setVerticalScrollMode(QListView::ScrollPerPixel);
144 recentDocumentsListView->verticalScrollBar()->setSingleStep(50);
145 {
146 QScroller* scroller = KisKineticScroller::createPreconfiguredScroller(recentDocumentsListView);
147 if (scroller) {
148 connect(scroller, SIGNAL(stateChanged(QScroller::State)), this, SLOT(slotScrollerStateChanged(QScroller::State)));
149 }
150 }
151 recentDocumentsListView->setContextMenuPolicy(Qt::CustomContextMenu);
152 connect(recentDocumentsListView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotRecentDocContextMenuRequest(QPoint)));
153
154 // News widget...
155 QMenu *newsOptionsMenu = new QMenu(this);
156 newsOptionsMenu->setToolTipsVisible(true);
157 ShowNewsAction *showNewsAction = new ShowNewsAction(i18n("Enable news and check for new releases"), newsOptionsMenu);
158 newsOptionsMenu->addAction(showNewsAction);
159 showNewsAction->setToolTip(i18n("Show news about Krita: this needs internet to retrieve information from the krita.org website"));
160 showNewsAction->setCheckable(true);
161
162 newsOptionsMenu->addSection(i18n("Language"));
163 QAction *newsInfoAction = newsOptionsMenu->addAction(i18n("English news is always up to date."));
164 newsInfoAction->setEnabled(false);
165
166 setupNewsLangSelection(newsOptionsMenu);
167 btnNewsOptions->setMenu(newsOptionsMenu);
168
169 labelSupportText->setFont(largerFont());
170 donationLink->setFont(largerFont());
171
172 connect(showNewsAction, SIGNAL(toggled(bool)), newsWidget, SLOT(setVisible(bool)));
173 connect(showNewsAction, SIGNAL(toggled(bool)), labelNoFeed, SLOT(setHidden(bool)));
174 connect(showNewsAction, SIGNAL(toggled(bool)), newsWidget, SLOT(toggleNews(bool)));
175 connect(labelNoFeed, SIGNAL(linkActivated(QString)), showNewsAction, SLOT(enableFromLink(QString)));
176
177 labelNoFeed->setDismissable(false);
178
179#ifdef ENABLE_UPDATERS
180 connect(showNewsAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleUpdateChecks(bool)));
181#endif
182
183 donationLink->hide();
184 supporterBadge->hide();
185#ifdef Q_OS_ANDROID
186 initDonations();
187#endif
188
189 // configure the News area
190 KisConfig cfg(true);
191 m_networkIsAllowed = cfg.readEntry<bool>("FetchNews", false);
192
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 } else {
209 m_versionUpdater.reset(new KisManualUpdater());
210 }
211 }
212#elif defined Q_OS_WIN
213 if (!KisWindowsPackageUtils::isRunningInPackage() && !qEnvironmentVariableIsSet("STEAMAPPID")) {
214 m_versionUpdater.reset(new KisManualUpdater());
215 KisUsageLogger::log("Non-store package - creating updater");
216 } else {
217 KisUsageLogger::log("detected appx or steam package - not creating the updater");
218 }
219#else
220 // always create updater for MacOS
221 m_versionUpdater.reset(new KisManualUpdater());
222#endif // Q_OS_*
223 if (!m_versionUpdater.isNull()) {
224 connect(bnVersionUpdate, SIGNAL(clicked()), this, SLOT(slotRunVersionUpdate()));
225 connect(bnErrorDetails, SIGNAL(clicked()), this, SLOT(slotShowUpdaterErrorDetails()));
226 connect(m_versionUpdater.data(), SIGNAL(sigUpdateCheckStateChange(KisUpdaterStatus)),
227 this, SLOT(slotSetUpdateStatus(const KisUpdaterStatus&)));
228
229 if (m_networkIsAllowed) { // only if the user wants them
230 m_versionUpdater->checkForUpdate();
231 }
232 }
233#endif // ifndef Q_OS_ANDROID
234#endif // ENABLE_UPDATERS
235
236
237 showNewsAction->setChecked(m_networkIsAllowed);
238 newsWidget->setVisible(m_networkIsAllowed);
239 versionNotificationLabel->setEnabled(m_networkIsAllowed);
240
241 // Drop area..
242 setAcceptDrops(true);
243}
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 245 of file KisWelcomePageWidget.cpp.

246{
247}

Member Function Documentation

◆ changeEvent()

void KisWelcomePageWidget::changeEvent ( QEvent * event)
overrideprotected

Definition at line 478 of file KisWelcomePageWidget.cpp.

479{
480 if (event->type() == QEvent::FontChange) {
481 labelSupportText->setFont(largerFont());
482 donationLink->setFont(largerFont());
483 }
484}

References largerFont().

◆ dragEnterEvent()

void KisWelcomePageWidget::dragEnterEvent ( QDragEnterEvent * event)
overrideprotected

Definition at line 416 of file KisWelcomePageWidget.cpp.

417{
419 if (event->mimeData()->hasUrls() ||
420 event->mimeData()->hasFormat("application/x-krita-node-internal-pointer") ||
421 event->mimeData()->hasFormat("application/x-qt-image")) {
422 return event->accept();
423 }
424
425 return event->ignore();
426}
void showDropAreaIndicator(bool show)

References showDropAreaIndicator().

◆ dragLeaveEvent()

void KisWelcomePageWidget::dragLeaveEvent ( QDragLeaveEvent * event)
overrideprotected

◆ dragMoveEvent()

void KisWelcomePageWidget::dragMoveEvent ( QDragMoveEvent * event)
overrideprotected

Definition at line 459 of file KisWelcomePageWidget.cpp.

460{
462
463 if (event->mimeData()->hasUrls() ||
464 event->mimeData()->hasFormat("application/x-krita-node-internal-pointer") ||
465 event->mimeData()->hasFormat("application/x-qt-image")) {
466 return event->accept();
467 }
468
469 return event->ignore();
470}
void dragMoveEvent(QDragMoveEvent *event) override

References KisMainWindow::dragMoveEvent(), and m_mainWindow.

◆ dropEvent()

void KisWelcomePageWidget::dropEvent ( QDropEvent * event)
overrideprotected

Definition at line 428 of file KisWelcomePageWidget.cpp.

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

487{
488 if (watched == recentDocumentsListView && event->type() == QEvent::Leave) {
489 recentDocumentsListView->clearSelection();
490 }
491 return QWidget::eventFilter(watched, event);
492}

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

831{
832 QFont larger = font();
833 // Font size may be in pixels (on Android) or points (everywhere else.)
834 qreal ratio = 1.1;
835 if (larger.pixelSize() == -1) {
836 larger.setPointSizeF(larger.pointSizeF() * ratio);
837 } else {
838 larger.setPixelSize(qRound(larger.pixelSize() * ratio));
839 }
840 return larger;
841}

◆ 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().

◆ setMainWindow()

void KisWelcomePageWidget::setMainWindow ( KisMainWindow * m_mainWindow)

Definition at line 249 of file KisWelcomePageWidget.cpp.

250{
251 if (mainWin) {
252 m_mainWindow = mainWin;
253
254 // set the shortcut links from actions (only if a shortcut exists)
255 if ( mainWin->viewManager()->actionManager()->actionByName("file_new")->shortcut().toString() != "") {
256 newFileLinkShortcut->setText(
257 QString("(") + mainWin->viewManager()->actionManager()->actionByName("file_new")->shortcut().toString(QKeySequence::NativeText) + QString(")"));
258 }
259 if (mainWin->viewManager()->actionManager()->actionByName("file_open")->shortcut().toString() != "") {
260 openFileShortcut->setText(
261 QString("(") + mainWin->viewManager()->actionManager()->actionByName("file_open")->shortcut().toString(QKeySequence::NativeText) + QString(")"));
262 }
263 connect(recentDocumentsListView, SIGNAL(clicked(QModelIndex)), this, SLOT(recentDocumentClicked(QModelIndex)));
264 // we need the view manager to actually call actions, so don't create the connections
265 // until after the view manager is set
266 connect(newFileLink, SIGNAL(clicked(bool)), this, SLOT(slotNewFileClicked()));
267 connect(openFileLink, SIGNAL(clicked(bool)), this, SLOT(slotOpenFileClicked()));
268 connect(clearRecentFilesLink, SIGNAL(clicked(bool)), mainWin, SLOT(clearRecentFiles()));
269
270 KisAction *pasteAction = mainWin->viewManager()->actionManager()->actionByName("edit_paste");
271 connect(pasteAction, SIGNAL(triggered()), this, SLOT(slotPaste()));
272
274
275 // allows RSS news items to apply analytics tracking.
276 newsWidget->setAnalyticsTracking("?" + analyticsString);
277
279 connect(recentFilesModel, SIGNAL(sigModelIsUpToDate()), this, SLOT(slotRecentFilesModelIsUpToDate()));
280 recentDocumentsListView->setModel(&recentFilesModel->model());
282 }
283}
KisAction * actionByName(const QString &name) const
KisActionManager * actionManager
static KisRecentDocumentsModelWrapper * instance()
void recentDocumentClicked(QModelIndex index)

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

◆ setupNewsLangSelection()

void KisWelcomePageWidget::setupNewsLangSelection ( QMenu * newsOptionMenu)
private

Definition at line 521 of file KisWelcomePageWidget.cpp.

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

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

◆ showDevVersionHighlight()

void KisWelcomePageWidget::showDevVersionHighlight ( )
private

Definition at line 604 of file KisWelcomePageWidget.cpp.

605{
606 // always flag development version
607 if (isDevelopmentBuild()) {
608 QString devBuildLabelText = QString("<a style=\"color: " +
609 blendedColor.name() +
610 " \" href=\"https://docs.krita.org/en/untranslatable_pages/triaging_bugs.html?"
611 + analyticsString + "dev-build" + "\">")
612 .append(i18n("DEV BUILD")).append("</a>");
613
614 devBuildLabel->setText(devBuildLabelText);
615 devBuildIcon->setVisible(true);
616 devBuildLabel->setVisible(true);
617 } else {
618 devBuildIcon->setVisible(false);
619 devBuildLabel->setVisible(false);
620 }
621}

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

287{
288 if (!show) {
289 QString dropFrameStyle = QStringLiteral("QFrame#dropAreaIndicator { border: 2px solid transparent }");
290 dropFrameBorder->setStyleSheet(dropFrameStyle);
291 } else {
292 QColor textColor = qApp->palette().color(QPalette::Text);
293 QColor backgroundColor = qApp->palette().color(QPalette::Window);
295
296 // QColor.name() turns it into a hex/web format
297 QString dropFrameStyle = QString("QFrame#dropAreaIndicator { border: 2px dotted ").append(blendedColor.name()).append(" }") ;
298 dropFrameBorder->setStyleSheet(dropFrameStyle);
299 }
300}
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 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 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 302 of file KisWelcomePageWidget.cpp.

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

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

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 117 of file KisWelcomePageWidget.h.

◆ backgroundColor

QColor KisWelcomePageWidget::backgroundColor
private

Definition at line 122 of file KisWelcomePageWidget.h.

◆ blendedColor

QColor KisWelcomePageWidget::blendedColor
private

Definition at line 123 of file KisWelcomePageWidget.h.

◆ blendedStyle

QString KisWelcomePageWidget::blendedStyle
private

Definition at line 124 of file KisWelcomePageWidget.h.

◆ m_mainWindow

KisMainWindow* KisWelcomePageWidget::m_mainWindow {nullptr}
private

Definition at line 111 of file KisWelcomePageWidget.h.

111{nullptr};

◆ m_networkIsAllowed

bool KisWelcomePageWidget::m_networkIsAllowed {false}
private

Definition at line 130 of file KisWelcomePageWidget.h.

130{false};

◆ recentItemDelegate

QScopedPointer<RecentItemDelegate> KisWelcomePageWidget::recentItemDelegate
private

Definition at line 132 of file KisWelcomePageWidget.h.

◆ textColor

QColor KisWelcomePageWidget::textColor
private

Definition at line 121 of file KisWelcomePageWidget.h.


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