Commit 3ddf2b6e authored by Scott Petrovic's avatar Scott Petrovic

Start hooking up UI for version update message

parent 5cad27a8
......@@ -85,8 +85,15 @@ KisWelcomePageWidget::KisWelcomePageWidget(QWidget *parent)
kdeIcon->setIcon(KisIconUtils::loadIcon(QStringLiteral("kde")).pixmap(20));
versionNotificationLabel->setTextFormat(Qt::RichText);
versionNotificationLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
versionNotificationLabel->setOpenExternalLinks(true);
connect(chkShowNews, SIGNAL(toggled(bool)), newsWidget, SLOT(toggleNews(bool)));
connect(newsWidget, SIGNAL(newsDataChanged()), this, SLOT(slotUpdateVersionMessage()));
// configure the News area
KisConfig cfg(true);
bool m_getNews = cfg.readEntry<bool>("FetchNews", false);
......@@ -146,12 +153,12 @@ void KisWelcomePageWidget::showDropAreaIndicator(bool show)
void KisWelcomePageWidget::slotUpdateThemeColors()
{
QColor textColor = qApp->palette().color(QPalette::Text);
QColor backgroundColor = qApp->palette().color(QPalette::Background);
textColor = qApp->palette().color(QPalette::Text);
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());
blendedColor = KritaUtils::blendColors(textColor, backgroundColor, 0.8);
blendedStyle = QString("color: ").append(blendedColor.name());
// what labels to change the color...
......@@ -211,6 +218,10 @@ void KisWelcomePageWidget::slotUpdateThemeColors()
poweredByKDELink->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://userbase.kde.org/What_is_KDE?" + analyticsString + "what-is-kde" + "\">")
.append(i18n("Powered by KDE")).append("</a>"));
slotUpdateVersionMessage(); // text set from RSS feed
// re-populate recent files since they might have themed icons
populateRecentDocuments();
......@@ -299,6 +310,30 @@ void KisWelcomePageWidget::populateRecentDocuments()
recentDocumentsListView->setModel(&m_recentFilesModel);
}
void KisWelcomePageWidget::slotUpdateVersionMessage()
{
// find out if we need an update...or if this is a development version
// TODO: show app version if dev version. Show version number available and provide link
QString versionText = "";
if (newsWidget->isDevelopmentBuild()) {
versionText = i18n("DEV BUILD");
versionNotificationLabel->setVisible(true);
} else if (newsWidget->hasUpdateAvailable()) {
versionText = i18n("New Update Available");
versionNotificationLabel->setVisible(true);
} else {
versionNotificationLabel->setVisible(false);
return;
}
if (!blendedStyle.isNull()) {
versionNotificationLabel->setStyleSheet(blendedStyle);
}
versionNotificationLabel->setText(QString("<a style=\"color: " + blendedColor.name() + " \" href=\"https://userbase.kde.org/What_is_KDE?" + analyticsString + "what-is-kde" + "\">")
.append(versionText).append("</a>"));
}
void KisWelcomePageWidget::dragEnterEvent(QDragEnterEvent *event)
{
//qDebug() << "dragEnterEvent formats" << event->mimeData()->formats() << "urls" << event->mimeData()->urls() << "has images" << event->mimeData()->hasImage();
......
......@@ -50,6 +50,8 @@ public Q_SLOTS:
/// have a preview, an icon is used that needs to be updated
void populateRecentDocuments();
void slotUpdateVersionMessage();
protected:
// QWidget overrides
......@@ -73,6 +75,13 @@ private:
const QString analyticsString = "pk_campaign=startup-sceen&pk_kwd=";
// keeping track of link colors with theme change
QColor textColor;
QColor backgroundColor;
QColor blendedColor;
QString blendedStyle;
private Q_SLOTS:
void slotNewFileClicked();
void slotOpenFileClicked();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>858</width>
<height>493</height>
<width>788</width>
<height>476</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -19,7 +19,7 @@
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QFrame" name="dropFrameBorder">
<property name="frameShape">
......@@ -434,16 +434,63 @@
<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>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="startTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="versionNotificationLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>Krita X.X.X Update Available</string>
</property>
<property name="indent">
<number>10</number>
</property>
<property name="openExternalLinks">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_14">
<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">
......@@ -741,7 +788,7 @@
<string>Show news about Krita: this needs internet to retrieve information from the krita.org website</string>
</property>
<property name="text">
<string>Enabled</string>
<string>Check for updates</string>
</property>
</widget>
</item>
......
......@@ -97,6 +97,16 @@ void KisNewsWidget::setAnalyticsTracking(QString text)
analyticsTrackingParameters = text;
}
bool KisNewsWidget::isDevelopmentBuild()
{
return isDevelopmentVersion;
}
bool KisNewsWidget::hasUpdateAvailable()
{
return needsVersionUpdate;
}
void KisNewsWidget::toggleNews(bool toggle)
{
KisConfig cfg(false);
......@@ -152,9 +162,8 @@ void KisNewsWidget::rssDataChanged()
QString linkTitle = idx.data(RssRoles::TitleRole).toString();
// come up with a regex pattern to find version number
// regex to capture version number
QRegularExpression versionRegex("\\d\\.\\d\\.?\\d?\\.?\\d");
QRegularExpressionMatch matched = versionRegex.match(linkTitle);
// only take the top match for release version since that is the newest
......@@ -169,6 +178,8 @@ void KisNewsWidget::rssDataChanged()
// see if we need to update our version, or we are on a dev version
calculateVersionUpdateStatus();
emit newsDataChanged();
}
void KisNewsWidget::calculateVersionUpdateStatus()
......
......@@ -46,6 +46,12 @@ public:
void setAnalyticsTracking(QString text);
bool isDevelopmentBuild();
bool hasUpdateAvailable();
Q_SIGNALS:
void newsDataChanged();
private Q_SLOTS:
void toggleNews(bool toggle);
void itemSelected(const QModelIndex &idx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment