mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
libs: slightly better drag source detection in Plasma::AppletIcon::mouseMoveEvent()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
700e6d1794
commit
ae63a4b4cb
1 changed files with 19 additions and 3 deletions
|
@ -50,7 +50,7 @@ static const int s_appletactiveiconsize = 22;
|
||||||
// kdelibs/plasma/corona.cpp
|
// kdelibs/plasma/corona.cpp
|
||||||
static const QString s_coronamimetype = QString::fromLatin1("text/x-plasmoidservicename");
|
static const QString s_coronamimetype = QString::fromLatin1("text/x-plasmoidservicename");
|
||||||
|
|
||||||
Qt::Orientation kOrientationForLocation(const Plasma::Location location)
|
static Qt::Orientation kOrientationForLocation(const Plasma::Location location)
|
||||||
{
|
{
|
||||||
switch (location) {
|
switch (location) {
|
||||||
case Plasma::Location::LeftEdge:
|
case Plasma::Location::LeftEdge:
|
||||||
|
@ -64,6 +64,22 @@ Qt::Orientation kOrientationForLocation(const Plasma::Location location)
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// similar to Plasma::Applet::view(), the important thing is to get a window (preferably active
|
||||||
|
// one)
|
||||||
|
static QGraphicsView* kSceneWindow(QGraphicsScene *scene)
|
||||||
|
{
|
||||||
|
if (!scene) {
|
||||||
|
kWarning() << "No AppletIcon scene";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
foreach (QGraphicsView *view, scene->views()) {
|
||||||
|
if (view->isActiveWindow()) {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
class AppletIcon : public Plasma::IconWidget
|
class AppletIcon : public Plasma::IconWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -97,8 +113,8 @@ void AppletIcon::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->buttons() & Qt::LeftButton &&
|
if (event->buttons() & Qt::LeftButton &&
|
||||||
(event->pos() - m_dragstartpos).manhattanLength() > KGlobalSettings::dndEventDelay())
|
(event->pos() - m_dragstartpos).manhattanLength() > KGlobalSettings::dndEventDelay())
|
||||||
{
|
{
|
||||||
// have to parent it to QWidget*..
|
QGraphicsView* sceneview = kSceneWindow(scene());
|
||||||
QDrag* drag = new QDrag(qApp->activeWindow());
|
QDrag* drag = new QDrag(sceneview ? sceneview : qApp->activeWindow());
|
||||||
QMimeData* mimedata = new QMimeData();
|
QMimeData* mimedata = new QMimeData();
|
||||||
mimedata->setData(s_coronamimetype, m_appletinfo.pluginName().toUtf8());
|
mimedata->setData(s_coronamimetype, m_appletinfo.pluginName().toUtf8());
|
||||||
drag->setMimeData(mimedata);
|
drag->setMimeData(mimedata);
|
||||||
|
|
Loading…
Add table
Reference in a new issue