Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/server/src/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ struct ConfigValue {
bool closeOnFocusLoss = false;
bool considerPreedit = false;
bool popToRootOnClose = false;
// seconds; with popToRootOnClose, reopening within this window keeps the query/view stack
int popToRootOnCloseDelay = 0;
bool popOnBackspace = true;
bool activateOnSingleClick = false;
#ifdef Q_OS_LINUX
Expand Down Expand Up @@ -331,6 +333,7 @@ template <> struct Partial<ConfigValue> {
std::optional<bool> closeOnFocusLoss;
std::optional<bool> considerPreedit;
std::optional<bool> popToRootOnClose;
std::optional<int> popToRootOnCloseDelay;
std::optional<bool> popOnBackspace;
std::optional<bool> activateOnSingleClick;
std::optional<bool> encryptSensitiveData;
Expand Down
14 changes: 12 additions & 2 deletions src/server/src/navigation-controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@ void NavigationController::showHud(const QString &title, const std::optional<Ima
}

void NavigationController::applyPopToRoot(const PendingPopToRoot &settings) {
// Raycast-style delayed pop to root: a Default-policy close that reopens within
// m_popToRootOnCloseDelay seconds keeps the view stack and search text.
bool const closedRecently = m_popToRootOnCloseDelay > 0 && m_closedAt.isValid() &&
m_closedAt.elapsed() < qint64(m_popToRootOnCloseDelay) * 1000;

auto resolveApplicablePopToRoot = [&]() {
if (settings.type == PopToRootType::Default)
if (settings.type == PopToRootType::Default) {
if (closedRecently) return PopToRootType::Suspended;
return m_popToRootOnClose ? PopToRootType::Immediate : PopToRootType::Suspended;
}
return settings.type;
};

Expand All @@ -106,7 +113,7 @@ void NavigationController::applyPopToRoot(const PendingPopToRoot &settings) {
break;
}

if (isRootSearch() && settings.clearSearch) clearSearchText();
if (isRootSearch() && settings.clearSearch && !closedRecently) clearSearchText();
}

void NavigationController::setDialog(DialogContentWidget *widget) {
Expand Down Expand Up @@ -312,6 +319,8 @@ QString NavigationController::navigationTitle(const BaseView *caller) const {

void NavigationController::setPopToRootOnClose(bool value) { m_popToRootOnClose = value; }

void NavigationController::setPopToRootOnCloseDelay(int seconds) { m_popToRootOnCloseDelay = seconds; }

void NavigationController::closeWindow(const CloseWindowOptions &settings, std::chrono::milliseconds delay) {
QTimer::singleShot(delay, [this, settings]() { closeWindow(settings); });
}
Expand All @@ -328,6 +337,7 @@ void NavigationController::closeWindow(const CloseWindowOptions &settings) {
}

m_pendingPopToRoot = PendingPopToRoot{.type = type, .clearSearch = settings.clearRootSearch};
m_closedAt.start();
m_windowOpened = false;
emit windowVisiblityChanged(false);
}
Expand Down
4 changes: 4 additions & 0 deletions src/server/src/navigation-controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ui/action-pannel/action-panel-state.hpp"
#include "ui/dialog/dialog.hpp"
#include "ui/image/url.hpp"
#include <QElapsedTimer>
#include <QString>
#include <chrono>
#include <cstdint>
Expand Down Expand Up @@ -144,6 +145,7 @@ class NavigationController : public QObject, NonCopyable {
QWindow *window() const { return m_window; }

void setPopToRootOnClose(bool value);
void setPopToRootOnCloseDelay(int seconds);

bool hasCompleter() const;

Expand Down Expand Up @@ -272,6 +274,8 @@ class NavigationController : public QObject, NonCopyable {
bool m_windowActivated = false;
bool m_isPanelOpened = false;
bool m_popToRootOnClose = false;
int m_popToRootOnCloseDelay = 0; // seconds; > 0 keeps state when reopened within the delay
QElapsedTimer m_closedAt;
bool m_instantDismiss = false;
bool m_closeOnFocusLoss = false;
QWindow *m_window = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/server/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ int startServer(const ServerLaunchOptions &launchOpts) {
}

ctx.navigation->setPopToRootOnClose(next.popToRootOnClose);
ctx.navigation->setPopToRootOnCloseDelay(next.popToRootOnCloseDelay);
ctx.navigation->setCloseOnFocusLoss(next.closeOnFocusLoss);
#ifdef Q_OS_LINUX
ctx.services->inputServer()->setEnabled(next.inputServer.enabled);
Expand Down