@@ -72,23 +72,12 @@ TaskManager::TaskManager(QObject *parent)
7272 , AbstractTaskManagerInterface(nullptr )
7373 , m_windowFullscreen(false )
7474{
75- qRegisterMetaType<ObjectInterfaceMap>();
76- qDBusRegisterMetaType<ObjectInterfaceMap>();
77- qRegisterMetaType<ObjectMap>();
78- qDBusRegisterMetaType<ObjectMap>();
79- qDBusRegisterMetaType<QStringMap>();
80- qRegisterMetaType<QStringMap>();
81- qRegisterMetaType<PropMap>();
82- qDBusRegisterMetaType<PropMap>();
83- qDBusRegisterMetaType<QDBusObjectPath>();
84-
8575 connect (Settings, &TaskManagerSettings::allowedForceQuitChanged, this , &TaskManager::allowedForceQuitChanged);
8676 connect (Settings, &TaskManagerSettings::windowSplitChanged, this , &TaskManager::windowSplitChanged);
8777}
8878
8979bool TaskManager::load ()
9080{
91- loadDockedAppItems ();
9281 auto platformName = QGuiApplication::platformName ();
9382 if (QStringLiteral (" wayland" ) == platformName) {
9483 m_windowMonitor.reset (new TreeLandWindowMonitor ());
@@ -146,9 +135,6 @@ bool TaskManager::init()
146135 m_itemModel = new DockItemModel (m_dockGlobalElementModel, this );
147136 }
148137
149- if (m_windowMonitor)
150- m_windowMonitor->start ();
151-
152138 connect (m_windowMonitor.data (), &AbstractWindowMonitor::windowFullscreenChanged, this , [this ] (bool isFullscreen) {
153139 m_windowFullscreen = isFullscreen;
154140 emit windowFullscreenChanged (isFullscreen);
@@ -161,12 +147,17 @@ bool TaskManager::init()
161147 modifyOpacityChanged ();
162148 connect (appearanceApplet, SIGNAL (opacityChanged ()), this , SLOT (modifyOpacityChanged ()));
163149 }
150+ QTimer::singleShot (500 , [this ]() {
151+ if (m_windowMonitor)
152+ m_windowMonitor->start ();
153+ });
154+
164155 return true ;
165156}
166157
167- ItemModel *TaskManager::dataModel ()
158+ DockItemModel *TaskManager::dataModel () const
168159{
169- return ItemModel::instance () ;
160+ return m_itemModel ;
170161}
171162
172163void TaskManager::requestActivate (const QModelIndex &index) const
@@ -250,25 +241,6 @@ void TaskManager::handleWindowAdded(QPointer<AbstractWindow> window)
250241 ItemModel::instance ()->addItem (appitem);
251242}
252243
253- void TaskManager::clickItem (const QString& itemId, const QString& menuId)
254- {
255- auto item = ItemModel::instance ()->getItemById (itemId);
256- if (!item) return ;
257-
258- if (menuId == DOCK_ACTION_ALLWINDOW) {
259- QList<uint32_t > windowIds;
260- auto windows = item->data ().toStringList ();
261- std::transform (windows.begin (), windows.end (), std::back_inserter (windowIds), [](const QString &windowId) {
262- return windowId.toUInt ();
263- });
264-
265- m_windowMonitor->presentWindows (windowIds);
266- return ;
267- }
268-
269- item->handleClick (menuId);
270- }
271-
272244void TaskManager::dropFilesOnItem (const QString& itemId, const QStringList& urls)
273245{
274246 auto indexes = m_itemModel->match (m_itemModel->index (0 , 0 ), TaskManager::ItemIdRole, itemId, 1 , Qt::MatchExactly);
@@ -284,21 +256,6 @@ void TaskManager::dropFilesOnItem(const QString& itemId, const QStringList& urls
284256 m_itemModel->requestOpenUrls (indexes.first (), urlList);
285257}
286258
287- void TaskManager::showItemPreview (const QString &itemId, QObject *relativePositionItem, int32_t previewXoffset, int32_t previewYoffset, uint32_t direction)
288- {
289- auto item = ItemModel::instance ()->getItemById (itemId).get ();
290- if (!item) {
291- return ;
292- }
293-
294- QPointer<AppItem> pItem = reinterpret_cast <AppItem *>(item);
295- if (pItem.isNull ()) {
296- return ;
297- }
298-
299- m_windowMonitor->showItemPreview (pItem, relativePositionItem, previewXoffset, previewYoffset, direction);
300- }
301-
302259void TaskManager::hideItemPreview ()
303260{
304261 m_windowMonitor->hideItemPreview ();
@@ -314,30 +271,6 @@ void TaskManager::setAppItemWindowIconGeometry(const QString& appid, QObject* re
314271 }
315272}
316273
317- void TaskManager::loadDockedAppItems ()
318- {
319- // TODO: remove this function once migrated to DockItemModel (when dataModel() returns m_itemModel instead of ItemModel::instance())
320- for (const auto &apps : TaskManagerSettings::instance ()->dockedElements ()) {
321- // app names in dockedElements are in format of "desktop/<appid>"
322- auto appid = apps.split (' /' ).last ();
323- auto desktopfile = DESKTOPFILEFACTORY::createById (appid, " amAPP" );
324- auto valid = desktopfile->isValied ();
325-
326- if (!valid.first ) {
327- qInfo (taskManagerLog ()) << " failed to load " << appid << " beacause " << valid.second ;
328- continue ;
329- }
330-
331- auto appitem = desktopfile->getAppItem ();
332- if (appitem.isNull ()) {
333- appitem = new AppItem (appid);
334- }
335-
336- appitem->setDesktopFileParser (desktopfile);
337- ItemModel::instance ()->addItem (appitem);
338- }
339- }
340-
341274bool TaskManager::allowForceQuit ()
342275{
343276 return Settings->isAllowedForceQuit ();
0 commit comments