Branch: master

9599fe54 2019-08-23 14:11:45 Michele Calgaro
Kate: added checkbox to select whether to display the session name on the
window caption or not. This relates to issue #62.

Signed-off-by: Michele Calgaro <michele.calgaro@...>
M kate/app/kateconfigdialog.cpp
M kate/app/kateconfigdialog.h
M kate/app/katemainwindow.cpp
M kate/app/katemainwindow.h

kate/app/kateconfigdialog.cpp

diff --git a/kate/app/kateconfigdialog.cpp b/kate/app/kateconfigdialog.cpp
index 38f71f2..883730c 100644
--- a/kate/app/kateconfigdialog.cpp
+++ b/kate/app/kateconfigdialog.cpp
@@ -107,18 +107,24 @@
 
   // show full path in title
   config->setGroup("General");
-  cb_fullPath = new TQCheckBox( i18n("&Show full path in title"), bgStartup);
-  cb_fullPath->setChecked( mainWindow->viewManager()->getShowFullPath() );
-  TQWhatsThis::add(cb_fullPath,i18n("If this option is checked, the full document path will be shown in the window caption."));
-  connect( cb_fullPath, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+  cb_fullPath = new TQCheckBox(i18n("&Show full path in title"), bgStartup);
+  cb_fullPath->setChecked(mainWindow->viewManager()->getShowFullPath());
+  TQWhatsThis::add(cb_fullPath, i18n("If this option is checked, the full document path will be shown in the window caption."));
+  connect(cb_fullPath, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+
+  // show session name in title
+  cb_showSessionName = new TQCheckBox(i18n("Show s&ession name in title"), bgStartup);
+  cb_showSessionName->setChecked(parent->showSessionName);
+  TQWhatsThis::add(cb_showSessionName, i18n("If this option is checked, the session name will be shown in the window caption."));
+  connect(cb_showSessionName, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
 
   // sort filelist if desired
-   cb_sortFiles = new TQCheckBox(bgStartup);
-   cb_sortFiles->setText(i18n("Sort &files alphabetically in the file list"));
-   cb_sortFiles->setChecked(parent->filelist->sortType() == KateFileList::sortByName);
-   TQWhatsThis::add( cb_sortFiles, i18n(
-         "If this is checked, the files in the file list will be sorted alphabetically.") );
-   connect( cb_sortFiles, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+  cb_sortFiles = new TQCheckBox(bgStartup);
+  cb_sortFiles->setText(i18n("Sort &files alphabetically in the file list"));
+  cb_sortFiles->setChecked(parent->filelist->sortType() == KateFileList::sortByName);
+  TQWhatsThis::add( cb_sortFiles, i18n(
+        "If this is checked, the files in the file list will be sorted alphabetically.") );
+  connect( cb_sortFiles, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
 
   // GROUP with the one below: "Behavior"
   bgStartup = new TQButtonGroup( 1, Qt::Horizontal, i18n("&Behavior"), frGeneral );
@@ -417,6 +423,7 @@
     config->writeEntry("Modified Notification", cb_modNotifications->isChecked());
     mainWindow->modNotification = cb_modNotifications->isChecked();
 
+    mainWindow->showSessionName = cb_showSessionName->isChecked();
     mainWindow->syncKonsole = cb_syncKonsole->isChecked();
     mainWindow->useInstance = cb_useInstance->isChecked();
     mainWindow->filelist->setSortType(cb_sortFiles->isChecked() ? KateFileList::sortByName : KateFileList::sortByID);
@@ -437,7 +444,7 @@
     }
     //mainWindow->externalTools->reload();
 
-    mainWindow->viewManager()->setShowFullPath( cb_fullPath->isChecked() ); // hm, stored 2 places :(
+    mainWindow->viewManager()->setShowFullPath(cb_fullPath->isChecked());
 
     mainWindow->saveOptions ();
 

kate/app/kateconfigdialog.h

diff --git a/kate/app/kateconfigdialog.h b/kate/app/kateconfigdialog.h
index 5bbfc52..a90cdd1 100644
--- a/kate/app/kateconfigdialog.h
+++ b/kate/app/kateconfigdialog.h
@@ -65,6 +65,7 @@
     bool dataChanged;
 
     TQCheckBox *cb_fullPath;
+    TQCheckBox *cb_showSessionName;
     TQCheckBox *cb_syncKonsole;
     TQCheckBox *cb_useInstance;
     TQCheckBox *cb_sortFiles;

kate/app/katemainwindow.cpp

diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp
index 1a021be..1e0a4b3 100644
--- a/kate/app/katemainwindow.cpp
+++ b/kate/app/katemainwindow.cpp
@@ -423,8 +423,9 @@
   TDEConfig *config = KateApp::self()->config ();
 
   config->setGroup("General");
-  syncKonsole =  config->readBoolEntry("Sync Konsole", true);
-  useInstance =  config->readBoolEntry("UseInstance", false);
+  showSessionName = config->readBoolEntry("Show session name", false);
+  syncKonsole = config->readBoolEntry("Sync Konsole", true);
+  useInstance = config->readBoolEntry("UseInstance", false);
   modNotification = config->readBoolEntry("Modified Notification", false);
   KateDocManager::self()->setSaveMetaInfos(config->readBoolEntry("Save Meta Infos", true));
   KateDocManager::self()->setDaysMetaInfos(config->readNumEntry("Days Meta Infos", 30));
@@ -447,6 +448,7 @@
   else
     config->writeEntry("Show Console", false);
 
+  config->writeEntry("Show session name", showSessionName);
   config->writeEntry("Save Meta Infos", KateDocManager::self()->getSaveMetaInfos());
   config->writeEntry("Days Meta Infos", KateDocManager::self()->getDaysMetaInfos());
   config->writeEntry("Show Full Path in Title", m_viewManager->getShowFullPath());
@@ -820,7 +822,7 @@
     fileOpenRecent->addURL(doc->url());
 }
 
-void KateMainWindow::updateCaption (Kate::Document *doc)
+void KateMainWindow::updateCaption(Kate::Document *doc)
 {
   if (!m_viewManager->activeView())
   {
@@ -841,12 +843,20 @@
     c = m_viewManager->activeView()->getDoc()->url().prettyURL();
   }
 
-  TQString sessName = KateApp::self()->sessionManager()->getActiveSessionName();
-  if ( !sessName.isEmpty() )
-    sessName = TQString("%1: ").arg( sessName );
-
-  setCaption( sessName + KStringHandler::lsqueeze(c,64),
-      m_viewManager->activeView()->getDoc()->isModified());
+  if (showSessionName)
+  {
+    TQString sessName = KateApp::self()->sessionManager()->getActiveSessionName();
+    if (!sessName.isEmpty())
+    {
+      sessName = TQString("%1: ").arg(sessName);
+    }
+    setCaption(KStringHandler::lsqueeze(sessName,32) + KStringHandler::lsqueeze(c,64),
+        m_viewManager->activeView()->getDoc()->isModified());
+  }
+  else
+  {
+    setCaption(KStringHandler::lsqueeze(c,64), m_viewManager->activeView()->getDoc()->isModified());
+  }
 }
 
 void KateMainWindow::saveProperties(TDEConfig *config)

kate/app/katemainwindow.h

diff --git a/kate/app/katemainwindow.h b/kate/app/katemainwindow.h
index aa2a6ce..48f4129 100644
--- a/kate/app/katemainwindow.h
+++ b/kate/app/katemainwindow.h
@@ -187,6 +187,7 @@
     Kate::MainWindow *m_mainWindow;
     Kate::ToolViewManager *m_toolViewManager;
 
+    bool showSessionName;
     bool syncKonsole;
     bool useInstance;
     bool modNotification;