From ec26cbb07a69bbfa0eee1d15926d4545d39f50d3 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 30 Apr 2016 09:49:50 -0400 Subject: [PATCH] Finished extending undo/redo framework into PropertiesView. --- glabels/LabelModel.cpp | 4 ++++ glabels/PropertiesView.cpp | 38 +++++++++++++++++++++--------------- glabels/PropertiesView.h | 4 ++-- glabels/ui/PropertiesView.ui | 38 ++++++++++++++++++------------------ 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/glabels/LabelModel.cpp b/glabels/LabelModel.cpp index 251133c..b3d7b4c 100644 --- a/glabels/LabelModel.cpp +++ b/glabels/LabelModel.cpp @@ -86,8 +86,12 @@ void LabelModel::restore( const LabelModel *savedModel ) mObjectList.append( object->clone() ); } + // Emit signals based on potential changes emit changed(); emit selectionChanged(); + emit modifiedChanged(); + emit nameChanged(); + emit sizeChanged(); } diff --git a/glabels/PropertiesView.cpp b/glabels/PropertiesView.cpp index 4f85cf6..9fa0a9d 100644 --- a/glabels/PropertiesView.cpp +++ b/glabels/PropertiesView.cpp @@ -156,32 +156,38 @@ void PropertiesView::onLabelSizeChanged() { orientationCombo->setCurrentIndex( isRotated ? 0 : 1 ); } + mOldOrientationIndex = orientationCombo->currentIndex(); } /// -/// Form changed handler +/// Orientation combo box changed handler /// -void PropertiesView::onFormChanged() +void PropertiesView::onOrientationActivated() { const glabels::Template *tmplate = mModel->tmplate(); const glabels::Frame *frame = tmplate->frames().first(); - if ( frame->w() == frame->h() ) + // Make sure index actually changed. + int index = orientationCombo->currentIndex(); + if ( index != mOldOrientationIndex ) { - mModel->setRotate( false ); - } - else if ( frame->w() > frame->h() ) - { - mUndoRedoModel->checkpoint( tr("Product Orientation") ); - int index = orientationCombo->currentIndex(); - mModel->setRotate( index == 1 ); - } - else - { - mUndoRedoModel->checkpoint( tr("Product Orientation") ); - int index = orientationCombo->currentIndex(); - mModel->setRotate( index == 0 ); + mOldOrientationIndex = index; + + mUndoRedoModel->checkpoint( tr("Product Rotate") ); + + if ( frame->w() == frame->h() ) + { + mModel->setRotate( false ); + } + else if ( frame->w() > frame->h() ) + { + mModel->setRotate( index == 1 ); + } + else + { + mModel->setRotate( index == 0 ); + } } } diff --git a/glabels/PropertiesView.h b/glabels/PropertiesView.h index dceb775..91909c3 100644 --- a/glabels/PropertiesView.h +++ b/glabels/PropertiesView.h @@ -58,7 +58,7 @@ public: private slots: void onSettingsChanged(); void onLabelSizeChanged(); - void onFormChanged(); + void onOrientationActivated(); void onChangeProductButtonClicked(); @@ -69,7 +69,7 @@ private: LabelModel* mModel; UndoRedoModel* mUndoRedoModel; glabels::Units mUnits; - + int mOldOrientationIndex; }; diff --git a/glabels/ui/PropertiesView.ui b/glabels/ui/PropertiesView.ui index ebf3009..496e5db 100644 --- a/glabels/ui/PropertiesView.ui +++ b/glabels/ui/PropertiesView.ui @@ -372,22 +372,6 @@ - - orientationCombo - currentIndexChanged(int) - PropertiesView - onFormChanged() - - - 671 - 283 - - - 723 - 285 - - - changeProductButton clicked() @@ -395,8 +379,8 @@ onChangeProductButtonClicked() - 684 - 192 + 311 + 221 728 @@ -404,9 +388,25 @@ + + orientationCombo + activated(int) + PropertiesView + onOrientationActivated() + + + 285 + 280 + + + 802 + 300 + + + onChangeProductButtonClicked() - onFormChanged() + onOrientationActivated()