fix:#I8EQUH【终端】系统日常运行一段时间后,在文件管理器右键打开的终端窗口没有置顶
This commit is contained in:
parent
6b21eb4cd2
commit
eb7712190d
|
@ -34,7 +34,9 @@
|
|||
#include <QtConcurrent>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusPendingCall>
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef KYLIN_COMMON
|
||||
|
@ -82,30 +84,23 @@ MateTerminalMenuPlugin::MateTerminalMenuPlugin(QObject *parent) : QObject (paren
|
|||
}
|
||||
|
||||
void MateTerminalMenuPlugin::openTerminal(){
|
||||
|
||||
//qDebug()<<"triggered"<<uri;
|
||||
QUrl url = m_uri;
|
||||
auto directory = url.path().toUtf8().constData();
|
||||
gchar **argv = nullptr;
|
||||
g_shell_parse_argv (terminal_cmd.toUtf8().constData(), nullptr, &argv, nullptr);
|
||||
GError *err = nullptr;
|
||||
g_spawn_async (directory,
|
||||
argv,
|
||||
nullptr,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&err);
|
||||
if (err) {
|
||||
qDebug()<<"openTerminal failed:"<<err->message;
|
||||
g_error_free(err);
|
||||
err = nullptr;
|
||||
//try again to open terminal
|
||||
//maybe this method is better,but still need more test to confirm
|
||||
tryOpenAgain();
|
||||
auto dir = url.path();
|
||||
|
||||
QStringList args;
|
||||
args << "--working-directory" << dir;
|
||||
QString terminal_path = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "mate-terminal.desktop");
|
||||
if (terminal_path.isEmpty()) {
|
||||
terminal_path = QFile(terminal_cmd).fileName() + ".desktop";
|
||||
terminal_path = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, terminal_path);
|
||||
if (!QFile(terminal_path).exists()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
g_strfreev (argv);
|
||||
|
||||
QDBusMessage msg = QDBusMessage::createMethodCall("com.kylin.AppManager", "/com/kylin/AppManager", "com.kylin.AppManager", "LaunchAppWithArguments");
|
||||
msg << terminal_path << args;
|
||||
QDBusConnection::sessionBus().asyncCall(msg);
|
||||
}
|
||||
|
||||
void MateTerminalMenuPlugin::tryOpenAgain()
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += widgets concurrent
|
||||
QT += widgets concurrent dbus
|
||||
|
||||
TARGET = peony-menu-plugin-mate-terminal
|
||||
TEMPLATE = lib
|
||||
|
|
Loading…
Reference in New Issue