Skip to content
Permalink
Browse files

add screenshots of global options

  • Loading branch information
3nids committed Oct 4, 2018
1 parent 18f6562 commit 2240e1fcfacc0130310cd9c10645e552c36fd104
Showing with 66 additions and 17 deletions.
  1. +11 −5 src/app/qgisapp.cpp
  2. +6 −1 src/app/qgisapp.h
  3. +44 −8 src/app/qgsappscreenshots.cpp
  4. +4 −2 src/app/qgsappscreenshots.h
  5. +1 −1 src/app/qgsoptions.h
@@ -10282,19 +10282,25 @@ QMap< QString, QString > QgisApp::optionsPagesMap()
return mOptionsPagesMap;
}

void QgisApp::showOptionsDialog( QWidget *parent, const QString &currentPage )
QgsOptions *QgisApp::createOptionsDialog( QWidget *parent )
{
QgsSettings mySettings;
QString oldScales = mySettings.value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString();

QList< QgsOptionsWidgetFactory * > factories;
Q_FOREACH ( const QPointer< QgsOptionsWidgetFactory > &f, mOptionsWidgetFactories )
{
// remove any deleted factories
if ( f )
factories << f;
}
std::unique_ptr< QgsOptions > optionsDialog( new QgsOptions( parent, QgsGuiUtils::ModalDialogFlags, factories ) );
return new QgsOptions( parent, QgsGuiUtils::ModalDialogFlags, factories );
}

void QgisApp::showOptionsDialog( QWidget *parent, const QString &currentPage )
{
std::unique_ptr< QgsOptions > optionsDialog( createOptionsDialog( parent ) );

QgsSettings mySettings;
QString oldScales = mySettings.value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString();

if ( !currentPage.isEmpty() )
{
optionsDialog->setCurrentPage( currentPage );
@@ -76,6 +76,7 @@ class QgsMapToolDigitizeFeature;
class QgsMapToolAdvancedDigitizing;
class QgsMapToolIdentifyAction;
class QgsMapToolSelect;
class QgsOptions;
class QgsPluginLayer;
class QgsPluginLayer;
class QgsPluginManager;
@@ -1962,6 +1963,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Populates project "load from" / "save to" menu based on project storages (when the menu is about to be shown)
void populateProjectStorageMenu( QMenu *menu, bool saving );

//! Create the option dialog
QgsOptions *createOptionsDialog( QWidget *parent = nullptr );

QgisAppStyleSheet *mStyleSheetBuilder = nullptr;

// actions for menus and toolbars -----------------
@@ -2134,7 +2138,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

//! interface to QgisApp for plugins
QgisAppInterface *mQgisInterface = nullptr;
friend class QgisAppInterface;

QSplashScreen *mSplash = nullptr;
//! list of recently opened/saved project files
@@ -2301,6 +2304,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
bool mBlockActiveLayerChanged = false;

friend class TestQgisAppPython;
friend class QgisAppInterface;
friend class QgsAppScreenShots;
};

#ifdef ANDROID
@@ -31,6 +31,8 @@
#include "qgsrendererpropertiesdialog.h"
#include "qgs25drendererwidget.h"
#include "qgsapplication.h"
#include "qgsoptions.h"
#include "qgsguiutils.h"


QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
@@ -188,6 +190,9 @@ QScreen *QgsAppScreenShots::screen( QWidget *widget )

void QgsAppScreenShots::takePicturesOf( Categories categories )
{
if ( !categories || categories.testFlag( GlobalOptions ) )
takeGlobalOptions();

if ( !categories || categories.testFlag( Symbol25D ) )
take25dSymbol();

@@ -206,8 +211,7 @@ void QgsAppScreenShots::setGradientSize( int size )

void QgsAppScreenShots::takeVectorLayerProperties()
{
QString folder = QLatin1String( "working_with_vector/img/auto_generated" );
QString rootName = QLatin1String( "vectorlayerproperties_" );
QString folder = QLatin1String( "working_with_vector/img/auto_generated/vector_layer_properties" );
QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( mLineLayer, QgisApp::instance() );
dlg->show();
// ----------------
@@ -218,8 +222,8 @@ void QgsAppScreenShots::takeVectorLayerProperties()
dlg->adjustSize();
QCoreApplication::processEvents();
QString name = dlg->mOptionsListWidget->item( row )[0].text().toLower();
name.replace( " ", "_" );
takeScreenshot( rootName + name, folder, dlg );
name.replace( " ", "_" ).replace( "&", "and" );
takeScreenshot( name, folder, dlg );
}
// ------------------
// style menu clicked
@@ -229,7 +233,7 @@ void QgsAppScreenShots::takeVectorLayerProperties()
QCoreApplication::processEvents();
dlg->mBtnStyle->click();
QCoreApplication::processEvents();
takeScreenshot( rootName + "style_menu", folder, dlg );
takeScreenshot( "style_menu", folder, dlg );
QCoreApplication::processEvents();
dlg->mBtnStyle->menu()->hide();
QCoreApplication::processEvents();
@@ -243,8 +247,7 @@ void QgsAppScreenShots::takeVectorLayerProperties()

void QgsAppScreenShots::take25dSymbol()
{
QString folder = QLatin1String( "working_with_vector/img/auto_generated" );
QString rootName = QLatin1String( "vectorlayerproperties_" );
QString folder = QLatin1String( "working_with_vector/img/auto_generated/vector_layer_properties/" );
QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( mPolygonLayer, QgisApp::instance() );
dlg->show();
dlg->mOptionsListWidget->setCurrentRow( 2 );
@@ -262,10 +265,43 @@ void QgsAppScreenShots::take25dSymbol()
QCoreApplication::processEvents();
int cropHeight = w->mAdvancedConfigurationBox->mapTo( dlg, w->mAdvancedConfigurationBox->frameGeometry().bottomLeft() ).y();
QPixmap pixmap = takeScreenshot( dlg, GrabWidgetAndFrame, QRect( 0, 0, 0, cropHeight ), true );
saveScreenshot( pixmap, rootName + QLatin1String( "25dsymbol" ), folder );
saveScreenshot( pixmap, QLatin1String( "25dsymbol" ), folder );

// exit properly
dlg->close();
dlg->deleteLater();
}

//---------------

void QgsAppScreenShots::takeGlobalOptions()
{
QString folder = QLatin1String( "introduction/img/auto_generated/global_options/" );
QgsOptions *dlg = QgisApp::instance()->createOptionsDialog();
dlg->setMinimumHeight( 600 );
dlg->show();
QCoreApplication::processEvents();
for ( int row = 0; row < dlg->mOptionsListWidget->count(); ++row )
{
dlg->mOptionsListWidget->setCurrentRow( row );
dlg->adjustSize();
QCoreApplication::processEvents();
QString name = dlg->mOptionsListWidget->item( row )[0].text().toLower();
name.replace( " ", "_" ).replace( "&", "and" );
takeScreenshot( name, folder, dlg );
}
// -----------------
// advanced settings
dlg->mOptionsListWidget->setCurrentRow( 15 );
QCoreApplication::processEvents();
Q_ASSERT( dlg->mOptionsListWidget->currentItem()->icon().pixmap( 24, 24 ).toImage()
== QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ).pixmap( 24, 24 ).toImage() );
dlg->mAdvancedSettingsEditor->show();
QCoreApplication::processEvents();
QCoreApplication::processEvents(); // seems a second call is needed, the tabble might not be fully displayed otherwise
takeScreenshot( QStringLiteral( "advanced_with_settings_shown" ), folder, dlg );

// exit properly
dlg->close();
dlg->deleteLater();
}
@@ -46,8 +46,9 @@ class QgsAppScreenShots
enum Category
{
All = 0,
Symbol25D,
VectorLayerProperties,
GlobalOptions = 1 << 1,
Symbol25D = 1 << 2,
VectorLayerProperties = 1 << 3,
};
Q_ENUM( Category )
Q_DECLARE_FLAGS( Categories, Category )
@@ -80,6 +81,7 @@ class QgsAppScreenShots

void takeVectorLayerProperties();
void take25dSymbol();
void takeGlobalOptions();

QString mSaveDirectory;
int mGradientSize = 200;
@@ -272,7 +272,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption

void updateActionsForCurrentColorScheme( QgsColorScheme *scheme );


friend class QgsAppScreenShots;
};

#endif // #ifndef QGSOPTIONS_H

0 comments on commit 2240e1f

Please sign in to comment.
You can’t perform that action at this time.