mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Welcome Windows on top of map canvas
This commit is contained in:
parent
831131d5e1
commit
b3a868fee4
@ -51,7 +51,7 @@ SET(QGIS_APP_SRCS
|
||||
qgssavestyletodbdialog.cpp
|
||||
qgsguivectorlayertools.cpp
|
||||
qgswelcomepageitemsmodel.cpp
|
||||
qgswelcomedialog.cpp
|
||||
qgswelcomepage.cpp
|
||||
|
||||
qgsmaptooladdfeature.cpp
|
||||
qgsmaptooladdpart.cpp
|
||||
@ -211,7 +211,7 @@ SET (QGIS_APP_MOC_HDRS
|
||||
qgsapplayertreeviewmenuprovider.h
|
||||
qgsguivectorlayertools.h
|
||||
qgswelcomepageitemsmodel.h
|
||||
qgswelcomedialog.h
|
||||
qgswelcomepage.h
|
||||
|
||||
qgsmaptooladdfeature.h
|
||||
qgsmaptoolcapture.h
|
||||
|
@ -211,7 +211,7 @@
|
||||
#include "qgsmessagelogviewer.h"
|
||||
#include "qgsdataitem.h"
|
||||
#include "qgsmaplayeractionregistry.h"
|
||||
#include "qgswelcomedialog.h"
|
||||
#include "qgswelcomepage.h"
|
||||
#include "qgsmaprendererparalleljob.h"
|
||||
|
||||
#include "qgssublayersdialog.h"
|
||||
@ -578,7 +578,16 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
||||
int myBlue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
|
||||
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
|
||||
|
||||
centralLayout->addWidget( mMapCanvas, 0, 0, 2, 1 );
|
||||
mWelcomePage = new QgsWelcomePage;
|
||||
|
||||
mCentralContainer = new QStackedWidget;
|
||||
mCentralContainer->insertWidget( 0, mMapCanvas );
|
||||
mCentralContainer->insertWidget( 1, mWelcomePage );
|
||||
|
||||
connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( showMapCanvas() ) );
|
||||
connect( this, SIGNAL( newProject() ), this, SLOT( showMapCanvas() ) );
|
||||
|
||||
centralLayout->addWidget( mCentralContainer, 0, 0, 2, 1 );
|
||||
|
||||
// a bar to warn the user with non-blocking messages
|
||||
mInfoBar = new QgsMessageBar( centralWidget );
|
||||
@ -864,6 +873,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
||||
|
||||
fileNewBlank(); // prepare empty project, also skips any default templates from loading
|
||||
|
||||
// Show the welcome page. Needs to be done after creating a new project because it gets hidden on new project
|
||||
mCentralContainer->setCurrentIndex( 1 );
|
||||
|
||||
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
|
||||
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
|
||||
QgsApplication::setFileOpenEventReceiver( this );
|
||||
@ -871,10 +883,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
||||
#ifdef ANDROID
|
||||
toggleFullScreen();
|
||||
#endif
|
||||
|
||||
QgsWelcomeDialog dlg;
|
||||
dlg.setRecentProjects( mRecentProjects );
|
||||
dlg.exec();
|
||||
} // QgisApp ctor
|
||||
|
||||
QgisApp::QgisApp()
|
||||
@ -2701,6 +2709,8 @@ void QgisApp::updateRecentProjectPaths()
|
||||
action->setEnabled( QFile::exists(( recentProject.path ) ) );
|
||||
action->setData( recentProject.path );
|
||||
}
|
||||
|
||||
mWelcomePage->setRecentProjects( mRecentProjects );
|
||||
} // QgisApp::updateRecentProjectPaths
|
||||
|
||||
// add this file to the recently opened/saved projects list
|
||||
@ -2718,16 +2728,24 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
|
||||
|
||||
if ( savePreviewImage )
|
||||
{
|
||||
QgsMapSettings mapSettings = mMapCanvas->mapSettings();
|
||||
mapSettings.setOutputSize( QSize( 200, 70 ) );
|
||||
QgsMapRendererParallelJob job( mapSettings );
|
||||
job.start();
|
||||
job.waitForFinished();
|
||||
// Generate a unique file name
|
||||
QString fileName( QCryptographicHash::hash( ( projectData.path.toUtf8() ), QCryptographicHash::Md5 ).toHex() );
|
||||
QString previewDir = QString( "%1/previewImages" ).arg( QgsApplication::qgisSettingsDirPath() );
|
||||
projectData.previewImagePath = QString( "%1/%2.png" ).arg( previewDir ).arg( fileName );
|
||||
QDir().mkdir( previewDir );
|
||||
job.renderedImage().save( projectData.previewImagePath );
|
||||
|
||||
// Render the map canvas
|
||||
QSize previewSize( 250, 177 ); // h = w / sqrt(2)
|
||||
QRect previewRect( QPoint( ( mMapCanvas->width() - previewSize.width() ) / 2
|
||||
, ( mMapCanvas->height() - previewSize.height() ) / 2 )
|
||||
, previewSize );
|
||||
|
||||
QPixmap previewImage( previewSize );
|
||||
QPainter previewPainter( &previewImage );
|
||||
mMapCanvas->render( &previewPainter, QRect( QPoint(), previewSize ), previewRect );
|
||||
|
||||
// Save
|
||||
previewImage.save( projectData.previewImagePath );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -9018,6 +9036,12 @@ void QgisApp::mapToolChanged( QgsMapTool *newTool, QgsMapTool *oldTool )
|
||||
}
|
||||
}
|
||||
|
||||
void QgisApp::showMapCanvas()
|
||||
{
|
||||
// Map layers changed -> switch to map canvas
|
||||
mCentralContainer->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
void QgisApp::extentsViewToggled( bool theFlag )
|
||||
{
|
||||
if ( theFlag )
|
||||
|
@ -42,12 +42,13 @@ class QgisAppStyleSheet;
|
||||
class QgsAnnotationItem;
|
||||
class QgsClipboard;
|
||||
class QgsComposer;
|
||||
class QgsComposerView;
|
||||
class QgsComposerManager;
|
||||
class QgsComposerView;
|
||||
class QgsContrastEnhancement;
|
||||
class QgsCustomLayerOrderWidget;
|
||||
class QgsGeometry;
|
||||
class QgsDoubleSpinBox;
|
||||
class QgsFeature;
|
||||
class QgsGeometry;
|
||||
class QgsLayerTreeMapCanvasBridge;
|
||||
class QgsLayerTreeView;
|
||||
class QgsMapCanvas;
|
||||
@ -65,7 +66,8 @@ class QgsUndoWidget;
|
||||
class QgsUserInputDockWidget;
|
||||
class QgsVectorLayer;
|
||||
class QgsVectorLayerTools;
|
||||
class QgsDoubleSpinBox;
|
||||
class QgsWelcomePage;
|
||||
|
||||
|
||||
class QDomDocument;
|
||||
class QNetworkReply;
|
||||
@ -1038,6 +1040,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
//! map tool changed
|
||||
void mapToolChanged( QgsMapTool *newTool, QgsMapTool *oldTool );
|
||||
|
||||
//! map layers changed
|
||||
void showMapCanvas();
|
||||
|
||||
/** Called when some layer's editing mode was toggled on/off */
|
||||
void layerEditStateChanged();
|
||||
|
||||
@ -1675,6 +1680,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
|
||||
QDateTime mProjectLastModified;
|
||||
|
||||
QgsWelcomePage* mWelcomePage;
|
||||
|
||||
QStackedWidget* mCentralContainer;
|
||||
#ifdef HAVE_TOUCH
|
||||
bool gestureEvent( QGestureEvent *event );
|
||||
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
|
||||
|
@ -13,7 +13,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgswelcomedialog.h"
|
||||
#include "qgswelcomepage.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgisapp.h"
|
||||
|
||||
@ -21,9 +21,11 @@
|
||||
#include <QListView>
|
||||
#include <QSettings>
|
||||
|
||||
QgsWelcomeDialog::QgsWelcomeDialog()
|
||||
QgsWelcomePage::QgsWelcomePage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setMargin( 9 );
|
||||
setLayout( layout );
|
||||
|
||||
QListView* welcomeScreenListView = new QListView();
|
||||
@ -33,27 +35,15 @@ QgsWelcomeDialog::QgsWelcomeDialog()
|
||||
|
||||
setWindowTitle( tr( "Recent Projects..." ) );
|
||||
|
||||
QSettings settings;
|
||||
restoreGeometry( settings.value( "/Windows/WelcomeDialog/geometry" ).toByteArray() );
|
||||
|
||||
connect( welcomeScreenListView, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( itemDoubleClicked( QModelIndex ) ) );
|
||||
}
|
||||
|
||||
void QgsWelcomeDialog::setRecentProjects(const QList<QgsWelcomePageItemsModel::RecentProjectData>& recentProjects)
|
||||
void QgsWelcomePage::setRecentProjects(const QList<QgsWelcomePageItemsModel::RecentProjectData>& recentProjects)
|
||||
{
|
||||
mModel->setRecentProjects( recentProjects );
|
||||
}
|
||||
|
||||
void QgsWelcomeDialog::itemDoubleClicked( const QModelIndex& index )
|
||||
void QgsWelcomePage::itemDoubleClicked( const QModelIndex& index )
|
||||
{
|
||||
QgisApp::instance()->openProject( mModel->data( index, Qt::ToolTipRole ).toString() );
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
void QgsWelcomeDialog::done( int result )
|
||||
{
|
||||
QDialog::done( result );
|
||||
QSettings settings;
|
||||
settings.setValue( "/Windows/WelcomeDialog/geometry", saveGeometry() );
|
||||
}
|
@ -16,16 +16,16 @@
|
||||
#ifndef QGSWELCOMEDIALOG_H
|
||||
#define QGSWELCOMEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
|
||||
#include "qgswelcomepageitemsmodel.h"
|
||||
|
||||
class QgsWelcomeDialog : public QDialog
|
||||
class QgsWelcomePage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QgsWelcomeDialog();
|
||||
QgsWelcomePage(QWidget* parent = 0);
|
||||
|
||||
void setRecentProjects( const QList<QgsWelcomePageItemsModel::RecentProjectData>& recentProjects );
|
||||
|
||||
@ -34,9 +34,6 @@ class QgsWelcomeDialog : public QDialog
|
||||
|
||||
private:
|
||||
QgsWelcomePageItemsModel* mModel;
|
||||
|
||||
public slots:
|
||||
void done( int result );
|
||||
};
|
||||
|
||||
#endif // QGSWELCOMEDIALOG_H
|
Loading…
x
Reference in New Issue
Block a user