[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:14:14 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=b29f0da
The following commit has been merged in the master branch:
commit b29f0daf9b94b20acd44e112ac366eef3d9476b4
Author: Othmane Moustaouda <othmane.moustaouda at gmail.com>
Date: Thu Mar 29 16:53:42 2012 +0100
Add missing files from last commit.
---
config/nowplaying-lineedit.cpp | 77 +++++++++++++++++
.../nowplaying-lineedit.h | 43 ++++------
config/nowplaying-listwidget.cpp | 98 ++++++++++++++++++++++
autoaway.h => config/nowplaying-listwidget.h | 50 +++++------
4 files changed, 213 insertions(+), 55 deletions(-)
diff --git a/config/nowplaying-lineedit.cpp b/config/nowplaying-lineedit.cpp
new file mode 100644
index 0000000..9008964
--- /dev/null
+++ b/config/nowplaying-lineedit.cpp
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "nowplaying-lineedit.h"
+
+#include <QtGui>
+
+NowPlayingLineEdit::NowPlayingLineEdit(QWidget *parent)
+: QLineEdit(parent)
+{
+
+}
+
+NowPlayingLineEdit::~NowPlayingLineEdit()
+{
+
+}
+
+void NowPlayingLineEdit::setLocalizedTagNames(QStringList tagNames)
+{
+ m_localizedTagNames = tagNames;
+}
+
+void NowPlayingLineEdit::dropEvent(QDropEvent *event)
+{
+ const QMimeData *content = event->mimeData();
+
+ //adapt the dropped text and insert it at current cursor position
+ if (content->hasText()) {
+ QString text = content->text();
+ text = text.toLower();
+ text = text.insert(0, QLatin1Char('%'));
+ insert(text);
+
+ setFocus();
+ event->accept();
+ } else
+ event->ignore();
+}
+
+void NowPlayingLineEdit::mousePressEvent(QMouseEvent *event)
+{
+ //small usability improvement:
+ //if we detect that the click is inside a tag name then that tag will be auto selected
+ if (event->button() == Qt::LeftButton) {
+ int currentCursorPosition = cursorPositionAt(event->pos());
+
+ Q_FOREACH (const QString tag, m_localizedTagNames) {
+ if(text().contains(tag)
+ && currentCursorPosition >= text().indexOf(tag) //cursor must be inside tag's bounds
+ && currentCursorPosition <= text().indexOf(tag) + tag.size()) {
+
+ setSelection(text().indexOf(tag), tag.size());
+ break;
+ }
+ else {
+ //since we are intercepting mouse events, setting manually the cursor's position is needed
+ setCursorPosition(currentCursorPosition);
+ }
+ }
+ }
+}
diff --git a/telepathy-kded-module-plugin.cpp b/config/nowplaying-lineedit.h
similarity index 51%
copy from telepathy-kded-module-plugin.cpp
copy to config/nowplaying-lineedit.h
index 418e96a..ef0d63e 100644
--- a/telepathy-kded-module-plugin.cpp
+++ b/config/nowplaying-lineedit.h
@@ -1,6 +1,5 @@
/*
- Parent class for Telepathy KDED Plugins
- Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,33 +17,27 @@
*/
-#include "telepathy-kded-module-plugin.h"
+#ifndef NOWPLAYING_LINEEDIT_H
+#define NOWPLAYING_LINEEDIT_H
-#include <KTp/global-presence.h>
+#include <QLineEdit>
-TelepathyKDEDModulePlugin::TelepathyKDEDModulePlugin(KTp::GlobalPresence* globalPresence, QObject* parent)
- : QObject(parent),
- m_enabled(false),
- m_pluginPriority(50)
+class NowPlayingLineEdit : public QLineEdit
{
- m_globalPresence = globalPresence;
-}
+ Q_OBJECT
-TelepathyKDEDModulePlugin::~TelepathyKDEDModulePlugin()
-{
-}
+public:
+ NowPlayingLineEdit(QWidget *parent = 0);
+ virtual ~NowPlayingLineEdit();
-void TelepathyKDEDModulePlugin::setEnabled(bool enabled)
-{
- m_enabled = enabled;
+ void setLocalizedTagNames(QStringList tagNames);
- if(!enabled) {
- setActive(false);
- }
-}
+protected:
+ void dropEvent(QDropEvent *event);
+ void mousePressEvent(QMouseEvent *event);
-void TelepathyKDEDModulePlugin::setActive(bool active)
-{
- m_active = active;
- Q_EMIT activate(active);
-}
+private:
+ QStringList m_localizedTagNames;
+};
+
+#endif // NOWPLAYING_LINEEDIT_H
diff --git a/config/nowplaying-listwidget.cpp b/config/nowplaying-listwidget.cpp
new file mode 100644
index 0000000..0262f48
--- /dev/null
+++ b/config/nowplaying-listwidget.cpp
@@ -0,0 +1,98 @@
+/*
+ Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "nowplaying-listwidget.h"
+
+#include <KIcon>
+#include <KIconLoader>
+
+NowPlayingListWidget::NowPlayingListWidget(QWidget *parent)
+: QListWidget(parent)
+{
+ setFlow(QListWidget::LeftToRight);
+ setDragEnabled(true);
+}
+
+NowPlayingListWidget::~NowPlayingListWidget()
+{
+
+}
+
+void NowPlayingListWidget::setLocalizedTagNames(QStringList tagNames)
+{
+ m_localizedTagNames = tagNames;
+}
+
+void NowPlayingListWidget::setItemsIcons(QStringList itemsIcons)
+{
+ m_itemsIcons = itemsIcons;
+}
+
+void NowPlayingListWidget::setupItems()
+{
+ QString tagName;
+ QFontMetrics *fontMetrics = new QFontMetrics(font()); //needed to calculate total width
+ int totalWidth = 0;
+
+ //items adding order is based on that in config/telepathy-kded-config.cpp
+ for (int i = 0; i < m_localizedTagNames.size(); i++) {
+ tagName = m_localizedTagNames.at(i);
+ tagName = tagName.right(tagName.size() - 1); //cut the '%' character
+ tagName = tagName.left(1).toUpper() + tagName.mid(1); //capitalize tag name
+
+ QListWidgetItem *newItem = new QListWidgetItem(KIcon(m_itemsIcons.at(i)), tagName);
+ addItem(newItem);
+
+ //+8 because we are considering also spaces between icons and items
+ totalWidth += fontMetrics->boundingRect(tagName).width() + KIconLoader::SizeSmallMedium + 8;
+ }
+
+ setMaximumWidth(totalWidth);
+ setMaximumHeight(size().height());
+}
+
+void NowPlayingListWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->accept();
+}
+
+void NowPlayingListWidget::dragMoveEvent(QDragMoveEvent *event)
+{
+ event->accept();
+}
+
+void NowPlayingListWidget::mousePressEvent(QMouseEvent *event)
+{
+ //after checking if we are in presence of a drag operation, we can then encapsulate
+ //the data to be sent and let start the drag operation
+ if (event->button() == Qt::LeftButton && itemAt(event->pos())) {
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData();
+
+ mimeData->setText(itemAt(event->pos())->text()); //who receives expects plain text data
+ drag->setMimeData(mimeData);
+ drag->exec();
+ }
+}
+
+QStringList NowPlayingListWidget::mimeTypes() const
+{
+ QStringList types;
+ types << QLatin1String("text/plain");
+ return types;
+}
diff --git a/autoaway.h b/config/nowplaying-listwidget.h
similarity index 51%
copy from autoaway.h
copy to config/nowplaying-listwidget.h
index 8691a4f..c1ee70e 100644
--- a/autoaway.h
+++ b/config/nowplaying-listwidget.h
@@ -1,6 +1,5 @@
/*
- Auto away-presence setter-class
- Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,42 +17,33 @@
*/
-#ifndef AUTOAWAY_H
-#define AUTOAWAY_H
+#ifndef NOWPLAYING_LISTWIDGET_H
+#define NOWPLAYING_LISTWIDGET_H
-#include "telepathy-kded-module-plugin.h"
+#include <QListWidget>
+#include <QDragEnterEvent>
-#include <TelepathyQt/Presence>
-#include <TelepathyQt/AccountManager>
-
-namespace KTp {
-class GlobalPresence;
-}
-
-class AutoAway : public TelepathyKDEDModulePlugin
+class NowPlayingListWidget : public QListWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- AutoAway(KTp::GlobalPresence *globalPresence, QObject* parent = 0);
- ~AutoAway();
+ NowPlayingListWidget(QWidget *parent = 0);
+ virtual ~NowPlayingListWidget();
- void readConfig();
- QString pluginName() const;
+ void setLocalizedTagNames(QStringList tagNames);
+ void setItemsIcons(QStringList itemsIcons);
+ void setupItems();
-public Q_SLOTS:
- void onSettingsChanged();
-
-private Q_SLOTS:
- void timeoutReached(int);
- void backFromIdle();
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dragMoveEvent(QDragMoveEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ QStringList mimeTypes() const;
private:
- int m_awayTimeoutId;
- int m_extAwayTimeoutId;
-
- QString m_awayMessage;
- QString m_xaMessage;
+ QStringList m_localizedTagNames;
+ QStringList m_itemsIcons;
};
-#endif // AUTOAWAY_H
+#endif // NOWPLAYING_LISTWIDGET_H
--
ktp-kded-integration-module packaging
More information about the pkg-kde-commits
mailing list