[qet] [1538] Title block template editor: now write the preview width to application settings. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1538
Author: xavier
Date: 2012-02-27 19:20:33 +0100 (Mon, 27 Feb 2012)
Log Message:
-----------
Title block template editor: now write the preview width to application settings.
Modified Paths:
--------------
branches/0.3/sources/titleblock/qettemplateeditor.cpp
branches/0.3/sources/titleblock/qettemplateeditor.h
branches/0.3/sources/titleblock/templateview.cpp
branches/0.3/sources/titleblock/templateview.h
Modified: branches/0.3/sources/titleblock/qettemplateeditor.cpp
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-02-27 18:19:39 UTC (rev 1537)
+++ branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-02-27 18:20:33 UTC (rev 1538)
@@ -377,6 +377,8 @@
Initialize layouts and widgets
*/
void QETTitleBlockTemplateEditor::initWidgets() {
+ QSettings &settings = QETApp::settings();
+
// undo list on the right
undo_stack_ = new QUndoStack(this);
undo_view_ = new QUndoView(undo_stack_);
@@ -390,7 +392,12 @@
// WYSIWYG editor as central widget
template_edition_area_scene_ = new QGraphicsScene(this);
- template_edition_area_view_ = new TitleBlockTemplateView(template_edition_area_scene_);
+ template_edition_area_view_ = new TitleBlockTemplateView(template_edition_area_scene_);
+ bool conv_ok;
+ int conf_preview_width = settings.value("titleblocktemplateeditor/preview_width", -1).toInt(&conv_ok);
+ if (conv_ok && conf_preview_width != -1) {
+ template_edition_area_view_ -> setPreviewWidth(conf_preview_width);
+ }
setCentralWidget(template_edition_area_view_);
// cell edition widget at the bottom
@@ -422,6 +429,12 @@
this,
SLOT(pushGridUndoCommand(TitleBlockTemplateCommand *))
);
+ connect(
+ template_edition_area_view_,
+ SIGNAL(previewWidthChanged(int,int)),
+ this,
+ SLOT(savePreviewWidthToApplicationSettings(int, int))
+ );
connect(undo_stack_, SIGNAL(cleanChanged(bool)), this, SLOT(updateEditorTitle()));
}
@@ -753,3 +766,13 @@
void QETTitleBlockTemplateEditor::quit() {
close();
}
+
+/**
+ Save the new preview width to application settings
+ @param former_preview_width Unused, former preview width
+ @param new_preview_width New preview width
+*/
+void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(int former_preview_width, int new_preview_width) {
+ Q_UNUSED(former_preview_width)
+ QETApp::settings().setValue("titleblocktemplateeditor/preview_width", new_preview_width);
+}
Modified: branches/0.3/sources/titleblock/qettemplateeditor.h
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.h 2012-02-27 18:19:39 UTC (rev 1537)
+++ branches/0.3/sources/titleblock/qettemplateeditor.h 2012-02-27 18:20:33 UTC (rev 1538)
@@ -116,6 +116,7 @@
bool saveAsFile();
void setReadOnly(bool);
void quit();
+ void savePreviewWidthToApplicationSettings(int, int);
private slots:
TitleBlockTemplateLocation getTitleBlockTemplateLocationFromUser(const QString & = QString(), bool existing_only = true);
Modified: branches/0.3/sources/titleblock/templateview.cpp
===================================================================
--- branches/0.3/sources/titleblock/templateview.cpp 2012-02-27 18:19:39 UTC (rev 1537)
+++ branches/0.3/sources/titleblock/templateview.cpp 2012-02-27 18:20:33 UTC (rev 1538)
@@ -23,7 +23,6 @@
#include "templatecommands.h"
#include "templatecellsset.h"
#include "dimensionwidget.h"
-#include "qetapp.h"
#include "qeticons.h"
#define ROW_OFFSET 2
#define COL_OFFSET 1
@@ -758,12 +757,15 @@
*/
void TitleBlockTemplateView::setPreviewWidth(int width) {
if (preview_width_ == width) return;
+ int former_preview_width = preview_width_;
preview_width_ = width;
- applyColumnsWidths();
- updateTotalWidthLabel();
- //adjustSceneRect();
- centerOn(form_);
- /// TODO center again the preview()
+ if (tbgrid_) {
+ applyColumnsWidths();
+ updateTotalWidthLabel();
+ //adjustSceneRect();
+ centerOn(form_);
+ }
+ emit(previewWidthChanged(former_preview_width, preview_width_));
}
/**
Modified: branches/0.3/sources/titleblock/templateview.h
===================================================================
--- branches/0.3/sources/titleblock/templateview.h 2012-02-27 18:19:39 UTC (rev 1537)
+++ branches/0.3/sources/titleblock/templateview.h 2012-02-27 18:20:33 UTC (rev 1538)
@@ -69,6 +69,7 @@
void splitSelectedCell();
void refresh();
void changePreviewWidth();
+ void setPreviewWidth(int);
void updateLayout();
void rowsDimensionsChanged();
void columnsDimensionsChanged();
@@ -93,11 +94,11 @@
signals:
void selectedCellsChanged(QList<TitleBlockCell *>);
void gridModificationRequested(TitleBlockTemplateCommand *);
+ void previewWidthChanged(int, int);
private:
QList<QAction *> rowsActions() const;
QList<QAction *> columnsActions() const;
- void setPreviewWidth(int);
void updateTotalWidthLabel();
void requestGridModification(TitleBlockTemplateCommand *);
int lastContextMenuCellIndex() const;