Skip to content

Commit

Permalink
Add screenCapturable support
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn>
  • Loading branch information
QQxiaoming committed Dec 20, 2024
1 parent 4fd3054 commit 14f2c78
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.5.3'
version: '6.8.1'
modules: 'qtwebsockets qtserialport qtmultimedia'
aqtversion: ==3.1.7
aqtversion: '==3.1.20'

- name: Install prerequisites
run: |
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
run: |
git fetch --tags --force
sed -i 's/--long --dirty/--long/g' ./tools/generate_info.sh
sed -i 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.5.3\/gcc_64/g' build_deb.sh
sed -i 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.8.1\/gcc_64/g' build_deb.sh
sed -i 's/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=\/usr\/local\/output/g' ./lib/qtssh/qtssh.pri
mkdir prebuilt_plugins
python3 ./.github/scripts/get_plugin.py ./.github/scripts/plugin_list.json ./prebuilt_plugins
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linux_appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.5.3'
version: '6.8.1'
modules: 'qtwebsockets qtserialport qtmultimedia'
aqtversion: ==3.1.7
aqtversion: '==3.1.20'

- name: Install prerequisites
run: |
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
run: |
git fetch --tags --force
sed -i 's/--long --dirty/--long/g' ./tools/generate_info.sh
sed -i 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.5.3\/gcc_64/g' build_AppImage.sh
sed -i 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.8.1\/gcc_64/g' build_AppImage.sh
sed -i 's/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=\/usr\/local\/output/g' ./lib/qtssh/qtssh.pri
mkdir prebuilt_plugins
python3 ./.github/scripts/get_plugin.py ./.github/scripts/plugin_list.json ./prebuilt_plugins
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.5.3'
version: '6.8.1'
modules: 'qtwebsockets qtserialport qtmultimedia'
aqtversion: ==3.1.7
aqtversion: '==3.1.20'

- name: Install prerequisites
run: |
Expand All @@ -76,7 +76,7 @@ jobs:
run: |
git fetch --tags --force
sed -i'.original' -e 's/--long --dirty/--long/g' ./tools/generate_info.sh
sed -i'.original' -e 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.5.3\/macos/g' build_dmg.sh
sed -i'.original' -e 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.8.1\/macos/g' build_dmg.sh
sed -i'.original' -e 's/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=\/usr\/local\/output/g' ./lib/qtssh/qtssh.pri
mkdir prebuilt_plugins
python3 ./.github/scripts/get_plugin.py ./.github/scripts/plugin_list.json ./prebuilt_plugins
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.5.3'
version: '6.8.1'
modules: 'qtwebsockets qtserialport qtmultimedia'
aqtversion: ==3.1.7
aqtversion: '==3.1.20'

- name: Install prerequisites
run: |
Expand All @@ -76,7 +76,7 @@ jobs:
run: |
git fetch --tags --force
sed -i'.original' -e 's/--long --dirty/--long/g' ./tools/generate_info.sh
sed -i'.original' -e 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.5.3\/macos/g' build_dmg.sh
sed -i'.original' -e 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.8.1\/macos/g' build_dmg.sh
sed -i'.original' -e 's/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=\/usr\/local\/output/g' ./lib/qtssh/qtssh.pri
mkdir prebuilt_plugins
python3 ./.github/scripts/get_plugin.py ./.github/scripts/plugin_list.json ./prebuilt_plugins
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ jobs:
uses: jurplel/install-qt-action@v4
with:
arch: win64_mingw
version: '6.5.3'
version: '6.8.1'
modules: 'qtwebsockets qtserialport qtmultimedia'
aqtversion: ==3.1.7
aqtversion: '==3.1.19'
tools: 'tools_mingw1310'

- name: Install cmake
uses: crazy-max/ghaction-chocolatey@v3
Expand All @@ -78,6 +79,7 @@ jobs:
run: |
pacman --noconfirm -S make cmake autoconf automake bison diffutils libtool texinfo xmlto
pacman --noconfirm -S base-devel msys2-devel mingw-w64-{x86_64,i686}-toolchain
gcc --version
mkdir mingw-w64-libpython
cp -r ${Python3_ROOT_DIR}/include ./mingw-w64-libpython/
mkdir mingw-w64-libpython/lib
Expand Down Expand Up @@ -118,8 +120,8 @@ jobs:
run: |
git fetch --tags --force
./tools/sed/sed.exe -i 's/--long --dirty/--long/g' ./tools/generate_info.ps1
./tools/sed/sed.exe -i "s/QT_DIR=C:\/Qt\/Qt6.2.0\/6.2.0\/mingw81_32\/bin/QT_DIR=%Qt5_Dir%/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/QT_TOOLS_DIR=C:\/Qt\/Qt6.2.0\/Tools\/mingw810_32\/bin/QT_TOOLS_DIR=C:\/ProgramData\/Chocolatey\/lib\/mingw\/tools\/install\/mingw64\/bin/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/QT_DIR=C:\/Qt\/Qt6.2.0\/6.2.0\/mingw81_32\/bin/QT_DIR=%QT_ROOT_DIR%\/bin/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/QT_TOOLS_DIR=C:\/Qt\/Qt6.2.0\/Tools\/mingw810_32\/bin/QT_TOOLS_DIR=%IQTA_TOOLS%\/mingw1310\/bin/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/mingw32-make -j8/mingw32-make -j1/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/WINPTY_DIR=D:\\quardCRT\\depend\\winpty/WINPTY_DIR=D:\\winpty/g" ./lib/ptyqt/ptyqt.pri
./tools/sed/sed.exe -i "s/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=D:\\libssh2/g" ./lib/qtssh/qtssh.pri
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/windows_msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ on:
workflow_dispatch:

jobs:
windows_msvc2019:
windows_msvc2022:
runs-on: windows-2022

steps:
Expand All @@ -49,10 +49,10 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
arch: 'win64_msvc2019_64'
version: '6.5.3'
arch: 'win64_msvc2022_64'
version: '6.8.1'
modules: 'qtwebsockets qtserialport qtmultimedia'
aqtversion: '==3.1.7'
aqtversion: '==3.1.19'

- name: Install cmake
uses: crazy-max/ghaction-chocolatey@v3
Expand Down Expand Up @@ -81,7 +81,6 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
toolset: 14.29

- name: Install libssh2
run: |
Expand Down Expand Up @@ -111,7 +110,7 @@ jobs:
- name: Upload build asserts
uses: actions/upload-artifact@v4
with:
name: quardCRT_windows_msvc2019
name: quardCRT_windows_msvc2022
path: |
./output/*.exe
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Windows ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/windows.yml?branch=main&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+V2luZG93czwvdGl0bGU+PHBhdGggZD0iTTAsMEgxMS4zNzdWMTEuMzcySDBaTTEyLjYyMywwSDI0VjExLjM3MkgxMi42MjNaTTAsMTIuNjIzSDExLjM3N1YyNEgwWm0xMi42MjMsMEgyNFYyNEgxMi42MjMiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=)](https://github.com/QQxiaoming/quardCRT/actions/workflows/windows.yml)
[![Linux ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/linux.yml?branch=main&logo=linux&logoColor=white)](https://github.com/QQxiaoming/quardCRT/actions/workflows/linux.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos_arm64.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos_arm64.yml)
[![CodeFactor](https://img.shields.io/codefactor/grade/github/qqxiaoming/quardCRT.svg?logo=codefactor)](https://www.codefactor.io/repository/github/qqxiaoming/quardCRT)
[![Documentation Status](https://img.shields.io/readthedocs/quardcrt.svg?logo=readthedocs)](https://quardcrt.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/github/license/qqxiaoming/quardCRT.svg?colorB=f48041&logo=gnu)](https://github.com/QQxiaoming/quardCRT)
Expand Down
2 changes: 1 addition & 1 deletion README_ja_JP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Windows ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/windows.yml?branch=main&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+V2luZG93czwvdGl0bGU+PHBhdGggZD0iTTAsMEgxMS4zNzdWMTEuMzcySDBaTTEyLjYyMywwSDI0VjExLjM3MkgxMi42MjNaTTAsMTIuNjIzSDExLjM3N1YyNEgwWm0xMi42MjMsMEgyNFYyNEgxMi42MjMiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=)](https://github.com/QQxiaoming/quardCRT/actions/workflows/windows.yml)
[![Linux ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/linux.yml?branch=main&logo=linux&logoColor=white)](https://github.com/QQxiaoming/quardCRT/actions/workflows/linux.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos_arm64.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos_arm64.yml)
[![CodeFactor](https://img.shields.io/codefactor/grade/github/qqxiaoming/quardCRT.svg?logo=codefactor)](https://www.codefactor.io/repository/github/qqxiaoming/quardCRT)
[![Documentation Status](https://img.shields.io/readthedocs/quardcrt.svg?logo=readthedocs)](https://quardcrt.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/github/license/qqxiaoming/quardCRT.svg?colorB=f48041&logo=gnu)](https://github.com/QQxiaoming/quardCRT)
Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Windows ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/windows.yml?branch=main&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+V2luZG93czwvdGl0bGU+PHBhdGggZD0iTTAsMEgxMS4zNzdWMTEuMzcySDBaTTEyLjYyMywwSDI0VjExLjM3MkgxMi42MjNaTTAsMTIuNjIzSDExLjM3N1YyNEgwWm0xMi42MjMsMEgyNFYyNEgxMi42MjMiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=)](https://github.com/QQxiaoming/quardCRT/actions/workflows/windows.yml)
[![Linux ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/linux.yml?branch=main&logo=linux&logoColor=white)](https://github.com/QQxiaoming/quardCRT/actions/workflows/linux.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos_arm64.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos_arm64.yml)
[![CodeFactor](https://img.shields.io/codefactor/grade/github/qqxiaoming/quardCRT.svg?logo=codefactor)](https://www.codefactor.io/repository/github/qqxiaoming/quardCRT)
[![Documentation Status](https://img.shields.io/readthedocs/quardcrt.svg?logo=readthedocs)](https://quardcrt.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/github/license/qqxiaoming/quardCRT.svg?colorB=f48041&logo=gnu)](https://github.com/QQxiaoming/quardCRT)
Expand Down
2 changes: 1 addition & 1 deletion README_zh_HK.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Windows ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/windows.yml?branch=main&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+V2luZG93czwvdGl0bGU+PHBhdGggZD0iTTAsMEgxMS4zNzdWMTEuMzcySDBaTTEyLjYyMywwSDI0VjExLjM3MkgxMi42MjNaTTAsMTIuNjIzSDExLjM3N1YyNEgwWm0xMi42MjMsMEgyNFYyNEgxMi42MjMiIGZpbGw9IiNmZmZmZmYiLz48L3N2Zz4=)](https://github.com/QQxiaoming/quardCRT/actions/workflows/windows.yml)
[![Linux ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/linux.yml?branch=main&logo=linux&logoColor=white)](https://github.com/QQxiaoming/quardCRT/actions/workflows/linux.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos.yml)
[![Macos ci](https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos_arm64.yml?branch=main&logo=apple)](https://github.com/QQxiaoming/quardCRT/actions/workflows/macos_arm64.yml)
[![CodeFactor](https://img.shields.io/codefactor/grade/github/qqxiaoming/quardCRT.svg?logo=codefactor)](https://www.codefactor.io/repository/github/qqxiaoming/quardCRT)
[![Documentation Status](https://img.shields.io/readthedocs/quardcrt.svg?logo=readthedocs)](https://quardcrt.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/github/license/qqxiaoming/quardCRT.svg?colorB=f48041&logo=gnu)](https://github.com/QQxiaoming/quardCRT)
Expand Down
4 changes: 2 additions & 2 deletions depend/build_fcitx_qt6_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set -e

# ubuntu20.04 need install
# sudo apt install fcitx-libs-dev qtbase5-private-dev libxkbcommon-dev extra-cmake-modules
# export PATH="~/Qt/6.5.3/gcc_64/bin":$PATH
# export PATH="~/Qt/6.8.1/gcc_64/bin":$PATH
# export PATH="~/Qt/Tools/CMake/bin":$PATH
# export Qt6GuiTools_DIR=/home/qqm/Qt/6.5.3/gcc_64
# export Qt6GuiTools_DIR=/home/qqm/Qt/6.8.1/gcc_64
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
tar -xzvf fcitx-qt5-1.2.7.tar.gz
cd $SHELL_FOLDER/fcitx-qt5-1.2.7
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ quardCRT
.. image:: https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/linux.yml?branch=main&logo=linux&logoColor=white
:target: https://github.com/QQxiaoming/quardCRT/actions/workflows/linux.yml
:alt: Linux ci
.. image:: https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos.yml?branch=main&logo=apple
:target: https://github.com/QQxiaoming/quardCRT/actions/workflows/macos.yml
.. image:: https://img.shields.io/github/actions/workflow/status/qqxiaoming/quardCRT/macos_arm64.yml?branch=main&logo=apple
:target: https://github.com/QQxiaoming/quardCRT/actions/workflows/macos_arm64.yml
:alt: Macos ci
.. image:: https://img.shields.io/codefactor/grade/github/qqxiaoming/quardCRT.svg?logo=codefactor
:target: https://www.codefactor.io/repository/github/qqxiaoming/quardCRT
Expand Down
2 changes: 1 addition & 1 deletion lib/QGoodWindow/QGoodWindow/src/qgoodwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void QGoodWindow::setup()
#endif

#ifdef Q_OS_LINUX
qputenv("XDG_SESSION_TYPE", "xcb");
qputenv("XDG_SESSION_TYPE", "x11");
qputenv("QT_QPA_PLATFORM", "xcb");

int argc = 0;
Expand Down
1 change: 1 addition & 0 deletions lib/QGoodWindow/QGoodWindow/src/qgoodwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace QGoodWindowUtils
{
class NativeEventFilter;
}
#include <windows.h>
#endif

#if defined Q_OS_WIN || defined Q_OS_LINUX
Expand Down
56 changes: 56 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
pyRun = new PyRun(this);
#endif

m_mediaCaptureSession = new QMediaCaptureSession(this);
m_windowCapture = new QWindowCapture(this);
m_mediaRecorder = new QMediaRecorder(this);
m_mediaCaptureSession->setWindowCapture(m_windowCapture);
m_mediaCaptureSession->setRecorder(m_mediaRecorder);
m_mediaRecorder->setQuality(QMediaRecorder::HighQuality);

splitter = new QSplitter(Qt::Horizontal,this);
splitter->setHandleWidth(1);
ui->centralwidget->layout()->addWidget(splitter);
Expand Down Expand Up @@ -1710,6 +1717,9 @@ void CentralWidget::menuAndToolBarRetranslateUi(void) {
screenShotAction->setIcon(QFontIcon::icon(QChar(0xf03e)));
screenShotAction->setStatusTip(tr("Screen shot current screen <Alt+P>"));
screenShotAction->setShortcut(QKeySequence(Qt::ALT|Qt::Key_P));
screenCapturableAction->setText(tr("Screen Capturable"));
screenCapturableAction->setStatusTip(tr("Screen capturable current screen"));
screenCapturableAction->setShortcut(QKeySequence(Qt::ALT|Qt::Key_G));
sessionExportAction->setText(tr("Session Export"));
sessionExportAction->setIcon(QFontIcon::icon(QChar(0xf093)));
sessionExportAction->setStatusTip(tr("Export current session to a file <Alt+O>"));
Expand Down Expand Up @@ -2035,6 +2045,9 @@ void CentralWidget::menuAndToolBarInit(bool disable_plugin) {
ui->toolBar->addAction(printScreenAction);
screenShotAction = new QAction(this);
editMenu->addAction(screenShotAction);
screenCapturableAction = new QAction(this);
screenCapturableAction->setCheckable(true);
editMenu->addAction(screenCapturableAction);
sessionExportAction = new QAction(this);
editMenu->addAction(sessionExportAction);
editMenu->addSeparator();
Expand Down Expand Up @@ -2604,6 +2617,7 @@ void CentralWidget::setSessionClassActionEnable(bool enable)
findAction->setEnabled(enable);
printScreenAction->setEnabled(enable);
screenShotAction->setEnabled(enable);
screenCapturableAction->setEnabled(enable);
sessionExportAction->setEnabled(enable);
clearScrollbackAction->setEnabled(enable);
clearScreenAction->setEnabled(enable);
Expand Down Expand Up @@ -2928,6 +2942,48 @@ void CentralWidget::menuAndToolBarConnectSignals(void) {
settings.setValue("Global/Options/ScreenShotPath",QFileInfo(fileName).absolutePath());
ui->statusBar->showMessage(tr("Screenshot saved to %1").arg(fileName),3000);
});
connect(screenCapturableAction,&QAction::triggered,this,[=](){
if(!screenCapturableAction->isChecked()) {
m_mediaRecorder->stop();
m_windowCapture->stop();
ui->statusBar->showMessage(tr("ScreenCapturable stop."),3000);
} else {
QWidget *widget = findCurrentFocusWidget();
if(widget == nullptr) return;

QList<QCapturableWindow> windowList = QWindowCapture::capturableWindows();
bool find = false;
foreach(const QCapturableWindow &w, windowList) {
auto handle = QCapturableWindowPrivate::handle(w);
if(handle && handle->id == this->mainWindow->winId()) {
m_windowCapture->setWindow(w);
find = true;
break;
}
}
if(!find) {
screenCapturableAction->setChecked(false);
return;
}

GlobalSetting settings;
QString screenCapturablePath = settings.value("Global/Options/ScreenCapturablePath",QDir::homePath()).toString();
QString willsaveName = screenCapturablePath + "/quartCRT-" + QDateTime::currentDateTime().toString("yyyyMMddhhmmss") + ".mp4";
QString fileName = FileDialog::getSaveFileName(this,tr("Save Screenshot"),willsaveName,tr("Video Files (*.mp4)"));
if(fileName.isEmpty()) {
screenCapturableAction->setChecked(false);
return;
}
if(!fileName.endsWith(".mp4")) fileName.append(".mp4");

m_mediaRecorder->setOutputLocation(QUrl::fromLocalFile(fileName));
m_windowCapture->start();
m_mediaRecorder->record();

settings.setValue("Global/Options/ScreenCapturablePath",QFileInfo(fileName).absolutePath());
ui->statusBar->showMessage(tr("ScreenCapturable saved to %1").arg(fileName),3000);
}
});
connect(sessionExportAction,&QAction::triggered,this,[=](){
QWidget *widget = findCurrentFocusWidget();
if(widget == nullptr) return;
Expand Down
Loading

0 comments on commit 14f2c78

Please sign in to comment.