-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18b2b52
commit 4f21afa
Showing
18 changed files
with
704 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutdesignerinterface.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLayoutDesignerInterface: QObject | ||
{ | ||
%Docstring | ||
A common interface for layout designer dialogs and widgets. | ||
|
||
Provides a common interface and stable API for layout designer dialogs and widgets. | ||
This interface can be used by plugins and scripts to interact with | ||
open layout designer dialogs. | ||
|
||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutdesignerinterface.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutDesignerInterface( QObject *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsLayoutDesignerInterface. | ||
%End | ||
|
||
virtual ~QgsLayoutDesignerInterface(); | ||
|
||
virtual QgsLayout *layout() = 0; | ||
%Docstring | ||
Returns the layout displayed in the designer. | ||
:rtype: QgsLayout | ||
%End | ||
|
||
public slots: | ||
|
||
virtual void close() = 0; | ||
%Docstring | ||
Closes the layout designer. | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutdesignerinterface.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/*************************************************************************** | ||
qgslayoutdesignerdialog.cpp | ||
--------------------------- | ||
begin : July 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutdesignerdialog.h" | ||
#include "qgssettings.h" | ||
#include "qgisapp.h" | ||
#include "qgslogger.h" | ||
|
||
QgsAppLayoutDesignerInterface::QgsAppLayoutDesignerInterface( QgsLayoutDesignerDialog *dialog ) | ||
: QgsLayoutDesignerInterface( dialog ) | ||
, mDesigner( dialog ) | ||
{} | ||
|
||
QgsLayout *QgsAppLayoutDesignerInterface::layout() | ||
{ | ||
return mDesigner->currentLayout(); | ||
} | ||
|
||
void QgsAppLayoutDesignerInterface::close() | ||
{ | ||
mDesigner->close(); | ||
} | ||
|
||
|
||
QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFlags flags ) | ||
: QMainWindow( parent, flags ) | ||
, mInterface( new QgsAppLayoutDesignerInterface( this ) ) | ||
{ | ||
QgsSettings settings; | ||
int size = settings.value( QStringLiteral( "IconSize" ), QGIS_ICON_SIZE ).toInt(); | ||
setIconSize( QSize( size, size ) ); | ||
setStyleSheet( QgisApp::instance()->styleSheet() ); | ||
setWindowTitle( tr( "QGIS Layout Designer" ) ); | ||
|
||
setupUi( this ); | ||
|
||
setAttribute( Qt::WA_DeleteOnClose ); | ||
#if QT_VERSION >= 0x050600 | ||
setDockOptions( dockOptions() | QMainWindow::GroupedDragging ) ; | ||
#endif | ||
|
||
connect( mActionClose, &QAction::triggered, this, &QWidget::close ); | ||
|
||
restoreWindowState(); | ||
} | ||
|
||
QgsAppLayoutDesignerInterface *QgsLayoutDesignerDialog::iface() | ||
{ | ||
return mInterface; | ||
} | ||
|
||
QgsLayout *QgsLayoutDesignerDialog::currentLayout() | ||
{ | ||
return mLayout; | ||
} | ||
|
||
void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout ) | ||
{ | ||
mLayout = layout; | ||
|
||
} | ||
|
||
void QgsLayoutDesignerDialog::setIconSizes( int size ) | ||
{ | ||
//Set the icon size of for all the toolbars created in the future. | ||
setIconSize( QSize( size, size ) ); | ||
|
||
//Change all current icon sizes. | ||
QList<QToolBar *> toolbars = findChildren<QToolBar *>(); | ||
Q_FOREACH ( QToolBar *toolbar, toolbars ) | ||
{ | ||
toolbar->setIconSize( QSize( size, size ) ); | ||
} | ||
} | ||
|
||
void QgsLayoutDesignerDialog::open() | ||
{ | ||
show(); | ||
activate(); | ||
#if 0 // TODO | ||
zoomFull(); // zoomFull() does not work properly until we have called show() | ||
if ( mView ) | ||
{ | ||
mView->updateRulers(); | ||
} | ||
#endif | ||
} | ||
|
||
void QgsLayoutDesignerDialog::activate() | ||
{ | ||
// bool shown = isVisible(); | ||
show(); | ||
raise(); | ||
setWindowState( windowState() & ~Qt::WindowMinimized ); | ||
activateWindow(); | ||
|
||
#if 0 // TODO | ||
if ( !shown ) | ||
{ | ||
on_mActionZoomAll_triggered(); | ||
} | ||
#endif | ||
} | ||
|
||
void QgsLayoutDesignerDialog::closeEvent( QCloseEvent * ) | ||
{ | ||
emit aboutToClose(); | ||
saveWindowState(); | ||
} | ||
|
||
void QgsLayoutDesignerDialog::saveWindowState() | ||
{ | ||
QgsSettings settings; | ||
settings.setValue( QStringLiteral( "LayoutDesigner/geometry" ), saveGeometry() ); | ||
// store the toolbar/dock widget settings using Qt settings API | ||
settings.setValue( QStringLiteral( "LayoutDesigner/state" ), saveState() ); | ||
} | ||
|
||
void QgsLayoutDesignerDialog::restoreWindowState() | ||
{ | ||
// restore the toolbar and dock widgets positions using Qt settings API | ||
QgsSettings settings; | ||
|
||
//TODO - defaults | ||
if ( !restoreState( settings.value( QStringLiteral( "LayoutDesigner/state" ) /*, QByteArray::fromRawData( ( char * )defaultComposerUIstate, sizeof defaultComposerUIstate ) */ ).toByteArray() ) ) | ||
{ | ||
QgsDebugMsg( "restore of layout UI state failed" ); | ||
} | ||
// restore window geometry | ||
if ( !restoreGeometry( settings.value( QStringLiteral( "LayoutDesigner/geometry" ) /*, QByteArray::fromRawData( ( char * )defaultComposerUIgeometry, sizeof defaultComposerUIgeometry ) */ ).toByteArray() ) ) | ||
{ | ||
QgsDebugMsg( "restore of layout UI geometry failed" ); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.