Skip to content

Commit f1a85a5

Browse files
amitkulzmhugent
authored andcommitted
add old/new scale comparison and emit scaleChanged only if new scale is different than old.
1 parent b5dc778 commit f1a85a5

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/gui/qgsscalecombobox.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,31 @@ void QgsScaleComboBox::fixupScale()
146146
{
147147
double newScale;
148148
double oldScale = mScale;
149-
bool ok;
150-
QStringList txtList;
149+
bool ok, userSetScale;
150+
QStringList txtList = currentText().split( ':' );
151+
txtList.size() == 2 ? userSetScale = false : userSetScale = true ;
151152

152153
// QgsDebugMsg( QString( "entered with oldScale: %1" ).arg( oldScale ) );
153154
newScale = toDouble( currentText(), &ok );
154-
if ( ok )
155+
156+
// Valid string representation
157+
if ( ok && (newScale != oldScale))
155158
{
156-
// Valid string representation
157-
if ( newScale != oldScale )
159+
// if a user types scale = 2345, we transform to 1:2345
160+
if(userSetScale)
161+
{
162+
mScale = 1 / newScale;
163+
}
164+
else
158165
{
159-
// Scale has change, update.
160-
// QgsDebugMsg( QString( "New scale OK!: %1" ).arg( newScale ) );
161166
mScale = newScale;
162-
setScale( mScale );
163-
emit scaleChanged();
164167
}
168+
setScale( mScale );
169+
emit scaleChanged();
165170
}
166171
else
167172
{
168-
// Invalid string representation
173+
// Invalid string representation or same scale
169174
// Reset to the old
170175
setScale( mScale );
171176
}

0 commit comments

Comments
 (0)