From 15a79881b02e2173f9b9ce7b8549c7df9d6362c0 Mon Sep 17 00:00:00 2001 From: xavier Date: Mon, 9 Apr 2012 18:56:17 +0000 Subject: [PATCH] The title block template editor now save its geometry and state when closing. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1650 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetapp.cpp | 4 +-- sources/titleblock/qettemplateeditor.cpp | 31 +++++++++++++++++++++++- sources/titleblock/qettemplateeditor.h | 2 ++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 0fe9af630..b0e864985 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -1050,7 +1050,7 @@ void QETApp::openTitleBlockTemplate(const TitleBlockTemplateLocation &location, QETTitleBlockTemplateEditor *qet_template_editor = new QETTitleBlockTemplateEditor(); qet_template_editor -> setOpenForDuplication(duplicate); qet_template_editor -> edit(location); - qet_template_editor -> showMaximized(); + qet_template_editor -> show(); } /** @@ -1060,7 +1060,7 @@ void QETApp::openTitleBlockTemplate(const TitleBlockTemplateLocation &location, void QETApp::openTitleBlockTemplate(const QString &filepath) { QETTitleBlockTemplateEditor *qet_template_editor = new QETTitleBlockTemplateEditor(); qet_template_editor -> edit(filepath); - qet_template_editor -> showMaximized(); + qet_template_editor -> show(); } /** diff --git a/sources/titleblock/qettemplateeditor.cpp b/sources/titleblock/qettemplateeditor.cpp index 7325dd002..f481d28a0 100644 --- a/sources/titleblock/qettemplateeditor.cpp +++ b/sources/titleblock/qettemplateeditor.cpp @@ -45,6 +45,7 @@ QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor(QWidget *parent) : initActions(); initMenus(); initToolbars(); + readSettings(); } /** @@ -142,6 +143,7 @@ void QETTitleBlockTemplateEditor::firstActivation(QEvent *event) { */ void QETTitleBlockTemplateEditor::closeEvent(QCloseEvent *qce) { if (canClose()) { + writeSettings(); setAttribute(Qt::WA_DeleteOnClose); qce -> accept(); } else qce -> ignore(); @@ -301,7 +303,7 @@ void QETTitleBlockTemplateEditor::editLogos() { void QETTitleBlockTemplateEditor::newTemplate() { QETTitleBlockTemplateEditor *qet_template_editor = new QETTitleBlockTemplateEditor(); qet_template_editor -> edit(TitleBlockTemplateLocation()); - qet_template_editor -> showMaximized(); + qet_template_editor -> show(); } /** @@ -426,6 +428,7 @@ void QETTitleBlockTemplateEditor::initToolbars() { addToolBar(Qt::TopToolBarArea, main_toolbar); QToolBar *edit_toolbar = new QToolBar(tr("\311dition", "toolbar title"), this); + edit_toolbar -> setObjectName("tbt_edit_toolbar"); edit_toolbar -> addAction(undo_); edit_toolbar -> addAction(redo_); edit_toolbar -> addSeparator(); @@ -454,6 +457,7 @@ void QETTitleBlockTemplateEditor::initWidgets() { undo_view_ -> setEmptyLabel(tr("Aucune modification", "label displayed in the undo list when empty")); undo_dock_widget_ = new QDockWidget(tr("Annulations", "dock title")); + undo_dock_widget_ -> setObjectName("tbt_undo_dock"); undo_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures); undo_dock_widget_ -> setWidget(undo_view_); undo_dock_widget_ -> setMinimumWidth(290); @@ -472,6 +476,7 @@ void QETTitleBlockTemplateEditor::initWidgets() { // cell edition widget at the bottom template_cell_editor_widget_ = new TitleBlockTemplateCellWidget(tb_template_); template_cell_editor_dock_widget_ = new QDockWidget(tr("Propri\351t\351s de la cellule", "dock title"), this); + template_cell_editor_dock_widget_ -> setObjectName("tbt_celleditor_dock"); template_cell_editor_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures); template_cell_editor_dock_widget_ -> setWidget(template_cell_editor_widget_); template_cell_editor_dock_widget_ -> setMinimumWidth(180); @@ -554,6 +559,30 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const { return(titleblock_title); } +/** + Load template editor-related parameters. +*/ +void QETTitleBlockTemplateEditor::readSettings() { + QSettings &settings = QETApp::settings(); + + // window size and position + QVariant geometry = settings.value("titleblocktemplateeditor/geometry"); + if (geometry.isValid()) restoreGeometry(geometry.toByteArray()); + + // window state (toolbars, docks...) + QVariant state = settings.value("titleblocktemplateeditor/state"); + if (state.isValid()) restoreState(state.toByteArray()); +} + +/** + Save template editor-related parameters. +*/ +void QETTitleBlockTemplateEditor::writeSettings() { + QSettings &settings = QETApp::settings(); + settings.setValue("titleblocktemplateeditor/geometry", saveGeometry()); + settings.setValue("titleblocktemplateeditor/state", saveState()); +} + /** Update various things when user changes the selected cells. @param selected_cells List of selected cells. diff --git a/sources/titleblock/qettemplateeditor.h b/sources/titleblock/qettemplateeditor.h index f912bb67c..de387d0c0 100644 --- a/sources/titleblock/qettemplateeditor.h +++ b/sources/titleblock/qettemplateeditor.h @@ -102,6 +102,8 @@ class QETTitleBlockTemplateEditor : public QETMainWindow { QString currentlyEditedTitle() const; public slots: + void readSettings(); + void writeSettings(); void selectedCellsChanged(QList); void duplicateCurrentLocation(); bool edit(const TitleBlockTemplateLocation &);