]>
cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinurlnavigatorwidgetaction.cpp
2 * Copyright 2020 Felix Ernst <fe.a.ernst@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <https://www.gnu.org/licenses/>.
21 #include "dolphinurlnavigatorwidgetaction.h"
23 #include "dolphin_generalsettings.h"
24 #include "dolphinviewcontainer.h"
26 #include <KLocalizedString>
28 DolphinUrlNavigatorWidgetAction::DolphinUrlNavigatorWidgetAction(QWidget
*parent
) :
31 setText(i18nc("@action:inmenu", "Url navigator"));
33 m_stackedWidget
= new QStackedWidget(parent
);
35 auto expandingSpacer
= new QWidget(m_stackedWidget
);
36 expandingSpacer
->setSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::MinimumExpanding
);
37 m_stackedWidget
->addWidget(expandingSpacer
); // index 0 of QStackedWidget
39 auto urlNavigator
= new DolphinUrlNavigator(m_stackedWidget
);
40 m_stackedWidget
->addWidget(urlNavigator
); // index 1 of QStackedWidget
42 setDefaultWidget(m_stackedWidget
);
43 setUrlNavigatorVisible(GeneralSettings::locationInToolbar());
46 DolphinUrlNavigator
* DolphinUrlNavigatorWidgetAction::urlNavigator() const
48 return static_cast<DolphinUrlNavigator
*>(m_stackedWidget
->widget(1));
51 void DolphinUrlNavigatorWidgetAction::setUrlNavigatorVisible(bool visible
)
54 m_stackedWidget
->setCurrentIndex(0); // expandingSpacer
56 m_stackedWidget
->setCurrentIndex(1); // urlNavigator