[utilities/kate] /: allow to disable the welcome page

Christoph Cullmann null at kde.org
Thu Sep 22 16:40:52 BST 2022


Git commit bac8b59f16b19171794653a005d179b25675b4d8 by Christoph Cullmann.
Committed on 22/09/2022 at 15:33.
Pushed by cullmann into branch 'master'.

allow to disable the welcome page

one can configure that every new window should
start with an untitled document

perhaps the UI element needs a better text, as
we naturally will only create an untitled document,
if we don't have something else to show

M  +6    -0    apps/lib/kateconfigdialog.cpp
M  +17   -2    apps/lib/kateviewmanager.cpp
M  +8    -1    apps/lib/ui/sessionconfigwidget.ui
M  +1    -1    doc/kate/configuring.docbook

https://invent.kde.org/utilities/kate/commit/bac8b59f16b19171794653a005d179b25675b4d8

diff --git a/apps/lib/kateconfigdialog.cpp b/apps/lib/kateconfigdialog.cpp
index 66d4f7408..72a7afd55 100644
--- a/apps/lib/kateconfigdialog.cpp
+++ b/apps/lib/kateconfigdialog.cpp
@@ -346,6 +346,10 @@ void KateConfigDialog::addSessionPage()
     connect(sessionConfigUi.loadLastUserSessionRadioButton, &QRadioButton::toggled, this, &KateConfigDialog::slotChanged);
     connect(sessionConfigUi.manuallyChooseSessionRadioButton, &QRadioButton::toggled, this, &KateConfigDialog::slotChanged);
 
+    // New main windows open always a new document if none there
+    sessionConfigUi.openNewDocumentPerWindow->setChecked(cgGeneral.readEntry("Open untitled document for new window", false));
+    connect(sessionConfigUi.openNewDocumentPerWindow, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
+
     // Closing last file closes Kate
     sessionConfigUi.modCloseAfterLast->setChecked(m_mainWindow->modCloseAfterLast());
     connect(sessionConfigUi.modCloseAfterLast, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
@@ -500,6 +504,8 @@ void KateConfigDialog::slotApply()
         cg.writeEntry("Days Meta Infos", sessionConfigUi.daysMetaInfos->value());
         KateApp::self()->documentManager()->setDaysMetaInfos(sessionConfigUi.daysMetaInfos->value());
 
+        cg.writeEntry("Open untitled document for new window", sessionConfigUi.openNewDocumentPerWindow->isChecked());
+
         cg.writeEntry("Close After Last", sessionConfigUi.modCloseAfterLast->isChecked());
         m_mainWindow->setModCloseAfterLast(sessionConfigUi.modCloseAfterLast->isChecked());
 
diff --git a/apps/lib/kateviewmanager.cpp b/apps/lib/kateviewmanager.cpp
index 0e79457e5..ba24b6070 100644
--- a/apps/lib/kateviewmanager.cpp
+++ b/apps/lib/kateviewmanager.cpp
@@ -75,8 +75,23 @@ KateViewManager::KateViewManager(QWidget *parentW, KateMainWindow *parent)
     connect(KateApp::self()->documentManager(), &KateDocManager::aboutToDeleteDocuments, this, &KateViewManager::aboutToDeleteDocuments);
     connect(KateApp::self()->documentManager(), &KateDocManager::documentsDeleted, this, &KateViewManager::documentsDeleted);
 
-    // ensure we have the welcome view if no active view is there
-    showWelcomeViewIfNeeded();
+    // the user can decide: welcome page or a new untitled document for a new window?
+    KSharedConfig::Ptr config = KSharedConfig::openConfig();
+    KConfigGroup cgGeneral = KConfigGroup(config, "General");
+    if (cgGeneral.readEntry("Open untitled document for new window", false)) {
+        // we only open one, if we have no other proper view around
+        QTimer::singleShot(0, this, [this]() {
+            // we really want to show up only if nothing is in the current view space
+            // this guard versus double invocation of this function, too
+            if (activeViewSpace() && (activeViewSpace()->currentView() || activeViewSpace()->currentWidget()))
+                return;
+
+            slotDocumentNew();
+        });
+    } else {
+        // ensure we have the welcome view if no active view is there
+        showWelcomeViewIfNeeded();
+    }
 }
 
 KateViewManager::~KateViewManager()
diff --git a/apps/lib/ui/sessionconfigwidget.ui b/apps/lib/ui/sessionconfigwidget.ui
index 38592f56b..53f6d98f4 100644
--- a/apps/lib/ui/sessionconfigwidget.ui
+++ b/apps/lib/ui/sessionconfigwidget.ui
@@ -44,7 +44,7 @@
    <item>
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
-      <string>Application Shutdown Behavior</string>
+      <string>Application Startup/Shutdown Behavior</string>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout_5">
       <item>
@@ -82,6 +82,13 @@
         </item>
        </layout>
       </item>
+      <item>
+       <widget class="QCheckBox" name="openNewDocumentPerWindow">
+        <property name="text">
+         <string>Open new window with fresh untitled document</string>
+        </property>
+       </widget>
+      </item>
       <item>
        <widget class="QCheckBox" name="modCloseAfterLast">
         <property name="whatsThis">
diff --git a/doc/kate/configuring.docbook b/doc/kate/configuring.docbook
index 85ebc7eb0..f72dc0f93 100644
--- a/doc/kate/configuring.docbook
+++ b/doc/kate/configuring.docbook
@@ -264,7 +264,7 @@ frequently.</para></listitem>
 
 <varlistentry>
 <term><anchor id="config-dialog-sessions-shutdown-behavior"/>
-<guilabel>Application Shutdown Behavior</guilabel></term>
+<guilabel>Application Startup/Shutdown Behavior</guilabel></term>
 <listitem>
 <para>Select how you want &kate; to behave at shutdown. It is possible to define what
 &kate; should <guilabel>Automatically save and restore</guilabel>.</para>


More information about the kde-doc-english mailing list