Signal changes of zoomlevel in Okteta::AbstractByteArrayView

Fixes KastenOkteta ByteArrayView to forward also zoomlevel changes e.g. by
Ctrl+scrollwheel on the view.

CCBUG: 361402

API change:
* added signal Okteta::AbstractByteArrayView::zoomLevelChanged(double)
parent 5651dc3e
......@@ -96,7 +96,7 @@ add_subdirectory( doc )
set( OKTETALIBS_MAJOR_VERSION 0 )
set( OKTETALIBS_MINOR_VERSION 9 )
set( OKTETALIBS_PATCHLEVEL_VERSION 0 )
set( OKTETALIBS_PATCHLEVEL_VERSION 1 )
set( OKTETALIBS_VERSION "${OKTETALIBS_MAJOR_VERSION}.${OKTETALIBS_MINOR_VERSION}.${OKTETALIBS_PATCHLEVEL_VERSION}" )
set( OKTETALIBS_ABI_VERSION 2 )
set( OKTETALIBS_INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/okteta ) #${OKTETALIBS_ABI_VERSION} )
......
......@@ -387,6 +387,8 @@ class OKTETAGUI_EXPORT AbstractByteArrayView : public ColumnsView
void undefinedCharChanged( QChar undefinedChar );
void noOfGroupedBytesChanged( int noOfGroupedBytes );
void zoomLevelChanged( double level );
protected:
void finishByteEdit();
void emitSelectionSignals();
......
......@@ -275,6 +275,7 @@ void AbstractByteArrayViewPrivate::changeEvent( QEvent* event )
&& !mInZooming )
{
mDefaultFontSize = q->font().pointSize();
// TODO: why reset zoomlevel here? should this not rather recalculate the new applied font size?
mZoomLevel = 1.0;
}
}
......@@ -297,6 +298,8 @@ void AbstractByteArrayViewPrivate::zoomIn( int pointIncrement )
mInZooming = true;
q->setFont( newFont );
mInZooming = false;
emit q->zoomLevelChanged( mZoomLevel );
}
void AbstractByteArrayViewPrivate::zoomOut( int pointDecrement )
......@@ -314,6 +317,8 @@ void AbstractByteArrayViewPrivate::zoomOut( int pointDecrement )
mInZooming = true;
q->setFont( newFont );
mInZooming = false;
emit q->zoomLevelChanged( mZoomLevel );
}
......@@ -336,6 +341,8 @@ void AbstractByteArrayViewPrivate::zoomTo( int newPointSize )
mInZooming = true;
q->setFont( newFont );
mInZooming = false;
emit q->zoomLevelChanged( mZoomLevel );
}
......@@ -348,7 +355,6 @@ void AbstractByteArrayViewPrivate::setZoomLevel( double zoomLevel )
{
Q_Q( AbstractByteArrayView );
const int newPointSize = (int)(zoomLevel*mDefaultFontSize);
const int currentPointSize = q->fontInfo().pointSize();
// TODO: here we catch any new zoomlevels which are out of bounds and the zoom already at that bound
......@@ -356,11 +362,26 @@ void AbstractByteArrayViewPrivate::setZoomLevel( double zoomLevel )
|| (MaxFontPointSize <= currentPointSize && (double)MaxFontPointSize/mDefaultFontSize < zoomLevel) )
return;
zoomTo( newPointSize );
// TODO: this hack overwrites the new zoomlevel calculated from the integers in zoomTo,
// to avoid getting trapped inside a small integer value, if the zoom tool operates relatively
int newPointSize = (int)(zoomLevel*mDefaultFontSize);
if( newPointSize < MinFontPointSize )
newPointSize = MinFontPointSize;
else if( newPointSize > MaxFontPointSize )
newPointSize = MaxFontPointSize;
QFont newFont( q->font() );
// other than in zoomTo(), where the new zoomlevel is calculated from the integers, here
// use the passed zoomlevel value, to avoid getting trapped inside a small integer value,
// if the zoom tool operates relatively
// think about, if this is the right approach
mZoomLevel = zoomLevel;
newFont.setPointSize( newPointSize );
mInZooming = true;
q->setFont( newFont );
mInZooming = false;
emit q->zoomLevelChanged(mZoomLevel);
}
......
......@@ -114,6 +114,7 @@ void ByteArrayJanusView::setViewModus( int viewModus )
connect( mView, &AbstractByteArrayView::substituteCharChanged, this, &ByteArrayJanusView::substituteCharChanged );
connect( mView, &AbstractByteArrayView::undefinedCharChanged, this, &ByteArrayJanusView::undefinedCharChanged );
connect( mView, &AbstractByteArrayView::noOfGroupedBytesChanged, this, &ByteArrayJanusView::noOfGroupedBytesChanged );
connect( mView, &AbstractByteArrayView::zoomLevelChanged, this, &ByteArrayJanusView::zoomLevelChanged );
emit viewModusChanged( mViewModus );
}
......
......@@ -151,6 +151,7 @@ class ByteArrayJanusView : public QWidget
void substituteCharChanged( QChar substituteChar );
void undefinedCharChanged( QChar undefinedChar );
void noOfGroupedBytesChanged( int noOfGroupedBytes );
void zoomLevelChanged( double level );
void viewModusChanged( int viewModus );
private:
......
......@@ -139,6 +139,7 @@ void ByteArrayView::init()
connect( mWidget, &ByteArrayJanusView::substituteCharChanged, this, &ByteArrayView::substituteCharChanged );
connect( mWidget, &ByteArrayJanusView::undefinedCharChanged, this, &ByteArrayView::undefinedCharChanged );
connect( mWidget, &ByteArrayJanusView::noOfGroupedBytesChanged, this, &ByteArrayView::noOfGroupedBytesChanged );
connect( mWidget, &ByteArrayJanusView::zoomLevelChanged, this, &ByteArrayView::zoomLevelChanged );
connect( mWidget, &ByteArrayJanusView::viewModusChanged, this, &ByteArrayView::viewModusChanged );
}
......@@ -164,7 +165,6 @@ void ByteArrayView::setReadOnly( bool isReadOnly ) { mWidget->setReadOnly( isRea
void ByteArrayView::setZoomLevel( double Level )
{
mWidget->setZoomLevel( Level );
emit zoomLevelChanged( mWidget->zoomLevel() );
}
double ByteArrayView::zoomLevel() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment