Skip to content
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Makefile
moc_*.o
moc_*.cpp
moc_*.h
qrc_*.cpp
*.o
*.so
build/
*.qm
*.pro.user*
deepin-screen-recorder
deepin-pin-screenshots
.qmake.stash
31 changes: 30 additions & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -241,8 +241,37 @@
//qDebug() << "udpateVersion: " << DSysInfo::udpateVersion();
//qDebug() << "majorVersion: " << DSysInfo::majorVersion();
//qDebug() << "majorVersion: " << DSysInfo::majorVersion();
qInfo() << "isVirtualMachine: " << isRunningInVirtualMachine();
}

//Detect whether running in a virtual machine
bool Utils::isRunningInVirtualMachine(bool forceVirtualMachine)
{
QProcess process;
process.start("/usr/bin/systemd-detect-virt");
process.waitForFinished();
QString output = process.readAllStandardOutput().trimmed();

// Print the output of systemd-detect-virt command
qInfo() << "systemd-detect-virt output: " << output;

// none: not a virtual machine
// kvm, vmware, virtualbox, xen, qemu, etc.: virtual machine
// empty output: also considered as not a virtual machine
if (forceVirtualMachine) {
qInfo() << "Force treat as virtual machine";
return true;
}

if (output.isEmpty() || output.toLower() == "none") {
qInfo() << "Running on physical machine, not a virtual machine";
return false;
} else {
qInfo() << "Running in a virtual machine, type:" << output;
return true;
}
}
void Utils::enableXGrabButton()

Check warning on line 274 in src/utils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'enableXGrabButton' is never used.
{
if (Utils::isWaylandMode == true)
return;
Expand Down
11 changes: 9 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -143,7 +143,14 @@ class Utils : public QObject
* @brief showCurrentSys 显示
*/
static void showCurrentSys();


/**
* @brief isRunningInVirtualMachine Detect whether running in a virtual machine
* @param forceVirtualMachine If true, force treat as virtual machine; if false, auto-detect
* @return true: running in a virtual machine; false: not running in a virtual machine
*/
static bool isRunningInVirtualMachine(bool forceVirtualMachine = false);

/**
* @brief 使能XGrabButton抓取所有的鼠标点击事件
*/
Expand Down
3 changes: 2 additions & 1 deletion src/utils/voicevolumewatcher.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "voicevolumewatcher.h"
#include "audioutils.h"
#include "utils.h"

Check warning on line 8 in src/utils/voicevolumewatcher.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "utils.h" not found.

#include <QDebug>

Check warning on line 10 in src/utils/voicevolumewatcher.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QThread>

Check warning on line 11 in src/utils/voicevolumewatcher.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QThread> not found. Please note: Cppcheck does not need standard library headers to get proper results.

voiceVolumeWatcher::voiceVolumeWatcher(QObject *parent)
: QObject(parent)
Expand Down
9 changes: 6 additions & 3 deletions src/widgets/subtoolwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -1456,8 +1456,11 @@ void SubToolWidget::setSystemAudioEnable(bool status)
m_haveSystemAudio = status;
m_systemAudioAction->setEnabled(status);
m_systemAudioAction->setCheckable(status);
m_systemAudioAction->setChecked(!status);
m_systemAudioAction->trigger();
m_systemAudioAction->setChecked(!status && !Utils::isRunningInVirtualMachine());
if (Utils::isRunningInVirtualMachine())
emit m_systemAudioAction->triggered(false);
else
m_systemAudioAction->trigger();
}
// 当m_microphoneAction或m_systemAudioAction被点击或者程序主动调用trigg()时,会触发工具栏音频采集图标的改变及发射实际需要录制的音频
void SubToolWidget::onChangeAudioType(bool checked)
Expand Down
Loading