2 Copyright (c) 2014-2016 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "storageservicenavigationbuttons.h"
23 #include <KLocalizedString>
25 #include <KStandardShortcut>
29 StorageServiceNavigationButtons::StorageServiceNavigationButtons(QWidget
*parent
)
32 mHome
= addAction(QIcon::fromTheme(QStringLiteral("go-home")), i18n("Home"), this, SIGNAL(goHome()));
34 mGoBack
= new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), i18n("Back"), this);
36 connect(mGoBack
, &QAction::triggered
, this, &StorageServiceNavigationButtons::slotGoBackClicked
);
37 mGoBack
->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Back
));
38 mGoBack
->setEnabled(false);
40 mGoForward
= new QAction(QIcon::fromTheme(QStringLiteral("go-next")), i18n("Forward"), this);
41 mGoForward
->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Forward
));
42 connect(mGoForward
, &QAction::triggered
, this, &StorageServiceNavigationButtons::slotGoForwardClicked
);
43 addAction(mGoForward
);
44 mGoForward
->setEnabled(false);
47 QAction
*StorageServiceNavigationButtons::goBack() const
52 QAction
*StorageServiceNavigationButtons::goForward() const
57 QAction
*StorageServiceNavigationButtons::home() const
62 void StorageServiceNavigationButtons::addNewUrl(const InformationUrl
&info
)
65 mBackUrls
.prepend(info
);
70 void StorageServiceNavigationButtons::addBackUrl(const InformationUrl
&info
)
73 mBackUrls
.prepend(info
);
78 void StorageServiceNavigationButtons::addForwadUrl(const InformationUrl
&info
)
81 mForwardUrls
.prepend(info
);
86 QList
<InformationUrl
> StorageServiceNavigationButtons::backUrls() const
91 void StorageServiceNavigationButtons::setBackUrls(const QList
<InformationUrl
> &value
)
93 if (mBackUrls
!= value
) {
99 QList
<InformationUrl
> StorageServiceNavigationButtons::forwardUrls() const
104 void StorageServiceNavigationButtons::setForwardUrls(const QList
<InformationUrl
> &value
)
106 if (mForwardUrls
!= value
) {
107 mForwardUrls
= value
;
112 void StorageServiceNavigationButtons::clear()
115 mForwardUrls
.clear();
119 void StorageServiceNavigationButtons::updateButtons()
121 mGoForward
->setEnabled(!mForwardUrls
.isEmpty());
122 mGoBack
->setEnabled(!mBackUrls
.isEmpty());
125 void StorageServiceNavigationButtons::slotGoBackClicked()
127 if (!mBackUrls
.isEmpty()) {
128 InformationUrl url
= mBackUrls
.takeFirst();
129 qCDebug(STORAGESERVICEMANAGER_LOG
) << " back clicked" << url
;
130 Q_EMIT
changeUrl(url
);
131 mForwardUrls
.prepend(url
);
136 void StorageServiceNavigationButtons::slotGoForwardClicked()
138 if (!mForwardUrls
.isEmpty()) {
139 InformationUrl url
= mForwardUrls
.takeFirst();
140 qCDebug(STORAGESERVICEMANAGER_LOG
) << " forward clicked" << url
;
141 Q_EMIT
changeUrl(url
);
142 mBackUrls
.prepend(url
);