correct action input field
This commit is contained in:
parent
01f041b3ef
commit
35748e1f1e
@ -37,10 +37,11 @@
|
|||||||
|
|
||||||
|
|
||||||
CurrentContainmentActionsModel::CurrentContainmentActionsModel(Plasma::Containment *cotainment, QObject *parent)
|
CurrentContainmentActionsModel::CurrentContainmentActionsModel(Plasma::Containment *cotainment, QObject *parent)
|
||||||
: QStandardItemModel(parent)
|
: QStandardItemModel(parent),
|
||||||
|
m_containment(cotainment)
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roleNames;
|
QHash<int, QByteArray> roleNames;
|
||||||
roleNames[NameRole] = "name";
|
roleNames[ActionRole] = "action";
|
||||||
roleNames[PluginRole] = "plugin";
|
roleNames[PluginRole] = "plugin";
|
||||||
|
|
||||||
setRoleNames(roleNames);
|
setRoleNames(roleNames);
|
||||||
@ -52,7 +53,7 @@ CurrentContainmentActionsModel::CurrentContainmentActionsModel(Plasma::Containme
|
|||||||
i.next();
|
i.next();
|
||||||
|
|
||||||
QStandardItem *item = new QStandardItem();
|
QStandardItem *item = new QStandardItem();
|
||||||
item->setData(i.key(), NameRole);
|
item->setData(i.key(), ActionRole);
|
||||||
item->setData(i.value()->pluginInfo().pluginName(), PluginRole);
|
item->setData(i.value()->pluginInfo().pluginName(), PluginRole);
|
||||||
appendRow(item);
|
appendRow(item);
|
||||||
}
|
}
|
||||||
@ -62,12 +63,39 @@ CurrentContainmentActionsModel::~CurrentContainmentActionsModel()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentContainmentActionsModel::append(const QString &action, const QString &plugin)
|
QString CurrentContainmentActionsModel::mouseEventString(int mouseButton, int modifiers)
|
||||||
{
|
{
|
||||||
|
QMouseEvent *mouse = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(), (Qt::MouseButton)mouseButton, (Qt::MouseButton)mouseButton, (Qt::KeyboardModifiers) modifiers);
|
||||||
|
|
||||||
|
QString string = Plasma::ContainmentActions::eventToString(mouse);
|
||||||
|
|
||||||
|
delete mouse;
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CurrentContainmentActionsModel::wheelEventString(const QPointF &delta, int mouseButtons, int modifiers)
|
||||||
|
{
|
||||||
|
QWheelEvent *wheel = new QWheelEvent(QPointF(), QPointF(), delta.toPoint(), QPoint(), 0, Qt::Vertical, (Qt::MouseButtons)mouseButtons, (Qt::KeyboardModifiers) modifiers);
|
||||||
|
|
||||||
|
QString string = Plasma::ContainmentActions::eventToString(wheel);
|
||||||
|
|
||||||
|
delete wheel;
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CurrentContainmentActionsModel::append(const QString &action, const QString &plugin)
|
||||||
|
{
|
||||||
|
if (!match(index(0,0), ActionRole, action).isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QStandardItem *item = new QStandardItem();
|
QStandardItem *item = new QStandardItem();
|
||||||
item->setData(action, NameRole);
|
item->setData(action, ActionRole);
|
||||||
item->setData(plugin, PluginRole);
|
item->setData(plugin, PluginRole);
|
||||||
appendRow(item);
|
appendRow(item);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentContainmentActionsModel::update(int row, const QString &action, const QString &plugin)
|
void CurrentContainmentActionsModel::update(int row, const QString &action, const QString &plugin)
|
||||||
@ -75,7 +103,7 @@ void CurrentContainmentActionsModel::update(int row, const QString &action, cons
|
|||||||
QModelIndex idx = index(row, 0);
|
QModelIndex idx = index(row, 0);
|
||||||
|
|
||||||
if (idx.isValid()) {
|
if (idx.isValid()) {
|
||||||
setData(idx, action, NameRole);
|
setData(idx, action, ActionRole);
|
||||||
setData(idx, plugin, PluginRole);
|
setData(idx, plugin, PluginRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,17 +35,22 @@ class CurrentContainmentActionsModel : public QStandardItemModel
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
NameRole = Qt::UserRole+1,
|
ActionRole = Qt::UserRole+1,
|
||||||
PluginRole
|
PluginRole
|
||||||
};
|
};
|
||||||
|
|
||||||
CurrentContainmentActionsModel(Plasma::Containment *cotainment, QObject *parent = 0);
|
CurrentContainmentActionsModel(Plasma::Containment *cotainment, QObject *parent = 0);
|
||||||
~CurrentContainmentActionsModel();
|
~CurrentContainmentActionsModel();
|
||||||
|
|
||||||
Q_INVOKABLE void append(const QString &action, const QString &plugin);
|
Q_INVOKABLE QString mouseEventString(int mouseButtons, int modifiers);
|
||||||
|
Q_INVOKABLE QString wheelEventString(const QPointF &delta, int mouseButtons, int modifiers);
|
||||||
|
Q_INVOKABLE bool append(const QString &action, const QString &plugin);
|
||||||
Q_INVOKABLE void update(int row, const QString &action, const QString &plugin);
|
Q_INVOKABLE void update(int row, const QString &action, const QString &plugin);
|
||||||
Q_INVOKABLE void remove(int row);
|
Q_INVOKABLE void remove(int row);
|
||||||
Q_INVOKABLE void save();
|
Q_INVOKABLE void save();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Plasma::Containment *m_containment;
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO: is it possible to move this in the shell?
|
//TODO: is it possible to move this in the shell?
|
||||||
|
@ -20,6 +20,7 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 1.0 as QtControls
|
import QtQuick.Controls 1.0 as QtControls
|
||||||
import QtQuick.Layouts 1.0
|
import QtQuick.Layouts 1.0
|
||||||
|
|
||||||
|
import org.kde.qtextracomponents 2.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
@ -37,9 +38,9 @@ Item {
|
|||||||
Repeater {
|
Repeater {
|
||||||
model: configDialog.currentContainmentActionsModel
|
model: configDialog.currentContainmentActionsModel
|
||||||
delegate: RowLayout {
|
delegate: RowLayout {
|
||||||
width: root.width * 0.8
|
width: root.width
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
text: "Middle Button"
|
text: model.action
|
||||||
}
|
}
|
||||||
QtControls.ComboBox {
|
QtControls.ComboBox {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -64,9 +65,36 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
text: "Add Action"
|
id: mouseInputButton
|
||||||
|
text: i18n("Add Action")
|
||||||
|
checkable: true
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked) {
|
||||||
|
text = i18n("Input Here");
|
||||||
|
mouseInputArea.enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: mouseInputArea
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.AllButtons
|
||||||
|
enabled: false
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
configDialog.currentContainmentActionsModel.append("RightButton;NoModifier", "org.kde.contextmenu");
|
if (configDialog.currentContainmentActionsModel.append(configDialog.currentContainmentActionsModel.mouseEventString(mouse.button, mouse.modifiers), "org.kde.contextmenu")) {
|
||||||
|
mouseInputButton.text = i18n("Add Action");
|
||||||
|
mouseInputButton.checked = false;
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onWheel: {
|
||||||
|
if (configDialog.currentContainmentActionsModel.append(configDialog.currentContainmentActionsModel.wheelEventString(wheel.pixelDelta, wheel.buttons, wheel.modifiers), "org.kde.contextmenu")) {
|
||||||
|
mouseInputButton.text = i18n("Add Action");
|
||||||
|
mouseInputButton.checked = false;
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user