-rw-r--r-- | korganizer/mainwindow.cpp | 106 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 15 |
2 files changed, 84 insertions, 37 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 348dd5e..119e28a 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -69,12 +69,13 @@ using namespace KCal; | |||
69 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
70 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
71 | #endif | 71 | #endif |
72 | #endif | 72 | #endif |
73 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
74 | 74 | ||
75 | |||
75 | class KOex2phonePrefs : public QDialog | 76 | class KOex2phonePrefs : public QDialog |
76 | { | 77 | { |
77 | public: | 78 | public: |
78 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
79 | QDialog( parent, name, true ) | 80 | QDialog( parent, name, true ) |
80 | { | 81 | { |
@@ -141,16 +142,17 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
141 | QString confFile = locateLocal("config","korganizerrc"); | 142 | QString confFile = locateLocal("config","korganizerrc"); |
142 | QFileInfo finf ( confFile ); | 143 | QFileInfo finf ( confFile ); |
143 | bool showWarning = !finf.exists(); | 144 | bool showWarning = !finf.exists(); |
144 | setIcon(SmallIcon( "ko24" ) ); | 145 | setIcon(SmallIcon( "ko24" ) ); |
145 | mBlockAtStartup = true; | 146 | mBlockAtStartup = true; |
146 | mFlagKeyPressed = false; | 147 | mFlagKeyPressed = false; |
148 | setCaption("KOrganizer/Pi"); | ||
147 | KOPrefs *p = KOPrefs::instance(); | 149 | KOPrefs *p = KOPrefs::instance(); |
148 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 150 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
149 | if ( p->mHourSize > 18 ) | 151 | if ( p->mHourSize > 22 ) |
150 | p->mHourSize = 18; | 152 | p->mHourSize = 22; |
151 | QMainWindow::ToolBarDock tbd; | 153 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 154 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 155 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 156 | tbd = Bottom; |
155 | else | 157 | else |
156 | tbd = Top; | 158 | tbd = Top; |
@@ -164,14 +166,12 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
164 | if ( KOPrefs::instance()->mUseAppColors ) | 166 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 167 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 168 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 169 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 170 | addToolBar (iconToolBar , tbd ); |
169 | mCalendarModifiedFlag = false; | 171 | mCalendarModifiedFlag = false; |
170 | |||
171 | setCaption("KOrganizer/Pi"); | ||
172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
173 | splash->setAlignment ( AlignCenter ); | 173 | splash->setAlignment ( AlignCenter ); |
174 | setCentralWidget( splash ); | 174 | setCentralWidget( splash ); |
175 | #ifndef DESKTOP_VERSION | 175 | #ifndef DESKTOP_VERSION |
176 | showMaximized(); | 176 | showMaximized(); |
177 | #endif | 177 | #endif |
@@ -554,49 +554,55 @@ void MainWindow::initActions() | |||
554 | menuBar->insertItem( i18n("Help"), helpMenu ); | 554 | menuBar->insertItem( i18n("Help"), helpMenu ); |
555 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 555 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
556 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 556 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
557 | } | 557 | } |
558 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 558 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
559 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 559 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
560 | 560 | QIconSet icon; | |
561 | menuBarWeek = new QPEMenuBar( iconToolBar ); | 561 | int pixWid = 22, pixHei = 22; |
562 | QPopupMenu * wpo = new QPopupMenu (this); | 562 | QString pathString = ""; |
563 | QPopupMenu * all = new QPopupMenu (this); | 563 | if ( !p->mToolBarMiniIcons ) { |
564 | //wpo->insertItem( i18n("W#"), 0 ); | 564 | if ( QApplication::desktop()->width() < 480 ) { |
565 | int first = 1; | 565 | pathString += "icons16/"; |
566 | int i; | 566 | pixWid = 18; pixHei = 16; |
567 | for ( i = 1; i < 50; ++i ) { | ||
568 | if ( !(i%10) ) { | ||
569 | all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); | ||
570 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); | ||
571 | first = i; | ||
572 | wpo = new QPopupMenu (this); | ||
573 | } | 567 | } |
574 | wpo->insertItem( QString::number(i), i ); | 568 | } else { |
575 | } | 569 | pathString += "iconsmini/"; |
576 | for ( i = 50; i < 53; ++i ) { | 570 | pixWid = 18; pixHei = 16; |
577 | wpo->insertItem( QString::number(i), i); | 571 | } |
572 | mWeekBgColor = iconToolBar->backgroundColor(); | ||
573 | mWeekPixmap.resize( pixWid , pixHei ); | ||
574 | mWeekPixmap.fill( mWeekBgColor ); | ||
575 | icon = mWeekPixmap; | ||
576 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | ||
577 | mWeekAction->addTo( iconToolBar ); | ||
578 | mWeekFont = font(); | ||
579 | |||
580 | int fontPoint = mWeekFont.pointSize(); | ||
581 | QFontMetrics f( mWeekFont ); | ||
582 | int fontWid = f.width( "30" ); | ||
583 | while ( fontWid > pixWid ) { | ||
584 | --fontPoint; | ||
585 | mWeekFont.setPointSize( fontPoint ); | ||
586 | QFontMetrics f( mWeekFont ); | ||
587 | fontWid = f.width( "30" ); | ||
588 | qDebug("dec-- "); | ||
578 | } | 589 | } |
579 | all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); | 590 | |
580 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); | 591 | connect( mWeekAction, SIGNAL( activated() ), |
581 | menuBarWeek->insertItem( "00",all,1); | 592 | this, SLOT( weekAction() ) ); |
582 | menuBarWeek->setMaximumSize( menuBarWeek->sizeHint( )); | ||
583 | 593 | ||
584 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 594 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
595 | |||
596 | //#endif | ||
585 | // ****************** | 597 | // ****************** |
586 | QAction *action; | 598 | QAction *action; |
587 | QIconSet icon; | ||
588 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 599 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
589 | configureToolBarMenu->setCheckable( true ); | 600 | configureToolBarMenu->setCheckable( true ); |
590 | 601 | ||
591 | QString pathString = ""; | 602 | |
592 | if ( !p->mToolBarMiniIcons ) { | ||
593 | if ( QApplication::desktop()->width() < 480 ) | ||
594 | pathString += "icons16/"; | ||
595 | } else | ||
596 | pathString += "iconsmini/"; | ||
597 | configureAgendaMenu->setCheckable( true ); | 603 | configureAgendaMenu->setCheckable( true ); |
598 | int iii ; | 604 | int iii ; |
599 | for ( iii = 1;iii<= 10 ;++iii ){ | 605 | for ( iii = 1;iii<= 10 ;++iii ){ |
600 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 606 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
601 | } | 607 | } |
602 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 608 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
@@ -1367,14 +1373,20 @@ void MainWindow::updateWeek(QDate seda) | |||
1367 | d = d.addDays( 1-dow ); | 1373 | d = d.addDays( 1-dow ); |
1368 | else // 5,6,7 | 1374 | else // 5,6,7 |
1369 | d = d.addDays( 8-dow ); | 1375 | d = d.addDays( 8-dow ); |
1370 | // we have the first week of the year.we are on monday | 1376 | // we have the first week of the year.we are on monday |
1371 | weekNum = d.daysTo( seda ) / 7 +1; | 1377 | weekNum = d.daysTo( seda ) / 7 +1; |
1372 | } | 1378 | } |
1373 | //qDebug("weeknum %s ", QString::number( weekNum).latin1()); | 1379 | |
1374 | menuBarWeek-> changeItem(1, QString::number( weekNum) ); | 1380 | mWeekPixmap.fill( mWeekBgColor ); |
1381 | QPainter p ( &mWeekPixmap ); | ||
1382 | p.setFont( mWeekFont ); | ||
1383 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | ||
1384 | p.end(); | ||
1385 | QIconSet icon3 ( mWeekPixmap ); | ||
1386 | mWeekAction->setIconSet ( icon3 ); | ||
1375 | 1387 | ||
1376 | } | 1388 | } |
1377 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1389 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1378 | { | 1390 | { |
1379 | updateWeek( selectedDates.first() ); | 1391 | updateWeek( selectedDates.first() ); |
1380 | } | 1392 | } |
@@ -1716,13 +1728,13 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) | |||
1716 | mView->newEvent(); | 1728 | mView->newEvent(); |
1717 | else | 1729 | else |
1718 | mView->editIncidence(); | 1730 | mView->editIncidence(); |
1719 | break; | 1731 | break; |
1720 | case Qt::Key_Plus: | 1732 | case Qt::Key_Plus: |
1721 | size = p->mHourSize +2; | 1733 | size = p->mHourSize +2; |
1722 | if ( size <= 18 ) | 1734 | if ( size <= 22 ) |
1723 | configureAgenda( size ); | 1735 | configureAgenda( size ); |
1724 | break; | 1736 | break; |
1725 | case Qt::Key_Minus: | 1737 | case Qt::Key_Minus: |
1726 | size = p->mHourSize - 2; | 1738 | size = p->mHourSize - 2; |
1727 | if ( size >= 4 ) | 1739 | if ( size >= 4 ) |
1728 | configureAgenda( size ); | 1740 | configureAgenda( size ); |
@@ -2008,6 +2020,30 @@ void MainWindow::printSel( ) | |||
2008 | 2020 | ||
2009 | void MainWindow::printCal() | 2021 | void MainWindow::printCal() |
2010 | { | 2022 | { |
2011 | mView->print();//mCp->showDialog(); | 2023 | mView->print();//mCp->showDialog(); |
2012 | } | 2024 | } |
2013 | 2025 | ||
2026 | |||
2027 | #include "libkdepim/kdatepicker.h" | ||
2028 | #include <kdatetbl.h> | ||
2029 | void MainWindow::weekAction() | ||
2030 | { | ||
2031 | int month; | ||
2032 | KPopupFrame* popup = new KPopupFrame(this); | ||
2033 | int size = 12; | ||
2034 | if ( QApplication::desktop()->width() >= 480 ) | ||
2035 | size = 18; | ||
2036 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup); | ||
2037 | // ----- | ||
2038 | picker->resize(picker->sizeHint()); | ||
2039 | popup->setMainWidget(picker); | ||
2040 | picker->setFocus(); | ||
2041 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | ||
2042 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height())))) | ||
2043 | { | ||
2044 | month = picker->getResult(); | ||
2045 | emit selectWeek ( month ); | ||
2046 | //qDebug("weekSelected %d ", month); | ||
2047 | } | ||
2048 | delete popup; | ||
2049 | } | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 076ab94..5b9f903 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -2,12 +2,13 @@ | |||
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qmenubar.h> | ||
8 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
9 | #include <qregexp.h> | 10 | #include <qregexp.h> |
10 | 11 | ||
11 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
12 | #include "simplealarmclient.h" | 13 | #include "simplealarmclient.h" |
13 | #include <ksyncmanager.h> | 14 | #include <ksyncmanager.h> |
@@ -20,19 +21,25 @@ class KSyncProfile; | |||
20 | #ifdef DESKTOP_VERSION | 21 | #ifdef DESKTOP_VERSION |
21 | 22 | ||
22 | #define QPEToolBar QToolBar | 23 | #define QPEToolBar QToolBar |
23 | #define QPEMenuBar QMenuBar | 24 | #define QPEMenuBar QMenuBar |
24 | #endif | 25 | #endif |
25 | class QPEToolBar; | 26 | class QPEToolBar; |
26 | class QPEMenuBar; | ||
27 | 27 | ||
28 | 28 | ||
29 | namespace KCal { | 29 | namespace KCal { |
30 | class CalendarLocal; | 30 | class CalendarLocal; |
31 | } | 31 | } |
32 | 32 | ||
33 | class KOMenuBar : public QMenuBar | ||
34 | { | ||
35 | public: | ||
36 | KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;} | ||
37 | QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );} | ||
38 | }; | ||
39 | |||
33 | using namespace KCal; | 40 | using namespace KCal; |
34 | 41 | ||
35 | class MainWindow : public QMainWindow | 42 | class MainWindow : public QMainWindow |
36 | { | 43 | { |
37 | Q_OBJECT | 44 | Q_OBJECT |
38 | public: | 45 | public: |
@@ -47,12 +54,13 @@ class MainWindow : public QMainWindow | |||
47 | void updateWeek(QDate); | 54 | void updateWeek(QDate); |
48 | virtual void showMaximized (); | 55 | virtual void showMaximized (); |
49 | void configureAgenda( int ); | 56 | void configureAgenda( int ); |
50 | void recieve( const QCString& msg, const QByteArray& data ); | 57 | void recieve( const QCString& msg, const QByteArray& data ); |
51 | protected slots: | 58 | protected slots: |
52 | void setCaptionToDates(); | 59 | void setCaptionToDates(); |
60 | void weekAction(); | ||
53 | void about(); | 61 | void about(); |
54 | void licence(); | 62 | void licence(); |
55 | void faq(); | 63 | void faq(); |
56 | void usertrans(); | 64 | void usertrans(); |
57 | void features(); | 65 | void features(); |
58 | void synchowto(); | 66 | void synchowto(); |
@@ -117,13 +125,16 @@ class MainWindow : public QMainWindow | |||
117 | QPopupMenu *configureToolBarMenu; | 125 | QPopupMenu *configureToolBarMenu; |
118 | QPopupMenu *selectFilterMenu; | 126 | QPopupMenu *selectFilterMenu; |
119 | QPopupMenu *configureAgendaMenu, *syncMenu; | 127 | QPopupMenu *configureAgendaMenu, *syncMenu; |
120 | CalendarLocal *mCalendar; | 128 | CalendarLocal *mCalendar; |
121 | CalendarView *mView; | 129 | CalendarView *mView; |
122 | QAction *mNewSubTodoAction; | 130 | QAction *mNewSubTodoAction; |
123 | QPEMenuBar *menuBarWeek; | 131 | QAction *mWeekAction; |
132 | QFont mWeekFont; | ||
133 | QPixmap mWeekPixmap; | ||
134 | QColor mWeekBgColor; | ||
124 | 135 | ||
125 | QAction *mShowAction; | 136 | QAction *mShowAction; |
126 | QAction *mEditAction; | 137 | QAction *mEditAction; |
127 | QAction *mDeleteAction; | 138 | QAction *mDeleteAction; |
128 | QAction *mCloneAction; | 139 | QAction *mCloneAction; |
129 | QAction *mMoveAction; | 140 | QAction *mMoveAction; |