Performs a DBus call to open the given @p files in the running kdev instance identified by @p pid Returns the exit status
| 234 | /// Performs a DBus call to open the given @p files in the running kdev instance identified by @p pid |
| 235 | /// Returns the exit status |
| 236 | static int openProjectInRunningInstance(const QVector<UrlInfo>& paths, qint64 pid) |
| 237 | { |
| 238 | const QString service = QStringLiteral("org.kdevelop.kdevelop-%1").arg(pid); |
| 239 | QDBusInterface iface(service, QStringLiteral("/org/kdevelop/ProjectController"), QStringLiteral("org.kdevelop.ProjectController")); |
| 240 | int errors = 0; |
| 241 | |
| 242 | for (const UrlInfo& path : paths) { |
| 243 | QDBusReply<void> result = iface.call(QStringLiteral("openProjectForUrl"), path.url.toString()); |
| 244 | if ( !result.isValid() ) { |
| 245 | QTextStream err(stderr); |
| 246 | err << i18n("Could not open project '%1': %2", path.url.toDisplayString(QUrl::PreferLocalFile), result.error().message()) << "\n"; |
| 247 | ++errors; |
| 248 | } |
| 249 | } |
| 250 | // make the window visible |
| 251 | QDBusMessage makeVisible = QDBusMessage::createMethodCall( service, QStringLiteral("/kdevelop/MainWindow"), QStringLiteral("org.kdevelop.MainWindow"), |
| 252 | QStringLiteral("ensureVisible") ); |
| 253 | QDBusConnection::sessionBus().asyncCall( makeVisible ); |
| 254 | return errors; |
| 255 | } |
| 256 | |
| 257 | /// Gets the PID of a running KDevelop instance, eventually asking the user if there is more than one. |
| 258 | /// Returns -1 in case there are no running sessions. |