plasma: implement drag for favorites in launcher applet

piece of cake with the custom widget class

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-19 09:00:27 +03:00
parent 6bdd5f3d39
commit 07e7d318a7

View file

@ -770,13 +770,13 @@ void LauncherFavorites::slotUpdateLayout()
bookmark = bookmarkgroup.next(bookmark); bookmark = bookmarkgroup.next(bookmark);
continue; continue;
} }
const QString serviceentrypath = bookmark.url().url(); const QString bookmarkentrypath = bookmark.url().url();
KService::Ptr service = KService::serviceByDesktopPath(serviceentrypath); KService::Ptr service = KService::serviceByDesktopPath(bookmarkentrypath);
if (service.isNull()) { if (service.isNull()) {
service = KService::serviceByDesktopName(bookmark.text()); service = KService::serviceByDesktopName(bookmark.text());
} }
if (service.isNull()) { if (service.isNull()) {
kWarning() << "could not find service for" << serviceentrypath; kWarning() << "could not find service for" << bookmarkentrypath;
bookmark = bookmarkgroup.next(bookmark); bookmark = bookmarkgroup.next(bookmark);
continue; continue;
} }
@ -784,17 +784,19 @@ void LauncherFavorites::slotUpdateLayout()
launcherwidget->setup( launcherwidget->setup(
iconsize, kFavoriteIcon(service->icon()), service->name(), service->genericName() iconsize, kFavoriteIcon(service->icon()), service->name(), service->genericName()
); );
launcherwidget->setData(service->entryPath()); const QString entrypath = service->entryPath();
launcherwidget->setData(entrypath);
QAction* favoriteaction = new QAction(launcherwidget); QAction* favoriteaction = new QAction(launcherwidget);
favoriteaction->setIcon(KIcon("edit-delete")); favoriteaction->setIcon(KIcon("edit-delete"));
favoriteaction->setToolTip(i18n("Remove")); favoriteaction->setToolTip(i18n("Remove"));
favoriteaction->setProperty("_k_id", serviceentrypath); favoriteaction->setProperty("_k_id", bookmarkentrypath);
connect( connect(
favoriteaction, SIGNAL(triggered()), favoriteaction, SIGNAL(triggered()),
this, SLOT(slotTriggered()), this, SLOT(slotTriggered()),
Qt::QueuedConnection Qt::QueuedConnection
); );
launcherwidget->addAction(favoriteaction); launcherwidget->addAction(favoriteaction);
launcherwidget->setMimeData(kMakeMimeData(entrypath));
m_launcherwidgets.append(launcherwidget); m_launcherwidgets.append(launcherwidget);
m_layout->addItem(launcherwidget); m_layout->addItem(launcherwidget);
connect( connect(