X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/37327c9b0aae112c5890703cba1f0157043007e0..38c34eeca:/src/dolphinurlnavigator.cpp diff --git a/src/dolphinurlnavigator.cpp b/src/dolphinurlnavigator.cpp index 2b7f3d4eb..ad0a86b77 100644 --- a/src/dolphinurlnavigator.cpp +++ b/src/dolphinurlnavigator.cpp @@ -9,64 +9,55 @@ #include "dolphin_generalsettings.h" #include "dolphinplacesmodelsingleton.h" +#include "dolphinurlnavigatorscontroller.h" #include "global.h" -#include #include +#include #include #include #include -DolphinUrlNavigator::DolphinUrlNavigator(QWidget *parent) : - KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), QUrl(), parent) -{ - init(); -} - -DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent) : - KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url, parent) +DolphinUrlNavigator::DolphinUrlNavigator(QWidget *parent) + : DolphinUrlNavigator(QUrl(), parent) { - init(); } -void DolphinUrlNavigator::init() +DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent) + : KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url, parent) { - const GeneralSettings* settings = GeneralSettings::self(); + const GeneralSettings *settings = GeneralSettings::self(); setUrlEditable(settings->editableUrl()); setShowFullPath(settings->showFullPath()); setHomeUrl(Dolphin::homeUrl()); - setPlacesSelectorVisible(s_placesSelectorVisible); + setPlacesSelectorVisible(DolphinUrlNavigatorsController::placesSelectorVisible()); editor()->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode())); setWhatsThis(xi18nc("@info:whatsthis location bar", - "This describes the location of the files and folders " - "displayed below.The name of the currently viewed " - "folder can be read at the very right. To the left of it is the " - "name of the folder that contains it. The whole line is called " - "the path to the current location because " - "following these folders from left to right leads here." - "This interactive path " - "is more powerful than one would expect. To learn more " - "about the basic and advanced features of the location bar " - "click here. " - "This will open the dedicated page in the Handbook.")); - - s_instances.push_front(this); - - connect(this, &DolphinUrlNavigator::returnPressed, - this, &DolphinUrlNavigator::slotReturnPressed); - connect(editor(), &KUrlComboBox::completionModeChanged, - this, DolphinUrlNavigator::setCompletionMode); + "This describes the location of the files and folders " + "displayed below.The name of the currently viewed " + "folder can be read at the very right. To the left of it is the " + "name of the folder that contains it. The whole line is called " + "the path to the current location because " + "following these folders from left to right leads here." + "This interactive path " + "is more powerful than one would expect. To learn more " + "about the basic and advanced features of the location bar " + "click here. " + "This will open the dedicated page in the Handbook.")); + + DolphinUrlNavigatorsController::registerDolphinUrlNavigator(this); + + connect(this, &KUrlNavigator::returnPressed, this, &DolphinUrlNavigator::slotReturnPressed); } DolphinUrlNavigator::~DolphinUrlNavigator() { - s_instances.remove(this); + DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(this); } QSize DolphinUrlNavigator::sizeHint() const { - // Change sizeHint() in KUrlNavigator instead. if (isUrlEditable()) { return editor()->lineEdit()->sizeHint(); } @@ -94,7 +85,7 @@ std::unique_ptr DolphinUrlNavigator::visualSta return visualState; } -void DolphinUrlNavigator::setVisualState(const VisualState& visualState) +void DolphinUrlNavigator::setVisualState(const VisualState &visualState) { setUrlEditable(visualState.isUrlEditable); if (!visualState.isUrlEditable) { @@ -110,49 +101,19 @@ void DolphinUrlNavigator::setVisualState(const VisualState& visualState) } } -void DolphinUrlNavigator::slotReadSettings() +void DolphinUrlNavigator::clearText() const { - // The startup settings should (only) get applied if they have been - // modified by the user. Otherwise keep the (possibly) different current - // settings of the URL navigators and split view. - if (GeneralSettings::modifiedStartupSettings()) { - for (DolphinUrlNavigator *urlNavigator : s_instances) { - urlNavigator->setUrlEditable(GeneralSettings::editableUrl()); - urlNavigator->setShowFullPath(GeneralSettings::showFullPath()); - urlNavigator->setHomeUrl(Dolphin::homeUrl()); - } - } + editor()->lineEdit()->clear(); } -void DolphinUrlNavigator::slotReturnPressed() +void DolphinUrlNavigator::setPlaceholderText(const QString &text) { - if (!GeneralSettings::editableUrl()) { - setUrlEditable(false); - } + editor()->lineEdit()->setPlaceholderText(text); } -void DolphinUrlNavigator::slotPlacesPanelVisibilityChanged(bool visible) -{ - // The places-selector from the URL navigator should only be shown - // if the places dock is invisible - s_placesSelectorVisible = !visible; - - for (DolphinUrlNavigator *urlNavigator : s_instances) { - urlNavigator->setPlacesSelectorVisible(s_placesSelectorVisible); - } -} - -void DolphinUrlNavigator::setCompletionMode(const KCompletion::CompletionMode completionMode) +void DolphinUrlNavigator::slotReturnPressed() { - if (completionMode != GeneralSettings::urlCompletionMode()) - { - GeneralSettings::setUrlCompletionMode(completionMode); - for (const DolphinUrlNavigator *urlNavigator : s_instances) - { - urlNavigator->editor()->setCompletionMode(completionMode); - } + if (!GeneralSettings::editableUrl()) { + setUrlEditable(false); } } - -std::forward_list DolphinUrlNavigator::s_instances; -bool DolphinUrlNavigator::s_placesSelectorVisible = true;