[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [krita/krita/4.1] libs/ui: Port the welcome page to 4.1
From: Boudewijn Rempt <null () kde ! org>
Date: 2018-09-07 14:15:56
Message-ID: E1fyHYC-0003Xd-NC () code ! kde ! org
[Download RAW message or body]
Git commit 15d9f8a2b1462b714e41c90f173535fd66a5264c by Boudewijn Rempt.
Committed on 07/09/2018 at 14:03.
Pushed by rempt into branch 'krita/4.1'.
Port the welcome page to 4.1
M +8 -1 libs/ui/CMakeLists.txt
M +1 -21 libs/ui/KisApplication.cpp
M +53 -1 libs/ui/KisMainWindow.cpp
M +26 -5 libs/ui/KisMainWindow.h
M +6 -1 libs/ui/KisMultiFeedRSSModel.cpp
M +1 -1 libs/ui/KisMultiFeedRSSModel.h
A +34 -0 libs/ui/forms/KisNewsPage.ui
A +775 -0 libs/ui/forms/KisWelcomePage.ui
A +121 -0 libs/ui/widgets/KisNewsWidget.cpp [License: GPL (v2+)]
A +54 -0 libs/ui/widgets/KisNewsWidget.h [License: GPL (v2+)]
A +278 -0 libs/ui/widgets/KisWelcomePageWidget.cpp [License: LGPL (v2+)]
A +77 -0 libs/ui/widgets/KisWelcomePageWidget.h [License: LGPL (v2+)]
https://commits.kde.org/krita/15d9f8a2b1462b714e41c90f173535fd66a5264c
diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt
index fe7af228024..1e8feaa7a43 100644
--- a/libs/ui/CMakeLists.txt
+++ b/libs/ui/CMakeLists.txt
@@ -152,10 +152,13 @@ set(kritaui_LIB_SRCS
kis_tooltip_manager.cpp
kis_multinode_property.cpp
kis_stopgradient_editor.cpp
+ widgets/KisWelcomePageWidget.cpp
+
kisexiv2/kis_exif_io.cpp
kisexiv2/kis_exiv2.cpp
kisexiv2/kis_iptc_io.cpp
kisexiv2/kis_xmp_io.cpp
+
opengl/kis_opengl.cpp
opengl/kis_opengl_canvas2.cpp
opengl/kis_opengl_canvas_debugger.cpp
@@ -262,7 +265,7 @@ set(kritaui_LIB_SRCS
widgets/KisVisualTriangleSelectorShape.cpp
widgets/KoStrokeConfigWidget.cpp
widgets/KoFillConfigWidget.cpp
-
+ widgets/KisNewsWidget.cpp
utils/kis_document_aware_spin_box_unit_manager.cpp
@@ -495,6 +498,10 @@ ki18n_wrap_ui(kritaui_LIB_SRCS
forms/wdgstopgradienteditor.ui
forms/wdgsessionmanager.ui
forms/wdgnewwindowlayout.ui
+ forms/KisWelcomePage.ui
+ forms/KisNewsPage.ui
+
+
brushhud/kis_dlg_brush_hud_config.ui
forms/wdgdlginternalcolorselector.ui
dialogs/kis_delayed_save_dialog.ui
diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index 59995653cc2..1cc067607b7 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -119,27 +119,7 @@ public:
~ResetStarting() {
if (m_splash) {
-
- KConfigGroup cfg( KSharedConfig::openConfig(), "SplashScreen");
- bool hideSplash = cfg.readEntry("HideSplashAfterStartup", false);
- if (m_fileCount > 0 || hideSplash) {
- m_splash->hide();
- }
- else {
- m_splash->setWindowFlags(Qt::Dialog);
- QRect r(QPoint(), m_splash->size());
- m_splash->move(QApplication::desktop()->availableGeometry().center() \
- r.center());
- m_splash->setWindowTitle(qAppName());
- m_splash->setParent(0);
- Q_FOREACH (QObject *o, m_splash->children()) {
- QWidget *w = qobject_cast<QWidget*>(o);
- if (w && w->isHidden()) {
- w->setVisible(true);
- }
- }
- m_splash->show();
- m_splash->activateWindow();
- }
+ m_splash->hide();
}
}
diff --git a/libs/ui/KisMainWindow.cpp b/libs/ui/KisMainWindow.cpp
index 7d823449ecc..952d3c37608 100644
--- a/libs/ui/KisMainWindow.cpp
+++ b/libs/ui/KisMainWindow.cpp
@@ -57,6 +57,7 @@
#include <QMenuBar>
#include <KisMimeDatabase.h>
#include <QMimeData>
+#include <QStackedWidget>
#include <kactioncollection.h>
#include <QAction>
@@ -140,6 +141,7 @@
#include <KisUpdateSchedulerConfigNotifier.h>
#include "KisWindowLayoutManager.h"
#include <KisUndoActionsUpdateManager.h>
+#include "KisWelcomePageWidget.h"
#include <mutex>
@@ -176,11 +178,17 @@ public:
, windowMenu(new KActionMenu(i18nc("@action:inmenu", "&Window"), parent))
, documentMenu(new KActionMenu(i18nc("@action:inmenu", "New &View"), \
parent))
, workspaceMenu(new KActionMenu(i18nc("@action:inmenu", "Wor&kspace"), \
parent)) + , welcomePage(new KisWelcomePageWidget(parent))
+ , widgetStack(new QStackedWidget(parent))
, mdiArea(new QMdiArea(parent))
, windowMapper(new QSignalMapper(parent))
, documentMapper(new QSignalMapper(parent))
{
if (id.isNull()) this->id = QUuid::createUuid();
+
+ widgetStack->addWidget(welcomePage);
+ widgetStack->addWidget(mdiArea);
+
mdiArea->setTabsMovable(true);
mdiArea->setActivationOrder(QMdiArea::ActivationHistoryOrder);
}
@@ -250,6 +258,9 @@ public:
Digikam::ThemeManager *themeManager {0};
+ KisWelcomePageWidget *welcomePage {0};
+ QStackedWidget *widgetStack {0};
+
QMdiArea *mdiArea;
QMdiSubWindow *activeSubWindow {0};
QSignalMapper *windowMapper;
@@ -367,7 +378,8 @@ KisMainWindow::KisMainWindow(QUuid uuid)
d->mdiArea->setTabPosition(QTabWidget::North);
d->mdiArea->setTabsClosable(true);
- setCentralWidget(d->mdiArea);
+ setCentralWidget(d->widgetStack);
+ d->widgetStack->setCurrentIndex(0);
connect(d->mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, \
SLOT(subWindowActivated()));
connect(d->windowMapper, SIGNAL(mapped(QWidget*)), this, \
SLOT(setActiveSubWindow(QWidget*))); @@ -726,6 +738,16 @@ void \
KisMainWindow::saveRecentFiles() }
}
+QList<QUrl> KisMainWindow::recentFilesUrls()
+{
+ return d->recentFiles->urls();
+}
+
+void KisMainWindow::clearRecentFiles()
+{
+ d->recentFiles->clear();
+}
+
void KisMainWindow::reloadRecentFileList()
{
d->recentFiles->loadEntries(KSharedConfig::openConfig()->group("RecentFiles"));
@@ -879,6 +901,8 @@ void KisMainWindow::showDocument(KisDocument *document) {
KisView* KisMainWindow::addViewAndNotifyLoadingCompleted(KisDocument *document)
{
+ showWelcomeScreen(false); // see workaround in function header
+
KisView *view = KisPart::instance()->createView(document, resourceManager(), \
actionCollection(), this); addView(view);
@@ -1386,6 +1410,12 @@ void KisMainWindow::switchTab(int index)
tabBar->setCurrentIndex(index);
}
+void KisMainWindow::showWelcomeScreen(bool show)
+{
+ d->widgetStack->setCurrentIndex(!show);
+}
+
+
void KisMainWindow::slotFileNew()
{
const QStringList mimeFilter = \
KisImportExportManager::supportedMimeTypes(KisImportExportManager::Import); @@ \
-2222,6 +2252,28 @@ void KisMainWindow::updateWindowMenu() }
}
+ bool showMdiArea = windows.count( ) > 0;
+ if (!showMdiArea) {
+ showWelcomeScreen(true); // see workaround in function in header
+
+ // keep the recent file list updated when going back to welcome screen
+ reloadRecentFileList();
+ d->welcomePage->populateRecentDocuments();
+ }
+
+ // enable/disable the toolbox docker if there are no documents open
+ Q_FOREACH (QObject* widget, children()) {
+ if (widget->inherits("QDockWidget")) {
+ QDockWidget* dw = static_cast<QDockWidget*>(widget);
+
+ if ( dw->objectName() == "ToolBox") {
+ dw->setEnabled(showMdiArea);
+ }
+ }
+ }
+
+
+
updateCaption();
}
diff --git a/libs/ui/KisMainWindow.h b/libs/ui/KisMainWindow.h
index 3ad3960930a..7da391636ad 100644
--- a/libs/ui/KisMainWindow.h
+++ b/libs/ui/KisMainWindow.h
@@ -107,6 +107,17 @@ public:
*/
void addRecentURL(const QUrl &url);
+ /**
+ * get list of URL strings for recent files
+ */
+ QList<QUrl> recentFilesUrls();
+
+ /**
+ * clears the list of the recent files
+ */
+ void clearRecentFiles();
+
+
/**
* Load the desired document and show it.
* @param url the URL to open
@@ -120,6 +131,16 @@ public:
*/
void showDocument(KisDocument *document);
+ /**
+ * Toggles between showing the welcome screen and the MDI area
+ *
+ * hack: There seems to be a bug that prevents events happening to the MDI area \
if it + * isn't actively displayed (set in the widgetStack). This can cause \
things like the title bar + * not to update correctly Before doing any actions \
related to opening or creating documents, + * make sure to switch this first to \
make sure everything can communicate to the MDI area correctly + */
+ void showWelcomeScreen(bool show);
+
/**
* Saves the document, asking for a filename if necessary.
*
@@ -405,6 +426,11 @@ public Q_SLOTS:
void windowFocused();
+ /**
+ * Reloads the recent documents list.
+ */
+ void reloadRecentFileList();
+
private:
friend class KisApplication;
@@ -421,11 +447,6 @@ private:
bool openDocumentInternal(const QUrl &url, KisMainWindow::OpenFlags flags = 0);
- /**
- * Reloads the recent documents list.
- */
- void reloadRecentFileList();
-
/**
* Updates the window caption based on the document info and path.
*/
diff --git a/libs/ui/KisMultiFeedRSSModel.cpp b/libs/ui/KisMultiFeedRSSModel.cpp
index 11028fdefe5..20c93ef791c 100644
--- a/libs/ui/KisMultiFeedRSSModel.cpp
+++ b/libs/ui/KisMultiFeedRSSModel.cpp
@@ -197,7 +197,12 @@ QVariant MultiFeedRssModel::data(const QModelIndex &index, int \
role) const RssItem item = m_aggregatedFeed.at(index.row());
switch (role) {
- case Qt::DisplayRole: // fall through
+ case Qt::DisplayRole:
+ {
+ return QString("<b><big>" + item.title + "</big></b>"
+ "<p><small>" + item.pubDate.toString("dd-MM-yyyy hh:mm") + \
"</small></p>" + "<p>" + item.description + "</p><hr>");
+ }
case TitleRole:
return item.title;
case DescriptionRole:
diff --git a/libs/ui/KisMultiFeedRSSModel.h b/libs/ui/KisMultiFeedRSSModel.h
index c87773e46a0..613d9a49fce 100644
--- a/libs/ui/KisMultiFeedRSSModel.h
+++ b/libs/ui/KisMultiFeedRSSModel.h
@@ -68,7 +68,7 @@ class KRITAUI_EXPORT MultiFeedRssModel : public QAbstractListModel
public:
explicit MultiFeedRssModel(QObject *parent = 0);
~MultiFeedRssModel() override;
- QHash<int, QByteArray> roleNames() const;
+ QHash<int, QByteArray> roleNames() const override;
void addFeed(const QString& feed);
void removeFeed(const QString& feed);
diff --git a/libs/ui/forms/KisNewsPage.ui b/libs/ui/forms/KisNewsPage.ui
new file mode 100644
index 00000000000..8b061cee318
--- /dev/null
+++ b/libs/ui/forms/KisNewsPage.ui
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>KisNewsPage</class>
+ <widget class="QWidget" name="KisNewsPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="chkShowNews">
+ <property name="toolTip">
+ <string>Show news about Krita: this needs internet to retrieve information \
from the krita.org website</string> + </property>
+ <property name="text">
+ <string>Show News about Krita</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListView" name="listNews"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/libs/ui/forms/KisWelcomePage.ui b/libs/ui/forms/KisWelcomePage.ui
new file mode 100644
index 00000000000..0d2214d990a
--- /dev/null
+++ b/libs/ui/forms/KisWelcomePage.ui
@@ -0,0 +1,775 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>KisWelcomePage</class>
+ <widget class="QWidget" name="KisWelcomePage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1061</width>
+ <height>538</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <widget class="QFrame" name="dropFrameBorder">
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="lineWidth">
+ <number>4</number>
+ </property>
+ <property name="midLineWidth">
+ <number>0</number>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="2">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0">
+ <spacer name="horizontalSpacer_11">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>20</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="startTitleLabel">
+ <property name="font">
+ <font>
+ <pointsize>18</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Start</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="newFileLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>New File</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="newFileLinkShortcut">
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <underline>false</underline>
+ </font>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>30</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="openFileLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Open File</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="openFileShortcut">
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <underline>false</underline>
+ </font>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <widget class="QLabel" name="recentDocumentsLabel">
+ <property name="font">
+ <font>
+ <pointsize>18</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Recent Documents</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearRecentFilesLink">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_12">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QListView" name="recentDocumentsListView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>300</width>
+ <height>250</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <property name="autoScroll">
+ <bool>false</bool>
+ </property>
+ <property name="showDropIndicator" stdset="0">
+ <bool>false</bool>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectItems</enum>
+ </property>
+ <property name="movement">
+ <enum>QListView::Snap</enum>
+ </property>
+ <property name="resizeMode">
+ <enum>QListView::Fixed</enum>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="viewMode">
+ <enum>QListView::ListMode</enum>
+ </property>
+ <property name="uniformItemSizes">
+ <bool>true</bool>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="2">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>30</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="helpTitleLabel">
+ <property name="font">
+ <font>
+ <pointsize>18</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Community</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="manualLink">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>User Manual</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="gettingStartedLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Getting Started</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QPushButton" name="supportKritaLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Support Krita</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QPushButton" name="userCommunityLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>User Community</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QPushButton" name="kritaWebsiteLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Krita Website</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="sourceCodeLink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Source Code</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_8">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <property name="bottomMargin">
+ <number>20</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="poweredByKDELink">
+ <property name="font">
+ <font>
+ <underline>true</underline>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Powered by KDE</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_13">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <widget class="QLabel" name="dragImageHereLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="lineWidth">
+ <number>2</number>
+ </property>
+ <property name="text">
+ <string>Drag Image in window to open</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="margin">
+ <number>30</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_10">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="3">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLabel" name="helpTitleLabel_2">
+ <property name="font">
+ <font>
+ <pointsize>18</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>News</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KisNewsWidget" name="newsWidget" native="true"/>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="4">
+ <spacer name="horizontalSpacer_9">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="1">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KisNewsWidget</class>
+ <extends>QWidget</extends>
+ <header>widgets/KisNewsWidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/libs/ui/widgets/KisNewsWidget.cpp b/libs/ui/widgets/KisNewsWidget.cpp
new file mode 100644
index 00000000000..812f1afdb0d
--- /dev/null
+++ b/libs/ui/widgets/KisNewsWidget.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2018 boud <boud@valdyas.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#include "KisNewsWidget.h"
+
+#include <QDesktopServices>
+#include <QUrl>
+#include <QPainter>
+#include <QStyleOptionViewItem>
+#include <QModelIndex>
+#include <QTextDocument>
+#include <QAbstractTextDocumentLayout>
+
+#include "kis_config.h"
+#include "KisMultiFeedRSSModel.h"
+
+
+KisNewsDelegate::KisNewsDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+ qDebug() << "Delegate created";
+}
+
+void KisNewsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, \
const QModelIndex &index) const +{
+ painter->save();
+
+ QStyleOptionViewItem optionCopy = option;
+ initStyleOption(&optionCopy, index);
+
+ QStyle *style = optionCopy.widget? optionCopy.widget->style() : \
QApplication::style(); +
+ QTextDocument doc;
+ doc.setHtml(optionCopy.text);
+
+ /// Painting item without text
+ optionCopy.text = QString();
+ style->drawControl(QStyle::CE_ItemViewItem, &optionCopy, painter);
+
+ QAbstractTextDocumentLayout::PaintContext ctx;
+
+ // Highlighting text if item is selected
+ if (optionCopy.state & QStyle::State_Selected) {
+ ctx.palette.setColor(QPalette::Text, \
optionCopy.palette.color(QPalette::Active, QPalette::HighlightedText)); + }
+
+ painter->translate(optionCopy.rect.left(), optionCopy.rect.top());
+ QRect clip(0, 0, optionCopy.rect.width(), optionCopy.rect.height());
+ doc.setPageSize(clip.size());
+ doc.drawContents(painter, clip);
+ painter->restore();
+}
+
+QSize KisNewsDelegate::sizeHint(const QStyleOptionViewItem &option, const \
QModelIndex &index) const +{
+ QStyleOptionViewItem optionCopy = option;
+ initStyleOption(&optionCopy, index);
+
+ QTextDocument doc;
+ doc.setHtml(optionCopy.text);
+ doc.setTextWidth(optionCopy.rect.width());
+ return QSize(doc.idealWidth(), doc.size().height());
+}
+
+KisNewsWidget::KisNewsWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+ KisConfig cfg;
+ m_getNews = cfg.readEntry<bool>("FetchNews", false);
+ chkShowNews->setChecked(m_getNews);
+ connect(chkShowNews, SIGNAL(toggled(bool)), this, SLOT(toggleNews(bool)));
+ m_rssModel = new MultiFeedRssModel(this);
+
+ if (m_getNews) {
+ m_rssModel->addFeed(QLatin1String("https://krita.org/en/feed/"));
+ }
+ else {
+ m_rssModel->removeFeed(QLatin1String("https://krita.org/en/feed/"));
+ }
+
+ listNews->setModel(m_rssModel);
+ listNews->setItemDelegate(new KisNewsDelegate(listNews));
+ connect(listNews, SIGNAL(clicked(const QModelIndex&)), this, \
SLOT(itemSelected(const QModelIndex&))); +}
+
+void KisNewsWidget::toggleNews(bool toggle)
+{
+ KisConfig cfg;
+ cfg.writeEntry<bool>("FetchNews", toggle);
+ m_getNews = toggle;
+
+ if (m_getNews) {
+ m_rssModel->addFeed(QLatin1String("https://krita.org/en/feed/"));
+ }
+ else {
+ m_rssModel->removeFeed(QLatin1String("https://krita.org/en/feed/"));
+ }
+}
+
+void KisNewsWidget::itemSelected(const QModelIndex &idx)
+{
+ if (idx.isValid()) {
+ QString link = idx.data(RssRoles::LinkRole).toString();
+ QDesktopServices::openUrl(QUrl(link));
+ }
+}
diff --git a/libs/ui/widgets/KisNewsWidget.h b/libs/ui/widgets/KisNewsWidget.h
new file mode 100644
index 00000000000..acb3e66b3ae
--- /dev/null
+++ b/libs/ui/widgets/KisNewsWidget.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018 boud <boud@valdyas.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#ifndef KISNEWSWIDGET_H
+#define KISNEWSWIDGET_H
+
+#include <QWidget>
+#include <QListView>
+#include <QStyledItemDelegate>
+
+#include <ui_KisNewsPage.h>
+
+class MultiFeedRssModel;
+
+class KisNewsDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+ KisNewsDelegate(QObject *parent = 0);
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const \
QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem \
&option, const QModelIndex &index) const override; +};
+
+/**
+ * @brief The KisNewsWidget class shows the latest news from Krita.org
+ */
+class KisNewsWidget : public QWidget, public Ui::KisNewsPage
+{
+ Q_OBJECT
+public:
+ explicit KisNewsWidget(QWidget *parent = nullptr);
+private Q_SLOTS:
+ void toggleNews(bool toggle);
+ void itemSelected(const QModelIndex &idx);
+private:
+ bool m_getNews {false};
+ MultiFeedRssModel *m_rssModel {0};
+};
+
+#endif // KISNEWSWIDGET_H
diff --git a/libs/ui/widgets/KisWelcomePageWidget.cpp \
b/libs/ui/widgets/KisWelcomePageWidget.cpp new file mode 100644
index 00000000000..fa4b6316ec6
--- /dev/null
+++ b/libs/ui/widgets/KisWelcomePageWidget.cpp
@@ -0,0 +1,278 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2018 Scott Petrovic <scottpetrovic@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "KisWelcomePageWidget.h"
+#include <QDebug>
+#include <QDesktopServices>
+#include "kis_action_manager.h"
+#include "kactioncollection.h"
+#include "kis_action.h"
+
+#include "KConfigGroup"
+#include "KSharedConfig"
+
+#include <QListWidget>
+#include <QListWidgetItem>
+#include "kis_icon_utils.h"
+#include "krita_utils.h"
+#include "KoStore.h"
+
+
+KisWelcomePageWidget::KisWelcomePageWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ recentDocumentsListView->viewport()->setAutoFillBackground(false);
+ recentDocumentsListView->setSpacing(2);
+}
+
+KisWelcomePageWidget::~KisWelcomePageWidget()
+{
+}
+
+void KisWelcomePageWidget::setMainWindow(KisMainWindow* mainWin)
+{
+ if (mainWin) {
+ mainWindow = mainWin;
+
+
+ // set the shortcut links from actions (only if a shortcut exists)
+ if ( mainWin->viewManager()->actionManager()->actionByName("file_new")->shortcut().toString() \
!= "") { + newFileLinkShortcut->setText(QString("(") + \
mainWin->viewManager()->actionManager()->actionByName("file_new")->shortcut().toString() \
+ QString(")")); + }
+
+ if (mainWin->viewManager()->actionManager()->actionByName("file_open")->shortcut().toString() \
!= "") { + openFileShortcut->setText(QString("(") + \
mainWin->viewManager()->actionManager()->actionByName("file_open")->shortcut().toString() \
+ QString(")")); + }
+
+
+ populateRecentDocuments();
+ connect(recentDocumentsListView, SIGNAL(clicked(QModelIndex)), this, \
SLOT(recentDocumentClicked(QModelIndex))); +
+
+ // we need the view manager to actually call actions, so don't create the \
connections + // until after the view manager is set
+ connect(newFileLink, SIGNAL(clicked(bool)), this, \
SLOT(slotNewFileClicked())); + connect(openFileLink, SIGNAL(clicked(bool)), \
this, SLOT(slotOpenFileClicked())); +
+ // URL link connections
+ connect(manualLink, SIGNAL(clicked(bool)), this, SLOT(slotGoToManual()));
+
+ connect(gettingStartedLink, SIGNAL(clicked(bool)), this, \
SLOT(slotGettingStarted())); + connect(supportKritaLink, \
SIGNAL(clicked(bool)), this, SLOT(slotSupportKrita())); + \
connect(userCommunityLink, SIGNAL(clicked(bool)), this, SLOT(slotUserCommunity())); + \
connect(kritaWebsiteLink, SIGNAL(clicked(bool)), this, SLOT(slotKritaWebsite())); + \
connect(sourceCodeLink, SIGNAL(clicked(bool)), this, SLOT(slotSourceCode())); + \
connect(clearRecentFilesLink, SIGNAL(clicked(bool)), this, \
SLOT(slotClearRecentFiles())); + connect(poweredByKDELink, \
SIGNAL(clicked(bool)), this, SLOT(slotKDESiteLink())); +
+
+ slotUpdateThemeColors();
+ }
+}
+
+void KisWelcomePageWidget::showDropAreaIndicator(bool show)
+{
+ if (!show) {
+ QString dropFrameStyle = "QFrame#dropAreaIndicator { border: 0px }";
+ dropFrameBorder->setStyleSheet(dropFrameStyle);
+ } else {
+ QColor textColor = qApp->palette().color(QPalette::Text);
+ QColor backgroundColor = qApp->palette().color(QPalette::Background);
+ QColor blendedColor = KritaUtils::blendColors(textColor, backgroundColor, \
0.8); +
+ // QColor.name() turns it into a hex/web format
+ QString dropFrameStyle = QString("QFrame#dropAreaIndicator { border: 2px \
dotted ").append(blendedColor.name()).append(" }") ; + \
dropFrameBorder->setStyleSheet(dropFrameStyle); + }
+}
+
+void KisWelcomePageWidget::slotUpdateThemeColors()
+{
+
+ QColor textColor = qApp->palette().color(QPalette::Text);
+ QColor backgroundColor = qApp->palette().color(QPalette::Background);
+
+ // make the welcome screen labels a subtle color so it doesn't clash with the \
main UI elements + QColor blendedColor = KritaUtils::blendColors(textColor, \
backgroundColor, 0.8); + QString blendedStyle = QString("color: \
").append(blendedColor.name()); +
+
+ // what labels to change the color...
+ startTitleLabel->setStyleSheet(blendedStyle);
+ recentDocumentsLabel->setStyleSheet(blendedStyle);
+ helpTitleLabel->setStyleSheet(blendedStyle);
+ manualLink->setStyleSheet(blendedStyle);
+ gettingStartedLink->setStyleSheet(blendedStyle);
+ supportKritaLink->setStyleSheet(blendedStyle);
+ userCommunityLink->setStyleSheet(blendedStyle);
+ kritaWebsiteLink->setStyleSheet(blendedStyle);
+ sourceCodeLink->setStyleSheet(blendedStyle);
+ newFileLinkShortcut->setStyleSheet(blendedStyle);
+ openFileShortcut->setStyleSheet(blendedStyle);
+ clearRecentFilesLink->setStyleSheet(blendedStyle);
+ poweredByKDELink->setStyleSheet(blendedStyle);
+ recentDocumentsListView->setStyleSheet(blendedStyle);
+
+ newFileLink->setStyleSheet(blendedStyle);
+ openFileLink->setStyleSheet(blendedStyle);
+
+
+ // giving the drag area messaging a dotted border
+ QString dottedBorderStyle = QString("border: 2px dotted \
").append(blendedColor.name()).append("; color:").append(blendedColor.name()).append( \
";"); + dragImageHereLabel->setStyleSheet(dottedBorderStyle);
+
+
+ // make drop area QFrame have a dotted line
+ dropFrameBorder->setObjectName("dropAreaIndicator");
+ QString dropFrameStyle = QString("QFrame#dropAreaIndicator { border: 4px dotted \
").append(blendedColor.name()).append("}"); + \
dropFrameBorder->setStyleSheet(dropFrameStyle); +
+ // only show drop area when we have a document over the empty area
+ showDropAreaIndicator(false);
+
+ // add icons for new and open settings to make them stand out a bit more
+ openFileLink->setIconSize(QSize(30, 30));
+ newFileLink->setIconSize(QSize(30, 30));
+ openFileLink->setIcon(KisIconUtils::loadIcon("document-open"));
+ newFileLink->setIcon(KisIconUtils::loadIcon("document-new"));
+
+ // needed for updating icon color for files that don't have a preview
+ if (mainWindow) {
+ populateRecentDocuments();
+ }
+}
+
+void KisWelcomePageWidget::populateRecentDocuments()
+{
+ // grab recent files data
+ recentFilesModel = new QStandardItemModel();
+ int recentDocumentsIterator = mainWindow->recentFilesUrls().length() > 5 ? 5 : \
mainWindow->recentFilesUrls().length(); // grab at most 5 +
+ for (int i = 0; i < recentDocumentsIterator; i++ ) {
+
+ QStandardItem *recentItem = new QStandardItem(1,2); // 1 row, 1 column
+ QString recentFileUrlPath = mainWindow->recentFilesUrls().at(i).toString();
+ QString fileName = recentFileUrlPath.split("/").last();
+
+
+ // get thumbnail -- almost all Krita-supported formats save a thumbnail
+ // this was mostly copied from the KisAutoSaveRecovery file
+ QScopedPointer<KoStore> store(KoStore::createStore(QUrl(recentFileUrlPath), \
KoStore::Read)); +
+ if (store) {
+ if (store->open(QString("Thumbnails/thumbnail.png"))
+ || store->open(QString("preview.png"))) {
+
+ QByteArray bytes = store->read(store->size());
+ store->close();
+ QImage img;
+ img.loadFromData(bytes);
+ recentItem->setIcon(QIcon(QPixmap::fromImage(img)));
+
+ }
+ else {
+ recentItem->setIcon(KisIconUtils::loadIcon("document-export"));
+ }
+
+ }
+ else {
+ recentItem->setIcon(KisIconUtils::loadIcon("document-export"));
+ }
+
+
+ // set the recent object with the data
+ recentItem->setText(fileName); // what to display for the item
+ recentItem->setToolTip(recentFileUrlPath);
+ recentFilesModel->appendRow(recentItem);
+
+
+ }
+
+
+ // hide clear and Recent files title if there are none
+ bool hasRecentFiles = mainWindow->recentFilesUrls().length() > 0;
+ recentDocumentsLabel->setVisible(hasRecentFiles);
+ clearRecentFilesLink->setVisible(hasRecentFiles);
+
+
+ recentDocumentsListView->setIconSize(QSize(40, 40));
+ recentDocumentsListView->setModel(recentFilesModel);
+}
+
+
+void KisWelcomePageWidget::recentDocumentClicked(QModelIndex index)
+{
+ QString fileUrl = index.data(Qt::ToolTipRole).toString();
+ mainWindow->openDocument(QUrl(fileUrl), KisMainWindow::None );
+}
+
+
+void KisWelcomePageWidget::slotNewFileClicked()
+{
+ mainWindow->slotFileNew();
+}
+
+void KisWelcomePageWidget::slotOpenFileClicked()
+{
+ mainWindow->slotFileOpen();
+}
+
+void KisWelcomePageWidget::slotClearRecentFiles()
+{
+ mainWindow->clearRecentFiles();
+ mainWindow->reloadRecentFileList();
+ populateRecentDocuments();
+}
+
+void KisWelcomePageWidget::slotGoToManual()
+{
+ QDesktopServices::openUrl(QUrl("https://docs.krita.org"));
+}
+
+void KisWelcomePageWidget::slotGettingStarted()
+{
+ QDesktopServices::openUrl(QUrl("https://docs.krita.org/en/user_manual/getting_started.html"));
+}
+
+void KisWelcomePageWidget::slotSupportKrita()
+{
+ QDesktopServices::openUrl(QUrl("https://krita.org/en/support-us/donations/"));
+}
+
+void KisWelcomePageWidget::slotUserCommunity()
+{
+ QDesktopServices::openUrl(QUrl("https://forum.kde.org/viewforum.php?f=136"));
+}
+
+void KisWelcomePageWidget::slotKritaWebsite()
+{
+ QDesktopServices::openUrl(QUrl("https://www.krita.org"));
+}
+
+void KisWelcomePageWidget::slotSourceCode()
+{
+ QDesktopServices::openUrl(QUrl("https://phabricator.kde.org/source/krita/"));
+}
+
+void KisWelcomePageWidget::slotKDESiteLink()
+{
+ QDesktopServices::openUrl(QUrl("https://userbase.kde.org/What_is_KDE"));
+}
diff --git a/libs/ui/widgets/KisWelcomePageWidget.h \
b/libs/ui/widgets/KisWelcomePageWidget.h new file mode 100644
index 00000000000..1e4d33e48b4
--- /dev/null
+++ b/libs/ui/widgets/KisWelcomePageWidget.h
@@ -0,0 +1,77 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2018 Scott Petrovic <scottpetrovic@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KISWELCOMEPAGEWIDGET_H
+#define KISWELCOMEPAGEWIDGET_H
+
+#include "kritaui_export.h"
+#include "KisViewManager.h"
+#include "KisMainWindow.h"
+
+#include <QWidget>
+#include "ui_KisWelcomePage.h"
+#include <QStandardItemModel>
+
+/// A widget for diplaying if no documents are open. This will display in the MDI \
area +class KRITAUI_EXPORT KisWelcomePageWidget : public QWidget, public \
Ui::KisWelcomePage +{
+ Q_OBJECT
+
+ public:
+ explicit KisWelcomePageWidget(QWidget *parent);
+ ~KisWelcomePageWidget() override;
+
+ void setMainWindow(KisMainWindow* mainWindow);
+
+public Q_SLOTS:
+ /// 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
+ void showDropAreaIndicator(bool show);
+
+ void slotUpdateThemeColors();
+
+ /// this could be called multiple times. If a recent document doesn't
+ /// have a preview, an icon is used that needs to be updated
+ void populateRecentDocuments();
+
+
+private:
+ KisMainWindow* mainWindow;
+ QStandardItemModel *recentFilesModel;
+
+private Q_SLOTS:
+ void slotNewFileClicked();
+ void slotOpenFileClicked();
+ void slotClearRecentFiles();
+
+ void recentDocumentClicked(QModelIndex index);
+
+ /// go to URL links
+ void slotGoToManual();
+
+ void slotGettingStarted();
+ void slotSupportKrita();
+ void slotUserCommunity();
+ void slotKritaWebsite();
+ void slotSourceCode();
+ void slotKDESiteLink();
+
+};
+
+#endif // KISWELCOMEPAGEWIDGET_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic