-rw-r--r-- | korganizer/mainwindow.cpp | 75 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 |
2 files changed, 62 insertions, 17 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index c597138..66bb19b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -167,12 +167,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
167 | p.drawRect( 0,0,11,11); | 167 | p.drawRect( 0,0,11,11); |
168 | p.drawLine( 2,3,5,3); | 168 | p.drawLine( 2,3,5,3); |
169 | p.drawLine( 2,5,8,5); | 169 | p.drawLine( 2,5,8,5); |
170 | p.drawLine( 2,7,6,7); | 170 | p.drawLine( 2,7,6,7); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | mAutoSaveDisabled = false; | ||
173 | mClosed = false; | 174 | mClosed = false; |
174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 175 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
175 | QString confFile = locateLocal("config","korganizerrc"); | 176 | QString confFile = locateLocal("config","korganizerrc"); |
176 | QFileInfo finf ( confFile ); | 177 | QFileInfo finf ( confFile ); |
177 | bool showWarning = !finf.exists(); | 178 | bool showWarning = !finf.exists(); |
178 | setIcon(SmallIcon( "ko24" ) ); | 179 | setIcon(SmallIcon( "ko24" ) ); |
@@ -534,39 +535,57 @@ bool MainWindow::askForQuitOnSaveError() | |||
534 | break; | 535 | break; |
535 | default: | 536 | default: |
536 | break; | 537 | break; |
537 | } | 538 | } |
538 | return retval; | 539 | return retval; |
539 | } | 540 | } |
540 | 541 | bool MainWindow::checkAutosave() | |
542 | { | ||
543 | bool savedata = true; | ||
544 | if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { | ||
545 | switch( QMessageBox::information( this, "KO/Pi", | ||
546 | i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), | ||
547 | i18n("Yes, Save!"), i18n("No"), | ||
548 | 0, 0 ) ) { | ||
549 | case 1: | ||
550 | case 2: | ||
551 | savedata = false; | ||
552 | break; | ||
553 | default: | ||
554 | break; | ||
555 | } | ||
556 | } | ||
557 | return savedata; | ||
558 | } | ||
541 | void MainWindow::closeEvent( QCloseEvent* ce ) | 559 | void MainWindow::closeEvent( QCloseEvent* ce ) |
542 | { | 560 | { |
543 | |||
544 | |||
545 | |||
546 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 561 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
547 | saveOnClose(); | 562 | if ( checkAutosave() ) { |
548 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { | 563 | saveOnClose(); |
549 | ce->ignore(); | 564 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { |
550 | return; | 565 | ce->ignore(); |
566 | return; | ||
567 | } | ||
551 | } | 568 | } |
552 | mClosed = true; | 569 | mClosed = true; |
553 | ce->accept(); | 570 | ce->accept(); |
554 | return; | 571 | return; |
555 | 572 | ||
556 | } | 573 | } |
557 | 574 | ||
558 | switch( QMessageBox::information( this, "KO/Pi", | 575 | switch( QMessageBox::information( this, "KO/Pi", |
559 | i18n("Do you really want\nto close KO/Pi?"), | 576 | i18n("Do you really want\nto close KO/Pi?"), |
560 | i18n("Close"), i18n("No"), | 577 | i18n("Close"), i18n("No"), |
561 | 0, 0 ) ) { | 578 | 0, 0 ) ) { |
562 | case 0: | 579 | case 0: |
563 | saveOnClose(); | 580 | if ( checkAutosave() ) { |
564 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { | 581 | saveOnClose(); |
565 | ce->ignore(); | 582 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { |
566 | return; | 583 | ce->ignore(); |
584 | return; | ||
585 | } | ||
567 | } | 586 | } |
568 | mClosed = true; | 587 | mClosed = true; |
569 | ce->accept(); | 588 | ce->accept(); |
570 | break; | 589 | break; |
571 | case 1: | 590 | case 1: |
572 | ce->ignore(); | 591 | ce->ignore(); |
@@ -1654,12 +1673,13 @@ void MainWindow::keyBindings() | |||
1654 | { | 1673 | { |
1655 | QString cap = i18n("KO/Pi Keys + Colors"); | 1674 | QString cap = i18n("KO/Pi Keys + Colors"); |
1656 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1675 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1657 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1676 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1658 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1677 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1659 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1678 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1679 | i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") + | ||
1660 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1680 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1661 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1681 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1662 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ | 1682 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ |
1663 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1683 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1664 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1684 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1665 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1685 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
@@ -1969,31 +1989,43 @@ void MainWindow::saveOnClose() | |||
1969 | void MainWindow::slotModifiedChanged( bool ) | 1989 | void MainWindow::slotModifiedChanged( bool ) |
1970 | { | 1990 | { |
1971 | if ( mBlockAtStartup ) | 1991 | if ( mBlockAtStartup ) |
1972 | return; | 1992 | return; |
1973 | 1993 | ||
1974 | int msec; | 1994 | int msec; |
1995 | if ( mAutoSaveDisabled ) { | ||
1996 | QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) ); | ||
1997 | qDebug("KO: Autosave disabled (data change deteced)!"); | ||
1998 | } | ||
1975 | if ( mCalendarModifiedFlag ) { | 1999 | if ( mCalendarModifiedFlag ) { |
1976 | //qDebug(" MainWindow timer is running "); | 2000 | //qDebug(" MainWindow timer is running "); |
1977 | return; | 2001 | return; |
1978 | } | 2002 | } |
2003 | mCalendarModifiedFlag = true; | ||
2004 | if ( mAutoSaveDisabled ) { | ||
2005 | return; | ||
2006 | } | ||
1979 | // we store the changes after 1 minute, | 2007 | // we store the changes after 1 minute, |
1980 | // and for safety reasons after 10 minutes again | 2008 | // and for safety reasons after 10 minutes again |
1981 | if ( !mSyncManager->blockSave() ) | 2009 | if ( !mSyncManager->blockSave() ) |
1982 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 2010 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1983 | else | 2011 | else |
1984 | msec = 1000 * 600; | 2012 | msec = 1000 * 600; |
1985 | mSaveTimer.start( msec, true ); // 1 minute | 2013 | mSaveTimer.start( msec, true ); // 1 minute |
1986 | mSaveTimerStart = QDateTime::currentDateTime(); | 2014 | mSaveTimerStart = QDateTime::currentDateTime(); |
1987 | mSaveDelay = msec/1000; | 2015 | mSaveDelay = msec/1000; |
1988 | qDebug("KO: Saving File in %d secs!", msec/1000); | 2016 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1989 | mCalendarModifiedFlag = true; | 2017 | } |
2018 | void MainWindow::autoSaveWarning() | ||
2019 | { | ||
2020 | setCaption(i18n("Autosave disabled!" )); | ||
1990 | } | 2021 | } |
1991 | void MainWindow::saveStopTimer() | 2022 | void MainWindow::saveStopTimer() |
1992 | { | 2023 | { |
1993 | mSaveTimer.stop(); | 2024 | mSaveTimer.stop(); |
2025 | mSaveDelay = 0; | ||
1994 | } | 2026 | } |
1995 | void MainWindow::backupAllFiles() | 2027 | void MainWindow::backupAllFiles() |
1996 | { | 2028 | { |
1997 | QDate reference ( 2000,1,1); | 2029 | QDate reference ( 2000,1,1); |
1998 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2030 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1999 | setCaption(i18n("Creating backup ... please wait ..." )); | 2031 | setCaption(i18n("Creating backup ... please wait ..." )); |
@@ -2204,14 +2236,25 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) | |||
2204 | case Qt::Key_N: | 2236 | case Qt::Key_N: |
2205 | mView->viewManager()->showNextView(); | 2237 | mView->viewManager()->showNextView(); |
2206 | break; | 2238 | break; |
2207 | case Qt::Key_V: | 2239 | case Qt::Key_V: |
2208 | mView->viewManager()->showTodoView(); | 2240 | mView->viewManager()->showTodoView(); |
2209 | break; | 2241 | break; |
2210 | case Qt::Key_C: | 2242 | case Qt::Key_C: |
2211 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 2243 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { |
2244 | if ( mAutoSaveDisabled ) { | ||
2245 | mAutoSaveDisabled = false; | ||
2246 | setCaption(i18n("Autosave enabled!" )); | ||
2247 | return; | ||
2248 | } else { | ||
2249 | mAutoSaveDisabled = true; | ||
2250 | saveStopTimer(); | ||
2251 | setCaption(i18n("Autosave disabled! Save timer stopped!" )); | ||
2252 | } | ||
2253 | } else | ||
2254 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | ||
2212 | break; | 2255 | break; |
2213 | case Qt::Key_P: | 2256 | case Qt::Key_P: |
2214 | mView->showDatePicker( ); | 2257 | mView->showDatePicker( ); |
2215 | break; | 2258 | break; |
2216 | case Qt::Key_F: | 2259 | case Qt::Key_F: |
2217 | mView->editFilters(); | 2260 | mView->editFilters(); |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 71c069b..d8018b6 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -49,12 +49,13 @@ class MainWindow : public QMainWindow | |||
49 | void updateFilterToolbar(); | 49 | void updateFilterToolbar(); |
50 | virtual void showMaximized (); | 50 | virtual void showMaximized (); |
51 | void configureAgenda( int ); | 51 | void configureAgenda( int ); |
52 | void recieve( const QCString& msg, const QByteArray& data ); | 52 | void recieve( const QCString& msg, const QByteArray& data ); |
53 | void receiveStart( const QCString& msg, const QByteArray& data ); | 53 | void receiveStart( const QCString& msg, const QByteArray& data ); |
54 | protected slots: | 54 | protected slots: |
55 | void autoSaveWarning(); | ||
55 | void loadDataAfterStart(); | 56 | void loadDataAfterStart(); |
56 | void calHint(); | 57 | void calHint(); |
57 | void startMultiSync(); | 58 | void startMultiSync(); |
58 | void setCaptionToDates(); | 59 | void setCaptionToDates(); |
59 | void weekAction(); | 60 | void weekAction(); |
60 | void about(); | 61 | void about(); |
@@ -118,13 +119,14 @@ class MainWindow : public QMainWindow | |||
118 | QString sentSyncFile(); | 119 | QString sentSyncFile(); |
119 | void displayText( QString, QString); | 120 | void displayText( QString, QString); |
120 | void enableIncidenceActions( bool ); | 121 | void enableIncidenceActions( bool ); |
121 | bool askForQuitOnSaveError(); | 122 | bool askForQuitOnSaveError(); |
122 | 123 | ||
123 | private: | 124 | private: |
124 | 125 | bool mAutoSaveDisabled; | |
126 | bool checkAutosave(); | ||
125 | QCString mCStringMess; | 127 | QCString mCStringMess; |
126 | QByteArray mByteData; | 128 | QByteArray mByteData; |
127 | 129 | ||
128 | //void setMenuBar( QMenuBar * ); | 130 | //void setMenuBar( QMenuBar * ); |
129 | bool mBRdisabled; | 131 | bool mBRdisabled; |
130 | #ifndef DESKTOP_VERSION | 132 | #ifndef DESKTOP_VERSION |