先看代码

void MainWindow::sendNotify(int saveIndex, QString saveFilePath, const bool succeed)
{
    // failed notify
    if (!succeed)
    {
        const auto tips = tr("Save failed. Please save it in your home directory.");
        m_notifyDBInterface->Notify("Deepin Screenshot", 0, "deepin-screenshot", QString(), tips, QStringList(), QVariantMap(), 0);

	exit(0);
    }

    QDBusInterface remote_dde_notify_obj("com.deepin.dde.Notification", "/com/deepin/dde/Notification",
                                         "com.deepin.dde.Notification");

    const bool remote_dde_notify_obj_exist = remote_dde_notify_obj.isValid();

    QStringList actions;
    QVariantMap hints;

    if (remote_dde_notify_obj_exist) {
        actions << "_open" << tr("View");

        QString fileDir  = QUrl::fromLocalFile(QFileInfo(saveFilePath).absoluteDir().absolutePath()).toString();
        QString filePath = QUrl::fromLocalFile(saveFilePath).toString();
        QString command;
        if (QFile("/usr/bin/dde-file-manager").exists()) {
            command = QString("/usr/bin/dde-file-manager,%1?selectUrl=%2").arg(fileDir).arg(filePath);
            qDebug() << command;
        }
        else {
            command = QString("xdg-open,%1").arg(filePath);
        }

        hints["x-deepin-action-_open"] = command;
    }

    qDebug() << "saveFilePath:" << saveFilePath;

    QString summary;
    if (saveIndex == 3) {
        summary = QString(tr("Picture has been saved to clipboard"));
    } else {
        summary = QString(tr("Picture has been saved to %1")).arg(saveFilePath);
    }

    if (saveIndex == 3 && !m_noNotify) {
        QVariantMap emptyMap;
        m_notifyDBInterface->Notify("Deepin Screenshot", 0,  "deepin-screenshot", "",
                                    summary,  QStringList(), emptyMap, 0);
    }  else if ( !m_noNotify &&  !(m_saveIndex == 2 && m_saveFileName.isEmpty())) {
        m_notifyDBInterface->Notify("Deepin Screenshot", 0,  "deepin-screenshot", "",
                                    summary, actions, hints, 0);
    }

    QTimer::singleShot(2, [=]{
        exitApp();
    });

}

deepin 深度截图中发送通知的操作
核心关注点

/usr/bin/dde-file-manager,file:///home/alda/Desktop?selectUrl=file:///home/pikachu/Desktop/深度截图_选择区域_20190324224011.png

这个回调的时候,会打开深度文件管理器,然后选中那个图片,很神奇
DBus为
deepin 深度截图中发送通知的操作
发送的参数为
deepin 深度截图中发送通知的操作
hints就是那个回调的参数,可以打开文管的

相关文章:

  • 2022-01-05
  • 2021-05-05
  • 2021-07-17
  • 2022-12-23
  • 2021-06-26
  • 2021-06-11
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2021-08-11
  • 2022-01-01
  • 2021-10-25
  • 2021-06-07
  • 2021-08-31
  • 2021-12-26
相关资源
相似解决方案