mirror of
https://github.com/ukui/peony.git
synced 2026-03-09 09:21:10 -07:00
[FIX]【任务栏】【TM】PC打开txt文件、文件夹,平板模式任务栏无显示[LINK]120473
This commit is contained in:
@@ -266,11 +266,9 @@ void FileLaunchAction::lauchFileAsync(bool forceWithArg, bool skipDialog)
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDesktopFileAction()) {
|
||||
if (launchAppWithDBus()) {
|
||||
qDebug() << "[FileLaunchAction::lauchFileAsync] launchAppWithDBus, name:" << fileInfo->displayName();
|
||||
return;
|
||||
}
|
||||
if (launchAppWithDBus()) {
|
||||
qDebug() << "[FileLaunchAction::lauchFileAsync] launchAppWithDBus, name:" << fileInfo->displayName();
|
||||
return;
|
||||
}
|
||||
|
||||
bool executable = fileInfo->canExecute();
|
||||
@@ -577,11 +575,10 @@ void FileLaunchAction::lauchFilesAsync(const QStringList files, bool forceWithAr
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDesktopFileAction()) {
|
||||
if (launchAppWithDBus()) {
|
||||
qDebug() << "[FileLaunchAction::lauchFilesAsync] launchAppWithDBus, name:" << fileInfo->displayName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (launchAppWithDBus()) {
|
||||
qDebug() << "[FileLaunchAction::lauchFilesAsync] launchAppWithDBus, name:" << fileInfo->displayName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDesktopFileAction() && !forceWithArg) {
|
||||
@@ -693,19 +690,26 @@ void FileLaunchAction::preCheck()
|
||||
|
||||
bool FileLaunchAction::launchAppWithDBus()
|
||||
{
|
||||
bool intel = (QString::compare(V10_SP1_EDU, QString::fromStdString(KDKGetPrjCodeName()), Qt::CaseInsensitive) == 0);
|
||||
if (intel) {
|
||||
return launchAppWithSession();
|
||||
}
|
||||
if (isDesktopFileAction()) {
|
||||
bool intel = (QString::compare(V10_SP1_EDU, QString::fromStdString(KDKGetPrjCodeName()), Qt::CaseInsensitive) == 0);
|
||||
if (intel) {
|
||||
return launchAppWithSession();
|
||||
}
|
||||
|
||||
//TODO 以下判断方式不能覆盖全部情况,后期还需要根据ukui3.1项目的os-release进行调整
|
||||
//see peony-qt-desktop/settings/desktop-global-settings.cpp -> getProductFeatures();
|
||||
int features = QString::fromStdString(KDKGetOSRelease("PRODUCT_FEATURES")).toInt();
|
||||
if (features == 2 || features == 3) {
|
||||
return launchAppWithAppMgr();
|
||||
}
|
||||
//TODO 以下判断方式不能覆盖全部情况,后期还需要根据ukui3.1项目的os-release进行调整
|
||||
//see peony-qt-desktop/settings/desktop-global-settings.cpp -> getProductFeatures();
|
||||
int features = QString::fromStdString(KDKGetOSRelease("PRODUCT_FEATURES")).toInt();
|
||||
if (features == 2 || features == 3) {
|
||||
return launchAppWithAppMgr();
|
||||
}
|
||||
|
||||
qDebug() << "[FileLaunchAction::launchAppWithDBus] can't launch app with DBus, features:" << features << ", is intel:" << intel;
|
||||
qDebug() << "[FileLaunchAction::launchAppWithDBus] can't launch app with DBus, features:" << features << ", is intel:" << intel;
|
||||
} else {
|
||||
int features = QString::fromStdString(KDKGetOSRelease("PRODUCT_FEATURES")).toInt();
|
||||
if (features == 2 || features == 3) {
|
||||
return launchDefaultAppWithUrl();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -732,6 +736,31 @@ bool FileLaunchAction::launchAppWithAppMgr()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileLaunchAction::launchDefaultAppWithUrl()
|
||||
{
|
||||
QDBusInterface session("com.kylin.AppManager", "/com/kylin/AppManager", "com.kylin.AppManager");
|
||||
if (session.isValid()) {
|
||||
auto fileInfo = FileInfo::fromUri(m_uri);
|
||||
if (fileInfo->isEmptyInfo()) {
|
||||
FileInfoJob j(fileInfo);
|
||||
j.querySync();
|
||||
}
|
||||
|
||||
QString uri = fileInfo->uri();
|
||||
|
||||
QDBusReply<bool> result = session.call("LaunchDefaultAppWithUrl", uri);
|
||||
qDebug() << "[FileLaunchAction::launchAppWithUrlbyAppMgr] uri:" << uri;
|
||||
|
||||
if (result.isValid()) {
|
||||
return true;
|
||||
}
|
||||
qDebug() << "[FileLaunchAction::launchAppWithUrlbyAppMgr] failed, uri:" << uri;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool FileLaunchAction::launchAppWithSession()
|
||||
{
|
||||
auto fileInfo = FileInfo::fromUri(m_uri);
|
||||
|
||||
@@ -71,6 +71,7 @@ public Q_SLOTS:
|
||||
private:
|
||||
bool launchAppWithDBus();
|
||||
bool launchAppWithAppMgr();
|
||||
bool launchDefaultAppWithUrl();
|
||||
bool launchAppWithSession();
|
||||
|
||||
bool checkAppDisabled();
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include "file-item-model.h"
|
||||
#include "file-info-job.h"
|
||||
#include "file-launch-manager.h"
|
||||
#include "desktop-global-settings.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
#include <QDesktopServices>
|
||||
@@ -89,7 +91,7 @@ using namespace Peony;
|
||||
#define PANEL_SETTINGS "org.ukui.panel.settings"
|
||||
#define UKUI_STYLE_SETTINGS "org.ukui.style"
|
||||
#define RESTORE_ITEM_POS_ATTRIBUTE "metadata::peony-qt-desktop-restore-item-position"
|
||||
|
||||
#define PEONY_DESKTOP_PATH "/usr/share/applications/peony.desktop"
|
||||
static bool iconSizeLessThan (const QPair<QRect, QString> &p1, const QPair<QRect, QString> &p2);
|
||||
|
||||
static bool initialized = false;
|
||||
@@ -920,41 +922,49 @@ void DesktopIconView::openFileByUri(QString uri)
|
||||
tr("Open directory failed, you have no permission!"));
|
||||
return;
|
||||
}
|
||||
|
||||
int features = DesktopGlobalSettings::globalInstance()->getProductFeatures();
|
||||
if (features == 2 || features == 3) {
|
||||
QUrl url = uri;
|
||||
QString desktopFile = PEONY_DESKTOP_PATH;
|
||||
QStringList args;
|
||||
args << url.toEncoded() <<"%U&";
|
||||
launchAppWithArguments(desktopFile, args);
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
QProcess p;
|
||||
QUrl url = uri;
|
||||
p.setProgram("peony");
|
||||
p.setArguments(QStringList() << url.toEncoded() <<"%U&");
|
||||
qint64 pid;
|
||||
p.startDetached(&pid);
|
||||
QProcess p;
|
||||
QUrl url = uri;
|
||||
p.setProgram("peony");
|
||||
p.setArguments(QStringList() << url.toEncoded() <<"%U&");
|
||||
qint64 pid;
|
||||
p.startDetached(&pid);
|
||||
|
||||
// send startinfo to kwindowsystem
|
||||
quint32 timeStamp = QX11Info::isPlatformX11() ? QX11Info::appUserTime() : 0;
|
||||
KStartupInfoId startInfoId;
|
||||
startInfoId.initId(KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
|
||||
startInfoId.setupStartupEnv();
|
||||
KStartupInfoData data;
|
||||
data.setHostname();
|
||||
data.addPid(pid);
|
||||
QRect rect = info.get()->property("iconGeometry").toRect();
|
||||
if (rect.isValid())
|
||||
data.setIconGeometry(rect);
|
||||
data.setLaunchedBy(getpid());
|
||||
KStartupInfo::sendStartup(startInfoId, data);
|
||||
// send startinfo to kwindowsystem
|
||||
quint32 timeStamp = QX11Info::isPlatformX11() ? QX11Info::appUserTime() : 0;
|
||||
KStartupInfoId startInfoId;
|
||||
startInfoId.initId(KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
|
||||
startInfoId.setupStartupEnv();
|
||||
KStartupInfoData data;
|
||||
data.setHostname();
|
||||
data.addPid(pid);
|
||||
QRect rect = info.get()->property("iconGeometry").toRect();
|
||||
if (rect.isValid())
|
||||
data.setIconGeometry(rect);
|
||||
data.setLaunchedBy(getpid());
|
||||
KStartupInfo::sendStartup(startInfoId, data);
|
||||
#else
|
||||
QProcess p;
|
||||
QString strq;
|
||||
for (int i = 0;i < uri.length();++i) {
|
||||
if(uri[i] == ' '){
|
||||
strq += "%20";
|
||||
}else{
|
||||
strq += uri[i];
|
||||
QProcess p;
|
||||
QString strq;
|
||||
for (int i = 0;i < uri.length();++i) {
|
||||
if(uri[i] == ' '){
|
||||
strq += "%20";
|
||||
}else{
|
||||
strq += uri[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.startDetached("peony", QStringList()<<strq<<"%U&");
|
||||
p.startDetached("peony", QStringList()<<strq<<"%U&");
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
FileLaunchManager::openAsync(uri, false, false);
|
||||
}
|
||||
@@ -2273,6 +2283,22 @@ void DesktopIconView::getAllRestoreInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool DesktopIconView::launchAppWithArguments(QString desktopFile, QStringList args)
|
||||
{
|
||||
QDBusInterface session("com.kylin.AppManager", "/com/kylin/AppManager", "com.kylin.AppManager");
|
||||
if (session.isValid()) {
|
||||
QDBusReply<bool> result = session.call("LaunchAppWithArguments", desktopFile, args);
|
||||
qDebug() << "[DesktopIconView::LaunchAppWithArguments] desktopFile:" << desktopFile << "args:" <<args;
|
||||
|
||||
if (result.isValid()) {
|
||||
return true;
|
||||
}
|
||||
qDebug() << "[DesktopIconView::LaunchAppWithArguments] failed, desktopFile:" << desktopFile << "args:" <<args;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DesktopIconView::clearAllRestoreInfo()
|
||||
{
|
||||
//bug#108126 超出屏幕的元素记录清空
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
|
||||
private:
|
||||
QRect getScreenArea(QScreen* screen);
|
||||
bool launchAppWithArguments(QString desktopFile, QStringList args);
|
||||
|
||||
Q_SIGNALS:
|
||||
void zoomLevelChanged(ZoomLevel level);
|
||||
|
||||
Reference in New Issue
Block a user