Title block template editor: now write the preview width to application settings.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1538 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-02-27 18:20:33 +00:00
parent 7a955b777f
commit f7d27f25a1
4 changed files with 35 additions and 8 deletions

View File

@@ -377,6 +377,8 @@ void QETTitleBlockTemplateEditor::initMenus() {
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_);
@@ -391,6 +393,11 @@ void QETTitleBlockTemplateEditor::initWidgets() {
// WYSIWYG editor as central widget
template_edition_area_scene_ = new QGraphicsScene(this);
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 @@ void QETTitleBlockTemplateEditor::initWidgets() {
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 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLoc
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);
}

View File

@@ -116,6 +116,7 @@ class QETTitleBlockTemplateEditor : public QETMainWindow {
bool saveAsFile();
void setReadOnly(bool);
void quit();
void savePreviewWidthToApplicationSettings(int, int);
private slots:
TitleBlockTemplateLocation getTitleBlockTemplateLocationFromUser(const QString & = QString(), bool existing_only = true);

View File

@@ -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::setReadOnly(bool read_only) {
*/
void TitleBlockTemplateView::setPreviewWidth(int width) {
if (preview_width_ == width) return;
int former_preview_width = preview_width_;
preview_width_ = width;
if (tbgrid_) {
applyColumnsWidths();
updateTotalWidthLabel();
//adjustSceneRect();
centerOn(form_);
/// TODO center again the preview()
}
emit(previewWidthChanged(former_preview_width, preview_width_));
}
/**

View File

@@ -69,6 +69,7 @@ class TitleBlockTemplateView : public QGraphicsView {
void splitSelectedCell();
void refresh();
void changePreviewWidth();
void setPreviewWidth(int);
void updateLayout();
void rowsDimensionsChanged();
void columnsDimensionsChanged();
@@ -93,11 +94,11 @@ class TitleBlockTemplateView : public QGraphicsView {
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;