author | zautrix <zautrix> | 2005-02-07 06:10:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-07 06:10:09 (UTC) |
commit | 301a4a207171549bd87815705d8dcf32ad15559d (patch) (side-by-side diff) | |
tree | 715fde2cd0af0c057f767c25d8e67298425b2c82 /korganizer | |
parent | 961fc44f4092c1f981eb3be4284715e6829f885c (diff) | |
download | kdepimpi-301a4a207171549bd87815705d8dcf32ad15559d.zip kdepimpi-301a4a207171549bd87815705d8dcf32ad15559d.tar.gz kdepimpi-301a4a207171549bd87815705d8dcf32ad15559d.tar.bz2 |
new cool feature
-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 @@ -63,24 +63,25 @@ #include "externalapphandler.h" using namespace KCal; #ifndef _WIN32_ #include <unistd.h> #else #ifdef _OL_IMPORT_ #include "koimportoldialog.h" #endif #endif #include "mainwindow.h" + class KOex2phonePrefs : public QDialog { public: KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Export to phone options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel *lab; lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); @@ -135,49 +136,48 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : #ifdef DESKTOP_VERSION setFont( QFont("Arial"), 14 ); #endif mClosed = false; //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; QString confFile = locateLocal("config","korganizerrc"); QFileInfo finf ( confFile ); bool showWarning = !finf.exists(); setIcon(SmallIcon( "ko24" ) ); mBlockAtStartup = true; mFlagKeyPressed = false; + setCaption("KOrganizer/Pi"); KOPrefs *p = KOPrefs::instance(); KPimGlobalPrefs::instance()->setGlobalConfig(); - if ( p->mHourSize > 18 ) - p->mHourSize = 18; + if ( p->mHourSize > 22 ) + p->mHourSize = 22; QMainWindow::ToolBarDock tbd; if ( p->mToolBarHor ) { if ( p->mToolBarUp ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUp ) tbd = Right; else tbd = Left; } if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); globalFlagBlockStartup = 1; iconToolBar = new QPEToolBar( this ); addToolBar (iconToolBar , tbd ); mCalendarModifiedFlag = false; - - setCaption("KOrganizer/Pi"); QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); splash->setAlignment ( AlignCenter ); setCentralWidget( splash ); #ifndef DESKTOP_VERSION showMaximized(); #endif //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); setDefaultPreferences(); mCalendar = new CalendarLocal(); mView = new CalendarView( mCalendar, this,"mCalendar " ); mView->hide(); @@ -548,61 +548,67 @@ void MainWindow::initActions() menuBar->insertItem( i18n("View"), viewMenu ); menuBar->insertItem( i18n("Actions"), actionMenu ); menuBar->insertItem( i18n("Synchronize"), syncMenu ); menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); menuBar->insertItem( i18n("Filter"),selectFilterMenu ); menuBar->insertItem( i18n("Help"), helpMenu ); //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); menuBar1->setMaximumSize( menuBar1->sizeHint( )); } connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); - - menuBarWeek = new QPEMenuBar( iconToolBar ); - QPopupMenu * wpo = new QPopupMenu (this); - QPopupMenu * all = new QPopupMenu (this); - //wpo->insertItem( i18n("W#"), 0 ); - int first = 1; - int i; - for ( i = 1; i < 50; ++i ) { - if ( !(i%10) ) { - all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); - connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); - first = i; - wpo = new QPopupMenu (this); + QIconSet icon; + int pixWid = 22, pixHei = 22; + QString pathString = ""; + if ( !p->mToolBarMiniIcons ) { + if ( QApplication::desktop()->width() < 480 ) { + pathString += "icons16/"; + pixWid = 18; pixHei = 16; } - wpo->insertItem( QString::number(i), i ); - } - for ( i = 50; i < 53; ++i ) { - wpo->insertItem( QString::number(i), i); + } else { + pathString += "iconsmini/"; + pixWid = 18; pixHei = 16; + } + mWeekBgColor = iconToolBar->backgroundColor(); + mWeekPixmap.resize( pixWid , pixHei ); + mWeekPixmap.fill( mWeekBgColor ); + icon = mWeekPixmap; + mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); + mWeekAction->addTo( iconToolBar ); + mWeekFont = font(); + + int fontPoint = mWeekFont.pointSize(); + QFontMetrics f( mWeekFont ); + int fontWid = f.width( "30" ); + while ( fontWid > pixWid ) { + --fontPoint; + mWeekFont.setPointSize( fontPoint ); + QFontMetrics f( mWeekFont ); + fontWid = f.width( "30" ); + qDebug("dec-- "); } - all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); - connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); - menuBarWeek->insertItem( "00",all,1); - menuBarWeek->setMaximumSize( menuBarWeek->sizeHint( )); + + connect( mWeekAction, SIGNAL( activated() ), + this, SLOT( weekAction() ) ); connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); + + //#endif // ****************** QAction *action; - QIconSet icon; // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); configureToolBarMenu->setCheckable( true ); - QString pathString = ""; - if ( !p->mToolBarMiniIcons ) { - if ( QApplication::desktop()->width() < 480 ) - pathString += "icons16/"; - } else - pathString += "iconsmini/"; + configureAgendaMenu->setCheckable( true ); int iii ; for ( iii = 1;iii<= 10 ;++iii ){ configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); } //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); connect( configureAgendaMenu, SIGNAL( aboutToShow()), this, SLOT( showConfigureAgenda( ) ) ); icon = loadPixmap( pathString + "configure" ); action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); @@ -1361,26 +1367,32 @@ void MainWindow::updateWeek(QDate seda) weekNum = 1; } } if ( weekNum == 0 ){ int dow = d.dayOfWeek(); if ( dow <= 4 ) d = d.addDays( 1-dow ); else // 5,6,7 d = d.addDays( 8-dow ); // we have the first week of the year.we are on monday weekNum = d.daysTo( seda ) / 7 +1; } - //qDebug("weeknum %s ", QString::number( weekNum).latin1()); - menuBarWeek-> changeItem(1, QString::number( weekNum) ); + + mWeekPixmap.fill( mWeekBgColor ); + QPainter p ( &mWeekPixmap ); + p.setFont( mWeekFont ); + p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); + p.end(); + QIconSet icon3 ( mWeekPixmap ); + mWeekAction->setIconSet ( icon3 ); } void MainWindow::updateWeekNum(const DateList &selectedDates) { updateWeek( selectedDates.first() ); } void MainWindow::processIncidenceSelection( Incidence *incidence ) { if ( !incidence ) { enableIncidenceActions( false ); @@ -1710,25 +1722,25 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) case Qt::Key_B: mView->editIncidenceDescription();; break; // case Qt::Key_Return: case Qt::Key_E: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->newEvent(); else mView->editIncidence(); break; case Qt::Key_Plus: size = p->mHourSize +2; - if ( size <= 18 ) + if ( size <= 22 ) configureAgenda( size ); break; case Qt::Key_Minus: size = p->mHourSize - 2; if ( size >= 4 ) configureAgenda( size ); break; default: e->ignore(); } @@ -2002,12 +2014,36 @@ void MainWindow::getFile( bool success ) } void MainWindow::printSel( ) { mView->viewManager()->agendaView()->agenda()->printSelection(); } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } + +#include "libkdepim/kdatepicker.h" +#include <kdatetbl.h> +void MainWindow::weekAction() +{ + int month; + KPopupFrame* popup = new KPopupFrame(this); + int size = 12; + if ( QApplication::desktop()->width() >= 480 ) + size = 18; + KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup); + // ----- + picker->resize(picker->sizeHint()); + popup->setMainWidget(picker); + picker->setFocus(); + connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); + if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height())))) + { + month = picker->getResult(); + emit selectWeek ( month ); + //qDebug("weekSelected %d ", month); + } + delete popup; +} diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 076ab94..5b9f903 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -1,64 +1,72 @@ #ifndef KORGE_MAINWINDOW_H #define KORGE_MAINWINDOW_H #include <qmainwindow.h> #include <qtimer.h> #include <qdict.h> #include <qfile.h> +#include <qmenubar.h> #include <qtextstream.h> #include <qregexp.h> #include <libkcal/incidence.h> #include "simplealarmclient.h" #include <ksyncmanager.h> #ifndef DESKTOP_VERSION #include <qcopchannel_qws.h> #endif class QAction; class CalendarView; class KSyncProfile; #ifdef DESKTOP_VERSION #define QPEToolBar QToolBar #define QPEMenuBar QMenuBar #endif class QPEToolBar; -class QPEMenuBar; namespace KCal { class CalendarLocal; } +class KOMenuBar : public QMenuBar +{ + public: + KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;} + QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );} +}; + using namespace KCal; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); ~MainWindow(); bool beamReceiveEnabled(); static QString defaultFileName(); static QString syncFileName(); static QString resourcePath(); public slots: void updateWeekNum(const KCal::DateList &); void updateWeek(QDate); virtual void showMaximized (); void configureAgenda( int ); void recieve( const QCString& msg, const QByteArray& data ); protected slots: void setCaptionToDates(); + void weekAction(); void about(); void licence(); void faq(); void usertrans(); void features(); void synchowto(); void kdesynchowto(); void multisynchowto(); void whatsNew(); void keyBindings(); void aboutAutoSaving();; void aboutKnownBugs(); @@ -111,25 +119,28 @@ class MainWindow : public QMainWindow bool mBlockAtStartup; QPEToolBar *iconToolBar; void initActions(); void setDefaultPreferences(); void keyPressEvent ( QKeyEvent * ) ; void keyReleaseEvent ( QKeyEvent * ) ; QPopupMenu *configureToolBarMenu; QPopupMenu *selectFilterMenu; QPopupMenu *configureAgendaMenu, *syncMenu; CalendarLocal *mCalendar; CalendarView *mView; QAction *mNewSubTodoAction; - QPEMenuBar *menuBarWeek; + QAction *mWeekAction; + QFont mWeekFont; + QPixmap mWeekPixmap; + QColor mWeekBgColor; QAction *mShowAction; QAction *mEditAction; QAction *mDeleteAction; QAction *mCloneAction; QAction *mMoveAction; QAction *mBeamAction; QAction *mCancelAction; QAction *mToggleNav; QAction *mToggleFilter; QAction *mToggleAllday; |