Merge branch 'Plasma/5.13'

wilder-5.14
Kai Uwe Broulik 8 years ago
commit 5587e4e0a7
  1. 1
      CMakeLists.txt
  2. 70
      runners/places/placesrunner.cpp
  3. 5
      runners/places/placesrunner.h
  4. 2
      templates/ion-dataengine/src/ion-%{APPNAMELC}.desktop

@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.0)
project(plasma-workspace)
set(PROJECT_VERSION "5.13.80")
set(PROJECT_VERSION_MAJOR 5)

@ -74,6 +74,13 @@ PlacesRunnerHelper::PlacesRunnerHelper(PlacesRunner *runner)
connect(runner, &PlacesRunner::doMatch,
this, &PlacesRunnerHelper::match,
Qt::BlockingQueuedConnection);
connect(&m_places, &KFilePlacesModel::setupDone, this, [this](const QModelIndex &index, bool success) {
if (success && m_pendingUdi == m_places.deviceForIndex(index).udi()) {
new KRun(m_places.url(index), nullptr);
}
m_pendingUdi.clear();
});
}
void PlacesRunnerHelper::match(Plasma::RunnerContext *c)
@ -112,16 +119,24 @@ void PlacesRunnerHelper::match(Plasma::RunnerContext *c)
match.setIcon(m_places.icon(current_index));
match.setText(text);
// Add category as subtext so one can tell "Pictures" folder from "Search for Pictures"
// Don't add it if it would match the category ("Places") of the runner to avoid "Places: Pictures (Places)"
const QString groupName = m_places.data(current_index, KFilePlacesModel::GroupRole).toString();
if (!groupName.isEmpty() && !static_cast<PlacesRunner *>(parent())->categories().contains(groupName)) {
match.setSubtext(groupName);
}
//if we have to mount it set the device udi instead of the URL, as we can't open it directly
QUrl url;
if (m_places.isDevice(current_index) && m_places.setupNeeded(current_index)) {
url = QUrl(m_places.deviceForIndex(current_index).udi());
const QString udi = m_places.deviceForIndex(current_index).udi();
match.setId(udi);
match.setData(udi);
} else {
url = m_places.url(current_index);
const QUrl url = KFilePlacesModel::convertedUrl(m_places.url(current_index));
match.setData(url);
match.setId(url.toDisplayString());
}
match.setData(url);
match.setId(url.toDisplayString());
matches << match;
}
}
@ -129,6 +144,19 @@ void PlacesRunnerHelper::match(Plasma::RunnerContext *c)
context.addMatches(matches);
}
void PlacesRunnerHelper::openDevice(const QString &udi)
{
m_pendingUdi.clear();
for (int i = 0; i < m_places.rowCount(); ++i) {
const QModelIndex idx = m_places.index(i, 0);
if (m_places.isDevice(idx) && m_places.deviceForIndex(idx).udi() == udi) {
m_pendingUdi = udi;
m_places.requestSetup(idx);
break;
}
}
}
void PlacesRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action)
{
@ -137,26 +165,7 @@ void PlacesRunner::run(const Plasma::RunnerContext &context, const Plasma::Query
if (action.data().type() == QVariant::Url) {
new KRun(action.data().toUrl(), nullptr);
} else if (action.data().canConvert<QString>()) {
//search our list for the device with the same udi, then set it up (mount it).
QString deviceUdi = action.data().toString();
// gets deleted in setupComplete
KFilePlacesModel *places = new KFilePlacesModel(this);
connect(places, SIGNAL(setupDone(QModelIndex,bool)), SLOT(setupComplete(QModelIndex,bool)));
bool found = false;
for (int i = 0; i <= places->rowCount();i++) {
QModelIndex current_index = places->index(i, 0);
if (places->isDevice(current_index) && places->deviceForIndex(current_index).udi() == deviceUdi) {
places->requestSetup(current_index);
found = true;
break;
}
}
if (!found) {
delete places;
}
m_helper->openDevice(action.data().toString());
}
}
@ -171,15 +180,4 @@ QMimeData *PlacesRunner::mimeDataForMatch(const Plasma::QueryMatch &match)
return nullptr;
}
//if a device needed mounting, this slot gets called when it's finished.
void PlacesRunner::setupComplete(QModelIndex index, bool success)
{
KFilePlacesModel *places = qobject_cast<KFilePlacesModel*>(sender());
//qDebug() << "setup complete" << places << sender();
if (success && places) {
new KRun(places->url(index), nullptr);
places->deleteLater();
}
}
#include "placesrunner.moc"

@ -35,9 +35,11 @@ public:
public Q_SLOTS:
void match(Plasma::RunnerContext *context);
void openDevice(const QString &udi);
private:
KFilePlacesModel m_places;
QString m_pendingUdi;
};
class PlacesRunner : public Plasma::AbstractRunner
@ -55,9 +57,6 @@ public:
Q_SIGNALS:
void doMatch(Plasma::RunnerContext *context);
private Q_SLOTS:
void setupComplete(QModelIndex, bool);
private:
PlacesRunnerHelper *m_helper;
};

@ -14,6 +14,7 @@ Name[fr]=%{APPNAME} Fournisseur de données météorologiques
Name[gl]=Fornecedor de datos meteorolóxicos %{APPNAME}
Name[he]=ספק מזג האוויר %{APPNAME}
Name[hu]=%{APPNAME} időjárásadat-szolgáltató
Name[id]=Penyedia Data Cuaca %{APPNAME}
Name[is]=%{APPNAME} veðurgagnaþjónusta
Name[it]=Fornitore di dati meteo di %{APPNAME}
Name[ko]=%{APPNAME} 날씨 데이터 공급자
@ -47,6 +48,7 @@ Comment[fr]=Accès au fournisseur de données météorologiques %{APPNAME}
Comment[gl]=Acceder ao fornecedor de datos meteorolóxicos %{APPNAME}.
Comment[he]=גישה למספק מזג האוויר %{APPNAME}
Comment[hu]=Hpzzáférés a(z) %{APPNAME} időjárási adataihoz
Comment[id]=Akses ke penyedia data cuaca %{APPNAME}
Comment[is]=Aðgangur að veðurgagnaþjónustunni %{APPNAME}
Comment[it]=Accedi al fornitore di dati meteo di %{APPNAME}
Comment[ko]=날씨 데이터 공급자 %{APPNAME}에 접근

Loading…
Cancel
Save