File indexing completed on 2024-05-19 04:29:22
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2018 Scott Petrovic <scottpetrovic@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KISWELCOMEPAGEWIDGET_H 0008 #define KISWELCOMEPAGEWIDGET_H 0009 0010 #include "kritaui_export.h" 0011 #include "KisViewManager.h" 0012 #include <KisUpdaterBase.h> 0013 #include <KisKineticScroller.h> 0014 0015 #include <QAction> 0016 #include <QWidget> 0017 #include "ui_KisWelcomePage.h" 0018 #include <QStandardItemModel> 0019 #include <QScopedPointer> 0020 #include <QFont> 0021 0022 #include "config-updaters.h" 0023 class RecentItemDelegate; 0024 class KisMainWindow; 0025 0026 // Custom QAction to bridge a QLabel::linkActivated signal to a QAction::setChecked signal 0027 class ShowNewsAction : public QAction 0028 { 0029 Q_OBJECT 0030 public: 0031 using QAction::QAction; 0032 private Q_SLOTS: 0033 void enableFromLink(QString unused_url); 0034 }; 0035 0036 /// A widget for displaying if no documents are open. This will display in the MDI area 0037 class KRITAUI_EXPORT KisWelcomePageWidget : public QWidget, public Ui::KisWelcomePage 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 explicit KisWelcomePageWidget(QWidget *parent); 0043 ~KisWelcomePageWidget() override; 0044 0045 void setMainWindow(KisMainWindow* m_mainWindow); 0046 0047 public Q_SLOTS: 0048 /// if a document is placed over this area, a dotted line will appear as an indicator 0049 /// that it is a droppable area. KisMainwindow is what triggers this 0050 void showDropAreaIndicator(bool show); 0051 0052 void slotUpdateThemeColors(); 0053 0054 #ifdef ENABLE_UPDATERS 0055 void slotSetUpdateStatus(KisUpdaterStatus updateStatus); 0056 void slotShowUpdaterErrorDetails(); 0057 #endif 0058 0059 #ifdef Q_OS_ANDROID 0060 void slotStartDonationFlow(); 0061 #endif 0062 0063 private Q_SLOTS: 0064 void slotNewFileClicked(); 0065 void slotOpenFileClicked(); 0066 void slotBannerClicked(); 0067 0068 void recentDocumentClicked(QModelIndex index); 0069 void slotRecentDocContextMenuRequest(const QPoint &pos); 0070 0071 /** 0072 * Once all files in the recent documents model are checked, cleanup the UI if the model is empty 0073 */ 0074 void slotRecentFilesModelIsUpToDate(); 0075 0076 void slotScrollerStateChanged(QScroller::State state){ KisKineticScroller::updateCursor(this, state); } 0077 0078 #ifdef ENABLE_UPDATERS 0079 void slotRunVersionUpdate(); 0080 void slotToggleUpdateChecks(bool state); 0081 #endif 0082 0083 bool isDevelopmentBuild(); 0084 0085 QFont largerFont(); 0086 0087 protected: 0088 0089 // QWidget overrides 0090 void dragEnterEvent(QDragEnterEvent * event) override; 0091 void dropEvent(QDropEvent * event) override; 0092 void dragMoveEvent(QDragMoveEvent * event) override; 0093 void dragLeaveEvent(QDragLeaveEvent * event) override; 0094 void changeEvent(QEvent *event) override; 0095 0096 bool eventFilter(QObject *watched, QEvent *event) override; 0097 0098 0099 private: 0100 void setupBanner(); 0101 void setupNewsLangSelection(QMenu *newsOptionMenu); 0102 void showDevVersionHighlight(); 0103 0104 #ifdef ENABLE_UPDATERS 0105 void updateVersionUpdaterFrame(); 0106 #endif 0107 0108 KisMainWindow *m_mainWindow {nullptr}; 0109 0110 /// help us see how many people are clicking startup screen links 0111 /// you can see the results in Matomo (stats.kde.org) 0112 /// this will be listed in the "Acquisition" section of Matomo 0113 /// just append some text to this to associate it with an event/page 0114 const QString analyticsString = "pk_campaign=startup-sceen&pk_kwd="; 0115 0116 0117 // keeping track of link colors with theme change 0118 QColor textColor; 0119 QColor backgroundColor; 0120 QColor blendedColor; 0121 QString blendedStyle; 0122 0123 #ifdef ENABLE_UPDATERS 0124 QScopedPointer<KisUpdaterBase> m_versionUpdater; 0125 KisUpdaterStatus m_updaterStatus; 0126 #endif 0127 bool m_networkIsAllowed {false}; 0128 0129 #ifdef Q_OS_ANDROID 0130 public: 0131 static QPushButton* donationLink; 0132 static QLabel* donationBannerImage; 0133 #endif 0134 QScopedPointer<RecentItemDelegate> recentItemDelegate; 0135 0136 QString m_bannerUrl; 0137 QImage m_bannerImage; 0138 bool m_bannerOverride {false}; 0139 bool m_showBanner {true}; 0140 0141 }; 0142 0143 #endif // KISWELCOMEPAGEWIDGET_H