File indexing completed on 2024-03-24 05:51:23
0001 /*********************************************************************** 0002 * SPDX-FileCopyrightText: 2003-2004 Max Howell <max.howell@methylblue.com> 0003 * SPDX-FileCopyrightText: 2008-2014 Martin Sandsmark <martin.sandsmark@kde.org> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 ***********************************************************************/ 0007 0008 #pragma once 0009 0010 #include <QAction> 0011 #include <QUrl> 0012 0013 class KConfigGroup; 0014 class KActionCollection; 0015 0016 class HistoryAction : QAction 0017 { 0018 Q_OBJECT 0019 0020 HistoryAction(const QIcon &icon, const QString &text, KActionCollection *ac); 0021 0022 friend class HistoryCollection; 0023 0024 public: 0025 virtual void setEnabled(bool b = true) 0026 { 0027 QAction::setEnabled(b && !m_list.isEmpty()); 0028 } 0029 0030 void clear() 0031 { 0032 m_list.clear(); 0033 setEnabled(false); 0034 QAction::setText(m_text); 0035 } 0036 0037 private: 0038 void setHelpText(const QUrl &url); 0039 0040 void push(const QUrl &url); 0041 QUrl pop(); 0042 0043 const QString m_text; 0044 QList<QUrl> m_list; 0045 }; 0046 0047 class HistoryCollection : public QObject 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 HistoryCollection(KActionCollection *ac, QObject *parent); 0053 0054 void save(KConfigGroup &configgroup); 0055 void restore(const KConfigGroup &configgroup); 0056 0057 public Q_SLOTS: 0058 void push(const QUrl &url); 0059 void stop() 0060 { 0061 m_receiver = nullptr; 0062 } 0063 0064 Q_SIGNALS: 0065 void activated(const QUrl &); 0066 0067 private Q_SLOTS: 0068 void pop(); 0069 0070 private: 0071 HistoryAction *m_b, *m_f, *m_receiver; 0072 };