Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix fail to kill linglong app #379

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions deepin-system-monitor-main/gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ void MainWindow::initUI()
// adjust toolbar tab order
setTabOrder(titlebar(), m_toolbar);

// kill process menu item
QAction *killAction = new QAction(DApplication::translate("Title.Bar.Context.Menu", "Force end application"), menu);
// control + alt + k
killAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_K));
// emit process kill requested signal if kill process menu item triggered
connect(killAction, &QAction::triggered, this, [=]() { Q_EMIT killProcessPerformed(); });
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.KWin"))) {
// kill process menu item
QAction *killAction = new QAction(DApplication::translate("Title.Bar.Context.Menu", "Force end application"), menu);
// control + alt + k
killAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_K));
// emit process kill requested signal if kill process menu item triggered
connect(killAction, &QAction::triggered, this, [=]() { Q_EMIT killProcessPerformed(); });
menu->addAction(killAction);
}

// display mode menu item
DMenu *modeMenu = new DMenu(DApplication::translate("Title.Bar.Context.Menu", "View"), menu);
Expand Down Expand Up @@ -155,7 +158,6 @@ void MainWindow::initUI()
QAction *settingAction(new QAction(tr("Settings"), this));
connect(settingAction, &QAction::triggered, this, &MainWindow::popupSettingsDialog);

menu->addAction(killAction);
menu->addSeparator();
menu->addMenu(modeMenu);

Expand Down Expand Up @@ -249,6 +251,8 @@ void MainWindow::initConnections()

connect(&DetailWidgetManager::getInstance(), &DetailWidgetManager::sigJumpToProcessWidget, this, &MainWindow::onDetailInfoByDbus, Qt::QueuedConnection);
connect(&DetailWidgetManager::getInstance(), &DetailWidgetManager::sigJumpToDetailWidget, this, &MainWindow::onDetailInfoByDbus, Qt::QueuedConnection);

connect(this, &MainWindow::killProcessPerformed, this, &MainWindow::onKillProcess);
}

// resize event handler
Expand Down Expand Up @@ -361,3 +365,14 @@ void MainWindow::popupSettingsDialog()
// 销毁窗口
dialog->deleteLater();
}

void MainWindow::onKillProcess()
{
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.KWin"))) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"),
QStringLiteral("/KWin"),
QStringLiteral("org.kde.KWin"),
QStringLiteral("killWindow"));
QDBusConnection::sessionBus().asyncCall(message);
}
}
5 changes: 5 additions & 0 deletions deepin-system-monitor-main/gui/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public Q_SLOTS:
*/
void popupSettingsDialog();

/**
* @brief onKillProcess
*/
void onKillProcess();

protected:
/**
* @brief Initialize ui components
Expand Down
4 changes: 2 additions & 2 deletions deepin-system-monitor-main/gui/process_page_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ void ProcessPageWidget::initConnections()
{
auto *mainWindow = gApp->mainWindow();
// kill application signal triggered, show application kill preview widget
connect(mainWindow, &MainWindow::killProcessPerformed, this,
&ProcessPageWidget::showWindowKiller);
// connect(mainWindow, &MainWindow::killProcessPerformed, this,
// &ProcessPageWidget::showWindowKiller);
// switch display mode signal triggered, switch performance display mode
connect(mainWindow, &MainWindow::displayModeChanged, this,
&ProcessPageWidget::switchDisplayMode);
Expand Down