Blob Blame History Raw
diff --git a/src/Application.h b/src/Application.h
index ae9b1fe..9d1ea9f 100644
--- a/src/Application.h
+++ b/src/Application.h
@@ -77,12 +77,13 @@ private:
     void listProfilePropertyInfo();
     void startBackgroundMode(MainWindow* window);
     bool processHelpArgs(KCmdLineArgs* args);
-    MainWindow* processWindowArgs(KCmdLineArgs* args);
+    MainWindow* processWindowArgs(KCmdLineArgs* args, bool &createdNewMainWindow);
     Profile::Ptr processProfileSelectArgs(KCmdLineArgs* args);
     Profile::Ptr processProfileChangeArgs(KCmdLineArgs* args, Profile::Ptr baseProfile);
     void processTabsFromFileArgs(KCmdLineArgs* args, MainWindow* window);
     void createTabFromArgs(KCmdLineArgs* args, MainWindow* window,
                            const QHash<QString, QString>&);
+    void newMainWindowFinalise(MainWindow* window);
 
     MainWindow* _backgroundInstance;
 };
-- 
2.7.0

From 354beb8b612e41cc4121283839dafd176f7639c0 Mon Sep 17 00:00:00 2001
From: subdiff <subdiff@gmail.com>
Date: Fri, 29 Jan 2016 19:34:43 +0100
Subject: [PATCH] Fix chosen window size on startup and deactivate unnecessary
 one time test in newInstance()

This patch should solve bug 345403. When not using window size recreation, loading
the preferred size from profile didn't work. This patch uses a manual resize
after creation of the main window and setting up its components.
We also deactivate an if clause, which is only relevant on first launch after
installation, but is not really needed.
---
 src/Application.cpp | 37 ++++++++++++++++++++++++++++++-------
 src/Application.h   |  3 ++-
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/Application.cpp b/src/Application.cpp
index 10f11a4..498d260 100644
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -36,6 +36,7 @@
 #include "MainWindow.h"
 #include "Session.h"
 #include "ShellCommand.h"
+#include "KonsoleSettings.h"
 
 using namespace Konsole;
 
@@ -83,7 +84,7 @@ void Application::createWindow(Profile::Ptr profile, const QString& directory)
 {
     MainWindow* window = newMainWindow();
     window->createSession(profile, directory);
-    window->show();
+    newMainWindowFinalise(window);
 }
 
 void Application::detachView(Session* session)
@@ -93,7 +94,7 @@ void Application::detachView(Session* session)
     // Since user is dragging and dropping, move dnd window to where
     // the user has the cursor (correct multiple monitor setups).
     window->move(QCursor::pos());
-    window->show();
+    newMainWindowFinalise(window);
 }
 
 int Application::newInstance()
@@ -109,8 +110,12 @@ int Application::newInstance()
         if (processHelpArgs(args))
             return 0;
 
+        // determines through processWindowArgs(args, createdNewMainWindow) if a new window
+        // should be created or only a tab in an existing one
+        bool createdNewMainWindow = false;
+
         // create a new window or use an existing one
-        MainWindow* window = processWindowArgs(args);
+        MainWindow* window = processWindowArgs(args, createdNewMainWindow);
 
         if (args->isSet("tabs-from-file")) {
             // create new session(s) as described in file
@@ -148,10 +153,21 @@ int Application::newInstance()
             // run. After that KMainWindow will have manually resized the
             // window to its saved size at this point (so the Qt::WA_Resized
             // attribute will be set)
-            if (!window->testAttribute(Qt::WA_Resized))
-                window->resize(window->sizeHint());
 
-            window->show();
+            // Trying deactivation: If this only affects the first time the application is run after installation,
+            // we should ignore it instead of adding runtime complexity for all subsequent executions.
+
+            //if (!window->testAttribute(Qt::WA_Resized))
+            //    window->resize(window->sizeHint());
+
+            // If not restoring size from last time or only adding new tab,
+            // resize window to chosen profile size (see Bug:345403)
+            if (createdNewMainWindow){
+                newMainWindowFinalise(window);
+            }
+            else{
+                window->show();
+            }
         }
     }
 
@@ -285,7 +301,7 @@ void Application::createTabFromArgs(KCmdLineArgs* args, MainWindow* window,
     window->hide();
 }
 
-MainWindow* Application::processWindowArgs(KCmdLineArgs* args)
+MainWindow* Application::processWindowArgs(KCmdLineArgs* args, bool &createdNewMainWindow)
 {
     MainWindow* window = 0;
     if (args->isSet("new-tab")) {
@@ -299,6 +315,7 @@ MainWindow* Application::processWindowArgs(KCmdLineArgs* args)
     }
 
     if (window == 0) {
+        createdNewMainWindow = true;
         window = newMainWindow();
 
         // override default menubar visibility
@@ -475,3 +492,9 @@ void Application::toggleBackgroundInstance()
     }
 }
 
+void Application::newMainWindowFinalise(MainWindow* window)
+{
+    if (!KonsoleSettings::saveGeometryOnExit())
+        window->resize(window->sizeHint());
+    window->show();
+}