-rw-r--r-- | korganizer/mainwindow.cpp | 53 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 |
2 files changed, 51 insertions, 6 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index c597138..66bb19b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -171,4 +171,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : } } + mAutoSaveDisabled = false; mClosed = false; //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; @@ -538,11 +539,26 @@ bool MainWindow::askForQuitOnSaveError() return retval; } - +bool MainWindow::checkAutosave() +{ + bool savedata = true; + if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { + switch( QMessageBox::information( this, "KO/Pi", + i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), + i18n("Yes, Save!"), i18n("No"), + 0, 0 ) ) { + case 1: + case 2: + savedata = false; + break; + default: + break; + } + } + return savedata; +} void MainWindow::closeEvent( QCloseEvent* ce ) { - - - if ( ! KOPrefs::instance()->mAskForQuit ) { + if ( checkAutosave() ) { saveOnClose(); if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { @@ -550,4 +566,5 @@ void MainWindow::closeEvent( QCloseEvent* ce ) return; } + } mClosed = true; ce->accept(); @@ -561,4 +578,5 @@ void MainWindow::closeEvent( QCloseEvent* ce ) 0, 0 ) ) { case 0: + if ( checkAutosave() ) { saveOnClose(); if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { @@ -566,4 +584,5 @@ void MainWindow::closeEvent( QCloseEvent* ce ) return; } + } mClosed = true; ce->accept(); @@ -1658,4 +1677,5 @@ void MainWindow::keyBindings() i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + + i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") + i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ @@ -1973,8 +1993,16 @@ void MainWindow::slotModifiedChanged( bool ) int msec; + if ( mAutoSaveDisabled ) { + QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) ); + qDebug("KO: Autosave disabled (data change deteced)!"); + } if ( mCalendarModifiedFlag ) { //qDebug(" MainWindow timer is running "); return; } + mCalendarModifiedFlag = true; + if ( mAutoSaveDisabled ) { + return; + } // we store the changes after 1 minute, // and for safety reasons after 10 minutes again @@ -1987,9 +2015,13 @@ void MainWindow::slotModifiedChanged( bool ) mSaveDelay = msec/1000; qDebug("KO: Saving File in %d secs!", msec/1000); - mCalendarModifiedFlag = true; +} +void MainWindow::autoSaveWarning() +{ + setCaption(i18n("Autosave disabled!" )); } void MainWindow::saveStopTimer() { mSaveTimer.stop(); + mSaveDelay = 0; } void MainWindow::backupAllFiles() @@ -2209,4 +2241,15 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) break; case Qt::Key_C: + if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { + if ( mAutoSaveDisabled ) { + mAutoSaveDisabled = false; + setCaption(i18n("Autosave enabled!" )); + return; + } else { + mAutoSaveDisabled = true; + saveStopTimer(); + setCaption(i18n("Autosave disabled! Save timer stopped!" )); + } + } else mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); break; diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 71c069b..d8018b6 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -53,4 +53,5 @@ class MainWindow : public QMainWindow void receiveStart( const QCString& msg, const QByteArray& data ); protected slots: + void autoSaveWarning(); void loadDataAfterStart(); void calHint(); @@ -122,5 +123,6 @@ class MainWindow : public QMainWindow private: - + bool mAutoSaveDisabled; + bool checkAutosave(); QCString mCStringMess; QByteArray mByteData; |