diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2021-05-14 17:41:27 +0300 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2021-07-18 21:33:28 +0300 |
commit | bbbdf5ffc635f7a0e9fd1832bbba1a9e9cee1e0d (patch) | |
tree | 2383ba7c6804e22d8f95e5140112b4f85b763148 | |
parent | 08ec3e383e3e77668542fb2ebd7a0dfbaf4d6abb (diff) | |
download | kompose-issue/10.tar.gz kompose-issue/10.zip |
Fixed desktop switching with "Show empty desktops minimized" option.issue/10
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r-- | src/komposelayout.cpp | 44 | ||||
-rw-r--r-- | src/komposelayout.h | 17 |
2 files changed, 39 insertions, 22 deletions
diff --git a/src/komposelayout.cpp b/src/komposelayout.cpp index 4eeacf0..567b275 100644 --- a/src/komposelayout.cpp +++ b/src/komposelayout.cpp @@ -34,8 +34,9 @@ KomposeLayout::KomposeLayout( KomposeWidget *parent, int type, int dist, const c : TQObject(parent, name), spacing(dist), widgetsChanged(false), - currentRows(0), - currentColumns(0), + filledRows(0), + filledColumns(0), + emptyColumns(0), parentWidget(parent) { setType( type ); @@ -115,7 +116,7 @@ void KomposeLayout::rearrangeContents() parentWidget->width(), parentWidget->height() - ( 40 + 2*spacing ) ); // arrange the filled desktops taking 90% of the screen - rearrangeContents( filledRect, filledContainers ); + rearrangeContents( filledRect, filledContainers, CONTAINER_FILLED ); // Arrange empty containers TQRect emptyRect( 0, @@ -123,7 +124,7 @@ void KomposeLayout::rearrangeContents() parentWidget->width(), ( 40 + 2*spacing ) ); // arrange the empty widget in one row - rearrangeContents( emptyRect, emptyContainers, 1, -1, false ); + rearrangeContents( emptyRect, emptyContainers, CONTAINER_EMPTY, 1, -1 ); } @@ -146,7 +147,7 @@ void KomposeLayout::rearrangeContents() * availRect specifies the size&pos of the contents * Specify either rows or cols to set a fixed number of those (setting both won't work correctly) */ -void KomposeLayout::rearrangeContents( const TQRect& availRect, const TQPtrList<KomposeWidget> widgets, int rows, int columns, bool setMemberRowsCols ) +void KomposeLayout::rearrangeContents( const TQRect& availRect, const TQPtrList<KomposeWidget> widgets, int containerType, int rows, int columns ) { // Check or empty list if (widgets.count() == 0) @@ -297,14 +298,15 @@ void KomposeLayout::rearrangeContents( const TQRect& availRect, const TQPtrList< if ( *maxRowHeightIt-h > 0 ) topOffset += *maxRowHeightIt-h; ++maxRowHeightIt; - } - - // Sync cols/rows member vars to current cols/rows - if ( setMemberRowsCols ) - { - currentRows = rows; - currentColumns = columns; - } + } + + // Sync cols/rows member vars to current cols/rows + if( containerType == CONTAINER_EMPTY ) { + emptyColumns = columns; + } else { + filledRows = rows; + filledColumns = columns; + } } @@ -320,12 +322,12 @@ KomposeWidget* KomposeLayout::getNeighbour( const KomposeWidget* widget, int dir KomposeWidget* neighbour = 0; if ( filledContainers.containsRef(widget) ) { - if ( ( neighbour = getNeighbour( filledContainers, widget, direction, WLAYOUT_HORIZONTAL ) ) == 0 ) + if ( ( neighbour = getNeighbour( filledContainers, CONTAINER_FILLED, widget, direction, WLAYOUT_HORIZONTAL ) ) == 0 ) return emptyContainers.first(); } else if ( emptyContainers.containsRef(widget) ) { - if ( ( neighbour = getNeighbour( emptyContainers, widget, direction, WLAYOUT_HORIZONTAL ) ) == 0 ) + if ( ( neighbour = getNeighbour( emptyContainers, CONTAINER_EMPTY, widget, direction, WLAYOUT_HORIZONTAL ) ) == 0 ) if ( direction == DLAYOUT_TOP ) return filledContainers.last(); else @@ -334,7 +336,7 @@ KomposeWidget* KomposeLayout::getNeighbour( const KomposeWidget* widget, int dir return neighbour; } else if (layoutType==TLAYOUT_GENERIC) - return getNeighbour( list, widget, direction, wrap ); + return getNeighbour( list, CONTAINER_GENERIC, widget, direction, wrap ); kdDebug() << "KomposeLayout::getNeighbour() - this should never happen!" << endl; return NULL; @@ -346,6 +348,7 @@ KomposeWidget* KomposeLayout::getNeighbour( const KomposeWidget* widget, int dir */ KomposeWidget* KomposeLayout::getNeighbour( TQPtrList<KomposeWidget> listToSearch, + int listType, const KomposeWidget* widget, int direction, int wrap ) @@ -366,6 +369,15 @@ KomposeWidget* KomposeLayout::getNeighbour( { if ( task == widget ) { + int currentRows, currentColumns; + if( listType == CONTAINER_EMPTY ) { + currentRows = 1; + currentColumns = emptyColumns; + } else { + currentRows = filledRows; + currentColumns = filledColumns; + } + switch ( direction ) { case DLAYOUT_RIGHT: diff --git a/src/komposelayout.h b/src/komposelayout.h index 4ab1df0..19c45d1 100644 --- a/src/komposelayout.h +++ b/src/komposelayout.h @@ -35,10 +35,12 @@ enum LayoutDirections { DLAYOUT_LEFT, DLAYOUT_RIGHT, DLAYOUT_TOP, DLAYOUT_BOTTOM enum WrapDirections { WLAYOUT_NONE, WLAYOUT_HORIZONTAL, WLAYOUT_VERTICAL, WLAYOUT_BOTH }; +enum ContainerType { CONTAINER_GENERIC, CONTAINER_FILLED, CONTAINER_EMPTY }; + /** The main layout class. TQLayout just didn't fit :( - + @author Hans Oischinger */ class KomposeLayout : public TQObject @@ -52,7 +54,7 @@ public: void add( KomposeWidget *w ); void remove( KomposeWidget *w ); void setType( int t ); -int getType() { return layoutType; } + int getType() { return layoutType; } const TQPtrList<KomposeWidget> *getManagedWidgets() { return &list; } int getNumofChilds() { return list.count(); } @@ -65,15 +67,16 @@ public slots: protected: KomposeWidget* getNeighbour( TQPtrList<KomposeWidget> listToSearch, + int listType, const KomposeWidget* widget, int direction = DLAYOUT_RIGHT, int wrap = WLAYOUT_NONE ); void rearrangeContents(); void rearrangeContents( const TQRect& availRect, const TQPtrList<KomposeWidget> widgets, + int containerType = CONTAINER_GENERIC, int rows = -1, - int columns = -1, - bool setMemberRowsCols = true ); + int columns = -1 ); private: // List of all managed childs @@ -86,8 +89,10 @@ private: int layoutType; int spacing; bool widgetsChanged; - int currentRows; - int currentColumns; + + int filledRows; + int filledColumns; + int emptyColumns; KomposeWidget* parentWidget; }; |