From f76c133e0983f2bcf6842909a0fc71b8702e2e04 Mon Sep 17 00:00:00 2001 From: tsujan Date: Sun, 21 Jul 2024 14:59:07 +0330 Subject: [PATCH] Prevent ordinary main windows under dropdown process (#1154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a new main window is opened in the dropdown mode (menubar → File → New Window), it should have a separate process because the dropdown process is supposed to consist of a single dropdown window. Of course, the work directory and profile must be respected too. Fixes https://github.com/lxqt/qterminal/issues/1153 --- src/mainwindow.cpp | 18 ++++++++++++++++-- src/properties.cpp | 5 +++++ src/properties.h | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c82b476..83ee2916 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -876,8 +876,22 @@ void MainWindow::newTerminalWindow() if (ch) cfg.provideCurrentDirectory(ch->currentTerminal()->impl()->workingDirectory()); - MainWindow *w = new MainWindow(cfg, false); - w->show(); + if (m_dropMode) + { // the dropdown process has only one (dropdown) main window + QStringList args; + args << QStringLiteral("-w") << cfg.getWorkingDirectory(); + QString profile = Properties::Instance()->profile(); + if (!profile.isEmpty()) + { + args << QStringLiteral("-p") << profile; + } + QProcess::startDetached(QStringLiteral("qterminal"), args); + } + else + { + MainWindow *w = new MainWindow(cfg, false); + w->show(); + } } void MainWindow::bookmarksWidget_callCommand(const QString& cmd) diff --git a/src/properties.cpp b/src/properties.cpp index 4f50603f..f384024a 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -416,3 +416,8 @@ QString Properties::configDir() const return QFileInfo(m_settings->fileName()).absoluteDir().canonicalPath(); } +QString Properties::profile() const +{ + return filename; +} + diff --git a/src/properties.h b/src/properties.h index ed550c36..c2a43b39 100644 --- a/src/properties.h +++ b/src/properties.h @@ -42,6 +42,7 @@ class Properties void loadSettings(); void migrate_settings(); QString configDir() const; + QString profile() const; static void removeAccelerator(QString& str);