From 5c26aae7ef81b70a9fd7e2ab0b0681a418970df8 Mon Sep 17 00:00:00 2001
From: Philippe Mavridis <philippe.mavridis@yandex.com>
Date: Sun, 26 Oct 2025 14:35:30 +0200
Subject: Add last save status widget to status bar

Signed-off-by: Philippe Mavridis <philippe.mavridis@yandex.com>
---
 src/knowit.cpp | 44 ++++++++++++++++++++++++++++++--------------
 src/knowit.h   | 12 +++++++-----
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/src/knowit.cpp b/src/knowit.cpp
index d59505d..20d5624 100644
--- a/src/knowit.cpp
+++ b/src/knowit.cpp
@@ -95,7 +95,7 @@ Knowit::Knowit(TQWidget*, const char *name) : TDEMainWindow(0, name),
      TQ_SLOT(slotEditCursorChanged(int, int)));
    connect(Edit, TQ_SIGNAL(textDropped(const TQString&, int)),
       this, TQ_SLOT(slotLinkDropped(const TQString&, int)));
-   
+
    /* Links (TDEListBox) */
    connect(Links, TQ_SIGNAL(doubleClicked(TQListBoxItem*)),
       this, TQ_SLOT(slotShowAttachment(TQListBoxItem*)));
@@ -230,7 +230,7 @@ Knowit::Knowit(TQWidget*, const char *name) : TDEMainWindow(0, name),
    KStdAction::keyBindings(this, TQ_SLOT(slotOptionsKeys()), actionCollection());
    KStdAction::configureToolbars(this, TQ_SLOT(slotOptionsToolbar()), actionCollection());
    KStdAction::preferences(this, TQ_SLOT(slotOptions()), actionCollection());
-            
+
    /* Actions: Help */
    new TDEAction(i18n("&Tip of the day"), "idea", "", this,
       TQ_SLOT(slotHelpTip()), actionCollection(), "help_tip");
@@ -258,9 +258,13 @@ Knowit::Knowit(TQWidget*, const char *name) : TDEMainWindow(0, name),
    /* Actions */
 #if TDE_VERSION_MAJOR >= 3 && TDE_VERSION_MINOR >= 1
    setStandardToolBarMenuEnabled(true);
-#endif   
+#endif
    createGUI("knowitui.rc", false);
 
+   /* Last save date */
+   TQString t = TDEGlobal::locale()->formatDateTime(TQDateTime::currentDateTime(), true, true);
+   statusBar()->insertFixedItem(t, StatusLastSave, true);
+   statusBar()->changeItem(i18n("Not saved"), StatusLastSave);
 
    /* Insert/overwrite mode */
    statusBar()->insertFixedItem(("WWW"), StatusOvr, true);
@@ -283,7 +287,7 @@ Knowit::Knowit(TQWidget*, const char *name) : TDEMainWindow(0, name),
 
    if (Options.docked && Options.dockOnStart)
        hide();
-   else 
+   else
        show();
 
    bool opened = false;
@@ -379,8 +383,11 @@ bool Knowit::open(const KURL& fname)
    slotStatusMsg(i18n("File %1 opened.").arg(filename.fileName()));
    slotActionUpdate();
 
+   TQFileInfo fi(file);
+   slotStatusLastSave(fi.lastModified());
+
    file.close();
-   if (Options.backup) 
+   if (Options.backup)
      URLOperator.copy(fname.path(), fname.path() + "~", false, false);
    if (Options.autosave)
      AutosaveTimer->start(Options.autosave * 60 * 1000, true);
@@ -408,6 +415,7 @@ bool Knowit::save(const KURL& fname)
   Edit->setModified(false);
   actionRecent->addURL(filename);
   slotStatusMsg(i18n("File %1 saved.").arg(filename.fileName()));
+  slotStatusLastSave(TQDateTime::currentDateTime());
   if (Options.autosave)
      AutosaveTimer->start(Options.autosave * 60 * 1000, true);
   return true;
@@ -423,6 +431,7 @@ void Knowit::reset()
    setCaption(Untitled);
    Notes.modified = false;
    slotActionUpdate();
+   statusBar()->changeItem(i18n("Not saved"), StatusLastSave);
 }
 
 
@@ -443,7 +452,7 @@ bool Knowit::queryClose()
    else if (Options.unconditionalSave) {
        slotFileSave();
        return shuttingDown = filename.isEmpty() || !modified()  || (KMessageBox::questionYesNo(0,
-           i18n("<qt>File <b>%1</b><br>\ncannot be saved. Quit anyway?</qt>").arg(filename.fileName())) 
+           i18n("<qt>File <b>%1</b><br>\ncannot be saved. Quit anyway?</qt>").arg(filename.fileName()))
 	   == KMessageBox::Yes);
        }
    else
@@ -600,6 +609,13 @@ void Knowit::slotStatusMsg(const TQString &text)
 }
 
 
+void Knowit::slotStatusLastSave(const TQDateTime &timestamp)
+{
+    TQString t = TDEGlobal::locale()->formatDateTime(timestamp, true, true);
+    statusBar()->changeItem(t, StatusLastSave);
+}
+
+
 void Knowit::slotContextMenu(TDEListView*, TQListViewItem*, const TQPoint& p)
 {
    TQWidget *w = factory()->container("notes_popup", this);
@@ -729,7 +745,7 @@ void Knowit::slotNoteMoveUp()
          above = 0;
       else while (above->nextSibling()->nextSibling() != elt)
          above = above->nextSibling();
-      if (above) 
+      if (above)
          elt->moveItem(above);
       else {
          TQListViewItem* parent = elt->parent();
@@ -778,7 +794,7 @@ void Knowit::slotNoteMoveEnd()
       Items->takeNode(elt);
       Items->insertNode(0, elt, last);
       slotNoteChanged(elt);
-      if (parent) 
+      if (parent)
          Notes.find(parent)->updateView();
       Notes.modified = true;
       }
@@ -855,7 +871,7 @@ void Knowit::slotFileSave()
 
 void Knowit::slotFileAutosave()
 {
-  if (modified()) 
+  if (modified())
      slotFileSave();
   if (modified()) {	/* file wasn't saved */
      KMessageBox::sorry(0, i18n("<qt><p>File couldn not be saved automatically."
@@ -1051,27 +1067,27 @@ void Knowit::slotEditAlignCenter()
 void Knowit::slotEditListBullet()
 {
    Edit->setParagType(TQStyleSheetItem::DisplayListItem, TQStyleSheetItem::ListDisc);
-}        
+}
 
 void Knowit::slotEditListNumber()
 {
    Edit->setParagType(TQStyleSheetItem::DisplayListItem, TQStyleSheetItem::ListDecimal);
-}        
+}
 
 void Knowit::slotEditListUpper()
 {
    Edit->setParagType(TQStyleSheetItem::DisplayListItem, TQStyleSheetItem::ListUpperAlpha);
-}        
+}
 
 void Knowit::slotEditListLower()
 {
    Edit->setParagType(TQStyleSheetItem::DisplayListItem, TQStyleSheetItem::ListLowerAlpha);
-}        
+}
 
 void Knowit::slotEditListNone()
 {
    Edit->setParagType(TQStyleSheetItem::DisplayBlock, TQStyleSheetItem::ListDisc);
-}        
+}
 
 void Knowit::slotEditFind()
 {
diff --git a/src/knowit.h b/src/knowit.h
index c862759..2ee4897 100644
--- a/src/knowit.h
+++ b/src/knowit.h
@@ -2,7 +2,7 @@
                           knowit.h  -  description
                              -------------------
     begin                : czw wrz 26 08:27:40 CEST 2002
-    copyright            : (C) 2002-2004 by Michał Rudolf
+    copyright            : (C) 2002-2004 by MichaĆ Rudolf
     email                : mrudolf@kdewebdev.org
  ***************************************************************************/
 
@@ -45,13 +45,13 @@ class TDERecentFilesAction;
 class KnowitTray;
 class KnowitEdit;
 class KnowitTree;
-   
+
 
 /** Knowit is the base class of the project */
 class Knowit : public TDEMainWindow
 {
   TQ_OBJECT
-  
+
   private:
     static const TQString Untitled;
     TDEConfig *config;
@@ -84,7 +84,7 @@ class Knowit : public TDEMainWindow
     TDEAction *actionCut, *actionCopy, *actionUndo, *actionRedo;
 
     /** Insert/Overwrite status */
-    enum {StatusText = 1, StatusOvr = 2};    
+    enum {StatusText = 1, StatusLastSave = 2, StatusOvr = 3};
   public:
     /** Constructor of main window */
     Knowit(TQWidget* parent=0, const char *name=0);
@@ -121,6 +121,8 @@ class Knowit : public TDEMainWindow
  public slots:
     /** Status bar text has changed - displays it */
     void slotStatusMsg(const TQString& text);
+    /** Last save status timestamp has changed - displays it */
+    void slotStatusLastSave(const TQDateTime& timestamp);
     /** Shows requested popup menu for notes */
     void slotContextMenu(TDEListView*, TQListViewItem*, const TQPoint&);
     /** Shows given note */
@@ -233,7 +235,7 @@ class Knowit : public TDEMainWindow
     void slotOverwriteModeChange();
     /** Toggles raw text/rich text edit mode */
     void slotRawTextMode();
-    
+
     /** Shows requested popup menu for links */
     void slotContextLinksMenu(TQListBoxItem* item, const TQPoint&);
     /** show current attachment **/
-- 
cgit v1.2.3

