-rw-r--r-- | microkde/kdatetbl.cpp | 22 | ||||
-rw-r--r-- | microkde/kglobalsettings.cpp | 6 |
2 files changed, 22 insertions, 6 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index fce0e5a..e827412 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -177,50 +177,54 @@ KDateTable::paintCell(QPainter *painter, int row, int col) | |||
177 | painter->setPen(red); | 177 | painter->setPen(red); |
178 | if(hasFocus()) | 178 | if(hasFocus()) |
179 | { | 179 | { |
180 | painter->setBrush(darkRed); | 180 | painter->setBrush(darkRed); |
181 | pen=white; | 181 | pen=white; |
182 | } else { | 182 | } else { |
183 | painter->setBrush(darkGray); | 183 | painter->setBrush(darkGray); |
184 | pen=white; | 184 | pen=white; |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
188 | { | 188 | { |
189 | painter->setPen(green); | 189 | painter->setPen(green); |
190 | painter->setBrush(darkGreen); | 190 | painter->setBrush(darkGreen); |
191 | pen=white; | 191 | pen=white; |
192 | } else { | 192 | } else { |
193 | painter->setBrush(QColor(220,245,255)); | 193 | painter->setBrush(QColor(220,245,255)); |
194 | painter->setPen(QColor(220,245,255)); | 194 | painter->setPen(QColor(220,245,255)); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | painter->drawRect(0, 0, w, h); | 197 | painter->drawRect(0, 0, w, h); |
198 | painter->setPen(pen); | 198 | painter->setPen(pen); |
199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | 199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); |
200 | } | 200 | } |
201 | /* | ||
201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | 202 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); |
202 | if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); | 203 | if(rect.height()>maxCell.height()) { |
204 | maxCell.setHeight(rect.height()); | ||
205 | } | ||
206 | */ | ||
203 | } | 207 | } |
204 | 208 | ||
205 | void | 209 | void |
206 | KDateTable::keyPressEvent( QKeyEvent *e ) | 210 | KDateTable::keyPressEvent( QKeyEvent *e ) |
207 | { | 211 | { |
208 | /* | 212 | /* |
209 | // not working properly | 213 | // not working properly |
210 | if ( e->key() == Qt::Key_Prior ) { | 214 | if ( e->key() == Qt::Key_Prior ) { |
211 | if ( date.month() == 1 ) { | 215 | if ( date.month() == 1 ) { |
212 | KNotifyClient::beep(); | 216 | KNotifyClient::beep(); |
213 | return; | 217 | return; |
214 | } | 218 | } |
215 | int day = date.day(); | 219 | int day = date.day(); |
216 | if ( day > 27 ) | 220 | if ( day > 27 ) |
217 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) | 221 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) |
218 | day--; | 222 | day--; |
219 | setDate(QDate(date.year(), date.month()-1, day)); | 223 | setDate(QDate(date.year(), date.month()-1, day)); |
220 | return; | 224 | return; |
221 | } | 225 | } |
222 | if ( e->key() == Qt::Key_Next ) { | 226 | if ( e->key() == Qt::Key_Next ) { |
223 | if ( date.month() == 12 ) { | 227 | if ( date.month() == 12 ) { |
224 | KNotifyClient::beep(); | 228 | KNotifyClient::beep(); |
225 | return; | 229 | return; |
226 | } | 230 | } |
@@ -292,51 +296,57 @@ KDateTable::viewportResizeEvent(QResizeEvent * e) | |||
292 | void | 296 | void |
293 | KDateTable::setFontSize(int size) | 297 | KDateTable::setFontSize(int size) |
294 | { | 298 | { |
295 | int count; | 299 | int count; |
296 | QRect rect; | 300 | QRect rect; |
297 | // ----- store rectangles: | 301 | // ----- store rectangles: |
298 | fontsize=size; | 302 | fontsize=size; |
299 | QFont font = KGlobalSettings::generalFont(); | 303 | QFont font = KGlobalSettings::generalFont(); |
300 | font.setPointSize(fontsize); | 304 | font.setPointSize(fontsize); |
301 | font.setBold( true ); | 305 | font.setBold( true ); |
302 | QFontMetrics metrics(font); | 306 | QFontMetrics metrics(font); |
303 | 307 | ||
304 | // ----- find largest day name: | 308 | // ----- find largest day name: |
305 | maxCell.setWidth(0); | 309 | maxCell.setWidth(0); |
306 | maxCell.setHeight(0); | 310 | maxCell.setHeight(0); |
307 | for(count=0; count<7; ++count) | 311 | for(count=0; count<7; ++count) |
308 | { | 312 | { |
309 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | 313 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); |
310 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | 314 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); |
311 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | 315 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); |
312 | } | 316 | } |
313 | // ----- compare with a real wide number and add some space: | 317 | // ----- compare with a real wide number and add some space: |
314 | rect=metrics.boundingRect(QString::fromLatin1("88")); | 318 | rect=metrics.boundingRect(QString::fromLatin1("88")); |
315 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | 319 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); |
320 | #ifdef DESKTOP_VERSION | ||
321 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); | ||
322 | #else | ||
316 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | 323 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); |
317 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) | 324 | #endif |
325 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { | ||
318 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); | 326 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); |
327 | qDebug("setmax "); | ||
328 | } | ||
319 | } | 329 | } |
320 | 330 | ||
321 | void | 331 | void |
322 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | 332 | KDateTable::contentsMousePressEvent(QMouseEvent *e) |
323 | { | 333 | { |
324 | if(e->type()!=QEvent::MouseButtonPress) | 334 | if(e->type()!=QEvent::MouseButtonPress) |
325 | { // the KDatePicker only reacts on mouse press events: | 335 | { // the KDatePicker only reacts on mouse press events: |
326 | return; | 336 | return; |
327 | } | 337 | } |
328 | if(!isEnabled()) | 338 | if(!isEnabled()) |
329 | { | 339 | { |
330 | KNotifyClient::beep(); | 340 | KNotifyClient::beep(); |
331 | return; | 341 | return; |
332 | } | 342 | } |
333 | 343 | ||
334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 344 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
335 | // ----- | 345 | // ----- |
336 | int row, col, pos, temp; | 346 | int row, col, pos, temp; |
337 | QPoint mouseCoord; | 347 | QPoint mouseCoord; |
338 | // ----- | 348 | // ----- |
339 | mouseCoord = e->pos(); | 349 | mouseCoord = e->pos(); |
340 | row=rowAt(mouseCoord.y()); | 350 | row=rowAt(mouseCoord.y()); |
341 | col=columnAt(mouseCoord.x()); | 351 | col=columnAt(mouseCoord.x()); |
342 | if(row<0 || col<0) | 352 | if(row<0 || col<0) |
@@ -422,49 +432,49 @@ void KDateTable::focusOutEvent( QFocusEvent *e ) | |||
422 | 432 | ||
423 | QSize | 433 | QSize |
424 | KDateTable::sizeHint() const | 434 | KDateTable::sizeHint() const |
425 | { | 435 | { |
426 | if(maxCell.height()>0 && maxCell.width()>0) | 436 | if(maxCell.height()>0 && maxCell.width()>0) |
427 | { | 437 | { |
428 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), | 438 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), |
429 | (maxCell.height()+4)*numRows()+2*frameWidth()); | 439 | (maxCell.height()+4)*numRows()+2*frameWidth()); |
430 | } else { | 440 | } else { |
431 | return QSize(-1, -1); | 441 | return QSize(-1, -1); |
432 | } | 442 | } |
433 | } | 443 | } |
434 | 444 | ||
435 | KDateInternalMonthPicker::KDateInternalMonthPicker | 445 | KDateInternalMonthPicker::KDateInternalMonthPicker |
436 | (int fontsize, QWidget* parent, const char* name) | 446 | (int fontsize, QWidget* parent, const char* name) |
437 | : QGridView(parent, name), | 447 | : QGridView(parent, name), |
438 | result(0) // invalid | 448 | result(0) // invalid |
439 | { | 449 | { |
440 | QRect rect; | 450 | QRect rect; |
441 | QFont font; | 451 | QFont font; |
442 | // ----- | 452 | // ----- |
443 | activeCol = -1; | 453 | activeCol = -1; |
444 | activeRow = -1; | 454 | activeRow = -1; |
445 | font=KGlobalSettings::generalFont(); | 455 | font=KGlobalSettings::generalFont(); |
446 | font.setPointSize(fontsize); | 456 | //font.setPointSize(fontsize); |
447 | setFont(font); | 457 | setFont(font); |
448 | setHScrollBarMode(AlwaysOff); | 458 | setHScrollBarMode(AlwaysOff); |
449 | setVScrollBarMode(AlwaysOff); | 459 | setVScrollBarMode(AlwaysOff); |
450 | setFrameStyle(QFrame::NoFrame); | 460 | setFrameStyle(QFrame::NoFrame); |
451 | setNumRows(4); | 461 | setNumRows(4); |
452 | setNumCols(3); | 462 | setNumCols(3); |
453 | // enable to find drawing failures: | 463 | // enable to find drawing failures: |
454 | // setTableFlags(Tbl_clipCellPainting); | 464 | // setTableFlags(Tbl_clipCellPainting); |
455 | #if 0 | 465 | #if 0 |
456 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 466 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
457 | #endif | 467 | #endif |
458 | // ----- find the preferred size | 468 | // ----- find the preferred size |
459 | // (this is slow, possibly, but unfortunatly it is needed here): | 469 | // (this is slow, possibly, but unfortunatly it is needed here): |
460 | QFontMetrics metrics(font); | 470 | QFontMetrics metrics(font); |
461 | for(int i=1; i <= 12; ++i) | 471 | for(int i=1; i <= 12; ++i) |
462 | { | 472 | { |
463 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | 473 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); |
464 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 474 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
465 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 475 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
466 | } | 476 | } |
467 | 477 | ||
468 | } | 478 | } |
469 | 479 | ||
470 | QSize | 480 | QSize |
@@ -740,70 +750,74 @@ KPopupFrame::exec(int x, int y) | |||
740 | { | 750 | { |
741 | return exec(QPoint(x, y)); | 751 | return exec(QPoint(x, y)); |
742 | } | 752 | } |
743 | 753 | ||
744 | void KPopupFrame::virtual_hook( int, void* ) | 754 | void KPopupFrame::virtual_hook( int, void* ) |
745 | { /*BASE::virtual_hook( id, data );*/ } | 755 | { /*BASE::virtual_hook( id, data );*/ } |
746 | 756 | ||
747 | void KDateTable::virtual_hook( int, void* ) | 757 | void KDateTable::virtual_hook( int, void* ) |
748 | { /*BASE::virtual_hook( id, data );*/ } | 758 | { /*BASE::virtual_hook( id, data );*/ } |
749 | 759 | ||
750 | //#include "kdatetbl.moc" | 760 | //#include "kdatetbl.moc" |
751 | 761 | ||
752 | 762 | ||
753 | KDateInternalWeekPicker::KDateInternalWeekPicker | 763 | KDateInternalWeekPicker::KDateInternalWeekPicker |
754 | (int fontsize, QWidget* parent, const char* name) | 764 | (int fontsize, QWidget* parent, const char* name) |
755 | : QGridView(parent, name), | 765 | : QGridView(parent, name), |
756 | result(0) // invalid | 766 | result(0) // invalid |
757 | { | 767 | { |
758 | QRect rect; | 768 | QRect rect; |
759 | QFont font; | 769 | QFont font; |
760 | // ----- | 770 | // ----- |
761 | activeCol = -1; | 771 | activeCol = -1; |
762 | activeRow = -1; | 772 | activeRow = -1; |
763 | font=KGlobalSettings::generalFont(); | 773 | font=KGlobalSettings::generalFont(); |
764 | font.setPointSize(fontsize); | 774 | //font.setPointSize(fontsize); |
765 | setFont(font); | 775 | setFont(font); |
766 | setHScrollBarMode(AlwaysOff); | 776 | setHScrollBarMode(AlwaysOff); |
767 | setVScrollBarMode(AlwaysOff); | 777 | setVScrollBarMode(AlwaysOff); |
768 | setFrameStyle(QFrame::NoFrame); | 778 | setFrameStyle(QFrame::NoFrame); |
769 | setNumRows(13); | 779 | setNumRows(13); |
770 | setNumCols(4); | 780 | setNumCols(4); |
771 | // enable to find drawing failures: | 781 | // enable to find drawing failures: |
772 | // setTableFlags(Tbl_clipCellPainting); | 782 | // setTableFlags(Tbl_clipCellPainting); |
773 | #if 0 | 783 | #if 0 |
774 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 784 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
775 | #endif | 785 | #endif |
776 | // ----- find the preferred size | 786 | // ----- find the preferred size |
777 | // (this is slow, possibly, but unfortunatly it is needed here): | 787 | // (this is slow, possibly, but unfortunatly it is needed here): |
778 | QFontMetrics metrics(font); | 788 | QFontMetrics metrics(font); |
779 | for(int i=1; i <= 52; ++i) | 789 | for(int i=1; i <= 52; ++i) |
780 | { | 790 | { |
781 | rect=metrics.boundingRect(QString::number( i )); | 791 | rect=metrics.boundingRect(QString::number( i )); |
782 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 792 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
783 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 793 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
784 | } | 794 | } |
795 | if ( QApplication::desktop()->width() > 640 ) { | ||
785 | 796 | ||
797 | max.setWidth(max.width()+6); | ||
798 | max.setHeight(max.height()+8); | ||
799 | } | ||
786 | } | 800 | } |
787 | 801 | ||
788 | QSize | 802 | QSize |
789 | KDateInternalWeekPicker::sizeHint() const | 803 | KDateInternalWeekPicker::sizeHint() const |
790 | { | 804 | { |
791 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 805 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
792 | (max.height()+6)*numRows()+2*frameWidth()); | 806 | (max.height()+6)*numRows()+2*frameWidth()); |
793 | } | 807 | } |
794 | 808 | ||
795 | int | 809 | int |
796 | KDateInternalWeekPicker::getResult() const | 810 | KDateInternalWeekPicker::getResult() const |
797 | { | 811 | { |
798 | return result; | 812 | return result; |
799 | } | 813 | } |
800 | 814 | ||
801 | void | 815 | void |
802 | KDateInternalWeekPicker::setupPainter(QPainter *p) | 816 | KDateInternalWeekPicker::setupPainter(QPainter *p) |
803 | { | 817 | { |
804 | p->setPen(black); | 818 | p->setPen(black); |
805 | } | 819 | } |
806 | 820 | ||
807 | void | 821 | void |
808 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) | 822 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) |
809 | { | 823 | { |
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp index 2fff8fc..30e793f 100644 --- a/microkde/kglobalsettings.cpp +++ b/microkde/kglobalsettings.cpp | |||
@@ -1,41 +1,43 @@ | |||
1 | #include "kglobalsettings.h" | 1 | #include "kglobalsettings.h" |
2 | #include "kconfig.h" | 2 | #include "kconfig.h" |
3 | #include "kglobal.h" | 3 | #include "kglobal.h" |
4 | #include "kconfigbase.h" | 4 | #include "kconfigbase.h" |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | QFont KGlobalSettings::generalFont() | 8 | QFont KGlobalSettings::generalFont() |
9 | { | 9 | { |
10 | int size = 12; | 10 | int size = 12; |
11 | if (QApplication::desktop()->width() < 480 ) | 11 | if (QApplication::desktop()->width() < 480 ) |
12 | size = 10; | 12 | size = 10; |
13 | return QFont("helvetica",size); | 13 | QFont f = QApplication::font(); |
14 | f.setPointSize( size ); | ||
15 | return f; | ||
14 | } | 16 | } |
15 | QFont KGlobalSettings::toolBarFont() | 17 | QFont KGlobalSettings::toolBarFont() |
16 | { | 18 | { |
17 | return QFont("helevetica",12); | 19 | return QApplication::font(); |
18 | } | 20 | } |
19 | 21 | ||
20 | QColor KGlobalSettings::toolBarHighlightColor() | 22 | QColor KGlobalSettings::toolBarHighlightColor() |
21 | { | 23 | { |
22 | return QColor("black"); | 24 | return QColor("black"); |
23 | } | 25 | } |
24 | 26 | ||
25 | QRect KGlobalSettings::desktopGeometry( QWidget * ) | 27 | QRect KGlobalSettings::desktopGeometry( QWidget * ) |
26 | { | 28 | { |
27 | return QApplication::desktop()->rect(); | 29 | return QApplication::desktop()->rect(); |
28 | } | 30 | } |
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Returns whether KDE runs in single (default) or double click | 33 | * Returns whether KDE runs in single (default) or double click |
32 | * mode. | 34 | * mode. |
33 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 35 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
34 | * @return true if single click mode, or false if double click mode. | 36 | * @return true if single click mode, or false if double click mode. |
35 | **/ | 37 | **/ |
36 | bool KGlobalSettings::singleClick() | 38 | bool KGlobalSettings::singleClick() |
37 | { | 39 | { |
38 | KConfig *c = KGlobal::config(); | 40 | KConfig *c = KGlobal::config(); |
39 | KConfigGroupSaver cgs( c, "KDE" ); | 41 | KConfigGroupSaver cgs( c, "KDE" ); |
40 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); | 42 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); |
41 | } | 43 | } |