Fix/improve visual look of new version notification

- Set a better background color (yellow feels like a negative warning)
- Set text color to black to play nice with themes
- Make the hyperlink clickable, we want people to update!
This commit is contained in:
Mathieu Pellerin 2019-01-18 09:05:21 +07:00
parent b43943a9b0
commit 4575547f65
2 changed files with 16 additions and 10 deletions

View File

@ -21,12 +21,14 @@
#include "qgssettings.h"
#include "qgsgui.h"
#include "qgsnative.h"
#include "qgsstringutils.h"
#include "qgsfileutils.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QListView>
#include <QDesktopServices>
#include <QTextBrowser>
QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
: QWidget( parent )
@ -67,7 +69,15 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
layout->addWidget( recentProjectsContainer );
mVersionInformation = new QLabel;
mVersionInformation = new QTextBrowser;
mVersionInformation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum );
mVersionInformation->setReadOnly( true );
mVersionInformation->setOpenExternalLinks( true );
mVersionInformation->setStyleSheet( "QTextEdit { background-color: #dff0d8; border: 1px solid #8e998a; padding-top: 0.25em; max-height: 1.75em; min-height: 1.75em; } "
"QScrollBar { background-color: rgba(0,0,0,0); } "
"QScrollBar::add-page,QScrollBar::sub-page,QScrollBar::handle { background-color: rgba(0,0,0,0); color: rgba(0,0,0,0); } "
"QScrollBar::up-arrow,QScrollBar::down-arrow { color: rgb(0,0,0); } " );
mainLayout->addWidget( mVersionInformation );
mVersionInformation->setVisible( false );
@ -105,13 +115,9 @@ void QgsWelcomePage::versionInfoReceived()
if ( versionInfo->newVersionAvailable() )
{
mVersionInformation->setVisible( true );
mVersionInformation->setText( QStringLiteral( "<b>%1</b>: %2" )
.arg( tr( "There is a new QGIS version available" ),
versionInfo->downloadInfo() ) );
mVersionInformation->setStyleSheet( "QLabel{"
" background-color: #dddd00;"
" padding: 5px;"
"}" );
mVersionInformation->setText( QStringLiteral( "<style> a, a:visited, a:hover { color:#268300; } </style><b>%1</b>: %2" )
.arg( tr( "New QGIS version available" ),
QgsStringUtils::insertLinks( versionInfo->downloadInfo() ) ) );
}
}

View File

@ -17,7 +17,7 @@
#define QGSWELCOMEDIALOG_H
#include <QWidget>
#include <QLabel>
#include <QTextBrowser>
#include "qgswelcomepageitemsmodel.h"
@ -47,7 +47,7 @@ class QgsWelcomePage : public QWidget
private:
QgsWelcomePageItemsModel *mModel = nullptr;
QLabel *mVersionInformation = nullptr;
QTextBrowser *mVersionInformation = nullptr;
QgsVersionInfo *mVersionInfo = nullptr;
QListView *mRecentProjectsListView = nullptr;
};