void Item::Execute (ICoreProxy_ptr proxy) const { auto command = GetCommand (); if (GetType () == Type::Application) { command.remove ("%c"); command.remove ("%f"); command.remove ("%F"); command.remove ("%u"); command.remove ("%U"); command.remove ("%i"); auto items = command.split (' ', QString::SkipEmptyParts); auto removePred = [] (const QString& str) { return str.size () == 2 && str.at (0) == '%'; }; items.erase (std::remove_if (items.begin (), items.end (), removePred), items.end ()); if (items.isEmpty ()) return; QProcess::startDetached (items.at (0), items.mid (1), GetWorkingDirectory ()); } else if (GetType () == Type::URL) { const auto& e = Util::MakeEntity (QUrl (command), QString (), FromUserInitiated | OnlyHandle); proxy->GetEntityManager ()->HandleEntity (e); } else { qWarning () << Q_FUNC_INFO << "don't know how to execute this type of app"; } }
void Plugin::Init (ICoreProxy_ptr proxy) { Util::InstallTranslator ("vrooby"); TrayView_ = new TrayView (proxy); new Util::UnhoverDeleteMixin (TrayView_, SLOT (hide ())); QList<std::shared_ptr<DevBackend>> candidates; #ifdef ENABLE_UDISKS2 candidates << std::make_shared<UDisks2::Backend> (proxy); #endif #ifdef ENABLE_UDISKS candidates << std::make_shared<UDisks::Backend> (proxy); #endif QStringList allBackends; for (const auto& cand : candidates) { allBackends << cand->GetBackendName (); if (cand->IsAvailable ()) { qDebug () << Q_FUNC_INFO << "selecting" << cand->GetBackendName (); Backend_ = cand; break; } } if (!Backend_) { const auto& e = Util::MakeNotification ("Vrooby", tr ("No backends are available, tried the following: %1.") .arg (allBackends.join ("; ")), Priority::Critical); Util::ExecuteLater ([e, proxy] { proxy->GetEntityManager ()->HandleEntity (e); }); } }