CVS commit by aseigo: let's conserve some space and make the layout a bit cuter on larger horiz panels when only showing the icon+temp. reviewed by geiseri M +31 -5 dockwidget.cpp 1.65 M +2 -0 dockwidget.h 1.27 M +2 -0 kweather.cpp 1.97 --- kdetoys/kweather/dockwidget.cpp #1.64:1.65 @@ -31,5 +31,5 @@ dockwidget::dockwidget(const QString &location, QWidget *parent, - const char *name) : QWidget(parent,name), m_locationCode( location ) + const char *name) : QWidget(parent,name), m_locationCode( location ), m_orientation( Horizontal ) { initDock(); @@ -158,6 +158,10 @@ void dockwidget::resizeView( const QSize int h = size.height(); - if (w >= h) + if (m_orientation == Horizontal) { + // in case we previously set this to hcenter previously + // and now change the layout + m_lblTemp->setAlignment(AlignVCenter); + // Kicker in horizontal mode if( m_mode == ShowAll) @@ -169,8 +173,21 @@ void dockwidget::resizeView( const QSize else if ( m_mode == ShowTempOnly) { + if (h > 32) + { + m_lblTemp->setAlignment(AlignVCenter | AlignHCenter); + m_lblTemp->setGeometry(1, h - h/5, w - 2, h/5); + m_button->setGeometry(0, 0, 4*h/5, 4*h/5); + } + else + { m_lblTemp->setGeometry(h+1, 0, w-h, h); + m_button->setGeometry(0, 0, h, h ); } + } + else + { m_button->setGeometry(0, 0, h, h ); } + } else { @@ -207,6 +224,14 @@ int dockwidget::widthForHeight(int h) int pixelSize = QMIN( h, fi.pixelSize() ); m_font.setPixelSize( pixelSize ); + + if (h > 32) + { + w = 4*h/5; + } + else + { w = h + fm.width(m_lblTemp->text()) + 1; } + } updateFont(); --- kdetoys/kweather/dockwidget.h #1.26:1.27 @@ -42,4 +42,5 @@ public: void setViewMode(int); void setFont(QFont newFont); + void setOrientation(Orientation o) { m_orientation = o; } /** resize the view **/ void resizeView(const QSize &size); @@ -66,4 +67,5 @@ private: QLabel *m_lblWind; QLabel *m_lblPres; + Orientation m_orientation; WeatherService_stub *m_weatherService; --- kdetoys/kweather/kweather.cpp #1.96:1.97 @@ -285,4 +285,5 @@ int kweather::widthForHeight(int h) cons { kdDebug(12004) << "widthForHeight " << h << endl; + dockWidget->setOrientation(Horizontal); int w = dockWidget->widthForHeight(h); return w; @@ -292,4 +293,5 @@ int kweather::heightForWidth(int w) cons { kdDebug(12004) << "heightForWidth " << w<< endl; + dockWidget->setOrientation(Vertical); int h = dockWidget->heightForWidth( w ); return h;