Skip to content

Commit 91ea9ed

Browse files
committedMay 27, 2019
Hide recent projects if empty
1 parent e27cca5 commit 91ea9ed

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
 

‎src/app/qgswelcomepage.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
5656
centerLayout->setMargin( 0 );
5757

5858
int titleSize = static_cast<int>( QApplication::fontMetrics().height() * 1.4 );
59-
QLabel *recentProjectsTitle = new QLabel( QStringLiteral( "<div style='font-size:%1px;font-weight:bold'>%2</div>" ).arg( QString::number( titleSize ), tr( "Recent Projects" ) ) );
60-
recentProjectsTitle->setContentsMargins( titleSize / 2, titleSize / 6, 0, 0 );
61-
centerLayout->addWidget( recentProjectsTitle, 0, 0 );
59+
mRecentProjectsTitle = new QLabel( QStringLiteral( "<div style='font-size:%1px;font-weight:bold'>%2</div>" ).arg( QString::number( titleSize ), tr( "Recent Projects" ) ) );
60+
mRecentProjectsTitle->setContentsMargins( titleSize / 2, titleSize / 6, 0, 0 );
61+
centerLayout->addWidget( mRecentProjectsTitle, 0, 0 );
6262

6363
mRecentProjectsListView = new QListView();
6464
mRecentProjectsListView->setResizeMode( QListView::Adjust );
@@ -121,6 +121,7 @@ QgsWelcomePage::~QgsWelcomePage()
121121
void QgsWelcomePage::setRecentProjects( const QList<QgsRecentProjectItemsModel::RecentProjectData> &recentProjects )
122122
{
123123
mRecentProjectsModel->setRecentProjects( recentProjects );
124+
updateRecentProjectsVisibility();
124125
}
125126

126127
void QgsWelcomePage::recentProjectItemActivated( const QModelIndex &index )
@@ -255,3 +256,10 @@ void QgsWelcomePage::showContextMenuForTemplates( QPoint point )
255256

256257
menu->popup( mTemplateProjectsListView->mapToGlobal( point ) );
257258
}
259+
260+
void QgsWelcomePage::updateRecentProjectsVisibility()
261+
{
262+
bool visible = mRecentProjectsModel->rowCount() > 0;
263+
mRecentProjectsListView->setVisible( visible );
264+
mRecentProjectsTitle->setVisible( visible );
265+
}

‎src/app/qgswelcomepage.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
class QgsVersionInfo;
2727
class QListView;
28+
class QLabel;
2829

2930
class QgsWelcomePage : public QWidget
3031
{
@@ -50,10 +51,13 @@ class QgsWelcomePage : public QWidget
5051
void showContextMenuForTemplates( QPoint point );
5152

5253
private:
54+
void updateRecentProjectsVisibility();
55+
5356
QgsRecentProjectItemsModel *mRecentProjectsModel = nullptr;
5457
QTextBrowser *mVersionInformation = nullptr;
5558
QgsVersionInfo *mVersionInfo = nullptr;
5659
QListView *mRecentProjectsListView = nullptr;
60+
QLabel *mRecentProjectsTitle = nullptr;
5761
QListView *mTemplateProjectsListView = nullptr;
5862
QStandardItemModel *mTemplateProjectsModel = nullptr;
5963
};

0 commit comments

Comments
 (0)
Please sign in to comment.