Skip to content

Commit

Permalink
add screenshots of global options
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 4, 2018
1 parent 18f6562 commit 2240e1f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
16 changes: 11 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -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 );
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgisapp.h
Expand Up @@ -76,6 +76,7 @@ class QgsMapToolDigitizeFeature;
class QgsMapToolAdvancedDigitizing;
class QgsMapToolIdentifyAction;
class QgsMapToolSelect;
class QgsOptions;
class QgsPluginLayer;
class QgsPluginLayer;
class QgsPluginManager;
Expand Down Expand Up @@ -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 -----------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
52 changes: 44 additions & 8 deletions src/app/qgsappscreenshots.cpp
Expand Up @@ -31,6 +31,8 @@
#include "qgsrendererpropertiesdialog.h"
#include "qgs25drendererwidget.h"
#include "qgsapplication.h"
#include "qgsoptions.h"
#include "qgsguiutils.h"


QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
Expand Down Expand Up @@ -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();

Expand All @@ -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();
// ----------------
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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 );
Expand All @@ -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();
}
6 changes: 4 additions & 2 deletions src/app/qgsappscreenshots.h
Expand Up @@ -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 )
Expand Down Expand Up @@ -80,6 +81,7 @@ class QgsAppScreenShots

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

QString mSaveDirectory;
int mGradientSize = 200;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.h
Expand Up @@ -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.