1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/*
* This file is part of the KDE project
* Copyright (c) 2013 Sascha Suelzer <s.suelzer@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* * Boston, MA 02110-1301, USA.
* */
#ifndef KORESOURCEITEMCHOOSERCONTEXTMENU_H
#define KORESOURCEITEMCHOOSERCONTEXTMENU_H
#include <QMenu>
#include <QWidgetAction>
#include <QLabel>
class KLineEdit;
class KoResource;
class ContextMenuExistingTagAction : public QAction
{
Q_OBJECT
public:
explicit ContextMenuExistingTagAction( KoResource * resource, const QString &tag, QObject* parent = 0);
~ContextMenuExistingTagAction() override = default;
Q_SIGNALS:
void triggered(KoResource * resource, const QString &tag);
protected Q_SLOTS:
void onTriggered();
private:
KoResource * m_resource;
QString m_tag;
};
/*!
* A line edit QWidgetAction.
* Default behavior: Closes its parent upon triggering.
*/
class KoLineEditAction : public QWidgetAction
{
Q_OBJECT
public:
explicit KoLineEditAction(QObject* parent);
~KoLineEditAction() override = default;
void setIcon(const QIcon &icon);
void closeParentOnTrigger(bool closeParent);
bool closeParentOnTrigger();
void setPlaceholderText(const QString& clickMessage);
void setText(const QString& text);
void setVisible(bool showAction);
Q_SIGNALS:
void triggered(const QString &tag);
protected Q_SLOTS:
void onTriggered(const QString& text);
private:
bool m_closeParentOnTrigger;
QLabel * m_label;
KLineEdit * m_editBox;
};
class NewTagAction : public KoLineEditAction
{
Q_OBJECT
public:
explicit NewTagAction (KoResource* resource, QMenu* parent);
~NewTagAction() override = default;
Q_SIGNALS:
void triggered(KoResource * resource, const QString &tag);
protected Q_SLOTS:
void onTriggered(const QString& tagName);
private:
KoResource * m_resource;
};
class KoResourceItemChooserContextMenu : public QMenu
{
Q_OBJECT
public:
explicit KoResourceItemChooserContextMenu
(
KoResource* resource,
const QStringList& resourceTags,
const QString& currentlySelectedTag,
const QStringList& allTags
);
~KoResourceItemChooserContextMenu() override = default;
Q_SIGNALS:
/// Emitted when a resource should be added to an existing tag.
void resourceTagAdditionRequested(KoResource* resource, const QString& tag);
/// Emitted when a resource should be removed from an existing tag.
void resourceTagRemovalRequested(KoResource* resource, const QString& tag);
/// Emitted when a resource should be added to a new tag, which will need to be created.
void resourceAssignmentToNewTagRequested(KoResource* resource, const QString& tag);
};
#endif // KORESOURCEITEMCHOOSERCONTEXTMENU_H
|