-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 13 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 30 | ||||
-rw-r--r-- | libkdepim/kcmconfigs/kdepimconfigwidget.cpp | 26 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 6 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 3 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 1 | ||||
-rw-r--r-- | microkde/kapplication.cpp | 120 | ||||
-rw-r--r-- | microkde/kapplication.h | 1 |
8 files changed, 195 insertions, 5 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt index fa18304..9e9a1a1 100644 --- a/bin/kdepim/korganizer/germantranslation.txt +++ b/bin/kdepim/korganizer/germantranslation.txt @@ -1164,197 +1164,210 @@ { "OK","OK" }, { "FilterEditor","FilterEditor" }, { "Include","Inclusive" }, { "Exclude","Exclusive" }, { "Edit Selection...","Editiere Auswahl" }, { "recurring events","wiederholende Termine" }, { "recurr. events","wiederh.Termine" }, { "completed to-dos","erledigte Todos" }, { "events","Termine" }, { "todos","Todos" }, { "journals","Journale" }, { "public","öffentl." }, { "private","privat" }, { "confidential","vertraul." }, { "\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!","\nhat Untertodos.\nAlle erledigten Untertodos\nwerden auch gelöscht!" }, { "Yesterday","Gestern" }, { "Day after tomorrow","Übermorgen" }, { "Tomorrow","Morgen" }, { "Day before yesterday","Vorgestern" }, { "Size %1","Größe %1" }, { "New Agendasize: %1","Neue Agendagröße: %1" }, { " (%1 y.)"," (%1 J.)" }, { "Allday:","Ganztägig:" }, { "compl.todos","erled.Todos" }, { "Day view","Tagesansicht" }, { "Next days","Nächste Tage" }, { "Next week","Nächste Woche" }, { "Next two weeks","Nächste zwei Wochen" }, { "This month","Dieser Monat" }, { "Journal view","Journal" }, { "Display all opened","Zeige alle geöffnet" }, { "Display all closed","Zeige alle geschlossen" }, { "Display all flat","Zeige alle flach" }, { "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" }, { "Default todo done color:","Standard Todo erledigt Farbe" }, { "Select week %1-%2","Wähle Woche %1-%2" }, { "Select Week","Wähle Woche" }, { "Set alarm for selected...","Setze Alarm für Selekt..." }, { "Set Alarm!","Setze Alarm!" }, { "Canged alarm for %1 items","Alarm für %1 Items geändert" }, { " and "," und " }, { "<IMG src="%1"> only )","nur <IMG src="%1"> )" }, { "Mail to selected","Mail an Ausgewählte" }, { "Mail to all","Mail an Alle" }, { "Week view mode uses bigger font","Wochenansicht Modus nutzt größeren Font" }, { "Set reminder ON with offset to:","Alarm AN mit Offset auf:" }, { " on"," am" }, { " completed on "," erledigt am " }, { "Save as Event template","Speichere als Vorlage" }, { "Load Event template","Lade Termin Vorlage" }, { "Save as Journal template","Speichere als Journal Vorlage" }, { "Insert Journal template","Füge Journal Vorlage ein" }, { "Sub todos:<br>","Unter Todos:<br>" }, { "Parent todo:<br>","Über Todo:<br>" }, { "Set current as color category","Setze Gewählte als Farbkategorie" }, { " completed"," erledigt" }, { "(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!","(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi basiert auf KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) und das KDE Team.\nKOrganizer/Pi ist lizensiert unter der GPL.\nKO/Pi kann kompiliert werden für\nLinux, Zaurus-PDA und Windows\nwww.pi-sync.info --- www.korganizer.org\nBesonderen Dank an Michael und Ben\nfür intensives Testen!" }, { "Syncing aborted. Nothing synced.","Syncing abgebrochen.Nichts wurde gesynct." }, { "Connected! Sending request for remote file ...","Verbunden! Sende Daten Anfrage..." }, { "Trying to connect to remote...","Versuche mit Gegenstelle zu verbinden..." }, { "Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?","Verbindungsversuch wegen\nZeitüberschreitung gescheitert!\nWurde vergessen Pi-Sync auf\nder Gegenstelle anzuschalten?" }, { "ERROR: Receiving remote file failed.","FEHLER: Empfang der entfernten Daten fehlgeschlagen." }, { "Error","Fehler" }, { ""You entered an invalid date!\n Date changed to current date.","Ungültiges Datum eingegeben.\nSetze heutiges Datum." }, { "You entered an invalid date!\n Will use current date instead.","Ungültiges Datum eingegeben.\nSetze stattdessen heutiges Datum." }, { "Warning","Warnung" }, { "Select week number","Wähle Wochen Nummer" }, { "Februar","Februar" }, { "Click on the week number to\nshow week zoomed","Klicke auf die Wochennummer\num die Woche groß zu zeigen" }, { "W","W" }, { "Click on this to\nselect week number","Klicke hierauf um\ndie Woche auszuwählen" }, { "T: %1","T: %1" }, { "Start: ","Start: " }, { "Pi-Sync options for device: ","Pi-Sync Einstellungen für Gerät: " }, { "Password for remote access:","Passwort für fernen Zugriff:" }, { "Remote IP address:","Ferne IP Adresse:" }, { "Remote port number:","Ferne Port Nummer:" }, { "Remote file saved to temp file.","Ferne Daten in temp Datei gespeichert." }, { "Remote from: ","Fern von: " }, { "Local from: ","Lokal von: " }, { "Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n","Synchronisationsübersicht:\n\n %d lokal hinzugefügt\n %d fern hinzugefügt\n %d lokal geändert\n %d fern geändert\n %d lokal gelöscht\n %d fern gelöscht\n %d eingehende ausgefiltert\n %d ausgehende ausgefiltert\n" }, { "Local calendar changed!\n","Lokaler Kalender geändert!\n" }, { "Write back","Schreibe zurück" }, { "KO/Pi Synchronization","KO/Pi Synchronisation" }, { "Pi-Sync succesful!","Pi-Sync erfolgreich!" }, { "Received sync request","Sync Anfrage erhalten" }, { "Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog.","Ferne Synchronisation ...\n\nBenutze diese Anwendung nicht!\n\nWenn das Syncen fehlschlägt kann\ndieser Dialog geschlossen werden." }, { "Saving Data to temp file ...","Speichere Daten in temp Datei..." }, { "Data saved to temp file!","Daten in temp Datei gespeichert!" }, { "Sending file...","Sende Datei..." }, { "Waiting for synced file...","Warte auf gesyncte Daten..." }, { "Receiving synced file...","Gesyncte Daten erhalten..." }, { "Received %1 bytes","%1 Bytes erhalten" }, { "Writing file to disk...","Speichere Datei..." }, { "Pi-Sync successful!","Pi-Sync erfolgreich!" }, { "Clock skew of\nsyncing devices\nis %1 seconds!","Uhrzeitunterschied der\nsyncenden Geräte\nist %1 Sekunden!" }, { "Synchronize!","Synchronisiere!" }, { "High clock skew!","Großer Uhrzeitunterschied!" }, { "ADJUST\nYOUR\nCLOCKS!","JUSTIERE\nDIE\nUHREN!" }, { "The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!","Die Uhren der syncenden Geräte\nhaben einen Unterschied von\nmehr als 5 Minuten. Bitte die\nUhrzeiten anpassen. Sie können\nfalsche Sync-Resultate erhalten!\nBitte das Syncen bestätigen!" }, { "This is a %1 recurring todo.","Das ist eine %1 wiederholende Aufgabe." }, { "<p><b>Start on:</b> %1</p>","<p><b>Start am:</b> %1</p>" }, { "List week view","Listenwochenansicht" }, { "List week","Listenwochenansicht" }, { "Next Week","Nächste Woche" }, { "Previous Week","Vorherige Woche" }, { "No items were found matching\nyour search expression.\nUse the wildcard characters\n'*' and '?' where needed.","Keine Einträge gefunden die\ndem Suchausdruck entsprechen.\nBenutze Platzhalter Zeichen\n'*' und '?' wo benötigt." }, { "Show in todo/event viewer:","Zeige in Termin/Todo Anzeige:" }, { "Details","Details" }, { "Created time","Erstellt Zeit" }, { "Last modified time","Geändert Zeit" }, { "Show in What'sThis quick overview:","Zeige in What'sThis Schnellübersicht:" }, { "View Options","Anzeige Optionen" }, { "<b>Created: ","<b>Erstellt am: " }, { "<b>Last modified: ","<b>Zuletzt geändert am: " }, { "Journal: ","Journal: " }, { "yearly","jährlich" }, { "(%1) ","%1-" }, { "<p><b>K</b>: Week view in Month view syle</p>\n","<p><b>K</b>: Wochenansicht in Art der Monatsansicht</p>\n" }, { "Enable tooltips displaying summary of ev.","Titel-Tooltips anzeigen" }, { "Enable scrollbars in month view cells","Scrollbar in Zellen anzeigen" }, { "Summary/Loc.","Titel/Ort" }, { "No items found. Use '*' and '?' where needed.","Nichts gefunden. Benutze '*' and '?' wo benötigt." }, { "Week Number","Wochennummer" }, { "Import","Importiere" }, { "Export","Exportiere" }, { "Beam","Beame" }, { "Export selected","Exportiere Selektierte" }, { "As iCal (ics) file...","Als iCal (ics) Datei..." }, { "As vCal (vcs) file...","Als vCal (vcs) Datei..." }, { "Journal/Details...","Journale/Details..." }, { "Agenda View","Agenda Ansicht" }, { "Show current time","Zeige aktuelle Zeit" }, { "Edit new item","Bearbeite neuen Eintrag" }, { "Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals","Bitte wählen Sie mindestens\neinen dieser Typen\num darin zu suchen:\n\nTermine\nTodos\nJournale" }, { "There is no next alarm.","Es gibt keinen nächsten Alarm." }, { "%1 %2 - %3 (next event/todo with alarm)","%1 %2 - %3 (nächster Termin/Todo mit Alarm)" }, { "The next alarm is in:\n","Der nächste Alarm ist in:\n" }, { "%1 days\n","%1 Tagen\n" }, { "1 day\n","1 Tag\n" }, { "%1 hours\n","%1 Stunden\n" }, { "1 hour\n","1 Stunde\n" }, { "%1 minutes\n","%1 Minuten\n" }, { "1 minute\n","1 Minute\n" }, { "Only one toolbar","Nur eine Toolbar" }, { "Print","Drucke" }, { "Print selected event / todo...","Drucke ausgewählten Termin / Todo..." }, { "There is nothing selected!","Es ist nichts ausgewählt!" }, { "\n\nDo you really want to print this item?","\n\nMöchten Sie wirklich diesen Eintrag ausdrucken? " }, { "KO/Pi Print Confirmation","KO/Pi Druckbestätigung" }, { "This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog.\n","Dies druckt die Ansicht wie man sie sieht.\n(Mit dem kompletten Inhalt natürlich.)\nMan kann das Layout ändern durch ändern der Fenstergröße.\nDrucke unskaliert druckt ggf. mehrere Seiten\nabhängig von der Menge der Daten.\nDrucke runterskaliert um auf eine Seite zu passen\ndruckt alles auf eine Seite.\nDrucke hoch/runterskaliert um genau auf eine Seite zu passen\nvergrößert den Text gegebenenfalls.\nDas Seitenlayout kann im nächsten Dialog gewählt werden.\n" }, { "KO/Pi Printout","KO/Pi Ausdruck" }, { "Print unscaled","Drucke unskaliert" }, { "Print scaled down to fit one page","Drucke runterskaliert um auf eine Seite zu passen." }, { "Print scaled up/down to fit one page","Drucke hoch/runterskaliert um genau auf eine Seite zu passen." }, { "Printout Mode","Druck Modus" }, { "Filter menu icon","Filtermenu Icon" }, { "<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n","<p><b>A+(shift oder ctrl)</b>: Zeige Zeit bis zum nächsten Alarm</p>\n" }, { "<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n","<p><b>N</b>: Wechsle zur nächsten Ansicht, die ein Icon in der Toolbar hat</p>\n" }, { "%1d","%1t" }, { "%1h","%1std" }, { "%1min","%1min" }, { "( %1 before )","( %1 vorher )" }, { "The next alarm is in\nless than one minute!","Der nächste Alarm kommt in\nweniger als einer Minute!" }, { "\nThe internal alarm notification is disabled!\n","\nDie interne Alarmbenachrichtigung ist ausgeschaltet!\n" }, { "Enable it in the settings menu, TAB alarm.","Schalten Sie sie an im Menu Einstellungen, TAB Alarm." }, { "Show Sync Events","Zeige Sync-Ereignisse" }, { "Use short date in WN+Event view","Zeige Kurzdatum in WN+Terminanzeige" }, { "Number of max.displayed todo prios:","Anzahl max.angezeigter Todo-Prios:" }, { " on "," am " }, { "On: ","Am: " }, { "<i>The recurrence is computed from the start datetime!</i>","<i>Die Wiederholung wird vom Startwert aus berechnet!</i>" }, { "Start/Stop todo...","Starte/Stoppe Todo..." }, { "Color for running todos:","Farbe für laufende Todos:" }, { "The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?","Das Todo\n%1\nist gestartet.\nWollen Sie es\nauf gestoppt setzen?" }, { "Todo is started","Todo is gestarted" }, { "Stop todo","Stoppe Todo" }, { "Todo is stopped","Todo ist gestoppt" }, { "Start todo","Starte Todo" }, { "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" }, { "The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?","Das Todo\n%1\nwird geklont!\nEs hat Untertodos!\nMöchten Sie alle\nUntertodos auch klonen?" }, { "Todo has subtodos","Todo hat Untertodos" }, { "Block popup until mouse button release","Sperre Popup bis Mausknopf losgelassen" }, { "Colors","Farben" }, { "Click on new parent item","Klicke auf neues Übertodo" }, { "Reparenting aborted!","Übertodo setzen abgebrochen" }, { "Cannot move Todo to itself\nor a child of itself","Kann nicht Todo auf\nsich selbst oder\nein Untertodo verschieben" }, { "Recursive reparenting not possible!","Rekursives Verschieben nicht möglich" }, { "Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)","Entferne alle erledigten Todos?\n(Erledigte wiederholende Todos\nwerden nicht gelöscht!)" }, { "Alternating background of list views","Abwechselnder Hintergrund für Listen" }, { "times","Zeiten" }, { "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" }, +{ "Backup enabled","Backup angeschaltet" }, +{ "Use standard backup dir","Standard Backupverzeichnis" }, +{ "Number of Backups:","Anzahl der Backups" }, +{ "Make backup every ","Mache ein Backup alle " }, +{ " days"," Tage" }, +{ "","" }, +{ "","" }, +{ "","" }, +{ "","" }, +{ "","" }, +{ "","" }, +{ "","" }, +{ "","" }, { "","" }, { "","" }, { "","" }, { "","" }, { "","" }, diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 68e5e5a..9ad0694 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1,255 +1,256 @@ #include <stdlib.h> #include <qaction.h> #include <qpopupmenu.h> #include <qpainter.h> #include <qwhatsthis.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qlineedit.h> #include <qtextcodec.h> #include <qfile.h> #include <qdir.h> #include <qapp.h> #include <qfileinfo.h> #include <qlabel.h> #include <qspinbox.h> #include <qcheckbox.h> #include <qmap.h> #include <qwmatrix.h> #include <qtextbrowser.h> #include <qtextstream.h> #ifndef DESKTOP_VERSION #include <qpe/global.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qtopia/alarmserver.h> #include <qtopia/qcopenvelope_qws.h> #include <unistd.h> // for sleep #else #include <qmenubar.h> #include <qtoolbar.h> #include <qapplication.h> //#include <resource.h> #endif #include <libkcal/calendarlocal.h> #include <libkcal/todo.h> #include <libkcal/phoneformat.h> #include <libkdepim/ksyncprofile.h> #include <libkdepim/phoneaccess.h> #include <libkcal/kincidenceformatter.h> #include <libkdepim/kpimglobalprefs.h> #include "calendarview.h" #include "koviewmanager.h" #include "datenavigator.h" #include "koagendaview.h" #include "koagenda.h" #include "kodialogmanager.h" #include "kdialogbase.h" #include "kapplication.h" #include "kofilterview.h" #include "kstandarddirs.h" #include "koprefs.h" #include "kfiledialog.h" #include "koglobals.h" #include "kglobal.h" #include "ktoolbar.h" #include "klocale.h" #include "kconfig.h" #include "externalapphandler.h" +#include <kglobalsettings.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 ) ); lab->setAlignment (AlignHCenter ); QHBox* temphb; temphb = new QHBox( this ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); lay->addWidget( temphb ); mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); mWriteBackFuture->setChecked( true ); lay->addWidget( mWriteBackFuture ); temphb = new QHBox( this ); new QLabel( i18n("Max. weeks in future: ") , temphb ); mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); mWriteBackFutureWeeks->setValue( 8 ); lay->addWidget( temphb ); lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); lab->setAlignment (AlignHCenter ); QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 220, 240 ); qApp->processEvents(); int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); move( (dw-width())/2, (dh - height() )/2 ); } public: QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; QCheckBox* mWriteBackFuture; QSpinBox* mWriteBackFutureWeeks; }; int globalFlagBlockStartup; MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : QMainWindow( parent, name ) { 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("KO/Pi"); KOPrefs *p = KOPrefs::instance(); KPimGlobalPrefs::instance()->setGlobalConfig(); p->mCurrentDisplayedView = 0; 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 ); #ifdef DESKTOP_VERSION if ( KOPrefs::instance()->mShowIconFilter ) #else if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) #endif { if ( p->mToolBarHorF ) { if ( p->mToolBarUpF ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpF ) tbd = Right; else tbd = Left; } filterToolBar = new QPEToolBar ( this ); filterMenubar = new QMenuBar( filterToolBar ); QFontMetrics fm ( filterMenubar->font() ); filterPopupMenu = new QPopupMenu( this ); filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); QString addTest = "A"; filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); #ifdef DESKTOP_VERSION addTest = "AAABBBCCCx"; #else addTest = "AAx"; #endif filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); addToolBar (filterToolBar , tbd ); connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) filterToolBar->hide(); } else { filterToolBar = 0; filterMenubar = 0; filterPopupMenu = 0; } if ( p->mShowIconOnetoolbar ) { viewToolBar = iconToolBar ; navigatorToolBar = iconToolBar ; } else { #ifndef DESKTOP_VERSION setToolBarsMovable( false ); #endif if ( p->mToolBarHorV ) { if ( p->mToolBarUpV ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpV ) tbd = Right; else tbd = Left; } viewToolBar = new QPEToolBar( this ); addToolBar (viewToolBar , tbd ); if ( p->mToolBarHorN ) { if ( p->mToolBarUpN ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpN ) tbd = Right; else tbd = Left; } navigatorToolBar = new QPEToolBar( this ); addToolBar (navigatorToolBar , tbd ); } mCalendarModifiedFlag = false; QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); splash->setAlignment ( AlignCenter ); setCentralWidget( splash ); #ifndef DESKTOP_VERSION @@ -1612,384 +1613,413 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) } } else startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); } } else startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); if ( !incidence->location().isEmpty() ) startString += " (" +incidence->location()+")"; setCaption( incidence->summary()+startString); enableIncidenceActions( true ); if ( incidence->type() == "Event" ) { mShowAction->setText( i18n("Show Event...") ); mEditAction->setText( i18n("Edit Event...") ); mDeleteAction->setText( i18n("Delete Event...") ); mNewSubTodoAction->setEnabled( false ); } else if ( incidence->type() == "Todo" ) { mShowAction->setText( i18n("Show Todo...") ); mEditAction->setText( i18n("Edit Todo...") ); mDeleteAction->setText( i18n("Delete Todo...") ); mNewSubTodoAction->setEnabled( true ); } else { mShowAction->setText( i18n("Show...") ); mShowAction->setText( i18n("Edit...") ); mShowAction->setText( i18n("Delete...") ); mNewSubTodoAction->setEnabled( false ); } } void MainWindow::enableIncidenceActions( bool enabled ) { mShowAction->setEnabled( enabled ); mEditAction->setEnabled( enabled ); mDeleteAction->setEnabled( enabled ); mCloneAction->setEnabled( enabled ); mMoveAction->setEnabled( enabled ); mBeamAction->setEnabled( enabled ); mCancelAction->setEnabled( enabled ); } void MainWindow::importOL() { #ifdef _OL_IMPORT_ KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); id->exec(); delete id; mView->updateView(); #endif } void MainWindow::importBday() { int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { mView->importBday(); } } void MainWindow::importQtopia() { //#ifndef DESKTOP_VERSION QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); #ifdef DESKTOP_VERSION mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); #endif int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { #ifndef DESKTOP_VERSION QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; #else QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; #endif mView->importQtopia( categories, datebook, todolist ); } #if 0 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Not supported \non desktop!\n"), i18n("Ok"), i18n("Cancel"), 0, 0, 1 ); #endif } void MainWindow::saveOnClose() { KOPrefs *p = KOPrefs::instance(); p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); if ( filterToolBar ) { p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); } #ifdef DESKTOP_VERSION QPoint myP; myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHor ) p->mToolBarUp = myP.y() > height()/2; else p->mToolBarUp = myP.x() > width()/2; myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHorV ) p->mToolBarUpV = myP.y() > height()/2; else p->mToolBarUpV = myP.x() > width()/2 ; myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHorN ) p->mToolBarUpN = myP.y() > height()/2; else p->mToolBarUpN = myP.x() > width()/2 ; if ( filterToolBar ) { myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); if ( p->mToolBarHorF ) p->mToolBarUpF = myP.y() > height()/2; else p->mToolBarUpF = myP.x() > width()/2 ; } #else if ( p->mToolBarHor ) p->mToolBarUp = iconToolBar->y() > height()/2; else p->mToolBarUp = iconToolBar->x() > width()/2; if ( p->mToolBarHorV ) p->mToolBarUpV = viewToolBar->y() > height()/2; else p->mToolBarUpV = viewToolBar->x() > width()/2 ; if ( p->mToolBarHorN ) p->mToolBarUpN = navigatorToolBar->y() > height()/2; else p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; if ( filterToolBar ) { if ( p->mToolBarHorF ) p->mToolBarUpF = filterToolBar->y() > height()/2; else p->mToolBarUpF = filterToolBar->x() > width()/2 ; } #endif mView->writeSettings(); if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) save(); } void MainWindow::slotModifiedChanged( bool changed ) { if ( mBlockAtStartup ) return; int msec; // we store the changes after 1 minute, // and for safety reasons after 10 minutes again if ( !mSyncManager->blockSave() ) msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; else msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; } void MainWindow::saveStopTimer() { mSaveTimer.stop(); } void MainWindow::save() { if ( !mCalendarModifiedFlag ) { qDebug("KO: Calendar not modified. Nothing saved."); return; } if ( mSyncManager->blockSave() ) return; mSyncManager->setBlockSave(true); if ( mView->checkFileVersion( defaultFileName()) ) { + if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ + QDate reference ( 2000,1,1); + int daysTo = reference.daysTo ( QDate::currentDate() ); + if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { + setCaption(i18n("KO/Pi:Creating backup ... please wait ..." )); + qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); + // we need the file path, the backup dir and the number of bups as param + QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; + if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) + bupDir = KGlobalSettings::backupDataDir(); + int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );//55;//call backup + if ( retval == 0 ) { + qDebug("KO: Backup cancelled. Will try again tomorrow "); + // retval == 0 : backup skipped for today, try again tomorrow + KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; + } else if ( retval == 1 ){ + qDebug("KO: Backup created."); + // backup ok + KOPrefs::instance()->mLastBackupDate = daysTo; + + } else if ( retval == 2 ){ + qDebug("KO: Backup globally cancelled."); + // backup globally cancelled + KPimGlobalPrefs::instance()->mBackupEnabled = false; + } + // retval == 3: do nothing, try again later + } + ; // KPimGlobalPrefs::instance()->mLastBackupDate + } QTime neededSaveTime = QDateTime::currentDateTime().time(); setCaption(i18n("KO/Pi:Saving Data to File ..." )); qDebug("KO: Start saving data to file!"); mView->saveCalendar( defaultFileName() ); mCalendarModifiedFlag = false; int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Needed %d ms for saving.",msNeeded ); QString savemes; savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); setCaption(savemes); } else setCaption(i18n("Saving cancelled!")); mSyncManager->setBlockSave( false ); } void MainWindow::keyReleaseEvent ( QKeyEvent * e) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void MainWindow::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) mFlagKeyPressed = true; KOPrefs *p = KOPrefs::instance(); bool showSelectedDates = false; int size; int pro = 0; //qDebug("MainWindow::keyPressEvent "); switch ( e->key() ) { case Qt::Key_Right: if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) mView->goNextMonth(); else mView->goNext(); showSelectedDates = true; break; case Qt::Key_Left: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->goPreviousMonth(); else mView->goPrevious(); showSelectedDates = true; break; case Qt::Key_Down: mView->viewManager()->agendaView()->scrollOneHourDown(); break; case Qt::Key_Up: mView->viewManager()->agendaView()->scrollOneHourUp(); break; case Qt::Key_K: mView->viewManager()->showMonthViewWeek(); break; case Qt::Key_I: mView->showIncidence(); break; case Qt::Key_Delete: case Qt::Key_Backspace: mView->deleteIncidence(); break; case Qt::Key_D: mView->viewManager()->showDayView(); showSelectedDates = true; break; case Qt::Key_O: mView->toggleFilerEnabled( ); break; case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: pro = e->key()-48; if ( pro == 0 ) pro = 10; if ( e->state() == Qt::ControlButton) pro += 10; break; case Qt::Key_M: mView->viewManager()->showMonthView(); showSelectedDates = true; break; case Qt::Key_Insert: mView->newEvent(); break; case Qt::Key_S : if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) mView->newSubTodo(); else mView->dialogManager()->showSearchDialog(); break; case Qt::Key_Y : case Qt::Key_Z : mView->viewManager()->showWorkWeekView(); showSelectedDates = true; break; case Qt::Key_U : mView->viewManager()->showWeekView(); showSelectedDates = true; break; case Qt::Key_H : keyBindings(); break; case Qt::Key_W: mView->viewManager()->showWhatsNextView(); break; case Qt::Key_L: mView->viewManager()->showListView(); break; case Qt::Key_N: mView->viewManager()->showNextView(); break; case Qt::Key_V: mView->viewManager()->showTodoView(); break; case Qt::Key_C: mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); break; case Qt::Key_P: mView->showDatePicker( ); break; case Qt::Key_F: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->editFilters(); else mView->toggleFilter(); break; case Qt::Key_X: if ( e->state() == Qt::ControlButton ) mView->toggleDateNavigatorWidget(); else { mView->viewManager()->showNextXView(); showSelectedDates = true; } break; case Qt::Key_Space: mView->toggleExpand(); break; case Qt::Key_A: if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) mView->showNextAlarms(); else mView->toggleAllDaySize(); break; case Qt::Key_T: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->newTodo(); else { mView->goToday(); showSelectedDates = true; } break; case Qt::Key_J: mView->viewManager()->showJournalView(); break; 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 <= 22 ) configureAgenda( size ); break; case Qt::Key_Minus: size = p->mHourSize - 2; if ( size >= 4 ) configureAgenda( size ); break; default: e->ignore(); } diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp index fbfbc45..93538ec 100644 --- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp +++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp @@ -1,346 +1,355 @@ /* This file is part of KdePim/Pi. Copyright (c) 2004 Ulf Schenk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qlayout.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qbuttongroup.h> #include <qcheckbox.h> #include <qfile.h> #include <qvbox.h> #include <qdir.h> #include <qregexp.h> #include <qspinbox.h> #include <kdialog.h> #include <kprefsdialog.h> #include <klocale.h> #include <kglobalsettings.h> #include <kdateedit.h> #include <kglobal.h> #include <stdlib.h> /*US #include <qcheckbox.h> #include <qframe.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qlineedit.h> #include <qlabel.h> #include <qfile.h> #include <kconfig.h> #include <kdebug.h> #include <kdialog.h> #include <klistview.h> #include <klocale.h> #include <kglobal.h> #include <kmessagebox.h> #include <kstandarddirs.h> #ifndef KAB_EMBEDDED #include <ktrader.h> #else // KAB_EMBEDDED #include <mergewidget.h> #include <distributionlistwidget.h> #endif // KAB_EMBEDDED #include "addresseewidget.h" #include "extensionconfigdialog.h" #include "extensionwidget.h" */ #include "qapplication.h" #include "kpimglobalprefs.h" #include "kdepimconfigwidget.h" #include <kprefs.h> #include <kmessagebox.h> KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) : KPrefsWidget(prefs, parent, name ) { mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); tabWidget = new QTabWidget( this ); topLayout->addWidget( tabWidget ); setupLocaleTab(); setupLocaleDateTab(); setupTimeZoneTab(); setupExternalAppTab(); setupStoreTab(); setupBackupTab(); } void KDEPIMConfigWidget::showTimeZoneTab() { tabWidget->setCurrentPage ( 3 ) ; } void KDEPIMConfigWidget::setupBackupTab() { QVBox *colorPage = new QVBox( this ); tabWidget->addTab( colorPage, i18n( "Backup" ) ); QWidget* topFrame = new QWidget( colorPage ); QVBoxLayout *topLayout = new QVBoxLayout(topFrame); KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); topLayout->addWidget((QWidget*)sb->checkBox()); QWidget* bupFrame = new QWidget( topFrame ); topLayout->addWidget((bupFrame)); QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); sb = addWidBool(i18n("Use standard backup dir"), - &(KPimGlobalPrefs::instance()->mBackupEnabled),bupFrame); + &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame); bupLayout->addWidget((QWidget*)sb->checkBox()); mBackupUrl = new KURLRequester( bupFrame ); mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); bupLayout->addWidget( mBackupUrl ); - + mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir ); + bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled ); QHBox *dummy = new QHBox(bupFrame); new QLabel(i18n("Number of Backups:"),dummy); mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); new QLabel(i18n(" "),dummy); bupLayout->addWidget( dummy ); dummy = new QHBox(bupFrame); new QLabel(i18n("Make backup every "),dummy); mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); new QLabel(i18n(" days"),dummy); new QLabel(i18n(" "),dummy); bupLayout->addWidget( dummy ); + QString localKdeDir; + localKdeDir = readEnvPath("LOCALMICROKDEHOME"); + if ( ! localKdeDir.isEmpty() ) { + sb->checkBox()->setEnabled( false ); + sb->checkBox()->setChecked( true ); + mBackupUrl->setEnabled( false ); + KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true; + } } void KDEPIMConfigWidget::setupStoreTab() { QVBox *colorPage = new QVBox( this ); tabWidget->addTab( colorPage, i18n( "Colors" ) ); QWidget* cw = new QWidget( colorPage ); KPrefsWidColor *holidayColor = addWidColor(i18n("Alternating background of list views"), &(KPimGlobalPrefs::instance()->mAlternateColor),cw); QHBoxLayout *topLayout = new QHBoxLayout(cw); topLayout->addWidget(holidayColor->label()); topLayout->addWidget( (QWidget* )holidayColor->button()); QVBox *storePage = new QVBox( this ); new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage ); new QLabel( i18n("<b>New data storage dir:</b>"), storePage ); mStoreUrl = new KURLRequester( storePage ); mStoreUrl->setURL( KGlobal::dirs()->localkdedir() ); #ifdef DESKTOP_VERSION QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; QFileInfo fi ( confFile ); if ( fi.exists() ) { KConfig cfg ( confFile ); cfg.setGroup("Global"); QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" ); if ( localKdeDir != "x_x_x" ) { mStoreUrl->setURL( localKdeDir ); qDebug("Reading config from %s ", confFile.latin1()); } } #endif new QLabel( i18n("New dirs are created automatically"), storePage ); QHBox *bb = new QHBox( storePage ); QPushButton * pb; if ( QApplication::desktop()->width() < 640 ) pb = new QPushButton ( i18n("Save"), bb ); else pb = new QPushButton ( i18n("Save settings"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) ); pb = new QPushButton ( i18n("Save standard"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) ); #ifdef DESKTOP_VERSION pb = new QPushButton ( i18n("Save using LOCAL storage"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) ); #endif new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage ); new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage ); tabWidget->addTab( storePage, i18n( "Data storage path" ) ); } void KDEPIMConfigWidget::setLocalStore() { mStoreUrl->setURL( "LOCAL:kdepimpi" ); saveStoreSettings(); QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data."); KMessageBox::information( this, message); } void KDEPIMConfigWidget::setStandardStore() { mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); saveStoreSettings(); } void KDEPIMConfigWidget::saveStoreSettings() { if ( !mStoreUrl->url().isEmpty() ) { QString path = QDir::homeDirPath(); QString url = mStoreUrl->url(); #ifdef DESKTOP_VERSION if ( url.startsWith( "LOCAL:" ) ) { path = qApp->applicationDirPath () ; } #endif KConfig cfg ( path + "/.microkdehome" ); cfg.setGroup("Global"); cfg.writeEntry( "MICROKDEHOME", url ); qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1()); cfg.sync(); } else { mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); saveStoreSettings(); } } void KDEPIMConfigWidget::setupExternalAppTab() { QWidget *externalAppsPage = new QWidget( this ); QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), KDialog::spacingHintSmall() ); mExternalApps = new QComboBox( externalAppsPage ); QMap<ExternalAppHandler::Types, QString>::Iterator it; for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) mExternalApps->insertItem( it.data(), it.key() ); layout->addWidget( mExternalApps ); connect( mExternalApps, SIGNAL( activated( int ) ), this, SLOT (externalapp_changed( int ) ) ); mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); mExternalAppGroupBox->layout()->setMargin(4); mClient = new QComboBox( mExternalAppGroupBox ); boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); connect( mClient, SIGNAL( activated( int ) ), this, SLOT (client_changed( int ) ) ); QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 1, 0 ); mChannel = new QLineEdit(mExternalAppGroupBox); mChannel->setReadOnly(true); boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 3, 0 ); mMessage = new QLineEdit(mExternalAppGroupBox); mMessage->setReadOnly(true); boxLayout->addWidget( mMessage , 4, 0); lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 3, 1 ); mParameters = new QLineEdit(mExternalAppGroupBox); mParameters->setReadOnly(true); boxLayout->addWidget( mParameters, 4, 1 ); lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 6, 0 ); mMessage2 = new QLineEdit(mExternalAppGroupBox); mMessage2->setReadOnly(true); boxLayout->addWidget( mMessage2 , 7, 0); lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 6, 1 ); mParameters2 = new QLineEdit(mExternalAppGroupBox); mParameters2->setReadOnly(true); boxLayout->addWidget( mParameters2, 7, 1 ); lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); layout->addWidget( mExternalAppGroupBox ); tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); } void KDEPIMConfigWidget::setupLocaleDateTab() { QWidget *topFrame = new QWidget( this ); QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); topLayout->setSpacing(KDialog::spacingHintSmall()); topLayout->setMargin(KDialog::marginHintSmall()); int iii = 0; KPrefsWidRadios *syncPrefsGroup = addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); QString format; if ( QApplication::desktop()->width() < 480 ) format = "(%d.%m.%Y)"; else format = "(%d.%m.%Y|%A %d %B %Y)"; syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%m.%d.%Y)"; else format = "(%m.%d.%Y|%A %B %d %Y)"; syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%Y-%m-%d)"; else format = "(%Y-%m-%d|%A %Y %B %d)"; syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); syncPrefsGroup->addRadio(i18n("User defined")); @@ -617,331 +626,338 @@ void KDEPIMConfigWidget::saveEditFieldSettings() if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) { mEmailOtherChannel = mChannel->text(); mEmailOtherMessage = mMessage->text(); mEmailOtherMessageParameters = mParameters->text(); mEmailOtherMessage2 = mMessage2->text(); mEmailOtherMessageParameters2 = mParameters2->text(); } else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) { mPhoneOtherChannel = mChannel->text(); mPhoneOtherMessage = mMessage->text(); mPhoneOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) { mSMSOtherChannel = mChannel->text(); mSMSOtherMessage = mMessage->text(); mSMSOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) { mFaxOtherChannel = mChannel->text(); mFaxOtherMessage = mMessage->text(); mFaxOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) { mPagerOtherChannel = mChannel->text(); mPagerOtherMessage = mMessage->text(); mPagerOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) { mSipOtherChannel = mChannel->text(); mSipOtherMessage = mMessage->text(); mSipOtherMessageParameters = mParameters->text(); } } void KDEPIMConfigWidget::updateClientWidgets() { bool blocked = signalsBlocked(); blockSignals( true ); // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); if (it == mExternalAppsMap.end()) return; // update group box mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); //update the entries in the client combobox mClient->clear(); QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); DefaultAppItem* dai; for ( dai=items.first(); dai != 0; dai=items.next() ) { mClient->insertItem( i18n(dai->_label), dai->_id ); if (dai->_id == mCurrentClient) { //restore the edit fields with the data of the local membervariables if we had set it to "other". //Otherwise take the default data from externalapphandler. mChannel->setText(dai->_channel); mMessage->setText(dai->_message); mParameters->setText(dai->_parameters); mMessage2->setText(dai->_message2); mParameters2->setText(dai->_parameters2); if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) { mChannel->setText(mEmailOtherChannel); mMessage->setText(mEmailOtherMessage); mParameters->setText(mEmailOtherMessageParameters); mMessage2->setText(mEmailOtherMessage2); mParameters2->setText(mEmailOtherMessageParameters2); } else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) { mChannel->setText(mPhoneOtherChannel); mMessage->setText(mPhoneOtherMessage); mParameters->setText(mPhoneOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) { mChannel->setText(mSMSOtherChannel); mMessage->setText(mSMSOtherMessage); mParameters->setText(mSMSOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) { mChannel->setText(mFaxOtherChannel); mMessage->setText(mFaxOtherMessage); mParameters->setText(mFaxOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) { mChannel->setText(mPagerOtherChannel); mMessage->setText(mPagerOtherMessage); mParameters->setText(mPagerOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) { mChannel->setText(mSipOtherChannel); mMessage->setText(mSipOtherMessage); mParameters->setText(mSipOtherMessageParameters); } } } bool readonly; bool enabled; if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) { readonly = false; } else { readonly = true; } if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) { enabled = false; } else { enabled = true; } mChannel->setReadOnly(readonly); mMessage->setReadOnly(readonly); mParameters->setReadOnly(readonly); mMessage2->setReadOnly(readonly); mParameters2->setReadOnly(readonly); mChannel->setEnabled(enabled); mMessage->setEnabled(enabled); mParameters->setEnabled(enabled); mMessage2->setEnabled(enabled); mParameters2->setEnabled(enabled); mClient->setCurrentItem(mCurrentClient); // enable/disable the extra message/parameter field if (mCurrentApp == ExternalAppHandler::EMAIL) { } else { mMessage2->setText( "" ); mParameters2->setText( "" ); } if (enabled == true) { mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); } blockSignals( blocked ); } void KDEPIMConfigWidget::usrReadConfig() { KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); bool blocked = signalsBlocked(); blockSignals( true ); + if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir ) + mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); + else + mBackupUrl->setURL(prefs->mBackupDatadir); + mBackupNumbersSpin->setValue( prefs->mBackupNumbers ); + mBackupDayCountSpin->setValue( prefs->mBackupDayCount); + QString dummy = prefs->mUserDateFormatLong; mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); dummy = prefs->mUserDateFormatShort; mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); QDate current ( 2001, 1,1); mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); - - - mEmailClient = prefs->mEmailClient; mEmailOtherChannel = prefs->mEmailOtherChannel; mEmailOtherMessage = prefs->mEmailOtherMessage; mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; mEmailOtherMessage2 = prefs->mEmailOtherMessage2; mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; mPhoneClient = prefs->mPhoneClient; mPhoneOtherChannel = prefs->mPhoneOtherChannel; mPhoneOtherMessage = prefs->mPhoneOtherMessage; mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; mFaxClient = prefs->mFaxClient; mFaxOtherChannel = prefs->mFaxOtherChannel; mFaxOtherMessage = prefs->mFaxOtherMessage; mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; mSMSClient = prefs->mSMSClient; mSMSOtherChannel = prefs->mSMSOtherChannel; mSMSOtherMessage = prefs->mSMSOtherMessage; mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; mPagerClient = prefs->mPagerClient; mPagerOtherChannel = prefs->mPagerOtherChannel; mPagerOtherMessage = prefs->mPagerOtherMessage; mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; mSipClient = prefs->mSipClient; mSipOtherChannel = prefs->mSipOtherChannel; mSipOtherMessage = prefs->mSipOtherMessage; mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; mCurrentApp = ExternalAppHandler::EMAIL; mCurrentClient = mEmailClient; updateClientWidgets(); blockSignals( blocked ); } void KDEPIMConfigWidget::usrWriteConfig() { KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); saveEditFieldSettings(); + prefs->mBackupNumbers = mBackupNumbersSpin->value(); + prefs->mBackupDayCount = mBackupDayCountSpin->value(); + prefs->mBackupDatadir = mBackupUrl->url(); prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); prefs->mTimeZoneId = mTimeZoneCombo->currentText(); QDate date; date = mStartDateSavingEdit->date(); int sub = 0; if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) sub = 1; prefs->mDaylightsavingStart = date.dayOfYear()-sub; date = mEndDateSavingEdit->date(); if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) sub = 1; else sub = 0; prefs->mDaylightsavingEnd = date.dayOfYear()-sub; prefs->mEmailClient = mEmailClient; prefs->mEmailOtherChannel = mEmailOtherChannel; prefs->mEmailOtherMessage = mEmailOtherMessage; prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; prefs->mEmailOtherMessage2 = mEmailOtherMessage2; prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; prefs->mPhoneClient = mPhoneClient; prefs->mPhoneOtherChannel = mPhoneOtherChannel; prefs->mPhoneOtherMessage = mPhoneOtherMessage; prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; prefs->mFaxClient = mFaxClient; prefs->mFaxOtherChannel = mFaxOtherChannel; prefs->mFaxOtherMessage = mFaxOtherMessage; prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; prefs->mSMSClient = mSMSClient; prefs->mSMSOtherChannel = mSMSOtherChannel; prefs->mSMSOtherMessage = mSMSOtherMessage; prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; prefs->mPagerClient = mPagerClient; prefs->mPagerOtherChannel = mPagerOtherChannel; prefs->mPagerOtherMessage = mPagerOtherMessage; prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; prefs->mSipClient = mSipClient; prefs->mSipOtherChannel = mSipOtherChannel; prefs->mSipOtherMessage = mSipOtherMessage; prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; //release the cache that other views can access the changed values instantanious ExternalAppHandler::instance()->loadConfig(); KPimGlobalPrefs::instance()->setGlobalConfig(); } void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text, const QStringList *tags) { if (tags) { int i = tags->findIndex(text); if (i > 0) combo->setCurrentItem(i); } else { for(int i=0;i<combo->count();++i) { if (combo->text(i) == text) { combo->setCurrentItem(i); break; } } } } void KDEPIMConfigWidget::textChanged( const QString& text ) { emit changed( true ); } diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 90321b2..9c28425 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp @@ -11,213 +11,219 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include <kglobalsettings.h> #include <kstaticdeleter.h> #include <qregexp.h> #include <qfile.h> #include <stdlib.h> #include <qtextstream.h> #include <qapplication.h> #include "kpimglobalprefs.h" KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) : KPrefs("microkdeglobalrc") { mLocaleDict = 0; KPrefs::setCurrentGroup("Fonts"); addItemFont("ApplicationFont",&mApplicationFont,KGlobalSettings::generalFont() ); KPrefs::setCurrentGroup("Locale"); addItemInt("PreferredLanguage",&mPreferredLanguage,0); addItemInt("PreferredTime",&mPreferredTime,0); addItemInt("PreferredDate",&mPreferredDate,0); addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); addItemString("UserDateFormatLong", &mUserDateFormatLong, "%AK %d. %b %y"); addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); KPrefs::setCurrentGroup("Colors"); addItemColor("AlternateBGcolor",&mAlternateColor,KGlobalSettings::alternateBackgroundColor()); KPrefs::setCurrentGroup("Time & Date"); addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); KPrefs::setCurrentGroup( "ExternalApplications" ); addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); addItemString( "EmailChannel", &mEmailOtherChannel, "" ); addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); addItemString( "FaxChannel", &mFaxOtherChannel, "" ); addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); addItemString( "SMSChannel", &mSMSOtherChannel, "" ); addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); addItemString( "PagerChannel", &mPagerOtherChannel, "" ); addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); addItemString( "SIPChannel", &mSipOtherChannel, "" ); addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); KPrefs::setCurrentGroup( "PhoneAccess" ); addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); KPrefs::setCurrentGroup( "BackupSettings" ); addItemString("BackupDatadir",&mBackupDatadir,KGlobalSettings::backupDataDir()); addItemInt( "BackupNumbers", &mBackupNumbers, 3 ); addItemInt( "BackupDayCount", &mBackupDayCount, 2 ); addItemBool( "BackupUseDefaultDir",&mBackupUseDefaultDir, true ); addItemBool( "BackupEnabled",&mBackupEnabled, false ); } void KPimGlobalPrefs::setGlobalConfig() { if ( mLocaleDict == 0 ) { QString fileName ; QString name = KGlobal::getAppName() +"/"; #ifndef DESKTOP_VERSION fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; #else fileName = qApp->applicationDirPath () + "/kdepim/"+ name; #endif mLocaleDict = 0; if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { if ( mPreferredLanguage == 1 ) fileName = fileName+"germantranslation.txt"; else if ( mPreferredLanguage == 4 ) fileName = fileName+"usertranslation.txt"; else if ( mPreferredLanguage == 2 ) fileName = fileName+"frenchtranslation.txt"; else if ( mPreferredLanguage == 3 ) fileName = fileName+"italiantranslation.txt"; QFile file( fileName ); if (file.open( IO_ReadOnly ) ) { QTextStream ts( &file ); ts.setEncoding( QTextStream::Latin1 ); //ts.setCodec( QTextCodec::latin1 ); QString text = ts.read(); file.close(); text.replace( QRegExp("\\\\n"), "\n" ); QString line; QString we; QString wt; int br = 0; int nbr; nbr = text.find ( "},", br ); line = text.mid( br, nbr - br ); br = nbr+1; int se, ee, st, et; mLocaleDict = new QDict<QString>; mLocaleDict->setAutoDelete( true ); QString end = "{ \"\",\"\" }"; while ( (line != end) && (br > 1) ) { //qDebug("%d *%s* ", br, line.latin1()); se = line.find("\"")+1; et = line.findRev("\"",-1); ee = line.find("\",\""); st = ee+3; we = line.mid( se, ee-se ); if ( mPreferredLanguage == 4 ) wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); else wt = line.mid( st, et-st ); //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); mLocaleDict->insert( we, new QString (wt) ); nbr = text.find ( "}", br ); line = text.mid( br, nbr - br ); br = nbr+1; } //qDebug("end *%s* ", end.latin1()); setLocaleDict( mLocaleDict ); } else { qDebug("KO: Cannot find translation file %s",fileName.latin1() ); } } } KGlobal::locale()->setHore24Format( !mPreferredTime ); KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); KGlobal::locale()->setLanguage( mPreferredLanguage ); QString dummy = mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = mUserDateFormatShort; KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, mDaylightsavingStart, mDaylightsavingEnd ); KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); + QString localKdeDir; + localKdeDir = readEnvPath("LOCALMICROKDEHOME"); + if ( ! localKdeDir.isEmpty() ) { + mBackupUseDefaultDir = true; + mBackupDatadir = KGlobalSettings::backupDataDir(); + } } KPimGlobalPrefs::~KPimGlobalPrefs() { if (sInstance == this) sInstance = staticDeleterGP.setObject(0); else qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); if ( mLocaleDict ) delete mLocaleDict; } KPimGlobalPrefs *KPimGlobalPrefs::instance() { if ( !sInstance ) { sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); sInstance->readConfig(); } return sInstance; } diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index d68ccb6..714d1b7 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp @@ -1,82 +1,85 @@ /* This file is part of libkdepim. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include "kpimprefs.h" KPimPrefs::KPimPrefs( const QString &name ) : KPrefs( name ) { #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif setCurrentGroup("SyncOptions"); addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); + + setCurrentGroup("BackupDate"); + addItemInt("LastBackupDate",&mLastBackupDate,0); } KPimPrefs::~KPimPrefs() { } void KPimPrefs::usrSetDefaults() { setCategoryDefaults(); } void KPimPrefs::usrReadConfig() { config()->setGroup("General"); mCustomCategories = config()->readListEntry("Custom Categories"); if (mCustomCategories.isEmpty()) setCategoryDefaults(); } void KPimPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); } void KPimPrefs::setCategoryDefaults() { // empty implementation } diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index c177bd6..bf80042 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h @@ -1,73 +1,74 @@ /* This file is part of libkdepim. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KPIMPREFS_H #define KPIMPREFS_H #include <qstringlist.h> #include "kprefs.h" class KPimPrefs : public KPrefs { public: KPimPrefs( const QString &name = QString::null ); virtual ~KPimPrefs(); /** Set preferences to default values */ void usrSetDefaults(); /** Read preferences from config file */ void usrReadConfig(); /** Write preferences to config file */ void usrWriteConfig(); public: QStringList mCustomCategories; QString mPassiveSyncPort; QString mPassiveSyncPw; bool mPassiveSyncWithDesktop; bool mPassiveSyncAutoStart; int mRingSyncAlgoPrefs; QString mLastSyncedLocalFile; + int mLastBackupDate; protected: virtual void setCategoryDefaults(); }; #endif diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 80a83e0..539397b 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp @@ -1,126 +1,246 @@ #include <stdlib.h> #include <stdio.h> #include "kapplication.h" #include "ktextedit.h" #include <qapplication.h> #include <qstring.h> #include <qfile.h> #include <qtextstream.h> #include <qdialog.h> #include <qlayout.h> #include <qtextbrowser.h> int KApplication::random() { return rand(); } //US QString KApplication::randomString(int length) { if (length <=0 ) return QString::null; QString str; while (length--) { int r=random() % 62; r+=48; if (r>57) r+=7; if (r>90) r+=6; str += char(r); // so what if I work backwards? } return str; } int KApplication::execDialog( QDialog* d ) { if (QApplication::desktop()->width() <= 640 ) d->showMaximized(); else ;//d->resize( 800, 600 ); return d->exec(); } void KApplication::showLicence() { KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); } void KApplication::testCoords( int* x, int* y, int* wid, int * hei ) { int dWid = QApplication::desktop()->width() ; int dHei = QApplication::desktop()->height(); if ( *x + *wid > dWid ) { *x = 0; if ( *wid > dWid ) *wid = dWid; } if ( *y + *hei > dHei ) { *y = 0; if ( *hei > dHei ) *hei = dHei; } } void KApplication::showFile(QString caption, QString fn) { QString text; QString fileName; #ifndef DESKTOP_VERSION fileName = getenv("QPEDIR"); fileName += "/pics/" + fn ; #else fileName = qApp->applicationDirPath () + "/" + fn; #endif QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return ; } QTextStream ts( &file ); text = ts.read(); file.close(); KApplication::showText( caption, text ); } bool KApplication::convert2latin1(QString fileName) { QString text; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return false; } QTextStream ts( &file ); ts.setEncoding( QTextStream::UnicodeUTF8 ); text = ts.read(); file.close(); if (!file.open( IO_WriteOnly ) ) { return false; } QTextStream tsIn( &file ); tsIn.setEncoding( QTextStream::Latin1 ); tsIn << text.latin1(); file.close(); return true; } void KApplication::showText(QString caption, QString text) { QDialog dia( 0, "name", true ); ; dia.setCaption( caption ); QVBoxLayout* lay = new QVBoxLayout( &dia ); lay->setSpacing( 3 ); lay->setMargin( 3 ); KTextEdit tb ( &dia ); tb.setWordWrap( QMultiLineEdit::WidgetWidth ); lay->addWidget( &tb ); tb.setText( text ); #ifdef DESKTOP_VERSION dia.resize( 640, 480); #else dia.showMaximized(); #endif dia.exec(); } + +#include <qlabel.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qdir.h> +#include <qradiobutton.h> +#include <qbuttongroup.h> +#include "kglobal.h" +#include "klocale.h" + +class KBackupPrefs : public QDialog +{ + public: + KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : + QDialog( parent, name, true ) + { + setCaption( i18n("Backup Failed!") ); + QVBoxLayout* lay = new QVBoxLayout( this ); + lay->setSpacing( 3 ); + lay->setMargin( 3 ); + QLabel * lab = new QLabel( message, this ); + lay->addWidget( lab ); + QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this ); + lay->addWidget( format ); + format->setExclusive ( true ) ; + vcal = new QRadioButton(i18n("Try again now"), format ); + tcal = new QRadioButton(i18n("Try again later"), format ); + ical = new QRadioButton(i18n("Try again tomorrow"), format ); + ocal = new QRadioButton(i18n("Disable backup"), format ); + vcal->setChecked( true ); + QPushButton * ok = new QPushButton( i18n("OK"), this ); + lay->addWidget(ok ); + connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); + } + + bool again() { return vcal->isChecked(); } + bool later() { return tcal->isChecked(); } + bool againTomorrow() { return ical->isChecked(); } +private: + QRadioButton* vcal, *ical, *ocal, *tcal; +}; +int KApplication::createBackup( QString fn, QString dp, int numBup ) +{ + if ( numBup < 1) return 3; + int ret = 3; + qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup); + QDir bupDir ( dp ); + bool tryAgain = true; + while ( tryAgain ) { + if ( !bupDir.exists() ) { + KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + dp.right(30)); + if ( !noDir.exec() ) return 3; + if ( noDir.againTomorrow() ) { + return 0; + } else if ( noDir.later() ) { + return 3; + } else if ( !noDir.again() ) { + return 2; + } + } else { + tryAgain = false; + } + } + // we have a valid dir! + QStringList allFileList = bupDir.entryList(QDir::Files); + QFileInfo fileInfo ( fn ); + QString fName = fileInfo.fileName (); + QStringList fileList; + + int i; + for ( i = 0; i < allFileList.count(); ++i ) { + QString fi = allFileList[i]; + if ( fi. find( fName ) > -1 ) + fileList.append( fi ); + } + qDebug("%d backup files exist ", fileList.count()); + int count = fileList.count(); + fileList.sort(); + int remCount = 0; + while ( count >= numBup ) { + QString fnr = dp + "/"+fileList[remCount]; + QFile::remove( fnr ); + --count; + ++remCount; + } + QDateTime mRunStart = QDateTime::currentDateTime(); + QString file = "%1%2%3-%4%5%6-"; + file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); + file.replace ( QRegExp (" "), "0" ); + file += fName ; + file = dp + "/"+file; + QString command; + int res = 0; +#ifdef _WIN32_ + command = "xcopy "+ fn+ " "+file; + command = QDir::convertSeparators( command ); +#else + command = "cp "+ fn+ " "+file; +#endif + qDebug("command %s ",command.latin1() ); + tryAgain = true; + while ( tryAgain ) { + res = system ( command.latin1() ); + qDebug("copy result %d ", res); + if ( res != 0 ) { + KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>")); + if ( !noDir.exec() ) return 3; + if ( noDir.againTomorrow() ) { + return 0; + } else if ( noDir.later() ) { + return 3; + } else if ( !noDir.again() ) { + return 2; + } + } else { + tryAgain = false; + } + } + return 1; +} diff --git a/microkde/kapplication.h b/microkde/kapplication.h index f7eb1ef..de5a084 100644 --- a/microkde/kapplication.h +++ b/microkde/kapplication.h @@ -1,31 +1,32 @@ #ifndef MINIKDE_KAPPLICATION_H #define MINIKDE_KAPPLICATION_H #include "qstring.h" #include <qdialog.h> #ifdef QDialog #undef QDialog #endif class KApplication { public: static int random(); //US /** * Generates a random string. It operates in the range [A-Za-z0-9] * @param length Generate a string of this length. * @return the random string */ static QString randomString(int length); static int execDialog( QDialog* ); static void showLicence(); static void testCoords( int* x, int* y, int* wid, int * hei ); static void showFile(QString caption, QString file); static void showText(QString caption, QString text); static bool convert2latin1(QString file); + static int createBackup( QString fn, QString dp, int numBup ); }; #endif |