Fixed desktop switching with "Show empty desktops minimized" option.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
issue/10
Mavridis Philippe 4 years ago
parent 08ec3e383e
commit bbbdf5ffc6
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -34,8 +34,9 @@ KomposeLayout::KomposeLayout( KomposeWidget *parent, int type, int dist, const c
: TQObject(parent, name), : TQObject(parent, name),
spacing(dist), spacing(dist),
widgetsChanged(false), widgetsChanged(false),
currentRows(0), filledRows(0),
currentColumns(0), filledColumns(0),
emptyColumns(0),
parentWidget(parent) parentWidget(parent)
{ {
setType( type ); setType( type );
@ -115,7 +116,7 @@ void KomposeLayout::rearrangeContents()
parentWidget->width(), parentWidget->width(),
parentWidget->height() - ( 40 + 2*spacing ) ); parentWidget->height() - ( 40 + 2*spacing ) );
// arrange the filled desktops taking 90% of the screen // arrange the filled desktops taking 90% of the screen
rearrangeContents( filledRect, filledContainers ); rearrangeContents( filledRect, filledContainers, CONTAINER_FILLED );
// Arrange empty containers // Arrange empty containers
TQRect emptyRect( 0, TQRect emptyRect( 0,
@ -123,7 +124,7 @@ void KomposeLayout::rearrangeContents()
parentWidget->width(), parentWidget->width(),
( 40 + 2*spacing ) ); ( 40 + 2*spacing ) );
// arrange the empty widget in one row // 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 * 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) * 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 // Check or empty list
if (widgets.count() == 0) if (widgets.count() == 0)
@ -300,10 +301,11 @@ void KomposeLayout::rearrangeContents( const TQRect& availRect, const TQPtrList<
} }
// Sync cols/rows member vars to current cols/rows // Sync cols/rows member vars to current cols/rows
if ( setMemberRowsCols ) if( containerType == CONTAINER_EMPTY ) {
{ emptyColumns = columns;
currentRows = rows; } else {
currentColumns = columns; filledRows = rows;
filledColumns = columns;
} }
} }
@ -320,12 +322,12 @@ KomposeWidget* KomposeLayout::getNeighbour( const KomposeWidget* widget, int dir
KomposeWidget* neighbour = 0; KomposeWidget* neighbour = 0;
if ( filledContainers.containsRef(widget) ) 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(); return emptyContainers.first();
} }
else if ( emptyContainers.containsRef(widget) ) 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 ) if ( direction == DLAYOUT_TOP )
return filledContainers.last(); return filledContainers.last();
else else
@ -334,7 +336,7 @@ KomposeWidget* KomposeLayout::getNeighbour( const KomposeWidget* widget, int dir
return neighbour; return neighbour;
} }
else if (layoutType==TLAYOUT_GENERIC) 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; kdDebug() << "KomposeLayout::getNeighbour() - this should never happen!" << endl;
return NULL; return NULL;
@ -346,6 +348,7 @@ KomposeWidget* KomposeLayout::getNeighbour( const KomposeWidget* widget, int dir
*/ */
KomposeWidget* KomposeLayout::getNeighbour( KomposeWidget* KomposeLayout::getNeighbour(
TQPtrList<KomposeWidget> listToSearch, TQPtrList<KomposeWidget> listToSearch,
int listType,
const KomposeWidget* widget, const KomposeWidget* widget,
int direction, int direction,
int wrap ) int wrap )
@ -366,6 +369,15 @@ KomposeWidget* KomposeLayout::getNeighbour(
{ {
if ( task == widget ) if ( task == widget )
{ {
int currentRows, currentColumns;
if( listType == CONTAINER_EMPTY ) {
currentRows = 1;
currentColumns = emptyColumns;
} else {
currentRows = filledRows;
currentColumns = filledColumns;
}
switch ( direction ) switch ( direction )
{ {
case DLAYOUT_RIGHT: case DLAYOUT_RIGHT:

@ -35,6 +35,8 @@ enum LayoutDirections { DLAYOUT_LEFT, DLAYOUT_RIGHT, DLAYOUT_TOP, DLAYOUT_BOTTOM
enum WrapDirections { WLAYOUT_NONE, WLAYOUT_HORIZONTAL, WLAYOUT_VERTICAL, WLAYOUT_BOTH }; enum WrapDirections { WLAYOUT_NONE, WLAYOUT_HORIZONTAL, WLAYOUT_VERTICAL, WLAYOUT_BOTH };
enum ContainerType { CONTAINER_GENERIC, CONTAINER_FILLED, CONTAINER_EMPTY };
/** /**
The main layout class. The main layout class.
TQLayout just didn't fit :( TQLayout just didn't fit :(
@ -65,15 +67,16 @@ public slots:
protected: protected:
KomposeWidget* getNeighbour( TQPtrList<KomposeWidget> listToSearch, KomposeWidget* getNeighbour( TQPtrList<KomposeWidget> listToSearch,
int listType,
const KomposeWidget* widget, const KomposeWidget* widget,
int direction = DLAYOUT_RIGHT, int direction = DLAYOUT_RIGHT,
int wrap = WLAYOUT_NONE ); int wrap = WLAYOUT_NONE );
void rearrangeContents(); void rearrangeContents();
void rearrangeContents( const TQRect& availRect, void rearrangeContents( const TQRect& availRect,
const TQPtrList<KomposeWidget> widgets, const TQPtrList<KomposeWidget> widgets,
int containerType = CONTAINER_GENERIC,
int rows = -1, int rows = -1,
int columns = -1, int columns = -1 );
bool setMemberRowsCols = true );
private: private:
// List of all managed childs // List of all managed childs
@ -86,8 +89,10 @@ private:
int layoutType; int layoutType;
int spacing; int spacing;
bool widgetsChanged; bool widgetsChanged;
int currentRows;
int currentColumns; int filledRows;
int filledColumns;
int emptyColumns;
KomposeWidget* parentWidget; KomposeWidget* parentWidget;
}; };

Loading…
Cancel
Save