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 @@ -297,21 +297,25 @@ void CalendarView::init() mLeftFrame = mLeftSplitter; #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 ); } //QBoxLayout * leftFrameLayout; - topLayout->addWidget( mainBox ); - mainBoxLayout->addWidget (mLeftFrame); + topLayout->addWidget( mMainFrame ); + //mainBoxLayout->addWidget (mLeftFrame); mDateNavigator = new DateNavigatorContainer( mLeftFrame, "CalendarView::DateNavigator" ); @@ -337,6 +341,6 @@ void CalendarView::init() #endif 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 ); mRightFrame = new QWidgetStack( rightBox ); @@ -345,11 +349,11 @@ void CalendarView::init() //mLeftFrame = (QWidget *)leftFrame; 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() ); } @@ -1836,9 +1840,9 @@ void CalendarView::readSettings() if ( !resetval ){// i.e. sizes.count() == 3 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; } } @@ -1857,4 +1861,35 @@ 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(); else if ( dateCount == 7 ) mNavigator->selectWeek(); @@ -1929,5 +1964,6 @@ void CalendarView::writeSettings() QValueList<int> listINT = mLeftFrame->sizes(); config->writeEntry("Left Splitter Frame",listINT); - + listINT = mMainFrame->sizes(); + config->writeEntry("Main Splitter Frame",listINT); #ifdef DESKTOP_VERSION config->setGroup("WidgetLayout"); diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index fac9a9e..16e671f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -532,5 +532,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser QSplitter *mPanner; 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 @@ -34,4 +34,5 @@ #include "datenavigatorcontainer.h" +#include "koprefs.h" DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, @@ -168,10 +169,31 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); + bool fontchange = false; + QFont fo; if ( horizontalCount != mHorizontalCount || verticalCount != mVerticalCount ) { uint count = horizontalCount * verticalCount; 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(); + } } @@ -189,9 +211,15 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) mExtraViews.removeLast(); } - + if ( fontchange ) { + //mNavigatorView->changeFont( fo ); + uint i; + for( i = 0; i < mExtraViews.count(); ++i ) { + KDateNavigator *view = mExtraViews.at( i ); + view->changeFont( fo ); + } + } mHorizontalCount = horizontalCount; mVerticalCount = verticalCount; } - int height = size().height() / verticalCount; int width = size().width() / horizontalCount; diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index b097dc1..92a0ac2 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -117,4 +117,44 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) enableRollover(FollowMonth); 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 ); } void KDateNavigator::slotMonthSelected( int m ) diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 292e71c..3177687 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h @@ -66,5 +66,10 @@ class KDateNavigator: public QFrame void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} 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: void selectDates( const KCal::DateList & ); @@ -118,4 +123,5 @@ class KDateNavigator: public QFrame private: QSize mySizeHint; + bool mFontChanged; int mMonthSignalOffset; NavigatorBar *mNavigatorBar; diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 619ae39..9181936 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -797,2 +797,13 @@ void KODayMatrix::resizeEvent(QResizeEvent *) daysize.setWidth(sz.width() / 7); } + +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 @@ -171,4 +171,5 @@ public: bool isEndOfMonth() const { return today>=27; } ; QString getWhatsThisText( QPoint ) ; + QSize sizeHint() const; public slots: diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 27d4d17..4a51bba 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp @@ -63,8 +63,5 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam topLayout->addWidget( mCtrlFrame ); - QFont tfont = font(); - if ( QApplication::desktop()->width() >= 480 ) - tfont.setPointSize(tfont.pointSize()+2); - tfont.setBold(true); + bool isRTL = KOGlobals::self()->reverseLayout(); @@ -121,32 +118,8 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam mNextWeek->hide(); } - 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 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); @@ -185,4 +158,34 @@ 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 ) { @@ -203,5 +206,5 @@ 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 @@ -40,4 +40,5 @@ class NavigatorBar: public QWidget ~NavigatorBar(); void showButtons( bool left, bool right ); + void resetFont ( QFont fo ); public slots: |