Skip to content

Commit

Permalink
[layouts] Save table editor panel state to avoid having to constantly
Browse files Browse the repository at this point in the history
resize formatting panel on reopen
  • Loading branch information
nyalldawson committed Jul 27, 2020
1 parent 51d8ad7 commit 7cfa476
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Expand Up @@ -138,6 +138,11 @@ Emitted whenever the table contents are changed.
Emitted whenever the "include table header" setting is changed.
%End

protected:

virtual void closeEvent( QCloseEvent * );


};

/************************************************************************
Expand Down
17 changes: 17 additions & 0 deletions src/gui/tableeditor/qgstableeditordialog.cpp
Expand Up @@ -20,6 +20,7 @@
#include "qgsdockwidget.h"
#include "qgspanelwidgetstack.h"
#include "qgstableeditorformattingwidget.h"
#include "qgssettings.h"

#include <QClipboard>
#include <QMessageBox>
Expand Down Expand Up @@ -135,6 +136,22 @@ QgsTableEditorDialog::QgsTableEditorDialog( QWidget *parent )
mTableWidget->setIncludeTableHeader( checked );
emit includeHeaderChanged( checked );
} );

// restore the toolbar and dock widgets positions using Qt settings API
QgsSettings settings;

const QByteArray state = settings.value( QStringLiteral( "LayoutDesigner/tableEditorState" ), QByteArray(), QgsSettings::App ).toByteArray();
if ( !state.isEmpty() && !restoreState( state ) )
{
QgsDebugMsg( QStringLiteral( "restore of table editor dialog UI state failed" ) );
}
}

void QgsTableEditorDialog::closeEvent( QCloseEvent * )
{
QgsSettings settings;
// store the toolbar/dock widget settings using Qt settings API
settings.setValue( QStringLiteral( "LayoutDesigner/tableEditorState" ), saveState(), QgsSettings::App );
}

bool QgsTableEditorDialog::setTableContentsFromClipboard()
Expand Down
4 changes: 4 additions & 0 deletions src/gui/tableeditor/qgstableeditordialog.h
Expand Up @@ -154,6 +154,10 @@ class GUI_EXPORT QgsTableEditorDialog : public QMainWindow, private Ui::QgsTable
*/
void includeHeaderChanged( bool included );

protected:

void closeEvent( QCloseEvent * ) override;

private:
QgsTableEditorWidget *mTableWidget = nullptr;
QgsMessageBar *mMessageBar = nullptr;
Expand Down

0 comments on commit 7cfa476

Please sign in to comment.