author | zautrix <zautrix> | 2005-03-20 14:04:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-20 14:04:37 (UTC) |
commit | 69d75020eea5f95b9f5d77d97ed85ec8869d32db (patch) (side-by-side diff) | |
tree | 378b920b9392e7ed4472597e586154d7b99b0645 | |
parent | 289dd44f4f23d92c45d8f28c867a14a980fd5dde (diff) | |
download | kdepimpi-69d75020eea5f95b9f5d77d97ed85ec8869d32db.zip kdepimpi-69d75020eea5f95b9f5d77d97ed85ec8869d32db.tar.gz kdepimpi-69d75020eea5f95b9f5d77d97ed85ec8869d32db.tar.bz2 |
layout fixes
-rw-r--r-- | korganizer/calendarview.cpp | 76 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 36 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 40 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 8 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 11 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 1 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 67 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 1 |
9 files changed, 184 insertions, 58 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3ce123c..ab59d00 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -298,14 +298,18 @@ void CalendarView::init() #else - QWidget *mainBox = new QWidget( this ); + //QWidget *mainBox = new QWidget( this ); //QWidget *leftFrame = new QWidget( mainBox ); - QBoxLayout * mainBoxLayout; + //QBoxLayout * mainBoxLayout; if ( KOPrefs::instance()->mVerticalScreen ) { - mainBoxLayout = new QVBoxLayout(mainBox); + //mainBoxLayout = new QVBoxLayout(mainBox); //leftFrameLayout = new QHBoxLayout(leftFrame ); - mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; - mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); + mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); + mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); + mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; + mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); } else { - mainBoxLayout = new QHBoxLayout(mainBox); + //mainBoxLayout = new QHBoxLayout(mainBox); //leftFrameLayout = new QVBoxLayout(leftFrame ); - mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; + mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); + mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); + mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); @@ -313,4 +317,4 @@ void CalendarView::init() //QBoxLayout * leftFrameLayout; - topLayout->addWidget( mainBox ); - mainBoxLayout->addWidget (mLeftFrame); + topLayout->addWidget( mMainFrame ); + //mainBoxLayout->addWidget (mLeftFrame); mDateNavigator = new DateNavigatorContainer( mLeftFrame, @@ -338,4 +342,4 @@ void CalendarView::init() mFilterView->hide(); - QWidget *rightBox = new QWidget( mainBox ); - mainBoxLayout->addWidget ( rightBox, 10 ); + QWidget *rightBox = new QWidget( mMainFrame ); + //mainBoxLayout->addWidget ( rightBox, 10 ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); @@ -346,9 +350,9 @@ void CalendarView::init() if ( KOPrefs::instance()->mVerticalScreen ) { - mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); + //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); - mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); + //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); } else { - mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); - mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); + //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); + //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); @@ -1837,7 +1841,7 @@ void CalendarView::readSettings() if ( KOPrefs::instance()->mVerticalScreen ) { - if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) - resetval = mDateNavigator->sizeHint().width()+2; + if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) + resetval = mDateNavigator->sizeHint().width()+2; } else { - if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) - resetval = mDateNavigator->sizeHint().height()+2; + if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) + resetval = mDateNavigator->sizeHint().height()+2; } @@ -1858,2 +1862,33 @@ void CalendarView::readSettings() mLeftFrame->setSizes(sizes); + sizes = config->readIntListEntry("Main Splitter Frame"); + if (sizes.count() != 3) { + if ( !KOPrefs::instance()->mVerticalScreen ) { + resetval = mDateNavigator->sizeHint().width()+2; + } else { + resetval = mDateNavigator->sizeHint().height()+2; + } + } + if ( !resetval ){// i.e. sizes.count() == 3 + if ( !KOPrefs::instance()->mVerticalScreen ) { + if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) + resetval = mDateNavigator->sizeHint().width()+2; + } else { + if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) + resetval = mDateNavigator->sizeHint().height()+2; + } + } + if ( resetval ) { + sizes.clear(); + if ( !KOPrefs::instance()->mVerticalScreen ) { + maxVal = QApplication::desktop()->width() -10; + } else { + maxVal = QApplication::desktop()->height()-10; + } + sizes << resetval; + if ( maxVal < resetval + resetval) + resetval = maxVal - resetval; + sizes << resetval; + } + mMainFrame->setSizes(sizes); + if ( dateCount == 5 ) mNavigator->selectWorkWeek(); @@ -1930,3 +1965,4 @@ void CalendarView::writeSettings() config->writeEntry("Left Splitter Frame",listINT); - + listINT = mMainFrame->sizes(); + config->writeEntry("Main Splitter Frame",listINT); #ifdef DESKTOP_VERSION diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index fac9a9e..16e671f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -533,3 +533,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser QSplitter *mLeftSplitter; - KDGanttMinimizeSplitter *mLeftFrame; + KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; QWidgetStack *mRightFrame; diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index b9bd1b9..3358ecf 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp @@ -35,2 +35,3 @@ #include "datenavigatorcontainer.h" +#include "koprefs.h" @@ -169,2 +170,4 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); + bool fontchange = false; + QFont fo; if ( horizontalCount != mHorizontalCount || @@ -173,4 +176,23 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) if ( count == 0 ) { - mNavigatorView->resize( minSize ); - return; + bool ok; + fo = mNavigatorView->yourFontHint( size() , &ok); + //mNavigatorView->resize( size() ); + //if ( ! ok ) + // return; + minSize = mNavigatorView->sizeHint(); + verticalCount = size().height() / minSize.height(); + horizontalCount = size().width() / minSize.width(); + if ( horizontalCount == 0 ) + horizontalCount = 1; + if ( verticalCount == 0 ) + verticalCount = 1; + fontchange = true; + count = horizontalCount * verticalCount; + } else { + if ( mNavigatorView->fontChanged() ) { + fontchange = true; + fo = KOPrefs::instance()->mDateNavigatorFont; + mNavigatorView->changeFont( fo ); + mNavigatorView->unsetFontChanged(); + } } @@ -190,3 +212,10 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) } - + if ( fontchange ) { + //mNavigatorView->changeFont( fo ); + uint i; + for( i = 0; i < mExtraViews.count(); ++i ) { + KDateNavigator *view = mExtraViews.at( i ); + view->changeFont( fo ); + } + } mHorizontalCount = horizontalCount; @@ -194,3 +223,2 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) } - int height = size().height() / verticalCount; diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index b097dc1..92a0ac2 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -118,2 +118,42 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) mySizeHint = sizeHint(); + mFontChanged = false; +} +void KDateNavigator::changeFont ( QFont fo ) +{ + setFont( fo ); + mNavigatorBar->resetFont( fo ); +} +QFont KDateNavigator::yourFontHint( QSize si , bool *b) +{ + QFont fo = KOPrefs::instance()->mDateNavigatorFont; + *b = false; + int fontPoint = fo.pointSize(); + while ( fontPoint > 5 ) { + --fontPoint; + fo.setPointSize( fontPoint ); + setFont( fo ); + mFontChanged = true; + mNavigatorBar->resetFont( fo ); + QSize sh = sizeHint(); + //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); + if ( si.width() > sh.width() && si.height() > sh.height()) { + *b = true; + //qDebug("fooooooooooooooooooooooouuuuund "); + break; + } + } + //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); + return fo; +} +QSize KDateNavigator::sizeHint() const +{ + QFontMetrics fm ( font() ); + QSize day = daymatrix->sizeHint(); + QSize nav = mNavigatorBar->sizeHint(); + int wid = fm.width( "30") + day.width()+3; + int hei = fm.height() +day.height()+nav.height()+2; + if ( wid < nav.width() ) + wid = nav.width() ; + //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); + return QSize ( wid, hei ); } diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 292e71c..3177687 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h @@ -67,3 +67,8 @@ class KDateNavigator: public QFrame QSize yourSizeHint() { return mySizeHint; } - KODayMatrix *dayMatrix() { return daymatrix ;} + QFont yourFontHint( QSize , bool * b); + bool fontChanged() {return mFontChanged; } + void unsetFontChanged() { mFontChanged = false; } + KODayMatrix *dayMatrix() { return daymatrix ;} + QSize sizeHint() const; + void changeFont ( QFont fo ); public slots: @@ -119,2 +124,3 @@ class KDateNavigator: public QFrame QSize mySizeHint; + bool mFontChanged; int mMonthSignalOffset; diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 619ae39..9181936 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -798 +798,12 @@ void KODayMatrix::resizeEvent(QResizeEvent *) } + +QSize KODayMatrix::sizeHint() const +{ + + QFontMetrics fm ( font() ); + int wid = fm.width( "30") *7+7; + int hei = fm.height() * 6+4; + //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); + return QSize ( wid, hei ); + +} diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index c049942..39946de 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h @@ -172,2 +172,3 @@ public: QString getWhatsThisText( QPoint ) ; + QSize sizeHint() const; diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 27d4d17..4a51bba 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp @@ -64,6 +64,3 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam - QFont tfont = font(); - if ( QApplication::desktop()->width() >= 480 ) - tfont.setPointSize(tfont.pointSize()+2); - tfont.setBold(true); + @@ -122,30 +119,6 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam } - mSelectMonth->setFont( tfont ); - // Set minimum width to width of widest month name label - int i; - int maxwidth = 0; - QFontMetrics fm ( mSelectMonth->font() ); - int width = fm.width("September '00" ); -// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); -// ++i ) { -// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, -// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); -// int width = fm.width("September 2000" ); -// if ( width > maxwidth ) maxwidth = width; -// } - maxwidth = width+2; - int size = fm.height()+2; - if ( QApplication::desktop()->width() >= 480 ) { - size += 6; - maxwidth+= 6; - } - mSelectMonth->setFixedWidth( maxwidth ); - mSelectMonth->setFixedHeight( size ); - mPrevYear->setFixedHeight( size ); - mPrevMonth->setFixedHeight( size ); - mPrevWeek->setFixedHeight( size ); - mNextMonth->setFixedHeight( size ); - mNextWeek->setFixedHeight( size ); - mNextYear->setFixedHeight ( size ); + resetFont( font() ); + + // set up control frame layout @@ -186,2 +159,32 @@ NavigatorBar::~NavigatorBar() } +void NavigatorBar::resetFont ( QFont fo ) +{ + + QFont tfont = fo; + if ( QApplication::desktop()->width() >= 480 ) + tfont.setPointSize(tfont.pointSize()+2); + tfont.setBold(true); + + mSelectMonth->setFont( tfont ); + // Set minimum width to width of widest month name label + int i; + int maxwidth = 0; + QFontMetrics fm ( mSelectMonth->font() ); + int width = fm.width("September '00" ); + maxwidth = width+2; + int size = fm.height()+2; + if ( QApplication::desktop()->width() >= 480 ) { + size += 6; + maxwidth+= 6; + } + mSelectMonth->setMinimumWidth( maxwidth ); + mSelectMonth->setFixedHeight( size ); + mPrevYear->setFixedHeight( size ); + mPrevMonth->setFixedHeight( size ); + mPrevWeek->setFixedHeight( size ); + mNextMonth->setFixedHeight( size ); + mNextWeek->setFixedHeight( size ); + mNextYear->setFixedHeight ( size ); +} + void NavigatorBar::showButtons( bool left, bool right ) @@ -204,3 +207,3 @@ void NavigatorBar::showButtons( bool left, bool right ) if ( !left && !right ) { - mSelectMonth->setMaximumWidth( 1024 ); + //mSelectMonth->setMaximumWidth( 1024 ); mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h index 4442caa..0b2f60b 100644 --- a/korganizer/navigatorbar.h +++ b/korganizer/navigatorbar.h @@ -41,2 +41,3 @@ class NavigatorBar: public QWidget void showButtons( bool left, bool right ); + void resetFont ( QFont fo ); |