mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-29 04:36:21 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d38d22270 | ||
|
|
de007176d5 |
@@ -19,9 +19,14 @@ inputs:
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Setup cmake
|
||||
uses: jwlawson/actions-setup-cmake@v1.13
|
||||
with:
|
||||
cmake-version: '3.x.x'
|
||||
|
||||
- name: Restore cached dependencies
|
||||
id: restore-cache
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.DEP_DIR }}
|
||||
key: ${{ env.DEP_DIR }}-${{ runner.os }}-${{ inputs.target }}
|
||||
|
||||
2
.github/actions/run-clang-format/action.yaml
vendored
2
.github/actions/run-clang-format/action.yaml
vendored
@@ -29,7 +29,6 @@ runs:
|
||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
|
||||
echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH
|
||||
brew update
|
||||
brew install --quiet zsh
|
||||
echo ::endgroup::
|
||||
|
||||
@@ -53,7 +52,6 @@ runs:
|
||||
|
||||
if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) {
|
||||
echo ::group::Install clang-format-16
|
||||
brew update
|
||||
brew install --quiet obsproject/tools/clang-format@16
|
||||
echo ::endgroup::
|
||||
|
||||
|
||||
2
.github/scripts/.Wingetfile
vendored
2
.github/scripts/.Wingetfile
vendored
@@ -1,4 +1,4 @@
|
||||
package 'cmake', path: 'Cmake\bin', bin: 'cmake'
|
||||
package 'innosetup', path: 'Inno Setup 6', bin: 'iscc'
|
||||
package 'OpenSSL', path: 'OpenSSL', bin: 'openssl', version: '3.6.2'
|
||||
package 'OpenSSL', path: 'OpenSSL', bin: 'openssl'
|
||||
package 'Microsoft.VisualStudio.Locator', path: 'vswhere', bin: 'vswhere'
|
||||
35
.github/scripts/Package-Windows.ps1
vendored
35
.github/scripts/Package-Windows.ps1
vendored
@@ -68,44 +68,14 @@ function Package {
|
||||
|
||||
Remove-Item @RemoveArgs
|
||||
|
||||
# Build a staging directory with two subfolders:
|
||||
# recommended/ - new layout, extract to %ProgramData%\obs-studio\
|
||||
# legacy/ - old layout, extract to the OBS install directory
|
||||
$ReleasePath = "${ProjectRoot}/release/${Configuration}"
|
||||
$StagingPath = "${ProjectRoot}/release/zip-staging"
|
||||
$NewBinPath = "${ReleasePath}/${ProductName}/bin/64bit"
|
||||
$NewDataPath = "${ReleasePath}/${ProductName}/data"
|
||||
|
||||
Remove-Item -Path $StagingPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Force -Path $StagingPath | Out-Null
|
||||
Copy-Item -Path "${ProjectRoot}/build-aux/CI/windows/README.txt" -Destination "${StagingPath}/README.txt"
|
||||
|
||||
if ( Test-Path -Path $NewBinPath ) {
|
||||
$RecBinPath = "${StagingPath}/recommended/${ProductName}/bin/64bit"
|
||||
$LegacyBinPath = "${StagingPath}/legacy/obs-plugins/64bit"
|
||||
New-Item -ItemType Directory -Force -Path $RecBinPath | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $LegacyBinPath | Out-Null
|
||||
Copy-Item -Path "${NewBinPath}/*" -Destination $RecBinPath -Recurse -Force
|
||||
Copy-Item -Path "${NewBinPath}/*" -Destination $LegacyBinPath -Recurse -Force
|
||||
}
|
||||
if ( Test-Path -Path $NewDataPath ) {
|
||||
$RecDataPath = "${StagingPath}/recommended/${ProductName}/data"
|
||||
$LegacyDataPath = "${StagingPath}/legacy/data/obs-plugins/${ProductName}"
|
||||
New-Item -ItemType Directory -Force -Path $RecDataPath | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $LegacyDataPath | Out-Null
|
||||
Copy-Item -Path "${NewDataPath}/*" -Destination $RecDataPath -Recurse -Force
|
||||
Copy-Item -Path "${NewDataPath}/*" -Destination $LegacyDataPath -Recurse -Force
|
||||
}
|
||||
|
||||
Log-Group "Archiving ${ProductName}..."
|
||||
$CompressArgs = @{
|
||||
Path = (Get-ChildItem -Path $StagingPath)
|
||||
Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*")
|
||||
CompressionLevel = 'Optimal'
|
||||
DestinationPath = "${ProjectRoot}/release/${OutputName}.zip"
|
||||
Verbose = ($null -ne $Env:CI)
|
||||
Verbose = ($Env:CI -ne $null)
|
||||
}
|
||||
Compress-Archive -Force @CompressArgs
|
||||
Remove-Item -Path $StagingPath -Recurse -Force
|
||||
Log-Group
|
||||
|
||||
if ( ( $BuildInstaller ) ) {
|
||||
@@ -119,7 +89,6 @@ function Package {
|
||||
Log-Information 'Creating InnoSetup installer...'
|
||||
Push-Location -Stack BuildTemp
|
||||
Ensure-Location -Path "${ProjectRoot}/release"
|
||||
Remove-Item -Path Package -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Copy-Item -Path ${Configuration} -Destination Package -Recurse
|
||||
Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer"
|
||||
Remove-Item -Path Package -Recurse
|
||||
|
||||
1
.github/scripts/utils.zsh/check_macos
vendored
1
.github/scripts/utils.zsh/check_macos
vendored
@@ -18,5 +18,4 @@ if (( ! ${+commands[brew]} )) {
|
||||
}
|
||||
|
||||
brew bundle --file ${SCRIPT_HOME}/.Brewfile
|
||||
rehash
|
||||
log_group
|
||||
|
||||
4
.github/workflows/build-debian.yml
vendored
4
.github/workflows/build-debian.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: "recursive"
|
||||
- name: check_libobs_revision
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
mv ../*.deb .
|
||||
- name: Publish
|
||||
if: success()
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: "obs-scene-switcher.deb"
|
||||
path: ${{ github.workspace }}/*.deb
|
||||
|
||||
34
.github/workflows/build-project.yaml
vendored
34
.github/workflows/build-project.yaml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
description: "Project name detected by parsing build spec file"
|
||||
value: ${{ jobs.check-event.outputs.pluginName }}
|
||||
env:
|
||||
DEP_DIR: .deps/advss-build-dependencies-5
|
||||
DEP_DIR: .deps/advss-build-dependencies-4
|
||||
jobs:
|
||||
check-event:
|
||||
name: Check GitHub Event Data 🔎
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
commitHash: ${{ steps.setup.outputs.commitHash }}
|
||||
pluginName: ${{ steps.setup.outputs.pluginName }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check Event Data ☑️
|
||||
@@ -81,7 +81,7 @@ jobs:
|
||||
run:
|
||||
shell: zsh --no-rcs --errexit --pipefail {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
sudo xcode-select --switch /Applications/Xcode_16.1.0.app/Contents/Developer
|
||||
print '::endgroup::'
|
||||
|
||||
- uses: actions/cache@v5
|
||||
- uses: actions/cache@v4
|
||||
id: ccache-cache
|
||||
with:
|
||||
path: ${{ github.workspace }}/.ccache
|
||||
@@ -163,13 +163,13 @@ jobs:
|
||||
codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
|
||||
|
||||
- name: Upload Artifacts 📡
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-macos-universal.*
|
||||
|
||||
- name: Upload Debug Symbol Artifacts 🪲
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ needs.check-event.outputs.config == 'Release' }}
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
|
||||
@@ -183,7 +183,7 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
@@ -202,7 +202,7 @@ jobs:
|
||||
echo "pluginName=${product_name}" >> $GITHUB_OUTPUT
|
||||
echo "pluginVersion=${git_tag}" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v5
|
||||
- uses: actions/cache@v4
|
||||
id: ccache-cache
|
||||
with:
|
||||
path: ${{ github.workspace }}/.ccache
|
||||
@@ -210,8 +210,13 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-ccache-x86_64-
|
||||
|
||||
- name: Set up CMake 🏗️
|
||||
uses: jwlawson/actions-setup-cmake@v1.13
|
||||
with:
|
||||
cmake-version: '3.x.x'
|
||||
|
||||
- name: Set up Homebrew 🍺
|
||||
uses: Homebrew/actions/setup-homebrew@main
|
||||
uses: Homebrew/actions/setup-homebrew@master
|
||||
|
||||
- name: Build Plugin 🧱
|
||||
uses: ./.github/actions/build-plugin
|
||||
@@ -233,24 +238,23 @@ jobs:
|
||||
config: ${{ needs.check-event.outputs.config }}
|
||||
|
||||
- name: Upload Source Tarball 🗜️
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-source.*
|
||||
|
||||
- name: Upload Artifacts 📡
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-24.04-x86_64-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-x86_64*.*
|
||||
|
||||
- name: Upload debug symbol artifacts 🪲
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ fromJSON(needs.check-event.outputs.package) }}
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-24.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-x86_64*-dbgsym.ddeb
|
||||
if-no-files-found: ignore
|
||||
|
||||
windows-build:
|
||||
name: Build for Windows 🪟
|
||||
@@ -260,7 +264,7 @@ jobs:
|
||||
run:
|
||||
shell: pwsh
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
@@ -307,7 +311,7 @@ jobs:
|
||||
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
||||
|
||||
- name: Upload Artifacts 📡
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-windows-x64*.*
|
||||
|
||||
4
.github/workflows/check-format.yaml
vendored
4
.github/workflows/check-format.yaml
vendored
@@ -5,7 +5,7 @@ jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: clang-format check 🐉
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
cmake-format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: cmake-format check 🎛️
|
||||
|
||||
2
.github/workflows/locale-check.yml
vendored
2
.github/workflows/locale-check.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check locale files
|
||||
run: |
|
||||
|
||||
4
.github/workflows/push.yaml
vendored
4
.github/workflows/push.yaml
vendored
@@ -59,7 +59,7 @@ jobs:
|
||||
esac
|
||||
|
||||
- name: Download Build Artifacts 📥
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
if: fromJSON(steps.check.outputs.validTag)
|
||||
id: download
|
||||
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
- name: Create Release 🛫
|
||||
if: fromJSON(steps.check.outputs.validTag)
|
||||
id: create_release
|
||||
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda
|
||||
uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b
|
||||
with:
|
||||
draft: true
|
||||
prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }}
|
||||
|
||||
@@ -134,9 +134,6 @@ target_sources(
|
||||
lib/macro/macro-dock-window.hpp
|
||||
lib/macro/macro-edit.cpp
|
||||
lib/macro/macro-edit.hpp
|
||||
lib/macro/macro-export-builtin-extensions.cpp
|
||||
lib/macro/macro-export-extensions.cpp
|
||||
lib/macro/macro-export-extensions.hpp
|
||||
lib/macro/macro-export-import-dialog.cpp
|
||||
lib/macro/macro-export-import-dialog.hpp
|
||||
lib/macro/macro-helpers.cpp
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
Advanced Scene Switcher - Windows Installation
|
||||
==============================================
|
||||
|
||||
For full installation instructions visit:
|
||||
https://github.com/WarmUpTill/SceneSwitcher/wiki/Installation
|
||||
|
||||
|
||||
Quick guide
|
||||
-----------
|
||||
|
||||
This archive contains two installation methods.
|
||||
Choose ONE depending on your OBS version.
|
||||
|
||||
|
||||
recommended\ (preferred)
|
||||
---------------------------------------------
|
||||
Extract the CONTENTS of this folder into:
|
||||
|
||||
C:\ProgramData\obs-studio\
|
||||
|
||||
Tip: press Win+R and type %ProgramData%\obs-studio\plugins to open that folder.
|
||||
|
||||
After extracting, the path should look like:
|
||||
C:\ProgramData\obs-studio\plugins\advanced-scene-switcher\bin\64bit\advanced-scene-switcher.dll
|
||||
|
||||
|
||||
legacy\ (older OBS versions, portable OBS installs, or if the recommended method does not work)
|
||||
---------------------------------------------------------------------------
|
||||
Extract the CONTENTS of this folder into your OBS installation directory,
|
||||
typically:
|
||||
|
||||
C:\Program Files\obs-studio\
|
||||
|
||||
Merge the data\ and obs-plugins\ folders with the existing ones when prompted.
|
||||
|
||||
Steam users: right-click OBS in your library -> Manage -> Browse local files,
|
||||
then extract the contents of legacy\ into that directory.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
if(BUILD_OUT_OF_TREE)
|
||||
if(OS_WINDOWS)
|
||||
set(OBS_PLUGIN_DESTINATION "${CMAKE_PROJECT_NAME}/bin/64bit")
|
||||
set(OBS_PLUGIN_DESTINATION "obs-plugins/64bit")
|
||||
else()
|
||||
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
|
||||
endif()
|
||||
|
||||
@@ -18,9 +18,7 @@ set(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_C_LIBRARY_ARCHITECTURE}"
|
||||
)
|
||||
|
||||
set(CPACK_GENERATOR
|
||||
"DEB"
|
||||
CACHE STRING "CPack generator to use")
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PLUGIN_EMAIL}")
|
||||
set(CPACK_SET_DESTDIR ON)
|
||||
@@ -48,19 +46,6 @@ set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
||||
set(CPACK_ARCHIVE_THREADS 0)
|
||||
|
||||
include(CPack)
|
||||
# CPack.cmake has a side effect that leaves binary packaging variables in the
|
||||
# state intended for source packaging when it finishes. Specifically it sets
|
||||
# CPACK_GENERATOR to CPACK_SOURCE_GENERATOR ("TXZ"), sets
|
||||
# CPACK_INSTALLED_DIRECTORIES to the source root (which would cause CPackDeb to
|
||||
# scan the entire source tree, including ccache object files that lack a Build
|
||||
# ID), and clears CPACK_INSTALL_CMAKE_PROJECTS (preventing the cmake install
|
||||
# mechanism from being used). In some cmake versions these overrides happen
|
||||
# before CPackConfig.cmake is written. Reset all three so that binary DEB
|
||||
# packaging works correctly regardless of cmake version.
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
set(CPACK_INSTALLED_DIRECTORIES "")
|
||||
set(CPACK_INSTALL_CMAKE_PROJECTS
|
||||
"${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
|
||||
|
||||
find_package(libobs QUIET)
|
||||
|
||||
|
||||
@@ -6,9 +6,3 @@ include_guard(GLOBAL)
|
||||
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
|
||||
|
||||
include(buildspec)
|
||||
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX
|
||||
"$ENV{ALLUSERSPROFILE}/obs-studio/plugins"
|
||||
CACHE STRING "Default plugin installation directory" FORCE)
|
||||
endif()
|
||||
|
||||
@@ -30,13 +30,13 @@ function(set_target_properties_plugin target)
|
||||
|
||||
install(
|
||||
TARGETS ${target}
|
||||
RUNTIME DESTINATION "${target}/bin/64bit"
|
||||
LIBRARY DESTINATION "${target}/bin/64bit")
|
||||
RUNTIME DESTINATION bin/64bit
|
||||
LIBRARY DESTINATION obs-plugins/64bit)
|
||||
|
||||
install(
|
||||
FILES "$<TARGET_PDB_FILE:${target}>"
|
||||
CONFIGURATIONS RelWithDebInfo Debug Release
|
||||
DESTINATION "${target}/bin/64bit"
|
||||
DESTINATION obs-plugins/64bit
|
||||
OPTIONAL)
|
||||
|
||||
if(OBS_BUILD_DIR)
|
||||
@@ -44,11 +44,11 @@ function(set_target_properties_plugin target)
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory
|
||||
"${OBS_BUILD_DIR}/plugins/${target}/bin/64bit"
|
||||
"${OBS_BUILD_DIR}/obs-plugins/64bit"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${target}>"
|
||||
"$<$<CONFIG:Debug,RelWithDebInfo,Release>:$<TARGET_PDB_FILE:${target}>>"
|
||||
"${OBS_BUILD_DIR}/plugins/${target}/bin/64bit"
|
||||
"${OBS_BUILD_DIR}/obs-plugins/64bit"
|
||||
COMMENT "Copy ${target} to obs-studio directory ${OBS_BUILD_DIR}"
|
||||
VERBATIM)
|
||||
endif()
|
||||
@@ -105,7 +105,7 @@ function(target_install_resources target)
|
||||
|
||||
install(
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
|
||||
DESTINATION "${target}/data"
|
||||
DESTINATION data/obs-plugins/${target}
|
||||
USE_SOURCE_PERMISSIONS)
|
||||
|
||||
if(OBS_BUILD_DIR)
|
||||
@@ -113,11 +113,11 @@ function(target_install_resources target)
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory
|
||||
"${OBS_BUILD_DIR}/plugins/${target}/data"
|
||||
"${OBS_BUILD_DIR}/data/obs-plugins/${target}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E copy_directory
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/data"
|
||||
"${OBS_BUILD_DIR}/plugins/${target}/data"
|
||||
"${OBS_BUILD_DIR}/data/obs-plugins/${target}"
|
||||
COMMENT "Copy ${target} resources to data directory"
|
||||
VERBATIM)
|
||||
endif()
|
||||
@@ -133,7 +133,7 @@ function(target_add_resource target resource)
|
||||
|
||||
install(
|
||||
FILES "${resource}"
|
||||
DESTINATION "${target}/data"
|
||||
DESTINATION data/obs-plugins/${target}
|
||||
COMPONENT Runtime)
|
||||
|
||||
if(OBS_BUILD_DIR)
|
||||
@@ -141,9 +141,9 @@ function(target_add_resource target resource)
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory
|
||||
"${OBS_BUILD_DIR}/plugins/${target}/data"
|
||||
"${OBS_BUILD_DIR}/data/obs-plugins/${target}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${resource}"
|
||||
"${OBS_BUILD_DIR}/plugins/${target}/data"
|
||||
"${OBS_BUILD_DIR}/data/obs-plugins/${target}"
|
||||
COMMENT "Copy ${target} resource ${resource} to library directory"
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
#define MyAppVersion "@CMAKE_PROJECT_VERSION@"
|
||||
#define MyAppPublisher "@PLUGIN_AUTHOR@"
|
||||
#define MyAppURL "@PLUGIN_WEBSITE@"
|
||||
#define MyAppId "@UUID_APP@"
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application.
|
||||
; Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{{#MyAppId}}
|
||||
AppId={{@UUID_APP@}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
@@ -21,9 +20,8 @@ OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
DirExistsWarning=no
|
||||
UsePreviousAppDir=no
|
||||
SetupIconFile=installer.ico
|
||||
UninstallDisplayIcon={app}\advanced-scene-switcher\data\res\images\logo.ico
|
||||
UninstallDisplayIcon={app}\data\obs-plugins\advanced-scene-switcher\res\images\logo.ico
|
||||
DisableDirPage=no
|
||||
|
||||
[Languages]
|
||||
@@ -53,34 +51,17 @@ begin
|
||||
);
|
||||
end;
|
||||
|
||||
// credit where it's due :
|
||||
// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45
|
||||
function GetDirName(Value: string): string;
|
||||
begin
|
||||
Result := ExpandConstant('{commonappdata}\obs-studio\plugins');
|
||||
end;
|
||||
|
||||
// Remove files placed by the legacy installer (obs-plugins/64bit and
|
||||
// data/obs-plugins layout) so the plugin is not loaded twice by OBS.
|
||||
// We read InstallLocation from our own previous uninstall entry, which is
|
||||
// the exact directory the old installer used regardless of OBS install path.
|
||||
procedure RemoveLegacyFiles();
|
||||
var
|
||||
OldInstallPath: string;
|
||||
UninstallKey: string;
|
||||
InstallPath: string;
|
||||
begin
|
||||
UninstallKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + '{' + '{#MyAppId}' + '}_is1';
|
||||
if not RegQueryStringValue(HKLM, UninstallKey, 'InstallLocation', OldInstallPath) then
|
||||
Exit;
|
||||
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher.dll');
|
||||
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher.pdb');
|
||||
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-lib.dll');
|
||||
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-lib.pdb');
|
||||
DelTree(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-plugins', True, True, True);
|
||||
DelTree(OldInstallPath + '\data\obs-plugins\advanced-scene-switcher', True, True, True);
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
if CurStep = ssInstall then
|
||||
RemoveLegacyFiles();
|
||||
// initialize default path, which will be returned when the following registry
|
||||
// key queries fail due to missing keys or for some different reason
|
||||
Result := '{autopf}\obs-studio';
|
||||
// query the first registry value; if this succeeds, return the obtained value
|
||||
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
|
||||
Result := InstallPath
|
||||
end;
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ AdvSceneSwitcher.macroList.deleted="gelöscht"
|
||||
AdvSceneSwitcher.macroList.duplicate="\"%1\" ist bereits ausgewählt!"
|
||||
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Eintrag ignorieren"
|
||||
AdvSceneSwitcher.logic.and="Und"
|
||||
AdvSceneSwitcher.logic.or="Oder"
|
||||
AdvSceneSwitcher.logic.andNot="Und nicht"
|
||||
|
||||
@@ -47,13 +47,6 @@ AdvSceneSwitcher.generalTab.generalBehavior.hideLegacyTabs="Hide tabs which can
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowMacroSearch="Always show macro search"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs="Always show all feature tabs"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs.tooltip="Show tabs that are normally hidden until first used in a macro (e.g. Action Queues, Variables, Twitch, Websockets)."
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock="Lock settings dialog with password"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title="Settings Locked"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordLabel="Enter password:"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.wrongPassword="Wrong password!"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.newPasswordLabel="New password:"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.confirmPasswordLabel="Confirm password:"
|
||||
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordMismatch="Passwords do not match!"
|
||||
AdvSceneSwitcher.generalTab.matchBehavior="Match behavior"
|
||||
AdvSceneSwitcher.generalTab.priority="Priority"
|
||||
AdvSceneSwitcher.generalTab.priority.description="Switching methods priority (Highest priority is at the top)"
|
||||
@@ -209,13 +202,6 @@ AdvSceneSwitcher.macroTab.remove="Remove"
|
||||
AdvSceneSwitcher.macroTab.export="Export"
|
||||
AdvSceneSwitcher.macroTab.export.info="Paste the string below into the import dialog to import the selected macros:"
|
||||
AdvSceneSwitcher.macroTab.export.usePlainText="Use plain text"
|
||||
AdvSceneSwitcher.macroTab.export.additionalContent="Export Additional Content"
|
||||
AdvSceneSwitcher.macroTab.export.variables="Variables"
|
||||
AdvSceneSwitcher.macroTab.export.actionQueues="Action Queues"
|
||||
AdvSceneSwitcher.macroTab.export.httpServers="HTTP Servers"
|
||||
AdvSceneSwitcher.macroTab.export.macroScheduleEntries="Macro Schedule"
|
||||
AdvSceneSwitcher.macroTab.export.twitchConnections="Twitch Connections"
|
||||
AdvSceneSwitcher.macroTab.export.websocketConnections="Websocket Connections"
|
||||
AdvSceneSwitcher.macroTab.import="Import"
|
||||
AdvSceneSwitcher.macroTab.import.info="Paste the export string into the below text box to import macros:"
|
||||
AdvSceneSwitcher.macroTab.import.invalid="Invalid import data provided!"
|
||||
@@ -320,6 +306,7 @@ AdvSceneSwitcher.macroList.deleted="deleted"
|
||||
AdvSceneSwitcher.macroList.duplicate="\"%1\" is alreay selected!"
|
||||
|
||||
# Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Ignore entry"
|
||||
AdvSceneSwitcher.logic.and="And"
|
||||
AdvSceneSwitcher.logic.or="Or"
|
||||
AdvSceneSwitcher.logic.andNot="And not"
|
||||
@@ -869,7 +856,6 @@ AdvSceneSwitcher.condition.streamDeck.stopListen="Stop listening"
|
||||
AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>"
|
||||
AdvSceneSwitcher.condition.gameCapture="Game capture"
|
||||
AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game."
|
||||
|
||||
AdvSceneSwitcher.condition.screenshot="Screenshot"
|
||||
AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken"
|
||||
AdvSceneSwitcher.condition.mqtt="MQTT"
|
||||
@@ -1090,8 +1076,8 @@ AdvSceneSwitcher.action.macro.type.runActions="Run macro actions"
|
||||
AdvSceneSwitcher.action.macro.type.run.conditions.ignore="Do not consider condition state"
|
||||
AdvSceneSwitcher.action.macro.type.run.conditions.true="Only if conditions evaluate to true"
|
||||
AdvSceneSwitcher.action.macro.type.run.conditions.false="Only if conditions evaluate to false"
|
||||
AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState="Check conditions now, even if macro is paused"
|
||||
AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState.help="The plugin operates in phases:\n * The phase evaluating the macro conditions\n * The phase running macro actions\nMacros executed before this particular action might have side effects on the condition state of macros.\nAdditionally, paused macros are assumed to not match their conditions.\nCheck this option to force a fresh condition evaluation before running this action, regardless of whether the macro is paused."
|
||||
AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState="Reevaluate the condition state before executing this action"
|
||||
AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState.help="The plugin operates in phases:\n * The phase evaluating the macro conditions\n * The phase running macro actions\nMacros executed before this particular action might have side effects on the condition state of macros.\nCheck this option if you want those side effects to be taken into account when evaluating the condition state."
|
||||
AdvSceneSwitcher.action.macro.type.run.actionType.regular="actions"
|
||||
AdvSceneSwitcher.action.macro.type.run.actionType.else="else-actions"
|
||||
AdvSceneSwitcher.action.macro.type.run.skipWhenPaused="Skip execution when macro is paused"
|
||||
@@ -2294,14 +2280,6 @@ AdvSceneSwitcher.tempVar.scene.position="Position in scenes list"
|
||||
|
||||
AdvSceneSwitcher.tempVar.window.window="Window title"
|
||||
AdvSceneSwitcher.tempVar.window.window.description="The window title of the matching window."
|
||||
AdvSceneSwitcher.tempVar.window.windowX="Window X position"
|
||||
AdvSceneSwitcher.tempVar.window.windowX.description="The X position (left edge) of the matching window in screen coordinates."
|
||||
AdvSceneSwitcher.tempVar.window.windowY="Window Y position"
|
||||
AdvSceneSwitcher.tempVar.window.windowY.description="The Y position (top edge) of the matching window in screen coordinates."
|
||||
AdvSceneSwitcher.tempVar.window.windowWidth="Window width"
|
||||
AdvSceneSwitcher.tempVar.window.windowWidth.description="The width of the matching window in pixels."
|
||||
AdvSceneSwitcher.tempVar.window.windowHeight="Window height"
|
||||
AdvSceneSwitcher.tempVar.window.windowHeight.description="The height of the matching window in pixels."
|
||||
AdvSceneSwitcher.tempVar.window.windowClass="Window class"
|
||||
AdvSceneSwitcher.tempVar.window.windowClass.description="The window class of the matching window."
|
||||
AdvSceneSwitcher.tempVar.window.windowText="Window text"
|
||||
@@ -2367,14 +2345,6 @@ AdvSceneSwitcher.tempVar.video.similarity="Similarity Rating"
|
||||
AdvSceneSwitcher.tempVar.video.similarity.description="Values range from 0 to 1, where 0 means dissimilar and 1 means highly similar."
|
||||
AdvSceneSwitcher.tempVar.video.patternCount="Pattern count"
|
||||
AdvSceneSwitcher.tempVar.video.patternCount.description="The number of times the given pattern has been found in a given video input frame."
|
||||
AdvSceneSwitcher.tempVar.video.matchX="Match X coordinate"
|
||||
AdvSceneSwitcher.tempVar.video.matchX.description="The X coordinate of the top-left corner of the best pattern match.\nIf the 'check area' option is enabled, the coordinate is relative to the video source, not the area.\nSet to -1 if no match was found."
|
||||
AdvSceneSwitcher.tempVar.video.matchY="Match Y coordinate"
|
||||
AdvSceneSwitcher.tempVar.video.matchY.description="The Y coordinate of the top-left corner of the best pattern match.\nIf the 'check area' option is enabled, the coordinate is relative to the video source, not the area.\nSet to -1 if no match was found."
|
||||
AdvSceneSwitcher.tempVar.video.matchWidth="Match width"
|
||||
AdvSceneSwitcher.tempVar.video.matchWidth.description="The width of the matched pattern in pixels."
|
||||
AdvSceneSwitcher.tempVar.video.matchHeight="Match height"
|
||||
AdvSceneSwitcher.tempVar.video.matchHeight.description="The height of the matched pattern in pixels."
|
||||
AdvSceneSwitcher.tempVar.video.objectCount="Object count"
|
||||
AdvSceneSwitcher.tempVar.video.objectCount.description="The number of objects the given model has identified in a given video input frame."
|
||||
AdvSceneSwitcher.tempVar.video.brightness="Average brightness"
|
||||
@@ -2568,9 +2538,6 @@ AdvSceneSwitcher.selectDisplay="--select display--"
|
||||
AdvSceneSwitcher.invaildEntriesWillNotBeSaved="invalid entries will not be saved"
|
||||
AdvSceneSwitcher.selectWindowTip="Use \"OBS\" to specify OBS window\nUse \"Task Switching\"to specify ALT + TAB"
|
||||
|
||||
AdvSceneSwitcher.keepSourceActive="Keep source active"
|
||||
AdvSceneSwitcher.keepSourceActive.help="When a source is not visible in the active scene it becomes inactive, which can cause it to stop producing output (e.g. video frames or game capture hooks).\nEnabling this option forces the source to remain active at all times, ensuring it continues to produce output even when not displayed.\n\nNote: Keeping a source permanently active may increase CPU and GPU usage, as the source continues to run even when not shown."
|
||||
|
||||
AdvSceneSwitcher.settings.suffix.type.invalid=" (Invalid)"
|
||||
AdvSceneSwitcher.settings.suffix.type.bool=" (Bool)"
|
||||
AdvSceneSwitcher.settings.suffix.type.int=" (Int)"
|
||||
@@ -2738,64 +2705,6 @@ Basic.Settings.Video.FPSCommon="Common FPS Values"
|
||||
Basic.Settings.Video.FPSInteger="Integer FPS Value"
|
||||
Basic.Settings.Video.FPSFraction="Fractional FPS Value"
|
||||
|
||||
# Calendar widget
|
||||
AdvSceneSwitcher.calendar.today="Today"
|
||||
AdvSceneSwitcher.calendar.month="Month"
|
||||
AdvSceneSwitcher.calendar.week="Week"
|
||||
AdvSceneSwitcher.calendar.day="Day"
|
||||
AdvSceneSwitcher.calendar.moreEvents="+%1 more"
|
||||
|
||||
# Macro Schedule tab
|
||||
AdvSceneSwitcher.macroScheduleTab.title="Macro Schedule"
|
||||
AdvSceneSwitcher.macroScheduleTab.help="No scheduled entries.\nClick '+' to schedule a macro."
|
||||
AdvSceneSwitcher.macroScheduleTab.add="Add"
|
||||
AdvSceneSwitcher.macroScheduleTab.add.tooltip="Add schedule entry"
|
||||
AdvSceneSwitcher.macroScheduleTab.edit="Edit"
|
||||
AdvSceneSwitcher.macroScheduleTab.remove="Remove"
|
||||
AdvSceneSwitcher.macroScheduleTab.remove.tooltip="Remove schedule entry"
|
||||
AdvSceneSwitcher.macroScheduleTab.enable="Enable"
|
||||
AdvSceneSwitcher.macroScheduleTab.disable="Disable"
|
||||
AdvSceneSwitcher.macroScheduleTab.showAll="Show All"
|
||||
AdvSceneSwitcher.macroScheduleTab.column.name="Name"
|
||||
AdvSceneSwitcher.macroScheduleTab.column.macro="Macro"
|
||||
AdvSceneSwitcher.macroScheduleTab.column.schedule="Schedule"
|
||||
AdvSceneSwitcher.macroScheduleTab.column.nextTrigger="Next Trigger"
|
||||
AdvSceneSwitcher.macroScheduleTab.column.status="Status"
|
||||
AdvSceneSwitcher.macroScheduleTab.remove.confirm="Are you sure you want to remove \"%1\"?"
|
||||
AdvSceneSwitcher.macroScheduleTab.remove.confirmMultiple="Are you sure you want to remove %1 entries?"
|
||||
AdvSceneSwitcher.macroScheduleTab.status.active="Active"
|
||||
AdvSceneSwitcher.macroScheduleTab.status.disabled="Disabled"
|
||||
AdvSceneSwitcher.macroScheduleTab.status.expired="Expired"
|
||||
|
||||
# Macro Schedule entry dialog
|
||||
AdvSceneSwitcher.macroScheduleEntry.dialog.title.add="Add Schedule Entry"
|
||||
AdvSceneSwitcher.macroScheduleEntry.dialog.title.edit="Edit Schedule Entry"
|
||||
AdvSceneSwitcher.macroScheduleEntry.name="Name (optional):"
|
||||
AdvSceneSwitcher.macroScheduleEntry.name.placeholder="e.g. Daily stream start"
|
||||
AdvSceneSwitcher.macroScheduleEntry.macro="Macro:"
|
||||
AdvSceneSwitcher.macroScheduleEntry.startDateTime="Start:"
|
||||
AdvSceneSwitcher.macroScheduleEntry.endDate="End date:"
|
||||
AdvSceneSwitcher.macroScheduleEntry.endDate.help="Controls how far the entry spans visually in the calendar and optionally triggers an action when the date is reached."
|
||||
AdvSceneSwitcher.macroScheduleEntry.endDate.action.none="No action"
|
||||
AdvSceneSwitcher.macroScheduleEntry.endDate.action.disableEntry="Disable schedule entry"
|
||||
AdvSceneSwitcher.macroScheduleEntry.endDate.action.pauseMacro="Pause macro"
|
||||
AdvSceneSwitcher.macroScheduleEntry.endDate.action.stopMacro="Stop macro"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeat="Repeat"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeat.once="Once"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeat.every="Every %1"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeat.interval="Repeat interval:"
|
||||
AdvSceneSwitcher.macroScheduleEntry.noMacro="(no macro)"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeatEnd="End repeat:"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.never="Never"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.afterNTimes="After"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.afterNTimes.suffix="occurrence(s)"
|
||||
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.untilDate="Until"
|
||||
AdvSceneSwitcher.macroScheduleEntry.color="Color:"
|
||||
AdvSceneSwitcher.macroScheduleEntry.color.dialog="Pick entry color"
|
||||
AdvSceneSwitcher.macroScheduleEntry.checkConditions="Check macro conditions before running"
|
||||
AdvSceneSwitcher.macroScheduleEntry.runElseActionsOnConditionFailure="Run else actions if conditions are not met"
|
||||
AdvSceneSwitcher.macroScheduleEntry.enabled="Enabled"
|
||||
|
||||
# Legacy tabs below - please don't waste your time adding translations for these :)
|
||||
# Transition Tab
|
||||
AdvSceneSwitcher.transitionTab.title="Transition"
|
||||
|
||||
@@ -83,6 +83,7 @@ AdvSceneSwitcher.macroTab.highlightTrueConditions="Resaltar condiciones de la ma
|
||||
AdvSceneSwitcher.macroTab.highlightPerformedActions="Resaltar acciones realizadas recientemente de la macro seleccionada actualmente"
|
||||
|
||||
; Lógica de macros
|
||||
AdvSceneSwitcher.logic.none="Omitir entrada"
|
||||
AdvSceneSwitcher.logic.and="Y"
|
||||
AdvSceneSwitcher.logic.or="O"
|
||||
AdvSceneSwitcher.logic.andNot="Y no"
|
||||
|
||||
@@ -131,6 +131,7 @@ AdvSceneSwitcher.macroList.deleted="supprimé"
|
||||
AdvSceneSwitcher.macroList.duplicate="\"%1\" est déjà sélectionné !"
|
||||
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Ignorer l'entrée"
|
||||
AdvSceneSwitcher.logic.and="Et"
|
||||
AdvSceneSwitcher.logic.or="Ou"
|
||||
AdvSceneSwitcher.logic.andNot="Et pas"
|
||||
|
||||
@@ -275,6 +275,7 @@ AdvSceneSwitcher.macroList.deleted="削除"
|
||||
AdvSceneSwitcher.macroList.duplicate="\"%1\" はすでに選択されています!"
|
||||
|
||||
# Macro Logic
|
||||
AdvSceneSwitcher.logic.none="入力無視"
|
||||
; AdvSceneSwitcher.logic.and="And"
|
||||
; AdvSceneSwitcher.logic.or="Or"
|
||||
; AdvSceneSwitcher.logic.andNot="And not"
|
||||
|
||||
@@ -239,6 +239,7 @@ AdvSceneSwitcher.macroList.deleted="excluída"
|
||||
AdvSceneSwitcher.macroList.duplicate="\"%1\" já está selecionada!"
|
||||
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Ignorar entrada"
|
||||
AdvSceneSwitcher.logic.and="E"
|
||||
AdvSceneSwitcher.logic.or="Ou"
|
||||
AdvSceneSwitcher.logic.andNot="E não"
|
||||
|
||||
@@ -70,6 +70,7 @@ AdvSceneSwitcher.macroTab.name="Имя:"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Макрос %1"
|
||||
AdvSceneSwitcher.macroTab.copy="Создать копию"
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Игнорировать вход"
|
||||
AdvSceneSwitcher.logic.and="И"
|
||||
AdvSceneSwitcher.logic.or="Или"
|
||||
AdvSceneSwitcher.logic.andNot="И не"
|
||||
|
||||
@@ -78,6 +78,7 @@ AdvSceneSwitcher.macroTab.expandAll="Hepsini Genişlet"
|
||||
AdvSceneSwitcher.macroTab.collapseAll="Hepsini Küçült"
|
||||
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Girişi yoksay"
|
||||
AdvSceneSwitcher.logic.and="Ve"
|
||||
AdvSceneSwitcher.logic.or="Ya da"
|
||||
AdvSceneSwitcher.logic.andNot="ve değil"
|
||||
|
||||
@@ -259,6 +259,7 @@ AdvSceneSwitcher.macroList.deleted="删除"
|
||||
AdvSceneSwitcher.macroList.duplicate="\"%1\" 已选择!"
|
||||
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="忽略条件"
|
||||
AdvSceneSwitcher.logic.and="且"
|
||||
AdvSceneSwitcher.logic.or="或"
|
||||
AdvSceneSwitcher.logic.andNot="且不"
|
||||
|
||||
2
deps/cpp-httplib
vendored
2
deps/cpp-httplib
vendored
Submodule deps/cpp-httplib updated: 811dd0b6f2...c7ed1796a7
2
deps/leptonica
vendored
2
deps/leptonica
vendored
Submodule deps/leptonica updated: 13275a278e...b667978e86
2
deps/libusb
vendored
2
deps/libusb
vendored
Submodule deps/libusb updated: bc368fb133...15a7ebb4d4
@@ -258,13 +258,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="settingsLock">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.generalBehavior.settingsLock</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QAction>
|
||||
#include <QDirIterator>
|
||||
#include <QInputDialog>
|
||||
#include <QLibrary>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
#include <regex>
|
||||
|
||||
@@ -43,12 +41,9 @@ AdvSceneSwitcher::AdvSceneSwitcher(QWidget *parent)
|
||||
{
|
||||
switcher->settingsWindowOpened = true;
|
||||
ui->setupUi(this);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->Prune();
|
||||
LoadUI();
|
||||
}
|
||||
CheckFirstTimeSetup();
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->Prune();
|
||||
LoadUI();
|
||||
}
|
||||
|
||||
AdvSceneSwitcher::~AdvSceneSwitcher()
|
||||
@@ -144,6 +139,7 @@ void AdvSceneSwitcher::LoadUI()
|
||||
SetTabOrder(ui->tabWidget);
|
||||
SetCurrentTab(ui->tabWidget);
|
||||
RestoreWindowGeo();
|
||||
CheckFirstTimeSetup();
|
||||
|
||||
loading = false;
|
||||
}
|
||||
@@ -510,8 +506,6 @@ bool SwitcherData::AnySceneTransitionStarted()
|
||||
******************************************************************************/
|
||||
extern "C" EXPORT void FreeSceneSwitcher()
|
||||
{
|
||||
switcher->Stop();
|
||||
|
||||
PlatformCleanup();
|
||||
RunPluginCleanupSteps();
|
||||
|
||||
@@ -633,20 +627,13 @@ static void handleSceneCollectionCleanup()
|
||||
return;
|
||||
}
|
||||
|
||||
// OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP is also called on
|
||||
// shutdown.
|
||||
// Here we also don't want to clear the settings.
|
||||
if (switcher->obsIsShuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
SaveSceneSwitcher(nullptr, false, nullptr);
|
||||
}
|
||||
|
||||
// Note to future self:
|
||||
// be careful using switcher->m here as there is potential for deadlocks when using
|
||||
// frontend functions such as obs_frontend_set_current_scene()
|
||||
static void OBSEvent(enum obs_frontend_event event, void *)
|
||||
static void OBSEvent(enum obs_frontend_event event, void *switcher)
|
||||
{
|
||||
if (!switcher) {
|
||||
return;
|
||||
@@ -720,54 +707,19 @@ static void LoadPlugins()
|
||||
}
|
||||
}
|
||||
|
||||
static bool settingsPasswordIsCorrect(QWidget *parent)
|
||||
{
|
||||
bool ok;
|
||||
QString input = QInputDialog::getText(
|
||||
parent,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordLabel"),
|
||||
QLineEdit::Password, QString(), &ok);
|
||||
|
||||
if (!ok) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.toStdString() == switcher->settingsLockPassword) {
|
||||
return true;
|
||||
}
|
||||
|
||||
QMessageBox::warning(
|
||||
parent,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.wrongPassword"));
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenSettingsWindow()
|
||||
{
|
||||
if (switcher->settingsWindowOpened) {
|
||||
AdvSceneSwitcher::window->show();
|
||||
AdvSceneSwitcher::window->raise();
|
||||
AdvSceneSwitcher::window->activateWindow();
|
||||
return;
|
||||
} else {
|
||||
AdvSceneSwitcher::window =
|
||||
new AdvSceneSwitcher(static_cast<QMainWindow *>(
|
||||
obs_frontend_get_main_window()));
|
||||
AdvSceneSwitcher::window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
AdvSceneSwitcher::window->show();
|
||||
}
|
||||
|
||||
auto parent =
|
||||
static_cast<QMainWindow *>(obs_frontend_get_main_window());
|
||||
if (switcher->settingsLockEnabled &&
|
||||
!switcher->settingsLockPassword.empty() &&
|
||||
!settingsPasswordIsCorrect(parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AdvSceneSwitcher::window = new AdvSceneSwitcher(parent);
|
||||
AdvSceneSwitcher::window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
AdvSceneSwitcher::window->show();
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::HighlightMacroSettingsButton(bool enable)
|
||||
@@ -815,6 +767,8 @@ void HighlightMacroSettingsButton(bool enable)
|
||||
enable);
|
||||
}
|
||||
|
||||
void SetupActionQueues();
|
||||
|
||||
extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
|
||||
translateFunc translate)
|
||||
{
|
||||
@@ -826,11 +780,12 @@ extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
|
||||
PlatformInit();
|
||||
LoadPlugins();
|
||||
SetupDock();
|
||||
SetupActionQueues();
|
||||
|
||||
RunPluginInitSteps();
|
||||
|
||||
obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr);
|
||||
obs_frontend_add_event_callback(OBSEvent, nullptr);
|
||||
obs_frontend_add_event_callback(OBSEvent, switcher);
|
||||
|
||||
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(
|
||||
obs_module_text("AdvSceneSwitcher.pluginName"));
|
||||
|
||||
@@ -68,7 +68,6 @@ public slots:
|
||||
void on_warnPluginLoadFailure_stateChanged(int state);
|
||||
void on_suppressCrashRecoveryDialog_stateChanged(int state);
|
||||
void on_hideLegacyTabs_stateChanged(int state);
|
||||
void on_settingsLock_stateChanged(int state);
|
||||
void on_priorityUp_clicked();
|
||||
void on_priorityDown_clicked();
|
||||
void on_threadPriority_currentTextChanged(const QString &text);
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -245,64 +243,6 @@ void AdvSceneSwitcher::on_hideLegacyTabs_stateChanged(int state)
|
||||
ui->priorityBox->setVisible(!switcher->hideLegacyTabs);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_settingsLock_stateChanged(int state)
|
||||
{
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
switcher->settingsLockEnabled = false;
|
||||
switcher->settingsLockPassword = "";
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
QString newPassword = QInputDialog::getText(
|
||||
this,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.newPasswordLabel"),
|
||||
QLineEdit::Password, QString(), &ok);
|
||||
|
||||
const auto disablePassword = [this]() {
|
||||
QSignalBlocker blocker(ui->settingsLock);
|
||||
ui->settingsLock->setChecked(false);
|
||||
ui->settingsLock->setCheckState(Qt::Unchecked);
|
||||
switcher->settingsLockEnabled = false;
|
||||
switcher->settingsLockPassword = "";
|
||||
};
|
||||
|
||||
if (!ok || newPassword.isEmpty()) {
|
||||
disablePassword();
|
||||
return;
|
||||
}
|
||||
|
||||
QString confirm = QInputDialog::getText(
|
||||
this,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.confirmPasswordLabel"),
|
||||
QLineEdit::Password, QString(), &ok);
|
||||
if (!ok || newPassword != confirm) {
|
||||
if (ok) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordMismatch"));
|
||||
}
|
||||
disablePassword();
|
||||
return;
|
||||
}
|
||||
|
||||
switcher->settingsLockEnabled = true;
|
||||
switcher->settingsLockPassword = newPassword.toStdString();
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetDeprecationWarnings()
|
||||
{
|
||||
QString toolTip =
|
||||
@@ -451,16 +391,12 @@ void AdvSceneSwitcher::CheckFirstTimeSetup()
|
||||
return;
|
||||
}
|
||||
|
||||
bool wasSkipped = false;
|
||||
auto macro = FirstRunWizard::ShowWizard(this, &wasSkipped);
|
||||
auto macro = FirstRunWizard::ShowWizard(this);
|
||||
if (macro) {
|
||||
renameMacroIfNecessary(macro);
|
||||
QTimer::singleShot(0, this,
|
||||
[this, macro]() { ui->macros->Add(macro); });
|
||||
}
|
||||
if (wasSkipped) {
|
||||
ui->alwaysShowFeatureTabs->setChecked(true);
|
||||
}
|
||||
switcher->Start();
|
||||
}
|
||||
|
||||
@@ -532,6 +468,7 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
|
||||
// Needs to be loaded before any entries which might rely on scene group
|
||||
// selections to be available.
|
||||
loadSceneGroups(obj);
|
||||
LoadVariables(obj);
|
||||
|
||||
RunLoadSteps(obj);
|
||||
|
||||
@@ -570,6 +507,7 @@ void SwitcherData::SaveSettings(obs_data_t *obj)
|
||||
saveSceneGroups(obj);
|
||||
SaveMacros(obj);
|
||||
SaveGlobalMacroSettings(obj);
|
||||
SaveVariables(obj);
|
||||
saveWindowTitleSwitches(obj);
|
||||
saveScreenRegionSwitches(obj);
|
||||
savePauseSwitches(obj);
|
||||
@@ -627,9 +565,6 @@ void SwitcherData::SaveGeneralSettings(obs_data_t *obj)
|
||||
disableFilterComboboxFilter);
|
||||
obs_data_set_bool(obj, "warnPluginLoadFailure", warnPluginLoadFailure);
|
||||
obs_data_set_bool(obj, "hideLegacyTabs", hideLegacyTabs);
|
||||
obs_data_set_bool(obj, "settingsLockEnabled", settingsLockEnabled);
|
||||
obs_data_set_string(obj, "settingsLockPassword",
|
||||
settingsLockPassword.c_str());
|
||||
|
||||
SaveFunctionPriorities(obj, functionNamesByPriority);
|
||||
|
||||
@@ -701,8 +636,6 @@ void SwitcherData::LoadGeneralSettings(obs_data_t *obj)
|
||||
warnPluginLoadFailure = obs_data_get_bool(obj, "warnPluginLoadFailure");
|
||||
obs_data_set_default_bool(obj, "hideLegacyTabs", true);
|
||||
hideLegacyTabs = obs_data_get_bool(obj, "hideLegacyTabs");
|
||||
settingsLockEnabled = obs_data_get_bool(obj, "settingsLockEnabled");
|
||||
settingsLockPassword = obs_data_get_string(obj, "settingsLockPassword");
|
||||
|
||||
SetDefaultFunctionPriorities(obj);
|
||||
LoadFunctionPriorities(obj, functionNamesByPriority);
|
||||
@@ -1025,7 +958,6 @@ void AdvSceneSwitcher::SetupGeneralTab()
|
||||
ui->warnPluginLoadFailure->setChecked(switcher->warnPluginLoadFailure);
|
||||
ui->suppressCrashRecoveryDialog->setChecked(GetSuppressCrashDialog());
|
||||
ui->hideLegacyTabs->setChecked(switcher->hideLegacyTabs);
|
||||
ui->settingsLock->setChecked(switcher->settingsLockEnabled);
|
||||
|
||||
populatePriorityFunctionList(ui->priorityList);
|
||||
populateThreadPriorityList(ui->threadPriority);
|
||||
|
||||
@@ -178,19 +178,47 @@ void AdvSceneSwitcher::on_ignoreWindows_currentRowChanged(int idx)
|
||||
}
|
||||
}
|
||||
|
||||
static bool windowInfoMatchesSwitch(const WindowInfo &info,
|
||||
const WindowSwitch &s)
|
||||
void checkWindowTitleSwitchDirect(WindowSwitch &s,
|
||||
std::string ¤tWindowTitle, bool &match,
|
||||
OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (s.focus && !info.focused) {
|
||||
return false;
|
||||
bool focus = (!s.focus || s.window == currentWindowTitle);
|
||||
bool fullscreen = (!s.fullscreen || IsFullscreen(s.window));
|
||||
bool max = (!s.maximized || IsMaximized(s.window));
|
||||
|
||||
if (focus && fullscreen && max) {
|
||||
match = true;
|
||||
scene = s.getScene();
|
||||
transition = s.transition;
|
||||
}
|
||||
if (s.fullscreen && !info.fullscreen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void checkWindowTitleSwitchRegex(WindowSwitch &s,
|
||||
std::string ¤tWindowTitle,
|
||||
std::vector<std::string> windowList,
|
||||
bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
for (auto &window : windowList) {
|
||||
try {
|
||||
std::regex expr(s.window);
|
||||
if (!std::regex_match(window, expr)) {
|
||||
continue;
|
||||
}
|
||||
} catch (const std::regex_error &) {
|
||||
}
|
||||
|
||||
bool focus = (!s.focus || window == currentWindowTitle);
|
||||
bool fullscreen = (!s.fullscreen || IsFullscreen(window));
|
||||
bool max = (!s.maximized || IsMaximized(window));
|
||||
|
||||
if (focus && fullscreen && max) {
|
||||
match = true;
|
||||
scene = s.getScene();
|
||||
transition = s.transition;
|
||||
}
|
||||
}
|
||||
if (s.maximized && !info.maximized) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SwitcherData::checkWindowTitleSwitch(OBSWeakSource &scene,
|
||||
@@ -200,37 +228,23 @@ bool SwitcherData::checkWindowTitleSwitch(OBSWeakSource &scene,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string currentWindowTitle = switcher->currentTitle;
|
||||
bool match = false;
|
||||
|
||||
WindowQueryOptions options;
|
||||
options.focus = true;
|
||||
options.fullscreen = true;
|
||||
options.maximized = true;
|
||||
const auto windows = GetWindows(options);
|
||||
const auto windowList = GetWindowList();
|
||||
|
||||
for (WindowSwitch &s : windowSwitches) {
|
||||
if (!s.initialized()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const auto &info : windows) {
|
||||
bool titleMatch = false;
|
||||
try {
|
||||
std::regex expr(s.window);
|
||||
titleMatch = info.title == s.window ||
|
||||
std::regex_match(info.title, expr);
|
||||
} catch (const std::regex_error &) {
|
||||
titleMatch = info.title == s.window;
|
||||
}
|
||||
|
||||
if (!titleMatch || !windowInfoMatchesSwitch(info, s)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match = true;
|
||||
scene = s.getScene();
|
||||
transition = s.transition;
|
||||
break;
|
||||
if (std::find(windowList.begin(), windowList.end(), s.window) !=
|
||||
windowList.end()) {
|
||||
checkWindowTitleSwitchDirect(s, currentWindowTitle,
|
||||
match, scene, transition);
|
||||
} else {
|
||||
checkWindowTitleSwitchRegex(s, currentWindowTitle,
|
||||
windowList, match, scene,
|
||||
transition);
|
||||
}
|
||||
|
||||
if (match) {
|
||||
|
||||
@@ -236,65 +236,17 @@ std::string getWindowName(Window window)
|
||||
return windowTitle;
|
||||
}
|
||||
|
||||
std::vector<WindowInfo> GetWindows(const WindowQueryOptions &options)
|
||||
std::vector<std::string> GetWindowList()
|
||||
{
|
||||
const std::string foregroundTitle = GetCurrentWindowTitle();
|
||||
const auto topLevel = getTopLevelWindows();
|
||||
auto display = disp();
|
||||
|
||||
std::vector<WindowInfo> result;
|
||||
result.reserve(topLevel.size());
|
||||
|
||||
for (auto window : topLevel) {
|
||||
std::vector<std::string> windows;
|
||||
for (auto window : getTopLevelWindows()) {
|
||||
auto name = getWindowName(window);
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
WindowInfo info;
|
||||
info.title = name;
|
||||
|
||||
if (options.focus) {
|
||||
info.focused = (name == foregroundTitle);
|
||||
}
|
||||
|
||||
if (options.fullscreen || options.maximized) {
|
||||
QStringList states = getStates(window);
|
||||
if (options.fullscreen) {
|
||||
info.fullscreen = states.contains(
|
||||
"_NET_WM_STATE_FULLSCREEN");
|
||||
}
|
||||
if (options.maximized) {
|
||||
info.maximized =
|
||||
states.contains(
|
||||
"_NET_WM_STATE_MAXIMIZED_VERT") &&
|
||||
states.contains(
|
||||
"_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
}
|
||||
}
|
||||
|
||||
if (options.geometry && display) {
|
||||
XWindowAttributes attrs;
|
||||
if (XGetWindowAttributes(display, window, &attrs)) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Window child;
|
||||
XTranslateCoordinates(
|
||||
display, window,
|
||||
DefaultRootWindow(display), 0, 0, &x,
|
||||
&y, &child);
|
||||
info.x = x;
|
||||
info.y = y;
|
||||
info.width = attrs.width;
|
||||
info.height = attrs.height;
|
||||
}
|
||||
}
|
||||
|
||||
// windowClass and text not implemented on Linux
|
||||
result.emplace_back(std::move(info));
|
||||
windows.emplace_back(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
return windows;
|
||||
}
|
||||
|
||||
int getActiveWindow(Window *&window)
|
||||
@@ -338,6 +290,68 @@ std::string GetCurrentWindowTitle()
|
||||
return name;
|
||||
}
|
||||
|
||||
bool windowStatesAreSet(const std::string &windowTitle,
|
||||
std::vector<QString> &expectedStates)
|
||||
{
|
||||
if (!ewmhIsSupported()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Window> windows = getTopLevelWindows();
|
||||
for (auto &window : windows) {
|
||||
auto name = getWindowName(window);
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool equals = windowTitle == name;
|
||||
bool matches = QString::fromStdString(name).contains(
|
||||
QRegularExpression(
|
||||
QString::fromStdString(windowTitle)));
|
||||
|
||||
if (!(equals || matches)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList states = getStates(window);
|
||||
if (states.isEmpty()) {
|
||||
if (expectedStates.empty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto &state : expectedStates) {
|
||||
if (!states.contains(state)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsMaximized(const std::string &title)
|
||||
{
|
||||
std::vector<QString> states;
|
||||
states.emplace_back("_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
states.emplace_back("_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
return windowStatesAreSet(title, states);
|
||||
}
|
||||
|
||||
bool IsFullscreen(const std::string &title)
|
||||
{
|
||||
std::vector<QString> states;
|
||||
states.emplace_back("_NET_WM_STATE_FULLSCREEN");
|
||||
return windowStatesAreSet(title, states);
|
||||
}
|
||||
|
||||
std::optional<std::string> GetTextInWindow(const std::string &)
|
||||
{
|
||||
// Not implemented
|
||||
return {};
|
||||
}
|
||||
|
||||
static void getProcessListProcps(QStringList &processes)
|
||||
{
|
||||
#ifdef PROCPS_AVAILABLE
|
||||
|
||||
@@ -871,8 +871,6 @@ void MacroActionMacroEdit::SetWidgetVisibility()
|
||||
} else {
|
||||
_noConditionsWarning->setVisible(false);
|
||||
}
|
||||
_runMacroHelp->setVisible(action ==
|
||||
MacroActionMacro::Action::RUN_MACRO);
|
||||
|
||||
_nestedMacro->setVisible(action ==
|
||||
MacroActionMacro::Action::NESTED_MACRO);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "macro-signals.hpp"
|
||||
#include "macro-settings.hpp"
|
||||
#include "macro.hpp"
|
||||
#include "path-helpers.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "section.hpp"
|
||||
#include "switch-button.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
@@ -104,15 +102,12 @@ MacroConditionEdit::MacroConditionEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroCondition> *entryData,
|
||||
bool isRootCondition)
|
||||
: MacroSegmentEdit(parent),
|
||||
_enable(new SwitchButton()),
|
||||
_logicSelection(new QComboBox()),
|
||||
_conditionSelection(new FilterComboBox()),
|
||||
_dur(new DurationModifierEdit()),
|
||||
_entryData(entryData),
|
||||
_isRoot(isRootCondition)
|
||||
{
|
||||
QWidget::connect(_enable, SIGNAL(checked(bool)), this,
|
||||
SLOT(ConditionEnableChanged(bool)));
|
||||
QWidget::connect(_logicSelection, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(LogicSelectionChanged(int)));
|
||||
QWidget::connect(_conditionSelection,
|
||||
@@ -127,7 +122,6 @@ MacroConditionEdit::MacroConditionEdit(
|
||||
Logic::PopulateLogicTypeSelection(_logicSelection, isRootCondition);
|
||||
populateConditionSelection(_conditionSelection);
|
||||
|
||||
_section->AddHeaderWidget(_enable);
|
||||
_section->AddHeaderWidget(_logicSelection);
|
||||
_section->AddHeaderWidget(_conditionSelection);
|
||||
_section->AddHeaderWidget(_headerInfo);
|
||||
@@ -160,17 +154,8 @@ void MacroConditionEdit::LogicSelectionChanged(int idx)
|
||||
const auto logic = static_cast<Logic::Type>(
|
||||
_logicSelection->itemData(idx).toInt());
|
||||
(*_entryData)->SetLogicType(logic);
|
||||
}
|
||||
|
||||
void MacroConditionEdit::ConditionEnableChanged(bool value)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto lock = LockContext();
|
||||
(*_entryData)->SetEnabled(value);
|
||||
SetDisableEffect(!value);
|
||||
SetEnableAppearance(logic != Logic::Type::NONE);
|
||||
}
|
||||
|
||||
bool MacroConditionEdit::IsRootNode() const
|
||||
@@ -183,9 +168,7 @@ void MacroConditionEdit::SetLogicSelection()
|
||||
const auto logic = (*_entryData)->GetLogicType();
|
||||
_logicSelection->setCurrentIndex(
|
||||
_logicSelection->findData(static_cast<int>(logic)));
|
||||
const bool enabled = (*_entryData)->Enabled();
|
||||
_enable->setChecked(enabled);
|
||||
SetEnableAppearance(enabled);
|
||||
SetEnableAppearance(logic != Logic::Type::NONE);
|
||||
}
|
||||
|
||||
void MacroConditionEdit::SetRootNode(bool root)
|
||||
@@ -256,12 +239,10 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
||||
{
|
||||
auto lock = LockContext();
|
||||
auto logic = (*_entryData)->GetLogicType();
|
||||
const bool enabled = (*_entryData)->Enabled();
|
||||
_entryData->reset();
|
||||
*_entryData = MacroConditionFactory::Create(id, macro);
|
||||
(*_entryData)->SetIndex(idx);
|
||||
(*_entryData)->SetLogicType(logic);
|
||||
(*_entryData)->SetEnabled(enabled);
|
||||
(*_entryData)->PostLoad();
|
||||
RunAndClearPostLoadSteps();
|
||||
}
|
||||
@@ -275,9 +256,6 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
||||
SetupVarMappings((*_entryData).get());
|
||||
_dur->setVisible(MacroConditionFactory::UsesDurationModifier(id));
|
||||
SetFocusPolicyOfWidgets();
|
||||
|
||||
emit MacroSignalManager::Instance()->ConditionTypeCreated(
|
||||
QString::fromStdString(id));
|
||||
}
|
||||
|
||||
void MacroConditionEdit::DurationChanged(const Duration &seconds)
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
namespace advss {
|
||||
|
||||
class SwitchButton;
|
||||
|
||||
class DurationModifierEdit : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -49,13 +47,11 @@ private slots:
|
||||
void ConditionSelectionChanged(const QString &text);
|
||||
void DurationChanged(const Duration &value);
|
||||
void DurationModifierChanged(DurationModifier::Type m);
|
||||
void ConditionEnableChanged(bool);
|
||||
|
||||
private:
|
||||
void SetLogicSelection();
|
||||
std::shared_ptr<MacroSegment> Data() const;
|
||||
|
||||
SwitchButton *_enable;
|
||||
QComboBox *_logicSelection;
|
||||
FilterComboBox *_conditionSelection;
|
||||
DurationModifierEdit *_dur;
|
||||
|
||||
@@ -31,10 +31,6 @@ bool MacroCondition::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroSegment::Load(obj);
|
||||
_logic.Load(obj, "logic");
|
||||
if (_logic.GetType() == Logic::Type::NONE) {
|
||||
SetEnabled(false);
|
||||
_logic.SetType(Logic::Type::AND);
|
||||
}
|
||||
_durationModifier.Load(obj);
|
||||
return true;
|
||||
}
|
||||
@@ -54,8 +50,7 @@ void MacroCondition::ValidateLogicSelection(bool isRootCondition,
|
||||
return;
|
||||
}
|
||||
|
||||
_logic.SetType(Logic::Type::AND);
|
||||
SetEnabled(false);
|
||||
_logic.SetType(Logic::Type::NONE);
|
||||
blog(LOG_WARNING,
|
||||
"setting invalid logic selection to 'ignore' for macro %s",
|
||||
context);
|
||||
|
||||
@@ -1118,9 +1118,6 @@ void MacroEdit::AddMacroAction(int idx)
|
||||
macro->Actions().at(idx - 1)->Save(data);
|
||||
}
|
||||
AddMacroAction(macro.get(), idx, id, data);
|
||||
if (idx < (int)macro->Actions().size()) {
|
||||
macro->Actions().at(idx)->FixupVarMappingRefs();
|
||||
}
|
||||
}
|
||||
|
||||
void MacroEdit::on_actionAdd_clicked()
|
||||
@@ -1429,9 +1426,6 @@ void MacroEdit::AddMacroElseAction(int idx)
|
||||
macro->ElseActions().at(idx - 1)->Save(data);
|
||||
}
|
||||
AddMacroElseAction(macro.get(), idx, id, data);
|
||||
if (idx < (int)macro->ElseActions().size()) {
|
||||
macro->ElseActions().at(idx)->FixupVarMappingRefs();
|
||||
}
|
||||
}
|
||||
|
||||
void MacroEdit::RemoveMacroElseAction(int idx)
|
||||
@@ -1576,9 +1570,6 @@ void MacroEdit::AddMacroCondition(int idx)
|
||||
macro->Conditions().at(idx - 1)->Save(data);
|
||||
}
|
||||
AddMacroCondition(macro.get(), idx, id, data.Get(), logic);
|
||||
if (idx < (int)macro->Conditions().size()) {
|
||||
macro->Conditions().at(idx)->FixupVarMappingRefs();
|
||||
}
|
||||
}
|
||||
|
||||
void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#include "macro-export-extensions.hpp"
|
||||
|
||||
#include "action-queue.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
#include <obs.hpp>
|
||||
|
||||
namespace advss {
|
||||
|
||||
static bool setup();
|
||||
static bool setupDone = setup();
|
||||
|
||||
static bool setup()
|
||||
{
|
||||
// --- Variables ---
|
||||
AddMacroExportExtension(
|
||||
{"AdvSceneSwitcher.macroTab.export.variables", "variables",
|
||||
[](obs_data_t *data, const QStringList &selectedIds) {
|
||||
if (selectedIds.isEmpty()) {
|
||||
SaveVariables(data);
|
||||
return;
|
||||
}
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_array_create();
|
||||
for (const auto &v : GetVariables()) {
|
||||
const QString name =
|
||||
QString::fromStdString(v->Name());
|
||||
if (!selectedIds.contains(name)) {
|
||||
continue;
|
||||
}
|
||||
OBSDataAutoRelease item = obs_data_create();
|
||||
v->Save(item);
|
||||
obs_data_array_push_back(array, item);
|
||||
}
|
||||
obs_data_set_array(data, "variables", array);
|
||||
},
|
||||
[](obs_data_t *data, const QStringList &) {
|
||||
ImportVariables(data);
|
||||
},
|
||||
[]() -> QList<QPair<QString, QString>> {
|
||||
QList<QPair<QString, QString>> items;
|
||||
for (const auto &v : GetVariables()) {
|
||||
const QString name =
|
||||
QString::fromStdString(v->Name());
|
||||
items.append({name, name});
|
||||
}
|
||||
return items;
|
||||
}});
|
||||
|
||||
// --- Action Queues ---
|
||||
AddMacroExportExtension(
|
||||
{"AdvSceneSwitcher.macroTab.export.actionQueues",
|
||||
"actionQueues",
|
||||
[](obs_data_t *data, const QStringList &selectedIds) {
|
||||
if (selectedIds.isEmpty()) {
|
||||
SaveActionQueues(data);
|
||||
return;
|
||||
}
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_array_create();
|
||||
for (const auto &q : GetActionQueues()) {
|
||||
const QString name =
|
||||
QString::fromStdString(q->Name());
|
||||
if (!selectedIds.contains(name)) {
|
||||
continue;
|
||||
}
|
||||
OBSDataAutoRelease item = obs_data_create();
|
||||
q->Save(item);
|
||||
obs_data_array_push_back(array, item);
|
||||
}
|
||||
obs_data_set_array(data, "actionQueues", array);
|
||||
},
|
||||
[](obs_data_t *data, const QStringList &) {
|
||||
ImportQueues(data);
|
||||
},
|
||||
[]() -> QList<QPair<QString, QString>> {
|
||||
QList<QPair<QString, QString>> items;
|
||||
for (const auto &q : GetActionQueues()) {
|
||||
const QString name =
|
||||
QString::fromStdString(q->Name());
|
||||
items.append({name, name});
|
||||
}
|
||||
return items;
|
||||
}});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "macro-export-extensions.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
static std::vector<MacroExportExtension> extensions;
|
||||
|
||||
void AddMacroExportExtension(const MacroExportExtension &ext)
|
||||
{
|
||||
extensions.emplace_back(ext);
|
||||
}
|
||||
|
||||
const std::vector<MacroExportExtension> &GetMacroExportExtensions()
|
||||
{
|
||||
return extensions;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <obs-data.h>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
namespace advss {
|
||||
|
||||
struct MacroExportExtension {
|
||||
const char *displayNameKey;
|
||||
const char *jsonKey;
|
||||
|
||||
// Export callback.
|
||||
// Write content into 'data'. 'selectedIds' contains the item IDs the
|
||||
// user explicitly checked; if empty (no per-item widget provided) save
|
||||
// everything.
|
||||
std::function<void(obs_data_t *data, const QStringList &selectedIds)>
|
||||
save;
|
||||
|
||||
// Import callback.
|
||||
// Read content from 'data'. 'selectedIds' contains the item IDs the
|
||||
// user explicitly checked; if empty import every item found in 'data'.
|
||||
std::function<void(obs_data_t *data, const QStringList &selectedIds)>
|
||||
load;
|
||||
|
||||
// Optional: enumerate items available for export as (id, displayName)
|
||||
// pairs. When nullptr the extension appears as a single all-or-nothing
|
||||
// checkbox in the export dialog.
|
||||
std::function<QList<QPair<QString, QString>>()> getExportItems =
|
||||
nullptr;
|
||||
};
|
||||
|
||||
EXPORT void AddMacroExportExtension(const MacroExportExtension &ext);
|
||||
const std::vector<MacroExportExtension> &GetMacroExportExtensions();
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,160 +1,22 @@
|
||||
#include "macro-export-import-dialog.hpp"
|
||||
#include "macro-export-extensions.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
|
||||
#include <obs.hpp>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <QLabel>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
namespace advss {
|
||||
|
||||
static bool usePlainText = false;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Compress / decompress helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QString compressMacroString(const QString &input)
|
||||
{
|
||||
QByteArray inputData = input.toUtf8();
|
||||
auto compressedData = qCompress(inputData);
|
||||
QByteArray encodedData = compressedData.toBase64();
|
||||
return QString::fromUtf8(encodedData);
|
||||
}
|
||||
|
||||
static QString decompressMacroString(const QString &input)
|
||||
{
|
||||
QByteArray encodedData = input.toUtf8();
|
||||
QByteArray compressedData = QByteArray::fromBase64(encodedData);
|
||||
auto outputData = qUncompress(compressedData);
|
||||
return QString::fromUtf8(outputData);
|
||||
}
|
||||
|
||||
static bool isValidData(const QString &json)
|
||||
{
|
||||
OBSDataAutoRelease data =
|
||||
obs_data_create_from_json(json.toStdString().c_str());
|
||||
return !!data;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Extension section
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Section *MacroExportImportDialog::BuildExtensionSection()
|
||||
{
|
||||
auto outerSection = new Section(300, this);
|
||||
outerSection->AddHeaderWidget(new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.export.additionalContent")));
|
||||
|
||||
auto outerContent = new QWidget();
|
||||
auto outerLayout = new QVBoxLayout(outerContent);
|
||||
outerLayout->setContentsMargins(4, 4, 4, 4);
|
||||
outerLayout->setSpacing(4);
|
||||
|
||||
const auto &extensions = GetMacroExportExtensions();
|
||||
|
||||
// Build a sorted index list (alphabetical by translated display name).
|
||||
std::vector<int> order(extensions.size());
|
||||
std::iota(order.begin(), order.end(), 0);
|
||||
std::sort(order.begin(), order.end(), [&](int a, int b) {
|
||||
return QString::localeAwareCompare(
|
||||
obs_module_text(extensions[a].displayNameKey),
|
||||
obs_module_text(extensions[b].displayNameKey)) <
|
||||
0;
|
||||
});
|
||||
|
||||
for (int extIdx : order) {
|
||||
const auto &ext = extensions[extIdx];
|
||||
ExtensionUI ui;
|
||||
|
||||
// Simple all-or-nothing checkbox (no sub-items).
|
||||
if (!ext.getExportItems) {
|
||||
ui.mainCheck = new QCheckBox(
|
||||
obs_module_text(ext.displayNameKey),
|
||||
outerContent);
|
||||
ui.mainCheck->setChecked(false);
|
||||
connect(ui.mainCheck, &QCheckBox::stateChanged, this,
|
||||
&MacroExportImportDialog::UpdateExportString);
|
||||
outerLayout->addWidget(ui.mainCheck);
|
||||
_extensionUIs.append(std::move(ui));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extensions with per-item selection get their own inner
|
||||
// Section: the main checkbox sits in the header (next to the
|
||||
// toggle arrow) and the per-item checkboxes live in the
|
||||
// collapsible content area.
|
||||
const auto items = ext.getExportItems();
|
||||
if (items.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto innerSection = new Section(200, outerContent);
|
||||
|
||||
ui.mainCheck =
|
||||
new QCheckBox(obs_module_text(ext.displayNameKey));
|
||||
ui.mainCheck->setChecked(false);
|
||||
innerSection->AddHeaderWidget(ui.mainCheck);
|
||||
|
||||
auto subWidget = new QWidget();
|
||||
auto subLayout = new QVBoxLayout(subWidget);
|
||||
subLayout->setContentsMargins(4, 2, 4, 2);
|
||||
subLayout->setSpacing(2);
|
||||
|
||||
for (const auto &[id, displayName] : items) {
|
||||
auto cb = new QCheckBox(displayName, subWidget);
|
||||
cb->setChecked(false);
|
||||
subLayout->addWidget(cb);
|
||||
ui.itemChecks.append({id, cb});
|
||||
connect(cb, &QCheckBox::stateChanged, this,
|
||||
&MacroExportImportDialog::UpdateExportString);
|
||||
}
|
||||
|
||||
// Main checkbox toggles all sub-items.
|
||||
// Capture uiIdx (position in _extensionUIs after append).
|
||||
const int uiIdx = _extensionUIs.size();
|
||||
connect(ui.mainCheck, &QCheckBox::stateChanged, this,
|
||||
[this, uiIdx](int state) {
|
||||
if (state == Qt::PartiallyChecked)
|
||||
return;
|
||||
const bool checked = (state == Qt::Checked);
|
||||
if (uiIdx < _extensionUIs.size()) {
|
||||
for (auto &[id, cb] :
|
||||
_extensionUIs[uiIdx].itemChecks) {
|
||||
QSignalBlocker b(cb);
|
||||
cb->setChecked(checked);
|
||||
}
|
||||
}
|
||||
UpdateExportString();
|
||||
});
|
||||
|
||||
innerSection->SetContent(subWidget, false);
|
||||
outerLayout->addWidget(innerSection);
|
||||
_extensionUIs.append(std::move(ui));
|
||||
}
|
||||
|
||||
outerSection->SetContent(outerContent, true);
|
||||
return outerSection;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Constructor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
MacroExportImportDialog::MacroExportImportDialog(Type type,
|
||||
const QString &baseJson)
|
||||
MacroExportImportDialog::MacroExportImportDialog(Type type)
|
||||
: QDialog(nullptr),
|
||||
_baseJson(baseJson),
|
||||
_importExportString(new QPlainTextEdit(this)),
|
||||
_usePlainText(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.export.usePlainText")))
|
||||
{
|
||||
_importExportString->setReadOnly(type == Type::EXPORT_MACRO);
|
||||
|
||||
auto label = new QLabel(obs_module_text(
|
||||
type == Type::EXPORT_MACRO
|
||||
? "AdvSceneSwitcher.macroTab.export.info"
|
||||
@@ -177,12 +39,7 @@ MacroExportImportDialog::MacroExportImportDialog(Type type,
|
||||
connect(_usePlainText, &QCheckBox::stateChanged, this,
|
||||
&MacroExportImportDialog::UsePlainTextChanged);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
|
||||
if (type == Type::EXPORT_MACRO && !GetMacroExportExtensions().empty()) {
|
||||
layout->addWidget(BuildExtensionSection());
|
||||
}
|
||||
|
||||
auto layout = new QVBoxLayout;
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(_importExportString);
|
||||
layout->addWidget(_usePlainText);
|
||||
@@ -190,57 +47,32 @@ MacroExportImportDialog::MacroExportImportDialog(Type type,
|
||||
setLayout(layout);
|
||||
|
||||
setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
||||
|
||||
if (type == Type::EXPORT_MACRO) {
|
||||
RefreshExportText();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Export string helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QString MacroExportImportDialog::BuildExportJson() const
|
||||
QString compressMacroString(const QString &input)
|
||||
{
|
||||
OBSDataAutoRelease data =
|
||||
obs_data_create_from_json(_baseJson.toStdString().c_str());
|
||||
if (!data) {
|
||||
return _baseJson;
|
||||
}
|
||||
|
||||
const auto &extensions = GetMacroExportExtensions();
|
||||
for (int i = 0;
|
||||
i < (int)extensions.size() && i < (int)_extensionUIs.size(); ++i) {
|
||||
if (!_extensionUIs[i].mainCheck->isChecked()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList selectedIds;
|
||||
for (const auto &[id, cb] : _extensionUIs[i].itemChecks) {
|
||||
if (cb->isChecked()) {
|
||||
selectedIds << id;
|
||||
}
|
||||
}
|
||||
extensions[i].save(data, selectedIds);
|
||||
}
|
||||
|
||||
const char *json = obs_data_get_json(data);
|
||||
return json ? QString::fromUtf8(json) : QString{};
|
||||
QByteArray inputData = input.toUtf8();
|
||||
auto compressedData = qCompress(inputData);
|
||||
QByteArray encodedData = compressedData.toBase64();
|
||||
return QString::fromUtf8(encodedData);
|
||||
}
|
||||
|
||||
void MacroExportImportDialog::RefreshExportText()
|
||||
QString decompressMacroString(const QString &input)
|
||||
{
|
||||
const QString json = BuildExportJson();
|
||||
if (usePlainText) {
|
||||
_importExportString->setPlainText(json);
|
||||
} else {
|
||||
_importExportString->setPlainText(compressMacroString(json));
|
||||
}
|
||||
QByteArray encodedData = input.toUtf8();
|
||||
QByteArray compressedData = QByteArray::fromBase64(encodedData);
|
||||
auto outputData = qUncompress(compressedData);
|
||||
return QString::fromUtf8(outputData);
|
||||
}
|
||||
|
||||
void MacroExportImportDialog::UpdateExportString()
|
||||
void MacroExportImportDialog::ExportMacros(const QString &json)
|
||||
{
|
||||
RefreshExportText();
|
||||
MacroExportImportDialog dialog(
|
||||
MacroExportImportDialog::Type::EXPORT_MACRO);
|
||||
dialog._importExportString->setPlainText(compressMacroString(json));
|
||||
dialog.adjustSize();
|
||||
dialog.updateGeometry();
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MacroExportImportDialog::UsePlainTextChanged(int value)
|
||||
@@ -258,45 +90,26 @@ void MacroExportImportDialog::UsePlainTextChanged(int value)
|
||||
usePlainText = value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Static entry points
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void MacroExportImportDialog::ExportMacros(obs_data_t *macroData)
|
||||
static bool isValidData(const QString &json)
|
||||
{
|
||||
const char *rawJson = obs_data_get_json(macroData);
|
||||
const QString baseJson = rawJson ? QString::fromUtf8(rawJson)
|
||||
: QString{};
|
||||
|
||||
MacroExportImportDialog dialog(Type::EXPORT_MACRO, baseJson);
|
||||
dialog.adjustSize();
|
||||
dialog.updateGeometry();
|
||||
dialog.exec();
|
||||
OBSDataAutoRelease data =
|
||||
obs_data_create_from_json(json.toStdString().c_str());
|
||||
return !!data;
|
||||
}
|
||||
|
||||
bool MacroExportImportDialog::ImportMacros(QString &json)
|
||||
{
|
||||
MacroExportImportDialog dialog(Type::IMPORT_MACRO);
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
json = decompressMacroString(dialog._importExportString->toPlainText());
|
||||
if (!isValidData(json)) {
|
||||
// Fallback: support raw (uncompressed) JSON pasted directly.
|
||||
json = dialog._importExportString->toPlainText();
|
||||
}
|
||||
|
||||
// Invoke all extension load callbacks.
|
||||
OBSDataAutoRelease data =
|
||||
obs_data_create_from_json(json.toStdString().c_str());
|
||||
if (data) {
|
||||
for (const auto &ext : GetMacroExportExtensions()) {
|
||||
ext.load(data, {});
|
||||
MacroExportImportDialog dialog(
|
||||
MacroExportImportDialog::Type::IMPORT_MACRO);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
json = decompressMacroString(
|
||||
dialog._importExportString->toPlainText());
|
||||
if (!isValidData(json)) { // Fallback to support raw json format
|
||||
json = dialog._importExportString->toPlainText();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -1,47 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "section.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include <obs-data.h>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class MacroExportImportDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Type { EXPORT_MACRO, IMPORT_MACRO };
|
||||
MacroExportImportDialog(Type type);
|
||||
|
||||
static void ExportMacros(obs_data_t *macroData);
|
||||
static void ExportMacros(const QString &json);
|
||||
static bool ImportMacros(QString &json);
|
||||
|
||||
private slots:
|
||||
void UsePlainTextChanged(int);
|
||||
void UpdateExportString();
|
||||
|
||||
private:
|
||||
explicit MacroExportImportDialog(Type type,
|
||||
const QString &baseJson = {});
|
||||
|
||||
// Per-extension widgets
|
||||
struct ExtensionUI {
|
||||
QCheckBox *mainCheck = nullptr;
|
||||
// (itemId, checkbox) pairs - empty when no per-item selection.
|
||||
QList<QPair<QString, QCheckBox *>> itemChecks;
|
||||
};
|
||||
|
||||
Section *BuildExtensionSection();
|
||||
QString BuildExportJson() const;
|
||||
void RefreshExportText();
|
||||
|
||||
QString _baseJson;
|
||||
QPlainTextEdit *_importExportString;
|
||||
QCheckBox *_usePlainText;
|
||||
QList<ExtensionUI> _extensionUIs;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -214,20 +214,6 @@ bool MacroIsPaused(const Macro *macro)
|
||||
return macro ? macro->Paused() : true;
|
||||
}
|
||||
|
||||
void SetMacroPaused(Macro *macro, bool paused)
|
||||
{
|
||||
if (macro) {
|
||||
macro->SetPaused(paused);
|
||||
}
|
||||
}
|
||||
|
||||
void StopMacro(Macro *macro)
|
||||
{
|
||||
if (macro) {
|
||||
macro->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
bool MacroWasPausedSince(
|
||||
const Macro *macro,
|
||||
const std::chrono::high_resolution_clock::time_point &time)
|
||||
@@ -251,20 +237,14 @@ void AddMacroHelperThread(Macro *macro, std::thread &&newThread)
|
||||
macro->AddHelperThread(std::move(newThread));
|
||||
}
|
||||
|
||||
bool RunMacroActions(Macro *macro, bool forceParallel, bool ignorePause)
|
||||
bool RunMacroActions(Macro *macro)
|
||||
{
|
||||
return macro && macro->PerformActions(true, forceParallel, ignorePause);
|
||||
return macro && macro->PerformActions(true);
|
||||
}
|
||||
|
||||
bool RunMacroElseActions(Macro *macro, bool forceParallel, bool ignorePause)
|
||||
bool RunMacroElseActions(Macro *macro)
|
||||
{
|
||||
return macro &&
|
||||
macro->PerformActions(false, forceParallel, ignorePause);
|
||||
}
|
||||
|
||||
bool CheckMacroConditions(Macro *macro, bool ignorePause)
|
||||
{
|
||||
return macro && macro->CheckConditions(ignorePause);
|
||||
return macro && macro->PerformActions(false);
|
||||
}
|
||||
|
||||
void ResetMacroConditionTimers(Macro *macro)
|
||||
|
||||
@@ -58,8 +58,6 @@ LastMacroConditionCheckTime(const Macro *);
|
||||
|
||||
EXPORT bool MacroIsStopped(const Macro *);
|
||||
EXPORT bool MacroIsPaused(const Macro *);
|
||||
EXPORT void SetMacroPaused(Macro *, bool paused);
|
||||
EXPORT void StopMacro(Macro *);
|
||||
EXPORT bool
|
||||
MacroWasPausedSince(const Macro *,
|
||||
const std::chrono::high_resolution_clock::time_point &);
|
||||
@@ -68,14 +66,10 @@ EXPORT bool MacroWasCheckedSinceLastStart(const Macro *);
|
||||
EXPORT void AddMacroHelperThread(Macro *, std::thread &&);
|
||||
|
||||
EXPORT bool CheckMacros();
|
||||
EXPORT bool CheckMacroConditions(Macro *, bool ignorePause = false);
|
||||
|
||||
EXPORT bool RunMacroActions(Macro *, bool forceParallel = false,
|
||||
bool ignorePause = false);
|
||||
EXPORT bool RunMacroElseActions(Macro *, bool forceParallel = false,
|
||||
bool ignorePause = false);
|
||||
EXPORT bool RunMacroActions(Macro *);
|
||||
bool RunMacroElseActions(Macro *);
|
||||
EXPORT bool RunMacros();
|
||||
|
||||
void StopAllMacros();
|
||||
|
||||
EXPORT void LoadMacros(obs_data_t *obj);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "macro-ref.hpp"
|
||||
#include "macro.hpp"
|
||||
|
||||
#include "plugin-state-helpers.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
MacroRef::MacroRef(std::string name)
|
||||
@@ -21,7 +19,6 @@ void MacroRef::Load(obs_data_t *obj)
|
||||
auto name = obs_data_get_string(obj, "macro");
|
||||
_postLoadName = name;
|
||||
_macro = GetWeakMacroByName(name);
|
||||
AddPostLoadStep([this]() { MacroRef::PostLoad(); });
|
||||
}
|
||||
|
||||
void MacroRef::PostLoad()
|
||||
|
||||
@@ -72,24 +72,15 @@ void MacroEdit::PasteMacroSegment()
|
||||
}
|
||||
AddMacroCondition(macro.get(), macro->Conditions().size(),
|
||||
copyInfo.segment->GetId(), data.Get(), logic);
|
||||
if (!macro->Conditions().empty()) {
|
||||
macro->Conditions().back()->FixupVarMappingRefs();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MacroSegmentCopyInfo::Type::ACTION:
|
||||
AddMacroAction(macro.get(), macro->Actions().size(),
|
||||
copyInfo.segment->GetId(), data.Get());
|
||||
if (!macro->Actions().empty()) {
|
||||
macro->Actions().back()->FixupVarMappingRefs();
|
||||
}
|
||||
break;
|
||||
case MacroSegmentCopyInfo::Type::ELSE:
|
||||
AddMacroElseAction(macro.get(), macro->ElseActions().size(),
|
||||
copyInfo.segment->GetId(), data.Get());
|
||||
if (!macro->ElseActions().empty()) {
|
||||
macro->ElseActions().back()->FixupVarMappingRefs();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -54,23 +54,6 @@ const std::vector<VarMapping> &MacroSegment::GetVarMappings() const
|
||||
void MacroSegment::SetVarMappings(const std::vector<VarMapping> &mappings)
|
||||
{
|
||||
_varMappings = mappings;
|
||||
IncrementTempVarInUseGeneration();
|
||||
}
|
||||
|
||||
void MacroSegment::FixupVarMappingRefs()
|
||||
{
|
||||
for (auto &mapping : _varMappings) {
|
||||
if (!mapping.tempVar.HasValidID()) {
|
||||
continue;
|
||||
}
|
||||
for (const auto &var : _tempVariables) {
|
||||
if (var.ID() == mapping.tempVar.GetID()) {
|
||||
mapping.tempVar = var.GetRef();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
NotifyUIAboutTempVarChange(this);
|
||||
}
|
||||
|
||||
std::vector<TempVariable> MacroSegment::GetOwnTempVars() const
|
||||
@@ -97,7 +80,7 @@ bool MacroSegment::Save(obs_data_t *obj) const
|
||||
obs_data_set_bool(data, "useCustomLabel", _useCustomLabel);
|
||||
obs_data_set_string(data, "customLabel", _customLabel.c_str());
|
||||
obs_data_set_bool(data, "enabled", _enabled);
|
||||
obs_data_set_int(data, "version", 2);
|
||||
obs_data_set_int(data, "version", 1);
|
||||
|
||||
OBSDataArrayAutoRelease mappingsArray = obs_data_array_create();
|
||||
for (const auto &mapping : _varMappings) {
|
||||
@@ -129,12 +112,6 @@ bool MacroSegment::Load(obs_data_t *obj)
|
||||
_enabled = obs_data_get_bool(obj, "enabled");
|
||||
}
|
||||
|
||||
// Reset the previously unused "enabled" value for conditions to "true"
|
||||
if (obs_data_get_int(data, "version") < 2 &&
|
||||
obs_data_has_user_value(obj, "logic")) {
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
_varMappings.clear();
|
||||
OBSDataArrayAutoRelease mappingsArray =
|
||||
obs_data_get_array(data, "varMappings");
|
||||
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
const std::vector<VarMapping> &GetVarMappings() const;
|
||||
void SetVarMappings(const std::vector<VarMapping> &mappings);
|
||||
std::vector<TempVariable> GetOwnTempVars() const;
|
||||
void FixupVarMappingRefs();
|
||||
|
||||
protected:
|
||||
friend bool SupportsVariableValue(MacroSegment *);
|
||||
|
||||
@@ -18,7 +18,6 @@ signals:
|
||||
void Remove(const QString &);
|
||||
void SegmentOrderChanged();
|
||||
void HighlightChanged(bool value);
|
||||
void ConditionTypeCreated(const QString &typeId);
|
||||
|
||||
private:
|
||||
MacroSignalManager(QObject *parent = nullptr);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "action-queue.hpp"
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "macro-export-import-dialog.hpp"
|
||||
@@ -315,9 +316,13 @@ void AdvSceneSwitcher::ExportMacros() const
|
||||
obs_data_array_push_back(macroArray, obj);
|
||||
}
|
||||
obs_data_set_array(data, "macros", macroArray);
|
||||
SaveVariables(data);
|
||||
SaveActionQueues(data);
|
||||
obs_data_set_string(data, "version", g_GIT_TAG);
|
||||
auto json = obs_data_get_json(data);
|
||||
QString exportString(json);
|
||||
|
||||
MacroExportImportDialog::ExportMacros(data);
|
||||
MacroExportImportDialog::ExportMacros(exportString);
|
||||
}
|
||||
|
||||
bool AdvSceneSwitcher::ResolveMacroImportNameConflict(
|
||||
@@ -379,6 +384,8 @@ void AdvSceneSwitcher::ImportMacros()
|
||||
ImportMacros();
|
||||
return;
|
||||
}
|
||||
ImportVariables(data);
|
||||
ImportQueues(data);
|
||||
|
||||
auto version = obs_data_get_string(data, "version");
|
||||
if (strcmp(version, g_GIT_TAG) != 0) {
|
||||
@@ -550,10 +557,6 @@ void AdvSceneSwitcher::HighlightOnChange() const
|
||||
return;
|
||||
}
|
||||
|
||||
if (macro->Paused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (macro->ActionTriggerModePreventedActionsSince(
|
||||
lastOnChangeHighlightCheckTime)) {
|
||||
HighlightWidget(ui->actionTriggerMode, Qt::yellow,
|
||||
|
||||
@@ -17,17 +17,6 @@
|
||||
|
||||
namespace advss {
|
||||
|
||||
static bool setup()
|
||||
{
|
||||
AddPluginCleanupStep([]() {
|
||||
GetTopLevelMacros().clear();
|
||||
GetTemporaryMacros().clear();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool setupDone = setup();
|
||||
|
||||
Macro::Macro(const std::string &name) : _dockSettings(this)
|
||||
{
|
||||
SetName(name);
|
||||
@@ -129,11 +118,12 @@ static bool checkCondition(const std::shared_ptr<MacroCondition> &condition)
|
||||
const auto timeSpent = endTime - startTime;
|
||||
|
||||
if (timeSpent >= perfLogThreshold) {
|
||||
const long int ms =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
timeSpent)
|
||||
.count();
|
||||
blog(LOG_WARNING,
|
||||
"spent %lld ms in %s condition check of macro '%s'!",
|
||||
(long long)std::chrono::duration_cast<
|
||||
std::chrono::milliseconds>(timeSpent)
|
||||
.count(),
|
||||
"spent %ld ms in %s condition check of macro '%s'!", ms,
|
||||
condition->GetId().c_str(),
|
||||
condition->GetMacro()->Name().c_str());
|
||||
}
|
||||
@@ -156,15 +146,6 @@ bool Macro::CheckConditionHelper(
|
||||
return conditionMatched;
|
||||
};
|
||||
|
||||
if (!condition->Enabled()) {
|
||||
vblog(LOG_INFO, "ignoring condition '%s' for '%s'",
|
||||
condition->GetId().c_str(), _name.c_str());
|
||||
if (!_useShortCircuitEvaluation) {
|
||||
(void)evaluateCondition();
|
||||
}
|
||||
return _matched;
|
||||
}
|
||||
|
||||
const auto logicType = condition->GetLogicType();
|
||||
if (logicType == Logic::Type::NONE) {
|
||||
vblog(LOG_INFO, "ignoring condition '%s' for '%s'",
|
||||
@@ -289,7 +270,7 @@ bool Macro::CheckConditions(bool ignorePause)
|
||||
|
||||
const bool hasActionsToExecute = _matched ? (_actions.size() > 0)
|
||||
: (_elseActions.size() > 0);
|
||||
if (!_actionModeMatch && hasActionsToExecute && !_paused) {
|
||||
if (!_actionModeMatch && hasActionsToExecute) {
|
||||
_lastActionRunModePreventTime =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
@@ -388,7 +369,7 @@ bool Macro::ShouldRunActions() const
|
||||
!_paused && (_matched || _elseActions.size() > 0) &&
|
||||
_actionModeMatch;
|
||||
|
||||
if (VerboseLoggingEnabled() && !_actionModeMatch && !_paused) {
|
||||
if (VerboseLoggingEnabled() && !_actionModeMatch) {
|
||||
if (_matched && _actions.size() > 0) {
|
||||
blog(LOG_INFO, "skip actions for Macro %s (on change)",
|
||||
_name.c_str());
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#import <Carbon/Carbon.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <util/platform.h>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <QStringList>
|
||||
#include <QRegularExpression>
|
||||
@@ -15,13 +14,41 @@
|
||||
|
||||
namespace advss {
|
||||
|
||||
static std::string nsStringToStdString(NSString *str)
|
||||
std::vector<std::string> GetWindowList()
|
||||
{
|
||||
if (!str) {
|
||||
return "";
|
||||
std::vector<std::string> windows;
|
||||
@autoreleasepool {
|
||||
CFArrayRef cfApps = CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
||||
NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
|
||||
for (NSDictionary *app in apps) {
|
||||
std::string name([[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
std::string owner(
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
|
||||
if (!name.empty() &&
|
||||
find(windows.begin(), windows.end(), name) ==
|
||||
windows.end()) {
|
||||
windows.emplace_back(name);
|
||||
}
|
||||
if (!owner.empty() &&
|
||||
find(windows.begin(), windows.end(), owner) ==
|
||||
windows.end()) {
|
||||
windows.emplace_back(owner);
|
||||
}
|
||||
}
|
||||
apps = nil;
|
||||
CFRelease(cfApps);
|
||||
}
|
||||
const char *utf8 = [str UTF8String];
|
||||
return utf8 ? utf8 : "";
|
||||
return windows;
|
||||
}
|
||||
|
||||
std::string GetCurrentWindowTitle()
|
||||
@@ -73,49 +100,100 @@ std::string GetCurrentWindowTitle()
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
bool isWindowMaximizedOnScreen(NSDictionary *app, NSScreen *screen)
|
||||
bool isWindowOriginOnScreen(NSDictionary *app, NSScreen *screen,
|
||||
bool fullscreen = false)
|
||||
{
|
||||
NSArray *screens = [NSScreen screens];
|
||||
NSRect mainScreenFrame = [screens[0] frame];
|
||||
NSRect screenFrame;
|
||||
if (fullscreen) {
|
||||
screenFrame = [screen frame];
|
||||
} else {
|
||||
screenFrame = [screen visibleFrame];
|
||||
}
|
||||
NSRect windowBounds;
|
||||
CGRectMakeWithDictionaryRepresentation(
|
||||
(CFDictionaryRef)[app objectForKey:@"kCGWindowBounds"],
|
||||
&windowBounds);
|
||||
|
||||
// CGWindowList: flipped coords, origin at top-left of main display.
|
||||
// NSScreen: Cocoa coords, origin at bottom-left of main display.
|
||||
NSRect mainFrame = [[NSScreen screens][0] frame];
|
||||
NSRect visFrame = [screen visibleFrame];
|
||||
return (windowBounds.origin.x == screenFrame.origin.x &&
|
||||
(mainScreenFrame.size.height - screenFrame.size.height -
|
||||
windowBounds.origin.y ==
|
||||
screenFrame.origin.y));
|
||||
}
|
||||
|
||||
// Convert visible area to CGWindow coordinates.
|
||||
// screenTop is just below the menubar; screenBottom is just above the
|
||||
// dock.
|
||||
CGFloat screenLeft = visFrame.origin.x;
|
||||
CGFloat screenTop =
|
||||
mainFrame.size.height - visFrame.origin.y - visFrame.size.height;
|
||||
CGFloat screenRight = screenLeft + visFrame.size.width;
|
||||
CGFloat screenBottom = screenTop + visFrame.size.height;
|
||||
bool isWindowMaximizedOnScreen(NSDictionary *app, NSScreen *screen)
|
||||
{
|
||||
double maximizedTolerance = 0.99;
|
||||
NSRect screenFrame = [screen frame];
|
||||
NSRect windowBounds;
|
||||
CGRectMakeWithDictionaryRepresentation(
|
||||
(CFDictionaryRef)[app objectForKey:@"kCGWindowBounds"],
|
||||
&windowBounds);
|
||||
|
||||
const double tolerance = 4.0;
|
||||
int sumX = windowBounds.origin.x + windowBounds.size.width;
|
||||
int sumY = windowBounds.origin.y + windowBounds.size.height;
|
||||
|
||||
// Width must span the full visible width.
|
||||
if (fabs(windowBounds.origin.x - screenLeft) > tolerance) {
|
||||
// Return false if window spans over multiple screens
|
||||
if (sumX > screenFrame.size.width) {
|
||||
return false;
|
||||
}
|
||||
if (fabs((windowBounds.origin.x + windowBounds.size.width) -
|
||||
screenRight) > tolerance) {
|
||||
if (sumY > screenFrame.size.height) {
|
||||
return false;
|
||||
}
|
||||
// Bottom edge must align with the visible bottom (above dock).
|
||||
if (fabs((windowBounds.origin.y + windowBounds.size.height) -
|
||||
screenBottom) > tolerance) {
|
||||
return false;
|
||||
|
||||
return ((double)sumX / (double)screenFrame.size.width) >
|
||||
maximizedTolerance &&
|
||||
((double)sumY / (double)screenFrame.size.height) >
|
||||
maximizedTolerance;
|
||||
}
|
||||
|
||||
bool nameMachesPattern(std::string windowName, std::string pattern)
|
||||
{
|
||||
return QString::fromStdString(windowName)
|
||||
.contains(QRegularExpression(QString::fromStdString(pattern)));
|
||||
}
|
||||
|
||||
bool IsMaximized(const std::string &title)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSArray *screens = [NSScreen screens];
|
||||
CFArrayRef cfApps = CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
||||
NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
|
||||
for (NSDictionary *app in apps) {
|
||||
std::string name([[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
std::string owner(
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
|
||||
bool equals = (title == name || title == owner);
|
||||
bool matches = nameMachesPattern(name, title) ||
|
||||
nameMachesPattern(owner, title);
|
||||
if (equals || matches) {
|
||||
for (NSScreen *screen in screens) {
|
||||
if (isWindowOriginOnScreen(app,
|
||||
screen) &&
|
||||
isWindowMaximizedOnScreen(app,
|
||||
screen)) {
|
||||
apps = nil;
|
||||
CFRelease(cfApps);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
apps = nil;
|
||||
CFRelease(cfApps);
|
||||
}
|
||||
// Top edge must be at or above the menubar line (some apps extend
|
||||
// their window frame behind the menubar).
|
||||
if (windowBounds.origin.y > screenTop + tolerance) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isWindowFullscreenOnScreen(NSDictionary *app, NSScreen *screen)
|
||||
@@ -129,176 +207,52 @@ bool isWindowFullscreenOnScreen(NSDictionary *app, NSScreen *screen)
|
||||
return NSEqualSizes(windowBounds.size, screenFrame.size);
|
||||
}
|
||||
|
||||
std::vector<WindowInfo> GetWindows(const WindowQueryOptions &options)
|
||||
bool IsFullscreen(const std::string &title)
|
||||
{
|
||||
std::vector<WindowInfo> result;
|
||||
const std::string foregroundTitle = GetCurrentWindowTitle();
|
||||
|
||||
@autoreleasepool {
|
||||
NSArray *screens = [NSScreen screens];
|
||||
|
||||
CFArrayRef cfApps = CGWindowListCopyWindowInfo(
|
||||
kCGWindowListExcludeDesktopElements, kCGNullWindowID);
|
||||
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
||||
NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
|
||||
|
||||
// Pre-compute which PIDs own at least one fullscreen-sized window.
|
||||
// A fullscreen app reports a small chrome/title bar window first and
|
||||
// its full-size content window second; checking only the first
|
||||
// window's bounds gives a false negative.
|
||||
std::set<int> fullscreenPIDs;
|
||||
if (options.fullscreen) {
|
||||
for (NSDictionary *app in apps) {
|
||||
int layer = [[app objectForKey:@"kCGWindowLayer"]
|
||||
intValue];
|
||||
if (layer != 0) {
|
||||
continue;
|
||||
}
|
||||
for (NSScreen *screen in screens) {
|
||||
if (isWindowFullscreenOnScreen(app,
|
||||
screen)) {
|
||||
int pid = [[app objectForKey:
|
||||
@"kCGWindowOwnerPID"]
|
||||
intValue];
|
||||
fullscreenPIDs.insert(pid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<int> maximizedPIDs;
|
||||
if (options.maximized) {
|
||||
for (NSDictionary *app in apps) {
|
||||
int layer = [[app objectForKey:@"kCGWindowLayer"]
|
||||
intValue];
|
||||
if (layer != 0) {
|
||||
continue;
|
||||
}
|
||||
for (NSScreen *screen in screens) {
|
||||
if (isWindowMaximizedOnScreen(app,
|
||||
screen)) {
|
||||
int pid = [[app objectForKey:
|
||||
@"kCGWindowOwnerPID"]
|
||||
intValue];
|
||||
maximizedPIDs.insert(pid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-compute the largest-area window bounds per PID.
|
||||
// CGWindowList often lists small auxiliary windows (toolbars,
|
||||
// chrome) before the main content window; using the largest area
|
||||
// avoids reporting those wrong bounds for geometry.
|
||||
std::map<int, NSRect> largestBoundsPerPID;
|
||||
if (options.geometry || options.maximized) {
|
||||
for (NSDictionary *app in apps) {
|
||||
int layer = [[app objectForKey:@"kCGWindowLayer"]
|
||||
intValue];
|
||||
if (layer != 0) {
|
||||
continue;
|
||||
}
|
||||
NSRect b = NSZeroRect;
|
||||
CGRectMakeWithDictionaryRepresentation(
|
||||
(CFDictionaryRef)[app
|
||||
objectForKey:@"kCGWindowBounds"],
|
||||
&b);
|
||||
int pid = [[app objectForKey:@"kCGWindowOwnerPID"]
|
||||
intValue];
|
||||
auto it = largestBoundsPerPID.find(pid);
|
||||
if (it == largestBoundsPerPID.end() ||
|
||||
b.size.width * b.size.height >
|
||||
it->second.size.width *
|
||||
it->second.size.height) {
|
||||
largestBoundsPerPID[pid] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Track titles already added to avoid duplicates (name + owner)
|
||||
std::vector<std::string> seen;
|
||||
|
||||
for (NSDictionary *app in apps) {
|
||||
int layer =
|
||||
[[app objectForKey:@"kCGWindowLayer"] intValue];
|
||||
if (layer != 0) {
|
||||
continue;
|
||||
}
|
||||
std::string name([[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
std::string owner(
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
|
||||
std::string name = nsStringToStdString(
|
||||
[app objectForKey:@"kCGWindowName"]);
|
||||
std::string owner = nsStringToStdString(
|
||||
[app objectForKey:@"kCGWindowOwnerName"]);
|
||||
|
||||
// Collect geometry once (used for multiple fields)
|
||||
NSRect bounds = NSZeroRect;
|
||||
if (options.geometry || options.fullscreen ||
|
||||
options.maximized) {
|
||||
CGRectMakeWithDictionaryRepresentation(
|
||||
(CFDictionaryRef)[app
|
||||
objectForKey:@"kCGWindowBounds"],
|
||||
&bounds);
|
||||
}
|
||||
|
||||
// Process both the window name and the owner name as
|
||||
// separate entries, matching the old GetWindowList() behaviour
|
||||
for (int pass = 0; pass < 2; ++pass) {
|
||||
const std::string &title = (pass == 0) ? name
|
||||
: owner;
|
||||
if (title.empty()) {
|
||||
continue;
|
||||
}
|
||||
if (std::find(seen.begin(), seen.end(),
|
||||
title) != seen.end()) {
|
||||
continue;
|
||||
}
|
||||
seen.emplace_back(title);
|
||||
|
||||
WindowInfo info;
|
||||
info.title = title;
|
||||
|
||||
if (options.focus) {
|
||||
info.focused =
|
||||
(title == foregroundTitle);
|
||||
}
|
||||
|
||||
if (options.geometry || options.fullscreen ||
|
||||
options.maximized) {
|
||||
int pid = [[app objectForKey:
|
||||
@"kCGWindowOwnerPID"]
|
||||
intValue];
|
||||
auto it = largestBoundsPerPID.find(pid);
|
||||
const NSRect &geoBounds =
|
||||
(it != largestBoundsPerPID.end())
|
||||
? it->second
|
||||
: bounds;
|
||||
info.x = (int)geoBounds.origin.x;
|
||||
info.y = (int)geoBounds.origin.y;
|
||||
info.width = (int)geoBounds.size.width;
|
||||
info.height = (int)geoBounds.size.height;
|
||||
|
||||
if (options.fullscreen) {
|
||||
info.fullscreen =
|
||||
fullscreenPIDs.count(pid) >
|
||||
0;
|
||||
}
|
||||
|
||||
if (options.maximized) {
|
||||
info.maximized =
|
||||
maximizedPIDs.count(pid) >
|
||||
0;
|
||||
bool equals = (title == name || title == owner);
|
||||
bool matches = nameMachesPattern(name, title) ||
|
||||
nameMachesPattern(owner, title);
|
||||
if (equals || matches) {
|
||||
for (NSScreen *screen in screens) {
|
||||
if (isWindowOriginOnScreen(app, screen,
|
||||
true) &&
|
||||
isWindowFullscreenOnScreen(
|
||||
app, screen)) {
|
||||
apps = nil;
|
||||
CFRelease(cfApps);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// windowClass and text not implemented on macOS
|
||||
result.emplace_back(std::move(info));
|
||||
}
|
||||
}
|
||||
apps = nil;
|
||||
CFRelease(cfApps);
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<std::string> GetTextInWindow(const std::string &)
|
||||
{
|
||||
// Not implemented
|
||||
return {};
|
||||
}
|
||||
|
||||
int SecondsSinceLastInput()
|
||||
@@ -387,7 +341,8 @@ QStringList GetProcessPathsFromName(const QString &name)
|
||||
continue;
|
||||
}
|
||||
const char *nameStr = appName.UTF8String;
|
||||
if (!nameStr || name != QString::fromUtf8(nameStr)) {
|
||||
if (!nameStr ||
|
||||
name != QString::fromUtf8(nameStr)) {
|
||||
continue;
|
||||
}
|
||||
NSURL *url = app.executableURL;
|
||||
|
||||
@@ -11,31 +11,11 @@ namespace advss {
|
||||
|
||||
enum class HotkeyType;
|
||||
|
||||
struct WindowQueryOptions {
|
||||
bool geometry = false;
|
||||
bool focus = false;
|
||||
bool fullscreen = false;
|
||||
bool maximized = false;
|
||||
bool windowClass = false; // Windows only, no-op on other platforms
|
||||
bool text = false; // Windows only, expensive, no-op on other platforms
|
||||
};
|
||||
|
||||
struct WindowInfo {
|
||||
std::string title;
|
||||
bool focused = false;
|
||||
bool fullscreen = false;
|
||||
bool maximized = false;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
std::string windowClass;
|
||||
std::optional<std::string> text;
|
||||
};
|
||||
|
||||
EXPORT std::vector<WindowInfo>
|
||||
GetWindows(const WindowQueryOptions &options = {});
|
||||
EXPORT std::vector<std::string> GetWindowList();
|
||||
EXPORT std::string GetCurrentWindowTitle();
|
||||
EXPORT bool IsFullscreen(const std::string &title);
|
||||
EXPORT bool IsMaximized(const std::string &title);
|
||||
EXPORT std::optional<std::string> GetTextInWindow(const std::string &window);
|
||||
EXPORT int SecondsSinceLastInput();
|
||||
EXPORT QStringList GetProcessList();
|
||||
EXPORT std::string GetForegroundProcessName();
|
||||
|
||||
@@ -16,17 +16,14 @@ static void setupTab(QTabWidget *);
|
||||
|
||||
static ActionQueueTable *tabWidget = nullptr;
|
||||
|
||||
static bool setup()
|
||||
void RegisterActionQueueTab()
|
||||
{
|
||||
AddPluginInitStep([] {
|
||||
AddPluginInitStep([]() {
|
||||
AddSetupTabCallback("actionQueueTab", ActionQueueTable::Create,
|
||||
setupTab);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool setupDone = setup();
|
||||
|
||||
static void setTabVisible(QTabWidget *tabWidget, bool visible)
|
||||
{
|
||||
SetTabVisibleByName(
|
||||
|
||||
@@ -12,16 +12,20 @@ std::deque<std::shared_ptr<Item>> &GetActionQueues()
|
||||
return queues;
|
||||
}
|
||||
|
||||
static bool setup()
|
||||
void RegisterActionQueueTab();
|
||||
|
||||
void SetupActionQueues()
|
||||
{
|
||||
static bool done = false;
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
AddSaveStep(SaveActionQueues);
|
||||
AddLoadStep(LoadActionQueues);
|
||||
AddPluginCleanupStep([]() { queues.clear(); });
|
||||
return true;
|
||||
RegisterActionQueueTab();
|
||||
done = true;
|
||||
}
|
||||
|
||||
static bool setupDone = setup();
|
||||
|
||||
ActionQueue::ActionQueue() : Item()
|
||||
{
|
||||
_lastEmpty = std::chrono::high_resolution_clock::now();
|
||||
|
||||
@@ -101,6 +101,7 @@ signals:
|
||||
};
|
||||
|
||||
std::deque<std::shared_ptr<Item>> &GetActionQueues();
|
||||
void SetupActionQueues();
|
||||
void SaveActionQueues(obs_data_t *);
|
||||
void LoadActionQueues(obs_data_t *);
|
||||
void ImportQueues(obs_data_t *);
|
||||
|
||||
@@ -163,8 +163,6 @@ public:
|
||||
bool disableHints = false;
|
||||
bool disableFilterComboboxFilter = false;
|
||||
bool hideLegacyTabs = true;
|
||||
bool settingsLockEnabled = false;
|
||||
std::string settingsLockPassword;
|
||||
bool saveWindowGeo = false;
|
||||
QPoint windowPos = {};
|
||||
QSize windowSize = {};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
namespace advss {
|
||||
|
||||
const std::map<Logic::Type, const char *> Logic::localeMap = {
|
||||
{Logic::Type::NONE, {"AdvSceneSwitcher.logic.none"}},
|
||||
{Logic::Type::AND, {"AdvSceneSwitcher.logic.and"}},
|
||||
{Logic::Type::OR, {"AdvSceneSwitcher.logic.or"}},
|
||||
{Logic::Type::AND_NOT, {"AdvSceneSwitcher.logic.andNot"}},
|
||||
@@ -66,7 +67,7 @@ void Logic::PopulateLogicTypeSelection(QComboBox *list, bool isRootCondition)
|
||||
return typeValue < rootOffset;
|
||||
}}
|
||||
: std::function<bool(int)>{[](int typeValue) {
|
||||
return typeValue > rootOffset;
|
||||
return typeValue >= rootOffset;
|
||||
}};
|
||||
for (const auto &[type, name] : localeMap) {
|
||||
const int typeValue = static_cast<int>(type);
|
||||
|
||||
@@ -28,8 +28,6 @@ static constexpr bool handleUncleanShutdown = true;
|
||||
static bool wasCleanShutdown = false;
|
||||
static bool suppressCrashDialog = false;
|
||||
|
||||
static char *sentinelFile = nullptr;
|
||||
|
||||
bool GetSuppressCrashDialog()
|
||||
{
|
||||
return suppressCrashDialog;
|
||||
@@ -60,6 +58,7 @@ static void handleShutdown(enum obs_frontend_event event, void *)
|
||||
return;
|
||||
}
|
||||
|
||||
char *sentinelFile = obs_module_config_path(sentinel.data());
|
||||
if (!sentinelFile) {
|
||||
return;
|
||||
}
|
||||
@@ -79,8 +78,7 @@ static void handleShutdown(enum obs_frontend_event event, void *)
|
||||
|
||||
static void setup()
|
||||
{
|
||||
// Freed in handleShutdown()
|
||||
sentinelFile = obs_module_config_path(sentinel.data());
|
||||
char *sentinelFile = obs_module_config_path(sentinel.data());
|
||||
if (!sentinelFile) {
|
||||
return;
|
||||
}
|
||||
@@ -108,6 +106,7 @@ static void setup()
|
||||
|
||||
file.write("running");
|
||||
file.close();
|
||||
bfree(sentinelFile);
|
||||
|
||||
obs_frontend_add_event_callback(handleShutdown, nullptr);
|
||||
return;
|
||||
|
||||
@@ -11,7 +11,6 @@ static void populateUnits(QComboBox *list)
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.unit.seconds"));
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.unit.minutes"));
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.unit.hours"));
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.unit.days"));
|
||||
}
|
||||
|
||||
DurationSelection::DurationSelection(QWidget *parent, bool showUnitSelection,
|
||||
@@ -67,8 +66,6 @@ static int durationUnitToMultiplier(Duration::Unit u)
|
||||
return 60;
|
||||
case Duration::Unit::HOURS:
|
||||
return 3600;
|
||||
case Duration::Unit::DAYS:
|
||||
return 86400;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,6 @@ static std::string durationUnitToString(Duration::Unit u)
|
||||
return obs_module_text("AdvSceneSwitcher.unit.minutes");
|
||||
case Duration::Unit::HOURS:
|
||||
return obs_module_text("AdvSceneSwitcher.unit.hours");
|
||||
case Duration::Unit::DAYS:
|
||||
return obs_module_text("AdvSceneSwitcher.unit.days");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -153,8 +151,6 @@ static int durationUnitToMultiplier(Duration::Unit u)
|
||||
return 60;
|
||||
case Duration::Unit::HOURS:
|
||||
return 3600;
|
||||
case Duration::Unit::DAYS:
|
||||
return 86400;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ public:
|
||||
SECONDS,
|
||||
MINUTES,
|
||||
HOURS,
|
||||
DAYS,
|
||||
};
|
||||
EXPORT Unit GetUnit() const { return _unit; }
|
||||
|
||||
|
||||
@@ -398,14 +398,10 @@ void FirstRunWizard::markFirstRunComplete()
|
||||
}
|
||||
|
||||
// static
|
||||
std::shared_ptr<Macro> FirstRunWizard::ShowWizard(QWidget *parent,
|
||||
bool *wasSkipped)
|
||||
std::shared_ptr<Macro> FirstRunWizard::ShowWizard(QWidget *parent)
|
||||
{
|
||||
auto wizard = new FirstRunWizard(parent);
|
||||
wizard->exec();
|
||||
if (wasSkipped) {
|
||||
*wasSkipped = (wizard->result() == QDialog::Rejected);
|
||||
}
|
||||
wizard->deleteLater();
|
||||
return wizard->_macro;
|
||||
}
|
||||
|
||||
@@ -113,8 +113,7 @@ class FirstRunWizard : public QWizard {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FirstRunWizard(QWidget *parent = nullptr);
|
||||
static std::shared_ptr<Macro> ShowWizard(QWidget *parent,
|
||||
bool *wasSkipped = nullptr);
|
||||
static std::shared_ptr<Macro> ShowWizard(QWidget *parent);
|
||||
static bool
|
||||
CreateMacro(std::shared_ptr<Macro> ¯o, const std::string ¯oName,
|
||||
const std::string &conditionId, obs_data_t *conditionData,
|
||||
|
||||
@@ -75,18 +75,6 @@ static std::vector<std::function<void()>> &getStopSteps()
|
||||
return steps;
|
||||
}
|
||||
|
||||
static std::vector<std::function<void(obs_data_t *)>> &getEarlySaveSteps()
|
||||
{
|
||||
static std::vector<std::function<void(obs_data_t *)>> steps;
|
||||
return steps;
|
||||
}
|
||||
|
||||
static std::vector<std::function<void(obs_data_t *)>> &getEarlyLoadSteps()
|
||||
{
|
||||
static std::vector<std::function<void(obs_data_t *)>> steps;
|
||||
return steps;
|
||||
}
|
||||
|
||||
static std::vector<std::function<void(obs_data_t *)>> &getSaveSteps()
|
||||
{
|
||||
static std::vector<std::function<void(obs_data_t *)>> steps;
|
||||
@@ -121,18 +109,6 @@ void LoadPluginSettings(obs_data_t *obj)
|
||||
GetSwitcher()->LoadSettings(obj);
|
||||
}
|
||||
|
||||
void AddEarlySaveStep(std::function<void(obs_data_t *)> step)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
getEarlySaveSteps().emplace_back(step);
|
||||
}
|
||||
|
||||
void AddEarlyLoadStep(std::function<void(obs_data_t *)> step)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
getEarlyLoadSteps().emplace_back(step);
|
||||
}
|
||||
|
||||
void AddSaveStep(std::function<void(obs_data_t *)> step)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
@@ -160,9 +136,6 @@ void AddIntervalResetStep(std::function<void()> step)
|
||||
void RunSaveSteps(obs_data_t *obj)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
for (const auto &func : getEarlySaveSteps()) {
|
||||
func(obj);
|
||||
}
|
||||
for (const auto &func : getSaveSteps()) {
|
||||
func(obj);
|
||||
}
|
||||
@@ -171,9 +144,6 @@ void RunSaveSteps(obs_data_t *obj)
|
||||
void RunLoadSteps(obs_data_t *obj)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
for (const auto &func : getEarlyLoadSteps()) {
|
||||
func(obj);
|
||||
}
|
||||
for (const auto &func : getLoadSteps()) {
|
||||
func(obj);
|
||||
}
|
||||
@@ -340,7 +310,7 @@ bool HighlightUIElementsEnabled()
|
||||
|
||||
bool OBSIsShuttingDown()
|
||||
{
|
||||
return !GetSwitcher() || GetSwitcher()->obsIsShuttingDown;
|
||||
return GetSwitcher() && GetSwitcher()->obsIsShuttingDown;
|
||||
}
|
||||
|
||||
bool InitialLoadIsComplete()
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace advss {
|
||||
void SavePluginSettings(obs_data_t *);
|
||||
EXPORT void LoadPluginSettings(obs_data_t *);
|
||||
|
||||
void AddEarlySaveStep(std::function<void(obs_data_t *)>);
|
||||
void AddEarlyLoadStep(std::function<void(obs_data_t *)>);
|
||||
EXPORT void AddSaveStep(std::function<void(obs_data_t *)>);
|
||||
EXPORT void AddLoadStep(std::function<void(obs_data_t *)>);
|
||||
EXPORT void AddPostLoadStep(std::function<void()>);
|
||||
|
||||
@@ -173,10 +173,10 @@ void PopulateTransitionSelection(QComboBox *sel, bool addCurrent, bool addAny,
|
||||
void PopulateWindowSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
|
||||
const auto windows = GetWindows();
|
||||
const auto windows = GetWindowList();
|
||||
|
||||
for (const auto &info : windows) {
|
||||
sel->addItem(info.title.c_str());
|
||||
for (const std::string &window : windows) {
|
||||
sel->addItem(window.c_str());
|
||||
}
|
||||
|
||||
sel->model()->sort(0);
|
||||
|
||||
@@ -162,48 +162,4 @@ bool IsMediaSource(obs_source_t *source)
|
||||
return (flags & OBS_SOURCE_CONTROLLABLE_MEDIA) != 0;
|
||||
}
|
||||
|
||||
SourceActiveKeeper::~SourceActiveKeeper()
|
||||
{
|
||||
ReleaseRef();
|
||||
}
|
||||
|
||||
void SourceActiveKeeper::SetActive(bool active)
|
||||
{
|
||||
if (_active == active) {
|
||||
return;
|
||||
}
|
||||
if (active) {
|
||||
_active = true;
|
||||
AcquireRef();
|
||||
} else {
|
||||
ReleaseRef();
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SourceActiveKeeper::SetSource(obs_source_t *source)
|
||||
{
|
||||
if (_source == source) {
|
||||
return;
|
||||
}
|
||||
ReleaseRef();
|
||||
_source = source;
|
||||
AcquireRef();
|
||||
}
|
||||
|
||||
void SourceActiveKeeper::AcquireRef()
|
||||
{
|
||||
if (_active && _source) {
|
||||
obs_source_inc_active(_source);
|
||||
}
|
||||
}
|
||||
|
||||
void SourceActiveKeeper::ReleaseRef()
|
||||
{
|
||||
if (_active && _source) {
|
||||
obs_source_dec_active(_source);
|
||||
_source = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -20,25 +20,4 @@ EXPORT OBSWeakSource GetWeakFilterByQString(OBSWeakSource source,
|
||||
EXPORT int GetSceneItemCount(const OBSWeakSource &);
|
||||
EXPORT bool IsMediaSource(obs_source_t *source);
|
||||
|
||||
// RAII helper that keeps an OBS source active (via obs_source_inc_active /
|
||||
// obs_source_dec_active) for as long as the keeper is enabled.
|
||||
class EXPORT SourceActiveKeeper {
|
||||
public:
|
||||
SourceActiveKeeper() = default;
|
||||
~SourceActiveKeeper();
|
||||
|
||||
SourceActiveKeeper(const SourceActiveKeeper &) = delete;
|
||||
SourceActiveKeeper &operator=(const SourceActiveKeeper &) = delete;
|
||||
|
||||
void SetActive(bool active);
|
||||
void SetSource(obs_source_t *source);
|
||||
|
||||
private:
|
||||
void AcquireRef();
|
||||
void ReleaseRef();
|
||||
|
||||
OBSSource _source;
|
||||
bool _active = false;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -74,7 +74,6 @@ public:
|
||||
EXPORT std::optional<const TempVariable> GetTempVariable(Macro *) const;
|
||||
EXPORT bool operator==(const TempVariableRef &other) const;
|
||||
bool HasValidID() const { return !_id.empty(); }
|
||||
std::string GetID() const { return _id; }
|
||||
|
||||
private:
|
||||
enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION };
|
||||
|
||||
@@ -29,7 +29,6 @@ static void save(obs_data_t *data)
|
||||
{
|
||||
tabSettings.Save(data, "tabSettings");
|
||||
dockSettings.Save(data, "dockSettings");
|
||||
|
||||
obs_data_set_bool(data, "addVariablesDock", addDock);
|
||||
}
|
||||
|
||||
@@ -64,6 +63,7 @@ static void load(obs_data_t *data)
|
||||
{
|
||||
tabSettings.Load(data, "tabSettings");
|
||||
dockSettings.Load(data, "dockSettings");
|
||||
|
||||
enableDock(obs_data_get_bool(data, "addVariablesDock"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#include "variable.hpp"
|
||||
#include "math-helpers.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include <obs.hpp>
|
||||
|
||||
#include <QGridLayout>
|
||||
|
||||
namespace advss {
|
||||
@@ -18,15 +15,6 @@ static std::deque<std::shared_ptr<Item>> variables;
|
||||
static std::mutex lastVariableChangeMutex;
|
||||
static std::chrono::high_resolution_clock::time_point lastVariableChange{};
|
||||
|
||||
static bool setup()
|
||||
{
|
||||
AddEarlySaveStep(SaveVariables);
|
||||
AddEarlyLoadStep(LoadVariables);
|
||||
AddPluginCleanupStep([]() { variables.clear(); });
|
||||
return true;
|
||||
}
|
||||
static bool setupDone = setup();
|
||||
|
||||
static void setLastVariableChangeTime()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(lastVariableChangeMutex);
|
||||
@@ -430,31 +418,34 @@ static bool variableWithNameExists(const std::string &name)
|
||||
|
||||
void SaveVariables(obs_data_t *obj)
|
||||
{
|
||||
OBSDataArrayAutoRelease variablesArray = obs_data_array_create();
|
||||
obs_data_array_t *variablesArray = obs_data_array_create();
|
||||
for (const auto &v : variables) {
|
||||
OBSDataAutoRelease array_obj = obs_data_create();
|
||||
obs_data_t *array_obj = obs_data_create();
|
||||
v->Save(array_obj);
|
||||
obs_data_array_push_back(variablesArray, array_obj);
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
obs_data_set_array(obj, "variables", variablesArray);
|
||||
obs_data_array_release(variablesArray);
|
||||
}
|
||||
|
||||
void LoadVariables(obs_data_t *obj)
|
||||
{
|
||||
variables.clear();
|
||||
|
||||
OBSDataArrayAutoRelease variablesArray =
|
||||
obs_data_get_array(obj, "variables");
|
||||
obs_data_array_t *variablesArray = obs_data_get_array(obj, "variables");
|
||||
size_t count = obs_data_array_count(variablesArray);
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
OBSDataAutoRelease array_obj =
|
||||
obs_data_array_item(variablesArray, i);
|
||||
obs_data_t *array_obj = obs_data_array_item(variablesArray, i);
|
||||
auto var = Variable::Create();
|
||||
variables.emplace_back(var);
|
||||
variables.back()->Load(array_obj);
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
obs_data_array_release(variablesArray);
|
||||
}
|
||||
|
||||
static void signalImportedVariables(void *varsPtr)
|
||||
@@ -469,15 +460,16 @@ static void signalImportedVariables(void *varsPtr)
|
||||
|
||||
void ImportVariables(obs_data_t *data)
|
||||
{
|
||||
OBSDataArrayAutoRelease array = obs_data_get_array(data, "variables");
|
||||
obs_data_array_t *array = obs_data_get_array(data, "variables");
|
||||
size_t count = obs_data_array_count(array);
|
||||
|
||||
auto importedVars = new std::vector<std::shared_ptr<Item>>;
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
OBSDataAutoRelease arrayElement = obs_data_array_item(array, i);
|
||||
obs_data_t *arrayElement = obs_data_array_item(array, i);
|
||||
auto var = Variable::Create();
|
||||
var->Load(arrayElement);
|
||||
obs_data_release(arrayElement);
|
||||
|
||||
if (variableWithNameExists(var->Name())) {
|
||||
continue;
|
||||
@@ -487,6 +479,8 @@ void ImportVariables(obs_data_t *data)
|
||||
importedVars->emplace_back(var);
|
||||
}
|
||||
|
||||
obs_data_array_release(array);
|
||||
|
||||
QueueUITask(signalImportedVariables, importedVars);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#include "platform-funcs.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
|
||||
#include <windows.h>
|
||||
#include <UIAutomation.h>
|
||||
#include <util/platform.h>
|
||||
#include <TlHelp32.h>
|
||||
#include <Psapi.h>
|
||||
#include <memory>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <string>
|
||||
@@ -18,9 +16,6 @@
|
||||
#include <QWidget>
|
||||
#include <mutex>
|
||||
|
||||
#define ADVSS_WIDEN_(x) L##x
|
||||
#define ADVSS_WIDEN(x) ADVSS_WIDEN_(x)
|
||||
|
||||
namespace advss {
|
||||
|
||||
#define MAX_SEARCH 1000
|
||||
@@ -138,7 +133,7 @@ const std::vector<std::string> getOBSWindows()
|
||||
return lastDoneHelper->windows;
|
||||
}
|
||||
|
||||
static std::vector<std::string> getAllWindowTitles()
|
||||
std::vector<std::string> GetWindowList()
|
||||
{
|
||||
std::vector<std::string> windows;
|
||||
EnumWindowsWithMetro(GetTitleCB, reinterpret_cast<LPARAM>(&windows));
|
||||
@@ -155,129 +150,6 @@ static std::vector<std::string> getAllWindowTitles()
|
||||
return windows;
|
||||
}
|
||||
|
||||
static bool isWindowMaximized(HWND hwnd)
|
||||
{
|
||||
if (!hwnd || hwnd == GetDesktopWindow() || hwnd == GetShellWindow()) {
|
||||
return false;
|
||||
}
|
||||
if (IsZoomed(hwnd)) {
|
||||
return true;
|
||||
}
|
||||
RECT appBounds;
|
||||
MONITORINFO monitorInfo = {0};
|
||||
monitorInfo.cbSize = sizeof(MONITORINFO);
|
||||
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
|
||||
&monitorInfo);
|
||||
GetWindowRect(hwnd, &appBounds);
|
||||
return monitorInfo.rcMonitor.bottom == appBounds.bottom &&
|
||||
monitorInfo.rcMonitor.top == appBounds.top &&
|
||||
monitorInfo.rcMonitor.left == appBounds.left &&
|
||||
monitorInfo.rcMonitor.right == appBounds.right;
|
||||
}
|
||||
|
||||
static bool isWindowFullscreen(HWND hwnd)
|
||||
{
|
||||
if (!hwnd || hwnd == GetDesktopWindow() || hwnd == GetShellWindow()) {
|
||||
return false;
|
||||
}
|
||||
RECT appBounds;
|
||||
MONITORINFO monitorInfo = {0};
|
||||
monitorInfo.cbSize = sizeof(MONITORINFO);
|
||||
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
|
||||
&monitorInfo);
|
||||
GetWindowRect(hwnd, &appBounds);
|
||||
return monitorInfo.rcMonitor.bottom == appBounds.bottom &&
|
||||
monitorInfo.rcMonitor.top == appBounds.top &&
|
||||
monitorInfo.rcMonitor.left == appBounds.left &&
|
||||
monitorInfo.rcMonitor.right == appBounds.right;
|
||||
}
|
||||
|
||||
static std::string getWindowClass(HWND hwnd)
|
||||
{
|
||||
std::wstring wClass;
|
||||
wClass.resize(256);
|
||||
int len = GetClassNameW(hwnd, &wClass[0], (int)wClass.size());
|
||||
if (len <= 0) {
|
||||
return "";
|
||||
}
|
||||
wClass.resize(len);
|
||||
size_t utf8len = os_wcs_to_utf8(wClass.c_str(), 0, nullptr, 0);
|
||||
std::string result;
|
||||
result.resize(utf8len);
|
||||
os_wcs_to_utf8(wClass.c_str(), 0, &result[0], utf8len + 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
static HWND getHWNDfromTitle(const std::string &title);
|
||||
static std::optional<std::string> GetTextInWindow(const std::string &window);
|
||||
|
||||
std::vector<WindowInfo> GetWindows(const WindowQueryOptions &options)
|
||||
{
|
||||
const std::string foregroundTitle = GetCurrentWindowTitle();
|
||||
const auto titles = getAllWindowTitles();
|
||||
|
||||
std::vector<WindowInfo> result;
|
||||
result.reserve(titles.size());
|
||||
|
||||
for (const auto &title : titles) {
|
||||
WindowInfo info;
|
||||
info.title = title;
|
||||
|
||||
const bool needHwnd = options.geometry || options.fullscreen ||
|
||||
options.maximized ||
|
||||
options.windowClass || options.text ||
|
||||
options.focus;
|
||||
|
||||
if (options.focus) {
|
||||
info.focused = (title == foregroundTitle);
|
||||
}
|
||||
|
||||
if (!needHwnd || (!options.geometry && !options.fullscreen &&
|
||||
!options.maximized && !options.windowClass &&
|
||||
!options.text)) {
|
||||
result.emplace_back(std::move(info));
|
||||
continue;
|
||||
}
|
||||
|
||||
HWND hwnd = getHWNDfromTitle(title);
|
||||
if (!hwnd) {
|
||||
result.emplace_back(std::move(info));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (options.geometry || options.fullscreen ||
|
||||
options.maximized) {
|
||||
RECT rect;
|
||||
if (GetWindowRect(hwnd, &rect)) {
|
||||
info.x = rect.left;
|
||||
info.y = rect.top;
|
||||
info.width = rect.right - rect.left;
|
||||
info.height = rect.bottom - rect.top;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.maximized) {
|
||||
info.maximized = isWindowMaximized(hwnd);
|
||||
}
|
||||
|
||||
if (options.fullscreen) {
|
||||
info.fullscreen = isWindowFullscreen(hwnd);
|
||||
}
|
||||
|
||||
if (options.windowClass) {
|
||||
info.windowClass = getWindowClass(hwnd);
|
||||
}
|
||||
|
||||
if (options.text) {
|
||||
info.text = GetTextInWindow(title);
|
||||
}
|
||||
|
||||
result.emplace_back(std::move(info));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetCurrentWindowTitle()
|
||||
{
|
||||
HWND window = GetForegroundWindow();
|
||||
@@ -316,6 +188,36 @@ static HWND getHWNDfromTitle(const std::string &title)
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
bool IsMaximized(const std::string &title)
|
||||
{
|
||||
RECT appBounds;
|
||||
MONITORINFO monitorInfo = {0};
|
||||
HWND hwnd = NULL;
|
||||
|
||||
hwnd = getHWNDfromTitle(title);
|
||||
if (!hwnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
monitorInfo.cbSize = sizeof(MONITORINFO);
|
||||
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
|
||||
&monitorInfo);
|
||||
|
||||
if (hwnd && hwnd != GetDesktopWindow() && hwnd != GetShellWindow()) {
|
||||
if (IsZoomed(hwnd)) {
|
||||
return true;
|
||||
}
|
||||
GetWindowRect(hwnd, &appBounds);
|
||||
if (monitorInfo.rcMonitor.bottom == appBounds.bottom &&
|
||||
monitorInfo.rcMonitor.top == appBounds.top &&
|
||||
monitorInfo.rcMonitor.left == appBounds.left &&
|
||||
monitorInfo.rcMonitor.right == appBounds.right) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::wstring GetControlText(HWND hwnd, IUIAutomationElement *element)
|
||||
{
|
||||
VARIANT var;
|
||||
@@ -342,7 +244,7 @@ static std::wstring GetControlText(HWND hwnd, IUIAutomationElement *element)
|
||||
return text;
|
||||
}
|
||||
|
||||
static std::optional<std::string> GetTextInWindow(const std::string &window)
|
||||
std::optional<std::string> GetTextInWindow(const std::string &window)
|
||||
{
|
||||
HWND hwnd = getHWNDfromTitle(window);
|
||||
if (!hwnd) {
|
||||
@@ -409,6 +311,35 @@ static std::optional<std::string> GetTextInWindow(const std::string &window)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
bool IsFullscreen(const std::string &title)
|
||||
{
|
||||
RECT appBounds;
|
||||
MONITORINFO monitorInfo = {0};
|
||||
|
||||
HWND hwnd = NULL;
|
||||
hwnd = getHWNDfromTitle(title);
|
||||
|
||||
if (!hwnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
monitorInfo.cbSize = sizeof(MONITORINFO);
|
||||
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
|
||||
&monitorInfo);
|
||||
|
||||
if (hwnd && hwnd != GetDesktopWindow() && hwnd != GetShellWindow()) {
|
||||
GetWindowRect(hwnd, &appBounds);
|
||||
if (monitorInfo.rcMonitor.bottom == appBounds.bottom &&
|
||||
monitorInfo.rcMonitor.top == appBounds.top &&
|
||||
monitorInfo.rcMonitor.left == appBounds.left &&
|
||||
monitorInfo.rcMonitor.right == appBounds.right) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList GetProcessList()
|
||||
{
|
||||
QStringList processes;
|
||||
@@ -569,86 +500,9 @@ int SecondsSinceLastInput()
|
||||
return (getTime() - getLastInputTime()) / 1000;
|
||||
}
|
||||
|
||||
static void addPluginFolderToSymbolPath()
|
||||
{
|
||||
// This runs after OBS_FRONTEND_EVENT_FINISHED_LOADING, which fires after
|
||||
// obs_load_all_modules() completes. By that point OBS has already called
|
||||
// reset_win32_symbol_paths() -> SymInitializeW(), so DbgHelp is
|
||||
// initialized and we can append our plugins subfolder (where the PDB
|
||||
// files live) to the existing search path.
|
||||
HMODULE dbghelp = LoadLibraryW(L"DbgHelp");
|
||||
if (!dbghelp) {
|
||||
return;
|
||||
}
|
||||
|
||||
typedef BOOL(WINAPI * SymGetSearchPathW_t)(HANDLE, PWSTR, DWORD);
|
||||
typedef BOOL(WINAPI * SymSetSearchPathW_t)(HANDLE, PCWSTR);
|
||||
typedef BOOL(WINAPI * SymRefreshModuleList_t)(HANDLE);
|
||||
|
||||
auto symGetSearchPathW = reinterpret_cast<SymGetSearchPathW_t>(
|
||||
GetProcAddress(dbghelp, "SymGetSearchPathW"));
|
||||
auto symSetSearchPathW = reinterpret_cast<SymSetSearchPathW_t>(
|
||||
GetProcAddress(dbghelp, "SymSetSearchPathW"));
|
||||
auto symRefreshModuleList = reinterpret_cast<SymRefreshModuleList_t>(
|
||||
GetProcAddress(dbghelp, "SymRefreshModuleList"));
|
||||
|
||||
if (!symGetSearchPathW || !symSetSearchPathW || !symRefreshModuleList) {
|
||||
FreeLibrary(dbghelp);
|
||||
return;
|
||||
}
|
||||
|
||||
HMODULE hModule = NULL;
|
||||
if (!GetModuleHandleExW(
|
||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
reinterpret_cast<LPCWSTR>(addPluginFolderToSymbolPath),
|
||||
&hModule)) {
|
||||
FreeLibrary(dbghelp);
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t dllDir[MAX_PATH];
|
||||
if (!GetModuleFileNameW(hModule, dllDir, MAX_PATH)) {
|
||||
FreeLibrary(dbghelp);
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t *lastSep = wcsrchr(dllDir, L'\\');
|
||||
if (!lastSep) {
|
||||
FreeLibrary(dbghelp);
|
||||
return;
|
||||
}
|
||||
*lastSep = L'\0';
|
||||
|
||||
wchar_t pluginsPath[MAX_PATH];
|
||||
wcsncpy_s(pluginsPath, MAX_PATH, dllDir, _TRUNCATE);
|
||||
wcsncat_s(pluginsPath, MAX_PATH, L"\\" ADVSS_WIDEN(ADVSS_PLUGIN_FOLDER),
|
||||
_TRUNCATE);
|
||||
|
||||
constexpr DWORD currentPathLen = 4096;
|
||||
constexpr DWORD newPathLen = 8192;
|
||||
auto currentPath = std::make_unique<wchar_t[]>(currentPathLen);
|
||||
auto newPath = std::make_unique<wchar_t[]>(newPathLen);
|
||||
|
||||
symGetSearchPathW(GetCurrentProcess(), currentPath.get(),
|
||||
currentPathLen);
|
||||
|
||||
if (currentPath[0] != L'\0') {
|
||||
_snwprintf_s(newPath.get(), newPathLen, _TRUNCATE, L"%s;%s",
|
||||
currentPath.get(), pluginsPath);
|
||||
} else {
|
||||
wcsncpy_s(newPath.get(), newPathLen, pluginsPath, _TRUNCATE);
|
||||
}
|
||||
|
||||
symSetSearchPathW(GetCurrentProcess(), newPath.get());
|
||||
symRefreshModuleList(GetCurrentProcess());
|
||||
FreeLibrary(dbghelp);
|
||||
}
|
||||
|
||||
void PlatformInit()
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
AddFinishedLoadingStep(addPluginFolderToSymbolPath);
|
||||
}
|
||||
|
||||
void PlatformCleanup()
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
#include <obs-module.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ADVSS_SETENV(k, v) _putenv_s(k, v)
|
||||
#define ADVSS_UNSETENV(k) _putenv_s(k, "")
|
||||
#else
|
||||
#define ADVSS_SETENV(k, v) setenv(k, v, 1)
|
||||
#define ADVSS_UNSETENV(k) unsetenv(k)
|
||||
#endif
|
||||
|
||||
#define ADVSS_INSTANCE_ENV "ADVSS_INSTANCE_LOADED"
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("advanced-scene-switcher", "en-US")
|
||||
@@ -28,12 +17,6 @@ void obs_module_post_load(void)
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
if (getenv(ADVSS_INSTANCE_ENV)) {
|
||||
blog(LOG_WARNING,
|
||||
"[adv-ss] Another instance is already loaded - skipping.");
|
||||
return false;
|
||||
}
|
||||
ADVSS_SETENV(ADVSS_INSTANCE_ENV, "1");
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
InitSceneSwitcher(obs_current_module(), obs_module_text);
|
||||
return true;
|
||||
@@ -42,5 +25,4 @@ bool obs_module_load(void)
|
||||
void obs_module_unload(void)
|
||||
{
|
||||
FreeSceneSwitcher();
|
||||
ADVSS_UNSETENV(ADVSS_INSTANCE_ENV);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ endmacro()
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
add_subdirectory(base)
|
||||
|
||||
# Add plugins below, which have dependencies to external libraries or other
|
||||
# components which might potentially not be fulfilled.
|
||||
|
||||
@@ -26,12 +28,10 @@ install_advss_plugin_dependency(...)
|
||||
... to install the plugin and its dependencies.
|
||||
#]]
|
||||
|
||||
add_plugin(base)
|
||||
add_plugin(http)
|
||||
add_plugin(midi)
|
||||
add_plugin(mqtt)
|
||||
add_plugin(openvr)
|
||||
add_plugin(schedule)
|
||||
add_plugin(scripting)
|
||||
add_plugin(stream-deck)
|
||||
add_plugin(twitch)
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
} // namespace
|
||||
|
||||
static void handleShutdown(enum obs_frontend_event event, void *)
|
||||
static void handleShutdown(enum obs_frontend_event event, void *private_data)
|
||||
{
|
||||
if (event != OBS_FRONTEND_EVENT_EXIT) {
|
||||
return;
|
||||
|
||||
@@ -259,7 +259,7 @@ void MacroActionSourceInteractionEdit::AcceptRecorded(
|
||||
_stepList->SetSteps(_entryData->_steps);
|
||||
}
|
||||
|
||||
void MacroActionSourceInteractionEdit::showEvent(QShowEvent *)
|
||||
void MacroActionSourceInteractionEdit::showEvent(QShowEvent *event)
|
||||
{
|
||||
const QSignalBlocker b(this);
|
||||
UpdateEntryData();
|
||||
|
||||
@@ -42,20 +42,19 @@ void CloseWindow(const std::string &) {}
|
||||
|
||||
std::optional<std::string> MacroActionWindow::GetMatchingWindow() const
|
||||
{
|
||||
const auto windows = GetWindows();
|
||||
const auto windowList = GetWindowList();
|
||||
|
||||
if (!_regex.Enabled()) {
|
||||
for (const auto &info : windows) {
|
||||
if (info.title == std::string(_window)) {
|
||||
return info.title;
|
||||
}
|
||||
if (std::find(windowList.begin(), windowList.end(),
|
||||
std::string(_window)) == windowList.end()) {
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
return _window;
|
||||
}
|
||||
|
||||
for (const auto &info : windows) {
|
||||
if (_regex.Matches(info.title, _window)) {
|
||||
return info.title;
|
||||
for (const auto &window : windowList) {
|
||||
if (_regex.Matches(window, _window)) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -710,7 +710,7 @@ void MacroConditionDateEdit::UpdateEntryData()
|
||||
SetWidgetStatus();
|
||||
}
|
||||
|
||||
void MacroConditionDateEdit::showEvent(QShowEvent *)
|
||||
void MacroConditionDateEdit::showEvent(QShowEvent *event)
|
||||
{
|
||||
const QSignalBlocker b(this);
|
||||
UpdateEntryData();
|
||||
|
||||
@@ -24,8 +24,6 @@ bool MacroConditionGameCapture::CheckCondition()
|
||||
return false;
|
||||
}
|
||||
|
||||
_activeKeeper.SetActive(_keepActive);
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
if (_hooked) {
|
||||
SetTempVarValue("title", _title);
|
||||
@@ -40,7 +38,6 @@ bool MacroConditionGameCapture::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroCondition::Save(obj);
|
||||
_source.Save(obj);
|
||||
obs_data_set_bool(obj, "keepActive", _keepActive);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,7 +45,6 @@ bool MacroConditionGameCapture::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroCondition::Load(obj);
|
||||
_source.Load(obj);
|
||||
_keepActive = obs_data_get_bool(obj, "keepActive");
|
||||
SetupSignalHandler(OBSGetStrongRef(_source.GetSource()));
|
||||
return true;
|
||||
}
|
||||
@@ -115,9 +111,6 @@ void MacroConditionGameCapture::SetupSignalHandler(obs_source_t *source)
|
||||
_unhookSignal = OBSSignal(sh, "unhooked", UnhookedSignalReceived, this);
|
||||
_lastSource = source;
|
||||
|
||||
_activeKeeper.SetActive(_keepActive);
|
||||
_activeKeeper.SetSource(source);
|
||||
|
||||
SetupInitialState(source);
|
||||
}
|
||||
|
||||
@@ -171,33 +164,17 @@ MacroConditionGameCaptureEdit::MacroConditionGameCaptureEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroConditionGameCapture> entryData)
|
||||
: QWidget(parent),
|
||||
_sources(new SourceSelectionWidget(this, getGameCaptureSourcesList,
|
||||
true)),
|
||||
_keepActive(new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.keepSourceActive"), this)),
|
||||
_keepActiveHelp(new HelpIcon(
|
||||
obs_module_text("AdvSceneSwitcher.keepSourceActive.help"),
|
||||
this))
|
||||
true))
|
||||
{
|
||||
QWidget::connect(_sources,
|
||||
SIGNAL(SourceChanged(const SourceSelection &)), this,
|
||||
SLOT(SourceChanged(const SourceSelection &)));
|
||||
QWidget::connect(_keepActive, SIGNAL(stateChanged(int)), this,
|
||||
SLOT(KeepActiveChanged(int)));
|
||||
|
||||
auto entryLayout = new QHBoxLayout;
|
||||
auto layout = new QHBoxLayout;
|
||||
PlaceWidgets(
|
||||
obs_module_text("AdvSceneSwitcher.condition.gameCapture.entry"),
|
||||
entryLayout, {{"{{sources}}", _sources}});
|
||||
|
||||
auto keepActiveLayout = new QHBoxLayout;
|
||||
keepActiveLayout->addWidget(_keepActive);
|
||||
keepActiveLayout->addWidget(_keepActiveHelp);
|
||||
keepActiveLayout->addStretch();
|
||||
|
||||
auto mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(entryLayout);
|
||||
mainLayout->addLayout(keepActiveLayout);
|
||||
setLayout(mainLayout);
|
||||
layout, {{"{{sources}}", _sources}});
|
||||
setLayout(layout);
|
||||
|
||||
_entryData = entryData;
|
||||
UpdateEntryData();
|
||||
@@ -210,16 +187,9 @@ void MacroConditionGameCaptureEdit::SourceChanged(const SourceSelection &source)
|
||||
_entryData->_source = source;
|
||||
}
|
||||
|
||||
void MacroConditionGameCaptureEdit::KeepActiveChanged(int state)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_keepActive = state;
|
||||
}
|
||||
|
||||
void MacroConditionGameCaptureEdit::UpdateEntryData()
|
||||
{
|
||||
_sources->SetSource(_entryData->_source);
|
||||
_keepActive->setChecked(_entryData->_keepActive);
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#pragma once
|
||||
#include "help-icon.hpp"
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "source-helpers.hpp"
|
||||
#include "source-selection.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
|
||||
namespace advss {
|
||||
|
||||
@@ -23,7 +20,6 @@ public:
|
||||
}
|
||||
|
||||
SourceSelection _source;
|
||||
bool _keepActive = false;
|
||||
|
||||
private:
|
||||
static void HookedSignalReceived(void *data, calldata_t *);
|
||||
@@ -35,7 +31,6 @@ private:
|
||||
void GetCalldataInfo(calldata_t *cd);
|
||||
|
||||
obs_source_t *_lastSource = nullptr;
|
||||
SourceActiveKeeper _activeKeeper;
|
||||
OBSSignal _hookSignal;
|
||||
OBSSignal _unhookSignal;
|
||||
|
||||
@@ -68,12 +63,9 @@ public:
|
||||
|
||||
private slots:
|
||||
void SourceChanged(const SourceSelection &);
|
||||
void KeepActiveChanged(int);
|
||||
|
||||
private:
|
||||
SourceSelectionWidget *_sources;
|
||||
QCheckBox *_keepActive;
|
||||
HelpIcon *_keepActiveHelp;
|
||||
std::shared_ptr<MacroConditionGameCapture> _entryData;
|
||||
|
||||
bool _loading = true;
|
||||
|
||||
@@ -158,21 +158,8 @@ void MacroConditionTransition::TransitionStarted(void *data, calldata_t *cd)
|
||||
|
||||
OBSSourceAutoRelease startSource = obs_transition_get_source(
|
||||
transitionSource, OBS_TRANSITION_SOURCE_A);
|
||||
|
||||
// In studio mode, source A may be a private copy of the scene.
|
||||
// Look up the original by name to get a comparable reference.
|
||||
const bool studioModeActive =
|
||||
obs_frontend_preview_program_mode_active();
|
||||
if (studioModeActive) {
|
||||
OBSSourceAutoRelease startSourceByName = obs_get_source_by_name(
|
||||
obs_source_get_name(startSource));
|
||||
if (startSourceByName) {
|
||||
startSource = std::move(startSourceByName);
|
||||
}
|
||||
}
|
||||
|
||||
OBSSourceAutoRelease endSource =
|
||||
studioModeActive
|
||||
obs_frontend_preview_program_mode_active()
|
||||
? obs_frontend_get_current_scene()
|
||||
: obs_transition_get_source(transitionSource,
|
||||
OBS_TRANSITION_SOURCE_B);
|
||||
@@ -370,7 +357,6 @@ void MacroConditionTransitionEdit::SceneChanged(const SceneSelection &s)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_scene = s;
|
||||
_entryData->ConnectToTransitionSignals();
|
||||
}
|
||||
|
||||
void MacroConditionTransitionEdit::DurationChanged(const Duration &dur)
|
||||
|
||||
@@ -14,6 +14,21 @@ bool MacroConditionWindow::_registered = MacroConditionFactory::Register(
|
||||
{MacroConditionWindow::Create, MacroConditionWindowEdit::Create,
|
||||
"AdvSceneSwitcher.condition.window"});
|
||||
|
||||
static bool windowContainsText(const std::string &window,
|
||||
const std::string &matchText,
|
||||
const RegexConfig ®ex)
|
||||
{
|
||||
auto text = GetTextInWindow(window);
|
||||
if (!text.has_value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (regex.Enabled()) {
|
||||
return regex.Matches(*text, matchText);
|
||||
}
|
||||
return text == matchText;
|
||||
}
|
||||
|
||||
void MacroConditionWindow::SetCheckText(bool value)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -31,76 +46,83 @@ bool MacroConditionWindow::GetCheckText()
|
||||
}
|
||||
|
||||
bool MacroConditionWindow::WindowMatchesRequirements(
|
||||
const WindowInfo &info) const
|
||||
const std::string &window) const
|
||||
{
|
||||
if (_focus && !info.focused) {
|
||||
const bool focusCheckOK =
|
||||
(!_focus || window == ForegroundWindowTitle());
|
||||
if (!focusCheckOK) {
|
||||
return false;
|
||||
}
|
||||
if (_fullscreen && !info.fullscreen) {
|
||||
const bool fullscreenCheckOK = (!_fullscreen || IsFullscreen(window));
|
||||
if (!fullscreenCheckOK) {
|
||||
return false;
|
||||
}
|
||||
if (_maximized && !info.maximized) {
|
||||
const bool maxCheckOK = (!_maximized || IsMaximized(window));
|
||||
if (!maxCheckOK) {
|
||||
return false;
|
||||
}
|
||||
if (_checkText) {
|
||||
if (!info.text.has_value()) {
|
||||
return false;
|
||||
}
|
||||
if (_textRegex.Enabled()) {
|
||||
if (!_textRegex.Matches(*info.text, _text)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (*info.text != std::string(_text)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const bool textCheckOK =
|
||||
(!_checkText || windowContainsText(window, _text, _textRegex));
|
||||
if (!textCheckOK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroConditionWindow::FindMatch(const std::vector<WindowInfo> &windows)
|
||||
bool MacroConditionWindow::WindowMatches(
|
||||
const std::vector<std::string> &windowList)
|
||||
{
|
||||
// When regex is enabled the title check is always active (the backend
|
||||
// uses ".*" when the user disables the title check), so we can use a
|
||||
// single predicate for both modes.
|
||||
for (const auto &info : windows) {
|
||||
const bool titleOK =
|
||||
_windowRegex.Enabled()
|
||||
? _windowRegex.Matches(info.title, _window)
|
||||
: (!_checkTitle ||
|
||||
info.title == std::string(_window));
|
||||
if (!titleOK || !WindowMatchesRequirements(info)) {
|
||||
continue;
|
||||
bool match = !_checkTitle ||
|
||||
std::find(windowList.begin(), windowList.end(),
|
||||
std::string(_window)) != windowList.end();
|
||||
match = match && WindowMatchesRequirements(_window);
|
||||
SetVariableValueBasedOnMatch(_window);
|
||||
return match;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string GetWindowClassByWindowTitle(const std::string &window);
|
||||
#endif
|
||||
|
||||
bool MacroConditionWindow::WindowRegexMatches(
|
||||
const std::vector<std::string> &windowList)
|
||||
{
|
||||
// No need to test if checking for window title is required as if the
|
||||
// user has disabled window title matching the option will always be
|
||||
// enabled in the backend and use the regular expression ".*".
|
||||
|
||||
for (const auto &window : windowList) {
|
||||
if (_windowRegex.Matches(window, _window) &&
|
||||
WindowMatchesRequirements(window)) {
|
||||
SetVariableValueBasedOnMatch(window);
|
||||
return true;
|
||||
}
|
||||
SetVariableValueBasedOnMatch(&info);
|
||||
return true;
|
||||
}
|
||||
SetVariableValueBasedOnMatch(nullptr);
|
||||
SetVariableValueBasedOnMatch("");
|
||||
return false;
|
||||
}
|
||||
|
||||
void MacroConditionWindow::SetVariableValueBasedOnMatch(const WindowInfo *info)
|
||||
void MacroConditionWindow::SetVariableValueBasedOnMatch(
|
||||
const std::string &matchWindow)
|
||||
{
|
||||
const std::string title = info ? info->title : "";
|
||||
SetTempVarValue("window", title);
|
||||
SetTempVarValue("windowX", info ? std::to_string(info->x) : "");
|
||||
SetTempVarValue("windowY", info ? std::to_string(info->y) : "");
|
||||
SetTempVarValue("windowWidth", info ? std::to_string(info->width) : "");
|
||||
SetTempVarValue("windowHeight",
|
||||
info ? std::to_string(info->height) : "");
|
||||
SetTempVarValue("window", matchWindow);
|
||||
#ifdef _WIN32
|
||||
SetTempVarValue("windowClass", info ? info->windowClass : "");
|
||||
SetTempVarValue("windowClass",
|
||||
GetWindowClassByWindowTitle(matchWindow));
|
||||
if (_checkText) {
|
||||
SetTempVarValue("windowText",
|
||||
(info && info->text) ? *info->text : "");
|
||||
const auto text = GetTextInWindow(matchWindow);
|
||||
if (text) {
|
||||
SetTempVarValue("windowText", *text);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!IsReferencedInVars()) {
|
||||
return;
|
||||
}
|
||||
if (_checkText) {
|
||||
SetVariableValue((info && info->text) ? *info->text : "");
|
||||
const auto text = GetTextInWindow(matchWindow);
|
||||
SetVariableValue(text.value_or(""));
|
||||
} else {
|
||||
SetVariableValue(ForegroundWindowTitle());
|
||||
}
|
||||
@@ -113,18 +135,13 @@ static bool foregroundWindowChanged()
|
||||
|
||||
bool MacroConditionWindow::CheckCondition()
|
||||
{
|
||||
WindowQueryOptions options;
|
||||
options.focus = _focus;
|
||||
options.fullscreen = _fullscreen;
|
||||
options.maximized = _maximized;
|
||||
options.geometry = true;
|
||||
#ifdef _WIN32
|
||||
options.windowClass = true;
|
||||
options.text = _checkText;
|
||||
#endif
|
||||
|
||||
const auto windows = GetWindows(options);
|
||||
bool match = FindMatch(windows);
|
||||
const auto windowList = GetWindowList();
|
||||
bool match = false;
|
||||
if (_windowRegex.Enabled()) {
|
||||
match = WindowRegexMatches(windowList);
|
||||
} else {
|
||||
match = WindowMatches(windowList);
|
||||
}
|
||||
match = match && (!_windowFocusChanged || foregroundWindowChanged());
|
||||
return match;
|
||||
}
|
||||
@@ -184,26 +201,6 @@ void MacroConditionWindow::SetupTempVars()
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.window.window"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.window.description"));
|
||||
AddTempvar(
|
||||
"windowX",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.window.windowX"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.windowX.description"));
|
||||
AddTempvar(
|
||||
"windowY",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.window.windowY"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.windowY.description"));
|
||||
AddTempvar(
|
||||
"windowWidth",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.window.windowWidth"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.windowWidth.description"));
|
||||
AddTempvar(
|
||||
"windowHeight",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.window.windowHeight"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.window.windowHeight.description"));
|
||||
#ifdef _WIN32
|
||||
AddTempvar(
|
||||
"windowClass",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "platform-funcs.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
#include "window-selection.hpp"
|
||||
@@ -38,9 +37,10 @@ public:
|
||||
RegexConfig _textRegex = RegexConfig::PartialMatchRegexConfig();
|
||||
|
||||
private:
|
||||
bool WindowMatchesRequirements(const WindowInfo &info) const;
|
||||
bool FindMatch(const std::vector<WindowInfo> &windows);
|
||||
void SetVariableValueBasedOnMatch(const WindowInfo *info);
|
||||
bool WindowMatchesRequirements(const std::string &window) const;
|
||||
bool WindowMatches(const std::vector<std::string> &windowList);
|
||||
bool WindowRegexMatches(const std::vector<std::string> &windowList);
|
||||
void SetVariableValueBasedOnMatch(const std::string &matchWindow);
|
||||
void SetupTempVars();
|
||||
|
||||
// For now only supported on Windows
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "connection-manager.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
#include "macro-export-extensions.hpp"
|
||||
#include "name-dialog.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
@@ -24,52 +23,6 @@ bool setup()
|
||||
{
|
||||
AddSaveStep(saveConnections);
|
||||
AddLoadStep(loadConnections);
|
||||
AddPluginCleanupStep([]() { connections.clear(); });
|
||||
AddMacroExportExtension(
|
||||
{"AdvSceneSwitcher.macroTab.export.websocketConnections",
|
||||
"websocketConnections",
|
||||
[](obs_data_t *data, const QStringList &selectedIds) {
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_array_create();
|
||||
for (const auto &c : connections) {
|
||||
if (!selectedIds.isEmpty() &&
|
||||
!selectedIds.contains(
|
||||
QString::fromStdString(c->Name())))
|
||||
continue;
|
||||
OBSDataAutoRelease item = obs_data_create();
|
||||
c->Save(item);
|
||||
obs_data_array_push_back(array, item);
|
||||
}
|
||||
obs_data_set_array(data, "websocketConnections",
|
||||
array);
|
||||
},
|
||||
[](obs_data_t *data, const QStringList &) {
|
||||
OBSDataArrayAutoRelease array = obs_data_get_array(
|
||||
data, "websocketConnections");
|
||||
const size_t count = obs_data_array_count(array);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
OBSDataAutoRelease item =
|
||||
obs_data_array_item(array, i);
|
||||
auto con = WSConnection::Create();
|
||||
con->Load(item);
|
||||
if (!GetWeakConnectionByName(con->Name())
|
||||
.expired())
|
||||
continue;
|
||||
connections.emplace_back(con);
|
||||
ConnectionSelectionSignalManager::Instance()
|
||||
->Add(QString::fromStdString(
|
||||
con->Name()));
|
||||
}
|
||||
},
|
||||
[]() -> QList<QPair<QString, QString>> {
|
||||
QList<QPair<QString, QString>> items;
|
||||
for (const auto &c : connections) {
|
||||
const QString name =
|
||||
QString::fromStdString(c->Name());
|
||||
items.append({name, name});
|
||||
}
|
||||
return items;
|
||||
}});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,6 @@ void PopulateProfileSelection(QComboBox *box)
|
||||
std::string GetPathInProfileDir(const char *filePath)
|
||||
{
|
||||
auto path = obs_frontend_get_current_profile_path();
|
||||
if (!path) {
|
||||
return "";
|
||||
}
|
||||
std::string result(path);
|
||||
bfree(path);
|
||||
return result + "/" + filePath;
|
||||
|
||||
@@ -205,6 +205,26 @@ static std::vector<HWND> getHWNDfromTitle(const std::string &title)
|
||||
return hwnds;
|
||||
}
|
||||
|
||||
std::string GetWindowClassByWindowTitle(const std::string &window)
|
||||
{
|
||||
auto hwnds = getHWNDfromTitle(window);
|
||||
if (hwnds.empty()) {
|
||||
return "";
|
||||
}
|
||||
auto hwnd = hwnds.at(0);
|
||||
std::wstring wClass;
|
||||
wClass.resize(1024);
|
||||
if (!GetClassNameW(hwnd, &wClass[0], wClass.capacity())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t len = os_wcs_to_utf8(wClass.c_str(), 0, nullptr, 0);
|
||||
std::string className;
|
||||
className.resize(len);
|
||||
os_wcs_to_utf8(wClass.c_str(), 0, &className[0], len + 1);
|
||||
return className;
|
||||
}
|
||||
|
||||
void SetFocusWindow(const std::string &title)
|
||||
{
|
||||
auto hwnds = getHWNDfromTitle(title);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "http-server.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
#include "log-helper.hpp"
|
||||
#include "macro-export-extensions.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
|
||||
@@ -33,49 +32,6 @@ bool setup()
|
||||
}
|
||||
httpServers.clear();
|
||||
});
|
||||
AddMacroExportExtension(
|
||||
{"AdvSceneSwitcher.macroTab.export.httpServers", "httpServers",
|
||||
[](obs_data_t *data, const QStringList &selectedIds) {
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_array_create();
|
||||
for (const auto &s : httpServers) {
|
||||
if (!selectedIds.isEmpty() &&
|
||||
!selectedIds.contains(
|
||||
QString::fromStdString(s->Name())))
|
||||
continue;
|
||||
OBSDataAutoRelease item = obs_data_create();
|
||||
s->Save(item);
|
||||
obs_data_array_push_back(array, item);
|
||||
}
|
||||
obs_data_set_array(data, "httpServers", array);
|
||||
},
|
||||
[](obs_data_t *data, const QStringList &) {
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_get_array(data, "httpServers");
|
||||
const size_t count = obs_data_array_count(array);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
OBSDataAutoRelease item =
|
||||
obs_data_array_item(array, i);
|
||||
auto server = HttpServer::Create();
|
||||
server->Load(item);
|
||||
if (!GetWeakHttpServerByName(server->Name())
|
||||
.expired())
|
||||
continue;
|
||||
httpServers.emplace_back(server);
|
||||
HttpServerSignalManager::Instance()->Add(
|
||||
QString::fromStdString(
|
||||
server->Name()));
|
||||
}
|
||||
},
|
||||
[]() -> QList<QPair<QString, QString>> {
|
||||
QList<QPair<QString, QString>> items;
|
||||
for (const auto &s : httpServers) {
|
||||
const QString name =
|
||||
QString::fromStdString(s->Name());
|
||||
items.append({name, name});
|
||||
}
|
||||
return items;
|
||||
}});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,7 @@ else()
|
||||
-Wno-error=unused-parameter -Wno-error=unused-variable
|
||||
-Wno-error=sign-compare)
|
||||
if(OS_MACOS)
|
||||
target_compile_options(
|
||||
libremidi PUBLIC -Wno-error=vla-extension -Wno-vla-extension
|
||||
-Wno-shorten-64-to-32)
|
||||
target_compile_options(libremidi PUBLIC -Wno-error=vla-extension)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -718,7 +718,6 @@ static bool setup()
|
||||
{
|
||||
AddSaveStep(SaveMqttConnections);
|
||||
AddLoadStep(LoadMqttConnections);
|
||||
AddPluginCleanupStep([]() { GetMqttConnections().clear(); });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(advanced-scene-switcher-macro-schedule)
|
||||
|
||||
add_library(${PROJECT_NAME} MODULE)
|
||||
|
||||
target_sources(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE macro-schedule.cpp
|
||||
macro-schedule.hpp
|
||||
macro-schedule-entry-dialog.cpp
|
||||
macro-schedule-entry-dialog.hpp
|
||||
macro-schedule-tab.cpp
|
||||
macro-schedule-tab.hpp
|
||||
calendar/calendar-event.hpp
|
||||
calendar/calendar-view.hpp
|
||||
calendar/calendar-month-view.hpp
|
||||
calendar/calendar-month-view.cpp
|
||||
calendar/calendar-day-view.hpp
|
||||
calendar/calendar-day-view.cpp
|
||||
calendar/calendar-week-view.hpp
|
||||
calendar/calendar-week-view.cpp
|
||||
calendar/calendar-widget.hpp
|
||||
calendar/calendar-widget.cpp)
|
||||
|
||||
setup_advss_plugin(${PROJECT_NAME})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||
install_advss_plugin(${PROJECT_NAME})
|
||||
@@ -1,493 +0,0 @@
|
||||
#include "calendar-day-view.hpp"
|
||||
|
||||
#include <QLocale>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QTimerEvent>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace advss {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CalendarDayHeader – fixed date strip above the scroll area
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class CalendarDayHeader : public QWidget {
|
||||
public:
|
||||
explicit CalendarDayHeader(QWidget *parent = nullptr);
|
||||
void SetDate(const QDate &date);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
private:
|
||||
QDate _date;
|
||||
};
|
||||
|
||||
CalendarDayHeader::CalendarDayHeader(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setFixedHeight(CalendarDayView::DAY_HEADER_HEIGHT);
|
||||
}
|
||||
|
||||
void CalendarDayHeader::SetDate(const QDate &date)
|
||||
{
|
||||
_date = date;
|
||||
update();
|
||||
}
|
||||
|
||||
void CalendarDayHeader::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
const QDate today = QDate::currentDate();
|
||||
const bool isToday = (_date == today);
|
||||
QLocale locale;
|
||||
|
||||
// Time-axis placeholder
|
||||
p.fillRect(0, 0, CalendarDayView::TIME_AXIS_WIDTH, height(),
|
||||
palette().button());
|
||||
|
||||
// Day column
|
||||
const int colX = CalendarDayView::TIME_AXIS_WIDTH;
|
||||
const int colW = width() - colX;
|
||||
|
||||
QColor bg = palette().button().color();
|
||||
if (isToday) {
|
||||
bg = palette().highlight().color().lighter(165);
|
||||
}
|
||||
p.fillRect(colX, 0, colW, height(), bg);
|
||||
|
||||
p.setPen(palette().mid().color());
|
||||
p.drawLine(colX, 0, colX, height());
|
||||
|
||||
QFont f = p.font();
|
||||
f.setPixelSize(13);
|
||||
f.setBold(isToday);
|
||||
p.setFont(f);
|
||||
p.setPen(isToday ? palette().highlight().color()
|
||||
: palette().buttonText().color());
|
||||
|
||||
const QString label =
|
||||
locale.dayName(_date.dayOfWeek(), QLocale::LongFormat) + " " +
|
||||
QString::number(_date.day()) + " " +
|
||||
locale.monthName(_date.month(), QLocale::ShortFormat) + " " +
|
||||
QString::number(_date.year());
|
||||
p.drawText(colX, 0, colW, height(), Qt::AlignCenter, label);
|
||||
|
||||
p.setPen(palette().mid().color());
|
||||
p.drawLine(0, height() - 1, width(), height() - 1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CalendarDayTimeGrid – scrollable single-day painted time grid
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class CalendarDayTimeGrid : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CalendarDayTimeGrid(QWidget *parent = nullptr);
|
||||
void SetDate(const QDate &date);
|
||||
void SetEvents(const QList<CalendarEvent> &events);
|
||||
void ScrollToCurrentTime(QScrollArea *sa);
|
||||
|
||||
QSize sizeHint() const override;
|
||||
|
||||
signals:
|
||||
void SlotClicked(const QDateTime &startTime);
|
||||
void EventClicked(const QString &id);
|
||||
void EventDoubleClicked(const QString &id);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *) override;
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
|
||||
private:
|
||||
struct EventLayout {
|
||||
CalendarEvent event;
|
||||
QTime drawStart; // clipped to the day's [00:00, 23:59:59]
|
||||
QTime drawEnd;
|
||||
int col;
|
||||
int numCols;
|
||||
};
|
||||
|
||||
int TimeToY(const QTime &t) const;
|
||||
QTime YToTime(int y) const;
|
||||
int ColWidth() const;
|
||||
|
||||
QList<EventLayout> LayoutDay() const;
|
||||
QString EventIdAtPoint(const QPoint &pos) const;
|
||||
QDateTime SlotAtPoint(const QPoint &pos) const;
|
||||
|
||||
void DrawEvent(QPainter &p, const EventLayout &layout, int colW);
|
||||
|
||||
QDate _date;
|
||||
QList<CalendarEvent> _events;
|
||||
int _refreshTimerId = 0;
|
||||
};
|
||||
|
||||
CalendarDayTimeGrid::CalendarDayTimeGrid(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_refreshTimerId = startTimer(60 * 1000);
|
||||
}
|
||||
|
||||
QSize CalendarDayTimeGrid::sizeHint() const
|
||||
{
|
||||
return QSize(CalendarDayView::TIME_AXIS_WIDTH + 200,
|
||||
24 * CalendarDayView::PIXELS_PER_HOUR);
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::timerEvent(QTimerEvent *e)
|
||||
{
|
||||
if (e->timerId() == _refreshTimerId) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
int CalendarDayTimeGrid::TimeToY(const QTime &t) const
|
||||
{
|
||||
return (t.hour() * 60 + t.minute()) * CalendarDayView::PIXELS_PER_HOUR /
|
||||
60;
|
||||
}
|
||||
|
||||
QTime CalendarDayTimeGrid::YToTime(int y) const
|
||||
{
|
||||
int totalMin = y * 60 / CalendarDayView::PIXELS_PER_HOUR;
|
||||
totalMin = qBound(0, totalMin, 24 * 60 - 1);
|
||||
totalMin = (totalMin / 15) * 15; // snap to 15-min increments
|
||||
return QTime(totalMin / 60, totalMin % 60);
|
||||
}
|
||||
|
||||
int CalendarDayTimeGrid::ColWidth() const
|
||||
{
|
||||
return qMax(0, width() - CalendarDayView::TIME_AXIS_WIDTH);
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::SetDate(const QDate &date)
|
||||
{
|
||||
_date = date;
|
||||
update();
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::SetEvents(const QList<CalendarEvent> &events)
|
||||
{
|
||||
_events = events;
|
||||
update();
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::ScrollToCurrentTime(QScrollArea *sa)
|
||||
{
|
||||
if (!sa) {
|
||||
return;
|
||||
}
|
||||
const int y = qMax(0, TimeToY(QTime::currentTime().addSecs(-3600)));
|
||||
sa->verticalScrollBar()->setValue(y);
|
||||
}
|
||||
|
||||
static bool ClipEventToDayD(const CalendarEvent &ev, const QDate &date,
|
||||
QTime &drawStart, QTime &drawEnd)
|
||||
{
|
||||
if (!ev.start.isValid()) {
|
||||
return false;
|
||||
}
|
||||
const QDateTime dayStart(date, QTime(0, 0, 0));
|
||||
const QDateTime dayEnd(date.addDays(1), QTime(0, 0, 0));
|
||||
const QDateTime evEnd = ev.EffectiveEnd();
|
||||
|
||||
if (ev.start >= dayEnd || evEnd <= dayStart) {
|
||||
return false;
|
||||
}
|
||||
|
||||
drawStart = (ev.start < dayStart) ? QTime(0, 0, 0) : ev.start.time();
|
||||
drawEnd = (evEnd >= dayEnd) ? QTime(23, 59, 59) : evEnd.time();
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<CalendarDayTimeGrid::EventLayout> CalendarDayTimeGrid::LayoutDay() const
|
||||
{
|
||||
struct DayEvent {
|
||||
CalendarEvent ev;
|
||||
QTime drawStart;
|
||||
QTime drawEnd;
|
||||
};
|
||||
QList<DayEvent> dayEvents;
|
||||
for (const auto &ev : _events) {
|
||||
QTime ds, de;
|
||||
if (ClipEventToDayD(ev, _date, ds, de)) {
|
||||
dayEvents.append({ev, ds, de});
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(dayEvents.begin(), dayEvents.end(),
|
||||
[](const DayEvent &a, const DayEvent &b) {
|
||||
return a.drawStart < b.drawStart;
|
||||
});
|
||||
|
||||
QList<EventLayout> result;
|
||||
QList<QTime> columnEnds;
|
||||
|
||||
for (const auto &de : dayEvents) {
|
||||
int col = -1;
|
||||
for (int i = 0; i < columnEnds.size(); ++i) {
|
||||
if (columnEnds[i] <= de.drawStart) {
|
||||
col = i;
|
||||
columnEnds[i] = de.drawEnd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (col == -1) {
|
||||
col = columnEnds.size();
|
||||
columnEnds.append(de.drawEnd);
|
||||
}
|
||||
result.append({de.ev, de.drawStart, de.drawEnd, col, 0});
|
||||
}
|
||||
|
||||
const int totalCols = qMax(1, (int)columnEnds.size());
|
||||
for (auto &layout : result) {
|
||||
layout.numCols = totalCols;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString CalendarDayTimeGrid::EventIdAtPoint(const QPoint &pos) const
|
||||
{
|
||||
if (pos.x() < CalendarDayView::TIME_AXIS_WIDTH) {
|
||||
return {};
|
||||
}
|
||||
const int colW = ColWidth();
|
||||
for (const auto &layout : LayoutDay()) {
|
||||
const int subW = colW / layout.numCols;
|
||||
const int x = CalendarDayView::TIME_AXIS_WIDTH +
|
||||
layout.col * subW + 2;
|
||||
const int w = subW - 4;
|
||||
const int y = TimeToY(layout.drawStart);
|
||||
const int h = qMax(TimeToY(layout.drawEnd) - y, 20);
|
||||
if (QRect(x, y, w, h).contains(pos)) {
|
||||
return layout.event.id;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QDateTime CalendarDayTimeGrid::SlotAtPoint(const QPoint &pos) const
|
||||
{
|
||||
if (pos.x() < CalendarDayView::TIME_AXIS_WIDTH) {
|
||||
return {};
|
||||
}
|
||||
return QDateTime(_date, YToTime(pos.y()));
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::DrawEvent(QPainter &p, const EventLayout &layout,
|
||||
int colW)
|
||||
{
|
||||
const auto &ev = layout.event;
|
||||
const int subW = colW / layout.numCols;
|
||||
const int x = CalendarDayView::TIME_AXIS_WIDTH + layout.col * subW + 2;
|
||||
const int w = subW - 4;
|
||||
const int y = TimeToY(layout.drawStart);
|
||||
const int endY = TimeToY(layout.drawEnd);
|
||||
const int h = qMax(endY - y, 20);
|
||||
const QRect rect(x, y, w, h);
|
||||
|
||||
p.setBrush(ev.color);
|
||||
p.setPen(ev.color.darker(130));
|
||||
p.drawRoundedRect(rect, 3, 3);
|
||||
|
||||
p.fillRect(x, y + 1, 3, h - 2, ev.color.darker(160));
|
||||
|
||||
p.setPen(Qt::white);
|
||||
|
||||
QFont f = p.font();
|
||||
f.setPixelSize(10);
|
||||
f.setBold(true);
|
||||
p.setFont(f);
|
||||
|
||||
const QRect textRect = rect.adjusted(6, 2, -2, -2);
|
||||
if (h >= 34) {
|
||||
QFont tf = f;
|
||||
tf.setBold(false);
|
||||
p.setFont(tf);
|
||||
p.drawText(textRect, Qt::AlignTop | Qt::AlignLeft,
|
||||
ev.start.toString("HH:mm"));
|
||||
p.setFont(f);
|
||||
p.drawText(textRect.adjusted(0, 14, 0, 0),
|
||||
Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap,
|
||||
ev.title);
|
||||
} else {
|
||||
p.drawText(textRect,
|
||||
Qt::AlignVCenter | Qt::AlignLeft |
|
||||
Qt::TextSingleLine,
|
||||
ev.title);
|
||||
}
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
const int w = width();
|
||||
const int h = height();
|
||||
const int colW = ColWidth();
|
||||
const QDate today = QDate::currentDate();
|
||||
|
||||
p.fillRect(0, 0, w, h, palette().base());
|
||||
p.fillRect(0, 0, CalendarDayView::TIME_AXIS_WIDTH, h,
|
||||
palette().button());
|
||||
|
||||
// Day column background
|
||||
const int colX = CalendarDayView::TIME_AXIS_WIDTH;
|
||||
if (_date == today) {
|
||||
p.fillRect(colX, 0, colW, h,
|
||||
palette().highlight().color().lighter(190));
|
||||
} else if (_date.dayOfWeek() >= 6) {
|
||||
p.fillRect(colX, 0, colW, h, palette().alternateBase().color());
|
||||
}
|
||||
|
||||
QFont labelFont = p.font();
|
||||
labelFont.setPixelSize(10);
|
||||
p.setFont(labelFont);
|
||||
|
||||
for (int hour = 0; hour < 24; ++hour) {
|
||||
const int y = hour * CalendarDayView::PIXELS_PER_HOUR;
|
||||
|
||||
p.setPen(palette().text().color());
|
||||
p.drawText(2, y, CalendarDayView::TIME_AXIS_WIDTH - 6,
|
||||
CalendarDayView::PIXELS_PER_HOUR,
|
||||
Qt::AlignTop | Qt::AlignRight,
|
||||
QTime(hour, 0).toString("HH:mm"));
|
||||
|
||||
p.setPen(QPen(palette().mid().color(), 1));
|
||||
p.drawLine(CalendarDayView::TIME_AXIS_WIDTH, y, w, y);
|
||||
|
||||
QPen halfPen(palette().midlight().color(), 1, Qt::DotLine);
|
||||
p.setPen(halfPen);
|
||||
const int yHalf = y + CalendarDayView::PIXELS_PER_HOUR / 2;
|
||||
p.drawLine(CalendarDayView::TIME_AXIS_WIDTH, yHalf, w, yHalf);
|
||||
}
|
||||
|
||||
p.setPen(QPen(palette().mid().color(), 1));
|
||||
p.drawLine(colX, 0, colX, h);
|
||||
|
||||
for (const auto &layout : LayoutDay()) {
|
||||
DrawEvent(p, layout, colW);
|
||||
}
|
||||
|
||||
// Current-time indicator
|
||||
if (_date == today) {
|
||||
const int y = TimeToY(QTime::currentTime());
|
||||
p.setPen(QPen(QColor(220, 30, 30), 2));
|
||||
p.drawLine(colX, y, w, y);
|
||||
p.setBrush(QColor(220, 30, 30));
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(colX - 4, y - 4, 8, 8);
|
||||
}
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const QString id = EventIdAtPoint(e->pos());
|
||||
if (!id.isEmpty()) {
|
||||
emit EventClicked(id);
|
||||
return;
|
||||
}
|
||||
const QDateTime slot = SlotAtPoint(e->pos());
|
||||
if (slot.isValid()) {
|
||||
emit SlotClicked(slot);
|
||||
}
|
||||
}
|
||||
|
||||
void CalendarDayTimeGrid::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const QString id = EventIdAtPoint(e->pos());
|
||||
if (!id.isEmpty()) {
|
||||
emit EventDoubleClicked(id);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CalendarDayView
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CalendarDayView::CalendarDayView(QWidget *parent)
|
||||
: CalendarView(parent),
|
||||
_header(new CalendarDayHeader(this)),
|
||||
_timeGrid(new CalendarDayTimeGrid(this)),
|
||||
_scrollArea(new QScrollArea(this))
|
||||
{
|
||||
_timeGrid->setMinimumHeight(24 * CalendarDayView::PIXELS_PER_HOUR);
|
||||
|
||||
_scrollArea->setWidget(_timeGrid);
|
||||
_scrollArea->setWidgetResizable(true);
|
||||
_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
_scrollArea->setFrameShape(QFrame::NoFrame);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(_header);
|
||||
layout->addWidget(_scrollArea);
|
||||
setLayout(layout);
|
||||
|
||||
connect(_timeGrid, &CalendarDayTimeGrid::SlotClicked, this,
|
||||
&CalendarDayView::SlotClicked);
|
||||
connect(_timeGrid, &CalendarDayTimeGrid::EventClicked, this,
|
||||
&CalendarDayView::EventClicked);
|
||||
connect(_timeGrid, &CalendarDayTimeGrid::EventDoubleClicked, this,
|
||||
&CalendarDayView::EventDoubleClicked);
|
||||
|
||||
SetDate(QDate::currentDate());
|
||||
}
|
||||
|
||||
void CalendarDayView::SetDate(const QDate &date)
|
||||
{
|
||||
_date = date;
|
||||
UpdateViews();
|
||||
emit VisibleRangeChanged(RangeStart(), RangeEnd());
|
||||
}
|
||||
|
||||
void CalendarDayView::SetEvents(const QList<CalendarEvent> &events)
|
||||
{
|
||||
_events = events;
|
||||
_timeGrid->SetEvents(events);
|
||||
}
|
||||
|
||||
QDate CalendarDayView::CurrentDate() const
|
||||
{
|
||||
return _date;
|
||||
}
|
||||
|
||||
QDate CalendarDayView::RangeStart() const
|
||||
{
|
||||
return _date;
|
||||
}
|
||||
|
||||
QDate CalendarDayView::RangeEnd() const
|
||||
{
|
||||
return _date;
|
||||
}
|
||||
|
||||
void CalendarDayView::UpdateViews()
|
||||
{
|
||||
_header->SetDate(_date);
|
||||
_timeGrid->SetDate(_date);
|
||||
_timeGrid->ScrollToCurrentTime(_scrollArea);
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
// Required for CalendarDayTimeGrid defined in this file
|
||||
#include "calendar-day-view.moc"
|
||||
@@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
#include "calendar-view.hpp"
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class CalendarDayHeader;
|
||||
class CalendarDayTimeGrid;
|
||||
|
||||
// Displays a single day column with a vertical time axis (00:00 - 24:00).
|
||||
// Events are rendered as colored blocks sized to their duration.
|
||||
// Overlapping events are arranged in side-by-side sub-columns.
|
||||
// A red indicator marks the current time.
|
||||
class CalendarDayView : public CalendarView {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CalendarDayView(QWidget *parent = nullptr);
|
||||
|
||||
void SetDate(const QDate &date) override;
|
||||
void SetEvents(const QList<CalendarEvent> &events) override;
|
||||
|
||||
QDate CurrentDate() const override;
|
||||
QDate RangeStart() const override;
|
||||
QDate RangeEnd() const override;
|
||||
|
||||
// Shared layout constants (used by DayHeader and TimeGrid)
|
||||
static constexpr int TIME_AXIS_WIDTH = 56;
|
||||
static constexpr int PIXELS_PER_HOUR = 64;
|
||||
static constexpr int DAY_HEADER_HEIGHT = 36;
|
||||
|
||||
private:
|
||||
void UpdateViews();
|
||||
|
||||
CalendarDayHeader *_header;
|
||||
CalendarDayTimeGrid *_timeGrid;
|
||||
QScrollArea *_scrollArea;
|
||||
|
||||
QDate _date;
|
||||
QList<CalendarEvent> _events;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
namespace advss {
|
||||
|
||||
// Generic calendar event. All fields except id/start are optional.
|
||||
struct CalendarEvent {
|
||||
QString id;
|
||||
QString title;
|
||||
QDateTime start;
|
||||
QDateTime end;
|
||||
QColor color{70, 130, 180};
|
||||
QVariant userData; // Caller-defined payload, returned on click signals
|
||||
|
||||
// Returns end if valid and > start, otherwise start + 30 minutes.
|
||||
QDateTime EffectiveEnd() const
|
||||
{
|
||||
static constexpr qint64 defaultDuration = 1800;
|
||||
return (end.isValid() && end > start)
|
||||
? end
|
||||
: start.addSecs(defaultDuration);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,284 +0,0 @@
|
||||
#include "calendar-month-view.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
|
||||
#include <QLocale>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
namespace advss {
|
||||
|
||||
CalendarMonthView::CalendarMonthView(QWidget *parent) : CalendarView(parent)
|
||||
{
|
||||
setMinimumSize(320, 240);
|
||||
SetDate(QDate::currentDate());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Public interface
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void CalendarMonthView::SetDate(const QDate &date)
|
||||
{
|
||||
_currentDate = date;
|
||||
|
||||
// Grid starts on the Monday of the week that contains the 1st of the month.
|
||||
const QDate first(date.year(), date.month(), 1);
|
||||
// Qt: dayOfWeek() -> 1=Mon … 7=Sun
|
||||
_gridStart = first.addDays(-(first.dayOfWeek() - 1));
|
||||
|
||||
update();
|
||||
emit VisibleRangeChanged(RangeStart(), RangeEnd());
|
||||
}
|
||||
|
||||
void CalendarMonthView::SetEvents(const QList<CalendarEvent> &events)
|
||||
{
|
||||
_events = events;
|
||||
update();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Geometry helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QDate CalendarMonthView::CellDate(int row, int col) const
|
||||
{
|
||||
return _gridStart.addDays(row * COLS + col);
|
||||
}
|
||||
|
||||
QRect CalendarMonthView::CellRect(int row, int col) const
|
||||
{
|
||||
const int cellW = width() / COLS;
|
||||
const int cellH = (height() - HEADER_HEIGHT) / ROWS;
|
||||
return QRect(col * cellW, HEADER_HEIGHT + row * cellH, cellW, cellH);
|
||||
}
|
||||
|
||||
bool CalendarMonthView::CellFromPoint(const QPoint &pos, int &row,
|
||||
int &col) const
|
||||
{
|
||||
if (pos.y() < HEADER_HEIGHT) {
|
||||
return false;
|
||||
}
|
||||
const int cellW = width() / COLS;
|
||||
const int cellH = (height() - HEADER_HEIGHT) / ROWS;
|
||||
col = pos.x() / cellW;
|
||||
row = (pos.y() - HEADER_HEIGHT) / cellH;
|
||||
return col >= 0 && col < COLS && row >= 0 && row < ROWS;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Event helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QList<CalendarEvent> CalendarMonthView::EventsForDate(const QDate &date) const
|
||||
{
|
||||
QList<CalendarEvent> result;
|
||||
for (const auto &event : _events) {
|
||||
if (!event.start.isValid()) {
|
||||
continue;
|
||||
}
|
||||
const QDate evStart = event.start.date();
|
||||
const QDate evEnd = event.EffectiveEnd().date();
|
||||
if (date >= evStart && date <= evEnd) {
|
||||
result.append(event);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString CalendarMonthView::EventIdAtPoint(const QPoint &pos) const
|
||||
{
|
||||
int row, col;
|
||||
if (!CellFromPoint(pos, row, col)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const QRect cell = CellRect(row, col);
|
||||
const int evTop = cell.top() + DAY_NUM_HEIGHT + CELL_PAD;
|
||||
const auto events = EventsForDate(CellDate(row, col));
|
||||
|
||||
for (int i = 0; i < qMin((int)events.size(), MAX_VISIBLE_EVENTS); ++i) {
|
||||
const QRect evRect(cell.left() + CELL_PAD,
|
||||
evTop + i * (EVENT_HEIGHT + EVENT_MARGIN),
|
||||
cell.width() - CELL_PAD * 2, EVENT_HEIGHT);
|
||||
if (evRect.contains(pos)) {
|
||||
return events[i].id;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Painting
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void CalendarMonthView::PaintDayNameHeader(QPainter &p)
|
||||
{
|
||||
p.fillRect(0, 0, width(), HEADER_HEIGHT, palette().button());
|
||||
|
||||
const int cellW = width() / COLS;
|
||||
QLocale locale;
|
||||
|
||||
p.setPen(palette().buttonText().color());
|
||||
QFont f = p.font();
|
||||
f.setPixelSize(11);
|
||||
p.setFont(f);
|
||||
|
||||
for (int col = 0; col < COLS; ++col) {
|
||||
// dayOfWeek: 1=Mon … 7=Sun (ISO 8601 order matches our columns)
|
||||
const QString name =
|
||||
locale.dayName(col + 1, QLocale::ShortFormat);
|
||||
p.drawText(col * cellW, 0, cellW, HEADER_HEIGHT,
|
||||
Qt::AlignCenter, name);
|
||||
}
|
||||
|
||||
// Bottom border
|
||||
p.setPen(palette().mid().color());
|
||||
p.drawLine(0, HEADER_HEIGHT - 1, width(), HEADER_HEIGHT - 1);
|
||||
}
|
||||
|
||||
void CalendarMonthView::PaintCell(QPainter &p, int row, int col)
|
||||
{
|
||||
const QRect rect = CellRect(row, col);
|
||||
const QDate date = CellDate(row, col);
|
||||
const QDate today = QDate::currentDate();
|
||||
const bool isToday = (date == today);
|
||||
const bool inCurrentMonth = (date.month() == _currentDate.month());
|
||||
|
||||
// --- Background ---
|
||||
QColor bg;
|
||||
if (isToday) {
|
||||
bg = palette().highlight().color().lighter(185);
|
||||
} else if (!inCurrentMonth) {
|
||||
bg = palette().alternateBase().color();
|
||||
} else {
|
||||
bg = palette().base().color();
|
||||
}
|
||||
// Weekend tint
|
||||
if (col >= 5) {
|
||||
bg = bg.darker(104);
|
||||
}
|
||||
p.fillRect(rect, bg);
|
||||
|
||||
// --- Grid border ---
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setPen(palette().mid().color());
|
||||
p.drawRect(rect.adjusted(0, 0, -1, -1));
|
||||
|
||||
// --- Day number ---
|
||||
const QRect numArea(rect.left(), rect.top() + CELL_PAD,
|
||||
rect.width() - CELL_PAD, DAY_NUM_HEIGHT);
|
||||
|
||||
if (isToday) {
|
||||
// Filled circle behind the number
|
||||
const int dia = DAY_NUM_HEIGHT - 4;
|
||||
const QRect circleRect(numArea.right() - dia - 2,
|
||||
numArea.top() + 1, dia, dia);
|
||||
p.setBrush(palette().highlight());
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(circleRect);
|
||||
p.setPen(palette().highlightedText().color());
|
||||
} else {
|
||||
p.setPen(inCurrentMonth ? palette().text().color()
|
||||
: palette().placeholderText().color());
|
||||
}
|
||||
|
||||
QFont f = p.font();
|
||||
f.setPixelSize(11);
|
||||
f.setBold(isToday);
|
||||
p.setFont(f);
|
||||
p.drawText(numArea, Qt::AlignRight | Qt::AlignTop,
|
||||
QString::number(date.day()));
|
||||
|
||||
// --- Event bars ---
|
||||
const auto events = EventsForDate(date);
|
||||
const int evTop = rect.top() + DAY_NUM_HEIGHT + CELL_PAD;
|
||||
const int maxFit = (rect.height() - DAY_NUM_HEIGHT - CELL_PAD * 2) /
|
||||
(EVENT_HEIGHT + EVENT_MARGIN);
|
||||
const int visible =
|
||||
qMin(qMin((int)events.size(), maxFit), MAX_VISIBLE_EVENTS);
|
||||
|
||||
QFont evFont = p.font();
|
||||
evFont.setPixelSize(10);
|
||||
evFont.setBold(false);
|
||||
p.setFont(evFont);
|
||||
|
||||
for (int i = 0; i < visible; ++i) {
|
||||
const auto &ev = events[i];
|
||||
const QRect evRect(rect.left() + CELL_PAD,
|
||||
evTop + i * (EVENT_HEIGHT + EVENT_MARGIN),
|
||||
rect.width() - CELL_PAD * 2, EVENT_HEIGHT);
|
||||
|
||||
p.setBrush(ev.color);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(evRect, 2, 2);
|
||||
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(evRect.adjusted(4, 0, -2, 0),
|
||||
Qt::AlignVCenter | Qt::AlignLeft |
|
||||
Qt::TextSingleLine,
|
||||
ev.title);
|
||||
}
|
||||
|
||||
// "+N more" overflow label
|
||||
if ((int)events.size() > visible) {
|
||||
const int extra = events.size() - visible;
|
||||
const QRect moreRect(
|
||||
rect.left() + CELL_PAD,
|
||||
evTop + visible * (EVENT_HEIGHT + EVENT_MARGIN),
|
||||
rect.width() - CELL_PAD * 2, EVENT_HEIGHT);
|
||||
p.setPen(palette().placeholderText().color());
|
||||
p.drawText(
|
||||
moreRect,
|
||||
Qt::AlignVCenter | Qt::AlignLeft | Qt::TextSingleLine,
|
||||
QString(obs_module_text(
|
||||
"AdvSceneSwitcher.calendar.moreEvents"))
|
||||
.arg(extra));
|
||||
}
|
||||
}
|
||||
|
||||
void CalendarMonthView::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
PaintDayNameHeader(p);
|
||||
|
||||
for (int row = 0; row < ROWS; ++row) {
|
||||
for (int col = 0; col < COLS; ++col) {
|
||||
PaintCell(p, row, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mouse events
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void CalendarMonthView::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const QString id = EventIdAtPoint(e->pos());
|
||||
if (!id.isEmpty()) {
|
||||
emit EventClicked(id);
|
||||
return;
|
||||
}
|
||||
int row, col;
|
||||
if (CellFromPoint(e->pos(), row, col)) {
|
||||
emit SlotClicked(QDateTime(CellDate(row, col), QTime(0, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
void CalendarMonthView::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const QString id = EventIdAtPoint(e->pos());
|
||||
if (!id.isEmpty()) {
|
||||
emit EventDoubleClicked(id);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,57 +0,0 @@
|
||||
#pragma once
|
||||
#include "calendar-view.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
// Displays a traditional month grid (6 weeks × 7 days).
|
||||
// Events are rendered as small colored bars inside each day cell.
|
||||
// Up to three events are shown per cell; additional events are
|
||||
// indicated by a "+N more" label.
|
||||
class CalendarMonthView : public CalendarView {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CalendarMonthView(QWidget *parent = nullptr);
|
||||
|
||||
void SetDate(const QDate &date) override;
|
||||
void SetEvents(const QList<CalendarEvent> &events) override;
|
||||
|
||||
QDate CurrentDate() const override { return _currentDate; }
|
||||
QDate RangeStart() const override { return _gridStart; }
|
||||
QDate RangeEnd() const override { return _gridStart.addDays(41); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *) override;
|
||||
|
||||
private:
|
||||
// Geometry helpers
|
||||
QDate CellDate(int row, int col) const;
|
||||
QRect CellRect(int row, int col) const;
|
||||
bool CellFromPoint(const QPoint &pos, int &row, int &col) const;
|
||||
|
||||
// Event helpers
|
||||
QList<CalendarEvent> EventsForDate(const QDate &date) const;
|
||||
QString EventIdAtPoint(const QPoint &pos) const;
|
||||
|
||||
// Painting
|
||||
void PaintDayNameHeader(QPainter &p);
|
||||
void PaintCell(QPainter &p, int row, int col);
|
||||
|
||||
static constexpr int ROWS = 6;
|
||||
static constexpr int COLS = 7;
|
||||
static constexpr int HEADER_HEIGHT = 28; // day-name row
|
||||
static constexpr int DAY_NUM_HEIGHT =
|
||||
22; // space reserved for day number
|
||||
static constexpr int EVENT_HEIGHT = 16;
|
||||
static constexpr int EVENT_MARGIN = 2;
|
||||
static constexpr int CELL_PAD = 3;
|
||||
static constexpr int MAX_VISIBLE_EVENTS = 3;
|
||||
|
||||
QDate _currentDate;
|
||||
QDate _gridStart; // Monday of the week that contains the 1st of the month
|
||||
QList<CalendarEvent> _events;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
@@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
#include "calendar-event.hpp"
|
||||
|
||||
#include <QDate>
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
namespace advss {
|
||||
|
||||
// Abstract base class for calendar view modes (month, week, …).
|
||||
// Subclasses must implement the pure virtual interface and emit the
|
||||
// signals defined here via Q_SIGNALS so that CalendarWidget can
|
||||
// connect to them uniformly regardless of the active view.
|
||||
class CalendarView : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CalendarView(QWidget *parent = nullptr) : QWidget(parent) {}
|
||||
|
||||
// Navigate to show the given date. The visible range is determined
|
||||
// by the concrete view (e.g. the whole month, or the week).
|
||||
virtual void SetDate(const QDate &date) = 0;
|
||||
|
||||
// Replace the full set of events shown in this view.
|
||||
virtual void SetEvents(const QList<CalendarEvent> &events) = 0;
|
||||
|
||||
// A representative date for the current position (used for navigation).
|
||||
virtual QDate CurrentDate() const = 0;
|
||||
|
||||
// Inclusive range of dates currently rendered.
|
||||
virtual QDate RangeStart() const = 0;
|
||||
virtual QDate RangeEnd() const = 0;
|
||||
|
||||
signals:
|
||||
// User clicked an empty time slot.
|
||||
void SlotClicked(const QDateTime &startTime);
|
||||
|
||||
// User single-clicked an event (id = CalendarEvent::id).
|
||||
void EventClicked(const QString &eventId);
|
||||
|
||||
// User double-clicked an event.
|
||||
void EventDoubleClicked(const QString &eventId);
|
||||
|
||||
// The visible date range changed; the owner should refresh events.
|
||||
void VisibleRangeChanged(const QDate &rangeStart,
|
||||
const QDate &rangeEnd);
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user