┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinurlnavigator.h
diff options
context:
space:
mode:
authorElvis Angelaccio <[email protected]>2020-11-10 00:05:27 +0100
committerElvis Angelaccio <[email protected]>2020-11-10 00:05:27 +0100
commit6719072837f30c1822768da65e6ea222e987e32f (patch)
treeb61a3c588561946e9d462e23379d44fbdeed185b /src/dolphinurlnavigator.h
parente5d137b81debbbfe51c18d16d361fd28a3448416 (diff)
parent63f4981fe01d88b2ef1b27e0577d7f5d4c8cc485 (diff)
Merge branch 'release/20.12'
Diffstat (limited to 'src/dolphinurlnavigator.h')
-rw-r--r--src/dolphinurlnavigator.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/dolphinurlnavigator.h b/src/dolphinurlnavigator.h
new file mode 100644
index 000000000..9bcc32b4d
--- /dev/null
+++ b/src/dolphinurlnavigator.h
@@ -0,0 +1,77 @@
+/*
+ This file is part of the KDE project
+ SPDX-FileCopyrightText: 2020 Felix Ernst <[email protected]>
+
+ SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
+*/
+
+#ifndef DOLPHINURLNAVIGATOR_H
+#define DOLPHINURLNAVIGATOR_H
+
+#include <KUrlNavigator>
+
+/**
+ * @brief Extends KUrlNavigator in a Dolphin-specific way.
+ *
+ * Makes sure that Dolphin preferences and settings are
+ * applied to all constructed DolphinUrlNavigators.
+ * @see KUrlNavigator
+ *
+ * To apply changes to all instances of this class @see DolphinUrlNavigatorsController.
+ */
+class DolphinUrlNavigator : public KUrlNavigator
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Applies all Dolphin-specific settings to a KUrlNavigator
+ * @see KUrlNavigator::KurlNavigator()
+ */
+ DolphinUrlNavigator(QWidget *parent = nullptr);
+
+ /**
+ * Applies all Dolphin-specific settings to a KUrlNavigator
+ * @see KUrlNavigator::KurlNavigator()
+ */
+ DolphinUrlNavigator(const QUrl &url, QWidget *parent = nullptr);
+
+ virtual ~DolphinUrlNavigator();
+
+ // TODO: Fix KUrlNavigator::sizeHint() instead.
+ QSize sizeHint() const override;
+
+ /**
+ * Wraps the visual state of a DolphinUrlNavigator so it can be passed around.
+ * This notably doesn't involve the locationUrl or history.
+ */
+ struct VisualState {
+ bool isUrlEditable;
+ bool hasFocus;
+ QString text;
+ int cursorPosition;
+ int selectionStart;
+ int selectionLength;
+ };
+ /**
+ * Retrieve the visual state of this DolphinUrlNavigator.
+ * If two DolphinUrlNavigators have the same visual state they should look identical.
+ *
+ * @return a copy of the visualState of this object. Ownership of this copy is transferred
+ * to the caller via std::unique_ptr.
+ */
+ std::unique_ptr<VisualState> visualState() const;
+ /**
+ * @param visualState A struct describing the new visual state of this object.
+ */
+ void setVisualState(const VisualState &visualState);
+
+public slots:
+ /**
+ * Switches to "breadcrumb" mode if the editable mode is not set to be
+ * preferred in the Dolphin settings.
+ */
+ void slotReturnPressed();
+};
+
+#endif // DOLPHINURLNAVIGATOR_H