summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-21 09:40:04 (UTC)
committer zautrix <zautrix>2005-03-21 09:40:04 (UTC)
commitfd372d97084c401aacb999e89f8bdd94056a3b59 (patch) (unidiff)
tree8443519b847537711d6b423ef903ca132410a682 /korganizer
parentcd02f3880c5567a4bbb7b56e7034787005df7da8 (diff)
downloadkdepimpi-fd372d97084c401aacb999e89f8bdd94056a3b59.zip
kdepimpi-fd372d97084c401aacb999e89f8bdd94056a3b59.tar.gz
kdepimpi-fd372d97084c401aacb999e89f8bdd94056a3b59.tar.bz2
layout fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/navigatorbar.cpp22
-rw-r--r--korganizer/navigatorbar.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 4a51bba..e4abbf7 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -64,184 +64,206 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
64 64
65 65
66 66
67 bool isRTL = KOGlobals::self()->reverseLayout(); 67 bool isRTL = KOGlobals::self()->reverseLayout();
68#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
69 bool isDesktop = false; 69 bool isDesktop = false;
70#else 70#else
71 bool isDesktop = true; 71 bool isDesktop = true;
72#endif 72#endif
73 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 73 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
74 isDesktop = true; 74 isDesktop = true;
75 // Create backward navigation buttons 75 // Create backward navigation buttons
76 mPrevYear = new QPushButton( mCtrlFrame ); 76 mPrevYear = new QPushButton( mCtrlFrame );
77 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 77 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
78 QToolTip::add( mPrevYear, i18n("Previous Year") ); 78 QToolTip::add( mPrevYear, i18n("Previous Year") );
79 79
80 mPrevMonth = new QPushButton( mCtrlFrame ); 80 mPrevMonth = new QPushButton( mCtrlFrame );
81 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 81 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
82 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 82 QToolTip::add( mPrevMonth, i18n("Previous Month") );
83 83
84 // Create forward navigation buttons 84 // Create forward navigation buttons
85 mNextMonth = new QPushButton( mCtrlFrame ); 85 mNextMonth = new QPushButton( mCtrlFrame );
86 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 86 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
87 QToolTip::add( mNextMonth, i18n("Next Month") ); 87 QToolTip::add( mNextMonth, i18n("Next Month") );
88 88
89 mPrevWeek = new QPushButton( mCtrlFrame ); 89 mPrevWeek = new QPushButton( mCtrlFrame );
90 mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 90 mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
91 QToolTip::add( mPrevWeek, i18n("Previous Week") ); 91 QToolTip::add( mPrevWeek, i18n("Previous Week") );
92 92
93 // Create forward navigation buttons 93 // Create forward navigation buttons
94 mNextWeek = new QPushButton( mCtrlFrame ); 94 mNextWeek = new QPushButton( mCtrlFrame );
95 mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 95 mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
96 QToolTip::add( mNextWeek, i18n("Next Week") ); 96 QToolTip::add( mNextWeek, i18n("Next Week") );
97 97
98 mNextYear = new QPushButton( mCtrlFrame ); 98 mNextYear = new QPushButton( mCtrlFrame );
99 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 99 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
100 QToolTip::add( mNextYear, i18n("Next Year") ); 100 QToolTip::add( mNextYear, i18n("Next Year") );
101 mSelectMonth = new QPushButton( mCtrlFrame ); 101 mSelectMonth = new QPushButton( mCtrlFrame );
102 // Create month name label 102 // Create month name label
103 //selectMonth->setFont( tfont ); 103 //selectMonth->setFont( tfont );
104 // selectMonth->setAlignment( AlignCenter ); 104 // selectMonth->setAlignment( AlignCenter );
105 //mDateLabel = new QLabel( selectMonth ); 105 //mDateLabel = new QLabel( selectMonth );
106 //mDateLabel->setFont( tfont ); 106 //mDateLabel->setFont( tfont );
107 //mDateLabel->setAlignment( AlignCenter ); 107 //mDateLabel->setAlignment( AlignCenter );
108 if ( QString ( name ) == QString("useBigPixmaps") ) { 108 if ( QString ( name ) == QString("useBigPixmaps") ) {
109 mNextMonth->setFlat( true); 109 mNextMonth->setFlat( true);
110 mNextWeek->setFlat( true); 110 mNextWeek->setFlat( true);
111 mNextYear->setFlat( true); 111 mNextYear->setFlat( true);
112 mSelectMonth->setFlat( true); 112 mSelectMonth->setFlat( true);
113 mPrevYear->setFlat( true); 113 mPrevYear->setFlat( true);
114 mPrevMonth->setFlat( true); 114 mPrevMonth->setFlat( true);
115 mPrevWeek->setFlat( true); 115 mPrevWeek->setFlat( true);
116 } else { 116 } else {
117 mPrevWeek->hide(); 117 mPrevWeek->hide();
118 mNextWeek->hide(); 118 mNextWeek->hide();
119 } 119 }
120 120
121 resetFont( font() ); 121 resetFont( font() );
122 122
123 123
124 // set up control frame layout 124 // set up control frame layout
125 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 125 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
126 ctrlLayout->addWidget( mPrevYear, 3 ); 126 ctrlLayout->addWidget( mPrevYear, 3 );
127 ctrlLayout->addWidget( mPrevMonth, 3 ); 127 ctrlLayout->addWidget( mPrevMonth, 3 );
128 ctrlLayout->addWidget( mPrevWeek, 3 ); 128 ctrlLayout->addWidget( mPrevWeek, 3 );
129 //ctrlLayout->addStretch( 1 ); 129 //ctrlLayout->addStretch( 1 );
130 // ctrlLayout->addSpacing( 1 ); 130 // ctrlLayout->addSpacing( 1 );
131 // ctrlLayout->addWidget( mDateLabel ); 131 // ctrlLayout->addWidget( mDateLabel );
132 ctrlLayout->addWidget( mSelectMonth ); 132 ctrlLayout->addWidget( mSelectMonth );
133 // ctrlLayout->addSpacing( 1 ); 133 // ctrlLayout->addSpacing( 1 );
134 // ctrlLayout->addStretch( 1 ); 134 // ctrlLayout->addStretch( 1 );
135 ctrlLayout->addWidget( mNextWeek, 3 ); 135 ctrlLayout->addWidget( mNextWeek, 3 );
136 ctrlLayout->addWidget( mNextMonth, 3 ); 136 ctrlLayout->addWidget( mNextMonth, 3 );
137 ctrlLayout->addWidget( mNextYear, 3 ); 137 ctrlLayout->addWidget( mNextYear, 3 );
138 138
139 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 139 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
140 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 140 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
141 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 141 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
142 connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); 142 connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) );
143 connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); 143 connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) );
144 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 144 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
145 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 145 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
146 mPrevYear->setFocusPolicy(NoFocus); 146 mPrevYear->setFocusPolicy(NoFocus);
147 mPrevMonth->setFocusPolicy(NoFocus); 147 mPrevMonth->setFocusPolicy(NoFocus);
148 mNextMonth->setFocusPolicy(NoFocus); 148 mNextMonth->setFocusPolicy(NoFocus);
149 mPrevWeek->setFocusPolicy(NoFocus); 149 mPrevWeek->setFocusPolicy(NoFocus);
150 mNextWeek->setFocusPolicy(NoFocus); 150 mNextWeek->setFocusPolicy(NoFocus);
151 mNextYear->setFocusPolicy(NoFocus); 151 mNextYear->setFocusPolicy(NoFocus);
152 mSelectMonth->setFocusPolicy(NoFocus); 152 mSelectMonth->setFocusPolicy(NoFocus);
153 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 153 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
154 154
155} 155}
156 156
157NavigatorBar::~NavigatorBar() 157NavigatorBar::~NavigatorBar()
158{ 158{
159} 159}
160QSize NavigatorBar::sizeHint() const
161{
162 int wid = mCurrentMinWid ;
163 if ( mPrevYear->isVisible() )
164 wid += mCurrentButtonMinWid;
165 if ( mPrevMonth->isVisible() )
166 wid += mCurrentButtonMinWid;
167 if ( mPrevWeek->isVisible() )
168 wid += mCurrentButtonMinWid;
169 if ( mNextMonth->isVisible() )
170 wid += mCurrentButtonMinWid;
171 if ( mNextWeek->isVisible() )
172 wid += mCurrentButtonMinWid;
173 if ( mNextYear->isVisible() )
174 wid += mCurrentButtonMinWid;
175 //qDebug("ret %d %d ", wid, mCurrentHei);
176 int add = 2;
177 return QSize ( wid+add, mCurrentHei+add );
178}
160void NavigatorBar::resetFont ( QFont fo ) 179void NavigatorBar::resetFont ( QFont fo )
161{ 180{
162 181
163 QFont tfont = fo; 182 QFont tfont = fo;
164 if ( QApplication::desktop()->width() >= 480 ) 183 if ( QApplication::desktop()->width() >= 480 )
165 tfont.setPointSize(tfont.pointSize()+2); 184 tfont.setPointSize(tfont.pointSize()+2);
166 tfont.setBold(true); 185 tfont.setBold(true);
167 186
168 mSelectMonth->setFont( tfont ); 187 mSelectMonth->setFont( tfont );
169 // Set minimum width to width of widest month name label 188 // Set minimum width to width of widest month name label
170 int i; 189 int i;
171 int maxwidth = 0; 190 int maxwidth = 0;
172 QFontMetrics fm ( mSelectMonth->font() ); 191 QFontMetrics fm ( mSelectMonth->font() );
173 int width = fm.width("September '00" ); 192 int width = fm.width("September '00" );
174 maxwidth = width+2; 193 maxwidth = width+2;
175 int size = fm.height()+2; 194 int size = fm.height()+2;
176 if ( QApplication::desktop()->width() >= 480 ) { 195 if ( QApplication::desktop()->width() >= 480 ) {
177 size += 6; 196 size += 6;
178 maxwidth+= 6; 197 maxwidth+= 6;
179 } 198 }
180 mSelectMonth->setMinimumWidth( maxwidth ); 199 mSelectMonth->setMinimumWidth( maxwidth );
181 mSelectMonth->setFixedHeight( size ); 200 mSelectMonth->setFixedHeight( size );
182 mPrevYear->setFixedHeight( size ); 201 mPrevYear->setFixedHeight( size );
183 mPrevMonth->setFixedHeight( size ); 202 mPrevMonth->setFixedHeight( size );
184 mPrevWeek->setFixedHeight( size ); 203 mPrevWeek->setFixedHeight( size );
185 mNextMonth->setFixedHeight( size ); 204 mNextMonth->setFixedHeight( size );
186 mNextWeek->setFixedHeight( size ); 205 mNextWeek->setFixedHeight( size );
187 mNextYear->setFixedHeight ( size ); 206 mNextYear->setFixedHeight ( size );
207 mCurrentHei = size;
208 mCurrentMinWid = maxwidth;
209 mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2;
188} 210}
189 211
190void NavigatorBar::showButtons( bool left, bool right ) 212void NavigatorBar::showButtons( bool left, bool right )
191{ 213{
192 if ( left ) { 214 if ( left ) {
193 mPrevYear->show(); 215 mPrevYear->show();
194 mPrevMonth->show(); 216 mPrevMonth->show();
195 } else { 217 } else {
196 mPrevYear->hide(); 218 mPrevYear->hide();
197 mPrevMonth->hide(); 219 mPrevMonth->hide();
198 } 220 }
199 221
200 if ( right ) { 222 if ( right ) {
201 mNextYear->show(); 223 mNextYear->show();
202 mNextMonth->show(); 224 mNextMonth->show();
203 } else { 225 } else {
204 mNextYear->hide(); 226 mNextYear->hide();
205 mNextMonth->hide(); 227 mNextMonth->hide();
206 } 228 }
207 if ( !left && !right ) { 229 if ( !left && !right ) {
208 //mSelectMonth->setMaximumWidth( 1024 ); 230 //mSelectMonth->setMaximumWidth( 1024 );
209 mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 231 mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
210 } 232 }
211} 233}
212 234
213void NavigatorBar::selectMonth() 235void NavigatorBar::selectMonth()
214{ 236{
215 237
216 int month; 238 int month;
217 KPopupFrame* popup = new KPopupFrame(this); 239 KPopupFrame* popup = new KPopupFrame(this);
218 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); 240 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
219 // ----- 241 // -----
220 picker->resize(picker->sizeHint()); 242 picker->resize(picker->sizeHint());
221 popup->setMainWidget(picker); 243 popup->setMainWidget(picker);
222 picker->setFocus(); 244 picker->setFocus();
223 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 245 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
224 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 246 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
225 { 247 {
226 month = picker->getResult(); 248 month = picker->getResult();
227 emit monthSelected ( month ); 249 emit monthSelected ( month );
228 } else { 250 } else {
229 KNotifyClient::beep(); 251 KNotifyClient::beep();
230 } 252 }
231 delete popup; 253 delete popup;
232} 254}
233void NavigatorBar::selectDates( const KCal::DateList &dateList ) 255void NavigatorBar::selectDates( const KCal::DateList &dateList )
234{ 256{
235 if (dateList.count() > 0) { 257 if (dateList.count() > 0) {
236 QDate date = dateList.first(); 258 QDate date = dateList.first();
237 259
238 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 260 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
239 261
240 // compute the label at the top of the navigator 262 // compute the label at the top of the navigator
241 QString dtstr = i18n(calSys->monthName( date )) + " '" + 263 QString dtstr = i18n(calSys->monthName( date )) + " '" +
242 QString::number( calSys->year( date ) ).right(2); 264 QString::number( calSys->year( date ) ).right(2);
243 265
244 mSelectMonth->setText( dtstr ); 266 mSelectMonth->setText( dtstr );
245 } 267 }
246} 268}
247 269
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h
index 0b2f60b..5d5aff4 100644
--- a/korganizer/navigatorbar.h
+++ b/korganizer/navigatorbar.h
@@ -1,71 +1,75 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef NAVIGATORBAR_H 24#ifndef NAVIGATORBAR_H
25#define NAVIGATORBAR_H 25#define NAVIGATORBAR_H
26 26
27#include <libkcal/incidencebase.h> 27#include <libkcal/incidencebase.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30 30
31class QPushButton; 31class QPushButton;
32class QFrame; 32class QFrame;
33class QLabel; 33class QLabel;
34 34
35class NavigatorBar: public QWidget 35class NavigatorBar: public QWidget
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); 39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 );
40 ~NavigatorBar(); 40 ~NavigatorBar();
41 void showButtons( bool left, bool right ); 41 void showButtons( bool left, bool right );
42 void resetFont ( QFont fo ); 42 void resetFont ( QFont fo );
43 QSize sizeHint() const;
43 44
44 public slots: 45 public slots:
45 void selectDates( const KCal::DateList & ); 46 void selectDates( const KCal::DateList & );
46 void selectMonth(); 47 void selectMonth();
47 48
48 signals: 49 signals:
49 void goNextMonth(); 50 void goNextMonth();
50 void goPrevMonth(); 51 void goPrevMonth();
51 void goNextWeek(); 52 void goNextWeek();
52 void goPrevWeek(); 53 void goPrevWeek();
53 void goNextYear(); 54 void goNextYear();
54 void goPrevYear(); 55 void goPrevYear();
55 void monthSelected( int ); 56 void monthSelected( int );
56 57
57 private: 58 private:
59 int mCurrentHei;
60 int mCurrentMinWid;
61 int mCurrentButtonMinWid;
58 QFrame *mCtrlFrame; 62 QFrame *mCtrlFrame;
59 63
60 QPushButton *mPrevYear; 64 QPushButton *mPrevYear;
61 QPushButton *mPrevMonth; 65 QPushButton *mPrevMonth;
62 QPushButton *mNextMonth; 66 QPushButton *mNextMonth;
63 QPushButton *mPrevWeek; 67 QPushButton *mPrevWeek;
64 QPushButton *mNextWeek; 68 QPushButton *mNextWeek;
65 QPushButton *mNextYear; 69 QPushButton *mNextYear;
66 QPushButton *mSelectMonth; 70 QPushButton *mSelectMonth;
67 71
68 //QLabel *mDateLabel; 72 //QLabel *mDateLabel;
69}; 73};
70 74
71#endif 75#endif