-rw-r--r-- | korganizer/navigatorbar.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index b591232..934e153 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -60,128 +60,150 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam | |||
60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
61 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
62 | 62 | ||
63 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
64 | 64 | ||
65 | QFont tfont = font(); | 65 | QFont tfont = font(); |
66 | if ( QApplication::desktop()->width() >= 480 ) | 66 | if ( QApplication::desktop()->width() >= 480 ) |
67 | tfont.setPointSize(tfont.pointSize()+2); | 67 | tfont.setPointSize(tfont.pointSize()+2); |
68 | tfont.setBold(true); | 68 | tfont.setBold(true); |
69 | 69 | ||
70 | bool isRTL = KOGlobals::self()->reverseLayout(); | 70 | bool isRTL = KOGlobals::self()->reverseLayout(); |
71 | #ifndef DESKTOP_VERSION | 71 | #ifndef DESKTOP_VERSION |
72 | bool isDesktop = false; | 72 | bool isDesktop = false; |
73 | #else | 73 | #else |
74 | bool isDesktop = true; | 74 | bool isDesktop = true; |
75 | #endif | 75 | #endif |
76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
77 | isDesktop = true; | 77 | isDesktop = true; |
78 | // Create backward navigation buttons | 78 | // Create backward navigation buttons |
79 | mPrevYear = new QPushButton( mCtrlFrame ); | 79 | mPrevYear = new QPushButton( mCtrlFrame ); |
80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); | 80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); |
81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
82 | 82 | ||
83 | mPrevMonth = new QPushButton( mCtrlFrame ); | 83 | mPrevMonth = new QPushButton( mCtrlFrame ); |
84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
86 | 86 | ||
87 | // Create forward navigation buttons | 87 | // Create forward navigation buttons |
88 | mNextMonth = new QPushButton( mCtrlFrame ); | 88 | mNextMonth = new QPushButton( mCtrlFrame ); |
89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
90 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 90 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
91 | 91 | ||
92 | mPrevWeek = new QPushButton( mCtrlFrame ); | ||
93 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | ||
94 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | ||
95 | |||
96 | // Create forward navigation buttons | ||
97 | mNextWeek = new QPushButton( mCtrlFrame ); | ||
98 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | ||
99 | QToolTip::add( mNextWeek, i18n("Next Week") ); | ||
100 | |||
92 | mNextYear = new QPushButton( mCtrlFrame ); | 101 | mNextYear = new QPushButton( mCtrlFrame ); |
93 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); | 102 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); |
94 | QToolTip::add( mNextYear, i18n("Next Year") ); | 103 | QToolTip::add( mNextYear, i18n("Next Year") ); |
95 | mSelectMonth = new QPushButton( mCtrlFrame ); | 104 | mSelectMonth = new QPushButton( mCtrlFrame ); |
96 | // Create month name label | 105 | // Create month name label |
97 | //selectMonth->setFont( tfont ); | 106 | //selectMonth->setFont( tfont ); |
98 | // selectMonth->setAlignment( AlignCenter ); | 107 | // selectMonth->setAlignment( AlignCenter ); |
99 | //mDateLabel = new QLabel( selectMonth ); | 108 | //mDateLabel = new QLabel( selectMonth ); |
100 | //mDateLabel->setFont( tfont ); | 109 | //mDateLabel->setFont( tfont ); |
101 | //mDateLabel->setAlignment( AlignCenter ); | 110 | //mDateLabel->setAlignment( AlignCenter ); |
102 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 111 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
103 | mNextMonth->setFlat( true); | 112 | mNextMonth->setFlat( true); |
113 | mNextWeek->setFlat( true); | ||
104 | mNextYear->setFlat( true); | 114 | mNextYear->setFlat( true); |
105 | mSelectMonth->setFlat( true); | 115 | mSelectMonth->setFlat( true); |
106 | mPrevYear->setFlat( true); | 116 | mPrevYear->setFlat( true); |
107 | mPrevMonth->setFlat( true); | 117 | mPrevMonth->setFlat( true); |
118 | mPrevWeek->setFlat( true); | ||
119 | } else { | ||
120 | mPrevWeek->hide(); | ||
121 | mNextWeek->hide(); | ||
108 | } | 122 | } |
109 | mSelectMonth->setFont( tfont ); | 123 | mSelectMonth->setFont( tfont ); |
110 | // Set minimum width to width of widest month name label | 124 | // Set minimum width to width of widest month name label |
111 | int i; | 125 | int i; |
112 | int maxwidth = 0; | 126 | int maxwidth = 0; |
113 | QFontMetrics fm ( mSelectMonth->font() ); | 127 | QFontMetrics fm ( mSelectMonth->font() ); |
114 | int width = fm.width("September '00" ); | 128 | int width = fm.width("September '00" ); |
115 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); | 129 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); |
116 | // ++i ) { | 130 | // ++i ) { |
117 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, | 131 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, |
118 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); | 132 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); |
119 | // int width = fm.width("September 2000" ); | 133 | // int width = fm.width("September 2000" ); |
120 | // if ( width > maxwidth ) maxwidth = width; | 134 | // if ( width > maxwidth ) maxwidth = width; |
121 | // } | 135 | // } |
122 | maxwidth = width+2; | 136 | maxwidth = width+2; |
123 | int size = fm.height()+2; | 137 | int size = fm.height()+2; |
124 | if ( QApplication::desktop()->width() >= 480 ) { | 138 | if ( QApplication::desktop()->width() >= 480 ) { |
125 | size += 6; | 139 | size += 6; |
126 | maxwidth+= 6; | 140 | maxwidth+= 6; |
127 | } | 141 | } |
128 | 142 | ||
129 | mSelectMonth->setFixedWidth( maxwidth ); | 143 | mSelectMonth->setFixedWidth( maxwidth ); |
130 | mSelectMonth->setFixedHeight( size ); | 144 | mSelectMonth->setFixedHeight( size ); |
131 | mPrevYear->setFixedHeight( size ); | 145 | mPrevYear->setFixedHeight( size ); |
132 | mPrevMonth->setFixedHeight( size ); | 146 | mPrevMonth->setFixedHeight( size ); |
147 | mPrevWeek->setFixedHeight( size ); | ||
133 | mNextMonth->setFixedHeight( size ); | 148 | mNextMonth->setFixedHeight( size ); |
149 | mNextWeek->setFixedHeight( size ); | ||
134 | mNextYear->setFixedHeight ( size ); | 150 | mNextYear->setFixedHeight ( size ); |
135 | // set up control frame layout | 151 | // set up control frame layout |
136 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 152 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
137 | ctrlLayout->addWidget( mPrevYear, 3 ); | 153 | ctrlLayout->addWidget( mPrevYear, 3 ); |
138 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 154 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
155 | ctrlLayout->addWidget( mPrevWeek, 3 ); | ||
139 | //ctrlLayout->addStretch( 1 ); | 156 | //ctrlLayout->addStretch( 1 ); |
140 | // ctrlLayout->addSpacing( 1 ); | 157 | // ctrlLayout->addSpacing( 1 ); |
141 | // ctrlLayout->addWidget( mDateLabel ); | 158 | // ctrlLayout->addWidget( mDateLabel ); |
142 | ctrlLayout->addWidget( mSelectMonth ); | 159 | ctrlLayout->addWidget( mSelectMonth ); |
143 | // ctrlLayout->addSpacing( 1 ); | 160 | // ctrlLayout->addSpacing( 1 ); |
144 | // ctrlLayout->addStretch( 1 ); | 161 | // ctrlLayout->addStretch( 1 ); |
162 | ctrlLayout->addWidget( mNextWeek, 3 ); | ||
145 | ctrlLayout->addWidget( mNextMonth, 3 ); | 163 | ctrlLayout->addWidget( mNextMonth, 3 ); |
146 | ctrlLayout->addWidget( mNextYear, 3 ); | 164 | ctrlLayout->addWidget( mNextYear, 3 ); |
147 | 165 | ||
148 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 166 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
149 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 167 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
150 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 168 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
169 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | ||
170 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | ||
151 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 171 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
152 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 172 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
153 | mPrevYear->setFocusPolicy(NoFocus); | 173 | mPrevYear->setFocusPolicy(NoFocus); |
154 | mPrevMonth->setFocusPolicy(NoFocus); | 174 | mPrevMonth->setFocusPolicy(NoFocus); |
155 | mNextMonth->setFocusPolicy(NoFocus); | 175 | mNextMonth->setFocusPolicy(NoFocus); |
176 | mPrevWeek->setFocusPolicy(NoFocus); | ||
177 | mNextWeek->setFocusPolicy(NoFocus); | ||
156 | mNextYear->setFocusPolicy(NoFocus); | 178 | mNextYear->setFocusPolicy(NoFocus); |
157 | mSelectMonth->setFocusPolicy(NoFocus); | 179 | mSelectMonth->setFocusPolicy(NoFocus); |
158 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 180 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
159 | 181 | ||
160 | } | 182 | } |
161 | 183 | ||
162 | NavigatorBar::~NavigatorBar() | 184 | NavigatorBar::~NavigatorBar() |
163 | { | 185 | { |
164 | } | 186 | } |
165 | 187 | ||
166 | void NavigatorBar::selectMonth() | 188 | void NavigatorBar::selectMonth() |
167 | { | 189 | { |
168 | 190 | ||
169 | int month; | 191 | int month; |
170 | KPopupFrame* popup = new KPopupFrame(this); | 192 | KPopupFrame* popup = new KPopupFrame(this); |
171 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 193 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
172 | // ----- | 194 | // ----- |
173 | picker->resize(picker->sizeHint()); | 195 | picker->resize(picker->sizeHint()); |
174 | popup->setMainWidget(picker); | 196 | popup->setMainWidget(picker); |
175 | picker->setFocus(); | 197 | picker->setFocus(); |
176 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 198 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
177 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 199 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
178 | { | 200 | { |
179 | month = picker->getResult(); | 201 | month = picker->getResult(); |
180 | emit monthSelected ( month ); | 202 | emit monthSelected ( month ); |
181 | } else { | 203 | } else { |
182 | KNotifyClient::beep(); | 204 | KNotifyClient::beep(); |
183 | } | 205 | } |
184 | delete popup; | 206 | delete popup; |
185 | } | 207 | } |
186 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 208 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
187 | { | 209 | { |