mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7afdd817b |
@@ -120,16 +120,14 @@ target_sources(
|
|||||||
lib/macro/macro-export-import-dialog.hpp
|
lib/macro/macro-export-import-dialog.hpp
|
||||||
lib/macro/macro-helpers.cpp
|
lib/macro/macro-helpers.cpp
|
||||||
lib/macro/macro-helpers.hpp
|
lib/macro/macro-helpers.hpp
|
||||||
lib/macro/macro-input.cpp
|
|
||||||
lib/macro/macro-input.hpp
|
|
||||||
lib/macro/macro-list.cpp
|
lib/macro/macro-list.cpp
|
||||||
lib/macro/macro-list.hpp
|
lib/macro/macro-list.hpp
|
||||||
|
lib/macro/macro-properties.cpp
|
||||||
|
lib/macro/macro-properties.hpp
|
||||||
lib/macro/macro-ref.cpp
|
lib/macro/macro-ref.cpp
|
||||||
lib/macro/macro-ref.hpp
|
lib/macro/macro-ref.hpp
|
||||||
lib/macro/macro-run-button.cpp
|
lib/macro/macro-run-button.cpp
|
||||||
lib/macro/macro-run-button.hpp
|
lib/macro/macro-run-button.hpp
|
||||||
lib/macro/macro-segment-copy-paste.cpp
|
|
||||||
lib/macro/macro-segment-copy-paste.hpp
|
|
||||||
lib/macro/macro-segment-list.cpp
|
lib/macro/macro-segment-list.cpp
|
||||||
lib/macro/macro-segment-list.hpp
|
lib/macro/macro-segment-list.hpp
|
||||||
lib/macro/macro-segment-selection.cpp
|
lib/macro/macro-segment-selection.cpp
|
||||||
@@ -138,8 +136,6 @@ target_sources(
|
|||||||
lib/macro/macro-segment.hpp
|
lib/macro/macro-segment.hpp
|
||||||
lib/macro/macro-selection.cpp
|
lib/macro/macro-selection.cpp
|
||||||
lib/macro/macro-selection.hpp
|
lib/macro/macro-selection.hpp
|
||||||
lib/macro/macro-settings.cpp
|
|
||||||
lib/macro/macro-settings.hpp
|
|
||||||
lib/macro/macro-tab.cpp
|
lib/macro/macro-tab.cpp
|
||||||
lib/macro/macro-tree.cpp
|
lib/macro/macro-tree.cpp
|
||||||
lib/macro/macro-tree.hpp
|
lib/macro/macro-tree.hpp
|
||||||
@@ -168,14 +164,10 @@ target_sources(
|
|||||||
lib/utils/file-selection.hpp
|
lib/utils/file-selection.hpp
|
||||||
lib/utils/filter-combo-box.cpp
|
lib/utils/filter-combo-box.cpp
|
||||||
lib/utils/filter-combo-box.hpp
|
lib/utils/filter-combo-box.hpp
|
||||||
lib/utils/help-icon.hpp
|
|
||||||
lib/utils/help-icon.cpp
|
|
||||||
lib/utils/item-selection-helpers.cpp
|
lib/utils/item-selection-helpers.cpp
|
||||||
lib/utils/item-selection-helpers.hpp
|
lib/utils/item-selection-helpers.hpp
|
||||||
lib/utils/layout-helpers.cpp
|
lib/utils/layout-helpers.cpp
|
||||||
lib/utils/layout-helpers.hpp
|
lib/utils/layout-helpers.hpp
|
||||||
lib/utils/list-editor.cpp
|
|
||||||
lib/utils/list-editor.hpp
|
|
||||||
lib/utils/log-helper.cpp
|
lib/utils/log-helper.cpp
|
||||||
lib/utils/log-helper.hpp
|
lib/utils/log-helper.hpp
|
||||||
lib/utils/math-helpers.cpp
|
lib/utils/math-helpers.cpp
|
||||||
@@ -227,8 +219,6 @@ target_sources(
|
|||||||
lib/utils/splitter-helpers.hpp
|
lib/utils/splitter-helpers.hpp
|
||||||
lib/utils/status-control.cpp
|
lib/utils/status-control.cpp
|
||||||
lib/utils/status-control.hpp
|
lib/utils/status-control.hpp
|
||||||
lib/utils/string-list.cpp
|
|
||||||
lib/utils/string-list.hpp
|
|
||||||
lib/utils/switch-button.cpp
|
lib/utils/switch-button.cpp
|
||||||
lib/utils/switch-button.hpp
|
lib/utils/switch-button.hpp
|
||||||
lib/utils/sync-helpers.cpp
|
lib/utils/sync-helpers.cpp
|
||||||
@@ -345,9 +335,6 @@ if(OS_WINDOWS)
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(${LIB_NAME} PUBLIC /MP /d2FH4- /wd4267 /wd4267
|
target_compile_options(${LIB_NAME} PUBLIC /MP /d2FH4- /wd4267 /wd4267
|
||||||
/bigobj)
|
/bigobj)
|
||||||
|
|
||||||
# Workaround for MSVC incompatibility in CI environment
|
|
||||||
add_compile_definitions(${target_name} _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
|
|
||||||
endif()
|
endif()
|
||||||
target_sources(${LIB_NAME} PRIVATE lib/win/advanced-scene-switcher-win.cpp)
|
target_sources(${LIB_NAME} PRIVATE lib/win/advanced-scene-switcher-win.cpp)
|
||||||
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
||||||
|
|||||||
@@ -469,6 +469,7 @@ AdvSceneSwitcher.action.macro.type.unpause="Nicht mehr pausieren"
|
|||||||
AdvSceneSwitcher.action.macro.type.resetCounter="Zähler zurücksetzen"
|
AdvSceneSwitcher.action.macro.type.resetCounter="Zähler zurücksetzen"
|
||||||
AdvSceneSwitcher.action.macro.type.run="Aktionen ausführen"
|
AdvSceneSwitcher.action.macro.type.run="Aktionen ausführen"
|
||||||
AdvSceneSwitcher.action.macro.type.stop="Aktionen stoppen"
|
AdvSceneSwitcher.action.macro.type.stop="Aktionen stoppen"
|
||||||
|
AdvSceneSwitcher.action.macro.entry="{{actions}}{{actionIndex}}{{macros}}"
|
||||||
AdvSceneSwitcher.action.pluginState="Plugin-Status"
|
AdvSceneSwitcher.action.pluginState="Plugin-Status"
|
||||||
AdvSceneSwitcher.action.pluginState.type.stop="Erweiterten Automatischen Szenenwechsler stoppen"
|
AdvSceneSwitcher.action.pluginState.type.stop="Erweiterten Automatischen Szenenwechsler stoppen"
|
||||||
AdvSceneSwitcher.action.pluginState.type.noMatch="Ändern des Nichtübereinstimmungsverhaltens:"
|
AdvSceneSwitcher.action.pluginState.type.noMatch="Ändern des Nichtübereinstimmungsverhaltens:"
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ AdvSceneSwitcher.actionQueueTab.isRunning.header="Is running"
|
|||||||
AdvSceneSwitcher.actionQueueTab.runOnStartup.header="Run on startup"
|
AdvSceneSwitcher.actionQueueTab.runOnStartup.header="Run on startup"
|
||||||
AdvSceneSwitcher.actionQueueTab.yes="Yes"
|
AdvSceneSwitcher.actionQueueTab.yes="Yes"
|
||||||
AdvSceneSwitcher.actionQueueTab.no="No"
|
AdvSceneSwitcher.actionQueueTab.no="No"
|
||||||
AdvSceneSwitcher.actionQueueTab.removeSingleQueuePopup.text="Are you sure you want to remove \"%1\"?"
|
AdvSceneSwitcher.actionQueueTab.removeSingleConnectionPopup.text="Are you sure you want to remove \"%1\"?"
|
||||||
AdvSceneSwitcher.actionQueueTab.removeMultipleQueuesPopup.text="Are you sure you want to remove %1 action queues?"
|
AdvSceneSwitcher.actionQueueTab.removeMultipleConnectionsPopup.text="Are you sure you want to remove %1 action queues?"
|
||||||
|
|
||||||
; Websocket Connections Tab
|
; Websocket Connections Tab
|
||||||
AdvSceneSwitcher.websocketConnectionTab.title="Websocket Connections"
|
AdvSceneSwitcher.websocketConnectionTab.title="Websocket Connections"
|
||||||
@@ -177,15 +177,9 @@ AdvSceneSwitcher.macroTab.minimize="Minimize"
|
|||||||
AdvSceneSwitcher.macroTab.segment.useCustomLabel="Use custom label"
|
AdvSceneSwitcher.macroTab.segment.useCustomLabel="Use custom label"
|
||||||
AdvSceneSwitcher.macroTab.segment.defaultCustomLabel="My label"
|
AdvSceneSwitcher.macroTab.segment.defaultCustomLabel="My label"
|
||||||
AdvSceneSwitcher.macroTab.segment.setCustomLabel="Set label ..."
|
AdvSceneSwitcher.macroTab.segment.setCustomLabel="Set label ..."
|
||||||
AdvSceneSwitcher.macroTab.segment.copy="Copy"
|
|
||||||
AdvSceneSwitcher.macroTab.segment.paste="Paste"
|
|
||||||
AdvSceneSwitcher.macroTab.highlightSettings="Visual settings"
|
AdvSceneSwitcher.macroTab.highlightSettings="Visual settings"
|
||||||
AdvSceneSwitcher.macroTab.hotkeySettings="Hotkey settings"
|
AdvSceneSwitcher.macroTab.hotkeySettings="Hotkey settings"
|
||||||
AdvSceneSwitcher.macroTab.generalSettings="General settings"
|
AdvSceneSwitcher.macroTab.generalSettings="General settings"
|
||||||
AdvSceneSwitcher.macroTab.inputSettings="Input settings"
|
|
||||||
AdvSceneSwitcher.macroTab.inputSettings.description="This section will allow you to specify variables, which will be treated as input parameters for the selected macro.\nWhen executing the macro using the \"Macro\" action type, you will have the option to set the values for those variables."
|
|
||||||
AdvSceneSwitcher.macroTab.inputSettings.invalid="<Invalid selection>"
|
|
||||||
AdvSceneSwitcher.macroTab.inputSettings.noInputs="No inputs are defined for the selected macro!\nOpen the settings of the macro to define inputs.\nThe settings button is highlighted above."
|
|
||||||
AdvSceneSwitcher.macroTab.dockSettings="Dock settings"
|
AdvSceneSwitcher.macroTab.dockSettings="Dock settings"
|
||||||
AdvSceneSwitcher.macroTab.highlightExecutedMacros="Highlight recently executed macros"
|
AdvSceneSwitcher.macroTab.highlightExecutedMacros="Highlight recently executed macros"
|
||||||
AdvSceneSwitcher.macroTab.highlightTrueConditions="Highlight conditions of currently selected macro that evaluated to true recently"
|
AdvSceneSwitcher.macroTab.highlightTrueConditions="Highlight conditions of currently selected macro that evaluated to true recently"
|
||||||
@@ -230,7 +224,7 @@ AdvSceneSwitcher.macroTab.tooltip.elseActionTopButton="Move selected action to t
|
|||||||
AdvSceneSwitcher.macroTab.tooltip.elseActionUpButton="Move selected action up in the else section"
|
AdvSceneSwitcher.macroTab.tooltip.elseActionUpButton="Move selected action up in the else section"
|
||||||
AdvSceneSwitcher.macroTab.tooltip.elseActionDownButton="Move selected action down in the else section"
|
AdvSceneSwitcher.macroTab.tooltip.elseActionDownButton="Move selected action down in the else section"
|
||||||
AdvSceneSwitcher.macroTab.tooltip.elseActionBottomButton="Move selected action to the bottom in the else section"
|
AdvSceneSwitcher.macroTab.tooltip.elseActionBottomButton="Move selected action to the bottom in the else section"
|
||||||
AdvSceneSwitcher.macroTab.tooltip.openMacroSettingsButton="Open macro settings"
|
AdvSceneSwitcher.macroTab.tooltip.openMacroPropertiesButton="Open macro properties"
|
||||||
|
|
||||||
AdvSceneSwitcher.macroDock.pause="Pause"
|
AdvSceneSwitcher.macroDock.pause="Pause"
|
||||||
AdvSceneSwitcher.macroDock.unpause="Unpause"
|
AdvSceneSwitcher.macroDock.unpause="Unpause"
|
||||||
@@ -457,16 +451,11 @@ AdvSceneSwitcher.condition.source.type.settingsMatch="Settings match"
|
|||||||
AdvSceneSwitcher.condition.source.type.settingsChanged="Settings changed"
|
AdvSceneSwitcher.condition.source.type.settingsChanged="Settings changed"
|
||||||
AdvSceneSwitcher.condition.source.type.individualSettingMatches="Setting value matches"
|
AdvSceneSwitcher.condition.source.type.individualSettingMatches="Setting value matches"
|
||||||
AdvSceneSwitcher.condition.source.type.individualSettingChanged="Setting value changed"
|
AdvSceneSwitcher.condition.source.type.individualSettingChanged="Setting value changed"
|
||||||
AdvSceneSwitcher.condition.source.type.width="Width"
|
|
||||||
AdvSceneSwitcher.condition.source.type.height="Height"
|
|
||||||
AdvSceneSwitcher.condition.source.sizeCompare.less="Smaller than"
|
|
||||||
AdvSceneSwitcher.condition.source.sizeCompare.equal="Equals"
|
|
||||||
AdvSceneSwitcher.condition.source.sizeCompare.more="Bigger than"
|
|
||||||
AdvSceneSwitcher.condition.source.refresh="Refresh"
|
AdvSceneSwitcher.condition.source.refresh="Refresh"
|
||||||
AdvSceneSwitcher.condition.source.refreshTooltip="Repopulate the source settings selection with the settings of the source which's name matches the variable value."
|
AdvSceneSwitcher.condition.source.refreshTooltip="Repopulate the source settings selection with the settings of the source which's name matches the variable value."
|
||||||
AdvSceneSwitcher.condition.source.sceneVisibilityHint="Scene specific visibility can be checked using the \"Scene item visibility\" condition"
|
AdvSceneSwitcher.condition.source.sceneVisibilityHint="Scene specific visibility can be checked using the \"Scene item visibility\" condition"
|
||||||
AdvSceneSwitcher.condition.source.getSettings="Get current settings"
|
AdvSceneSwitcher.condition.source.getSettings="Get current settings"
|
||||||
AdvSceneSwitcher.condition.source.entry.line1="{{sources}}{{conditions}}{{settingSelection}}{{refresh}}{{sizeCompareMethods}}{{size}}"
|
AdvSceneSwitcher.condition.source.entry.line1="{{sources}}{{conditions}}{{settingSelection}}{{refresh}}"
|
||||||
AdvSceneSwitcher.condition.source.entry.line2="{{settings}}"
|
AdvSceneSwitcher.condition.source.entry.line2="{{settings}}"
|
||||||
AdvSceneSwitcher.condition.source.entry.line3="{{regex}}{{getSettings}}"
|
AdvSceneSwitcher.condition.source.entry.line3="{{regex}}{{getSettings}}"
|
||||||
AdvSceneSwitcher.condition.virtualCamera="Virtual camera"
|
AdvSceneSwitcher.condition.virtualCamera="Virtual camera"
|
||||||
@@ -603,7 +592,15 @@ AdvSceneSwitcher.condition.run="Run"
|
|||||||
AdvSceneSwitcher.condition.run.entry="Process exits before timeout of{{timeout}}seconds"
|
AdvSceneSwitcher.condition.run.entry="Process exits before timeout of{{timeout}}seconds"
|
||||||
AdvSceneSwitcher.condition.run.entry.exit="{{checkExitCode}}Check for exit code{{exitCode}}"
|
AdvSceneSwitcher.condition.run.entry.exit="{{checkExitCode}}Check for exit code{{exitCode}}"
|
||||||
AdvSceneSwitcher.condition.midi="MIDI"
|
AdvSceneSwitcher.condition.midi="MIDI"
|
||||||
|
<<<<<<< HEAD
|
||||||
AdvSceneSwitcher.condition.midi.entry="Message was received from{{device}}which matches:"
|
AdvSceneSwitcher.condition.midi.entry="Message was received from{{device}}which matches:"
|
||||||
|
=======
|
||||||
|
AdvSceneSwitcher.condition.midi.condition.message="MIDI message was received"
|
||||||
|
AdvSceneSwitcher.condition.midi.condition.deviceName="MIDI device is connected"
|
||||||
|
AdvSceneSwitcher.condition.midi.condition.deviceName.info="On some platforms with certain APIs dynamic MIDI device detection might not function.\nSo this type of check might not be 100% reliable in all circumstances."
|
||||||
|
AdvSceneSwitcher.condition.midi.entry.message="{{conditions}}from{{device}}which matches:"
|
||||||
|
AdvSceneSwitcher.condition.midi.entry.deviceName="{{conditions}}{{deviceNames}}{{regex}}{{deviceListInfo}}"
|
||||||
|
>>>>>>> c4e35d1a (Add MIDI device name check)
|
||||||
AdvSceneSwitcher.condition.midi.entry.listen="Set MIDI message selection to messages incoming on selected device:{{listenButton}}"
|
AdvSceneSwitcher.condition.midi.entry.listen="Set MIDI message selection to messages incoming on selected device:{{listenButton}}"
|
||||||
AdvSceneSwitcher.condition.display="Display"
|
AdvSceneSwitcher.condition.display="Display"
|
||||||
AdvSceneSwitcher.condition.display.type.displayName="Name of connected displays matches"
|
AdvSceneSwitcher.condition.display.type.displayName="Name of connected displays matches"
|
||||||
@@ -692,17 +689,6 @@ AdvSceneSwitcher.condition.clipboard.condition.isImage="Clipboard contains an im
|
|||||||
AdvSceneSwitcher.condition.clipboard.condition.isURL="Clipboard contains an URL"
|
AdvSceneSwitcher.condition.clipboard.condition.isURL="Clipboard contains an URL"
|
||||||
AdvSceneSwitcher.condition.clipboard.condition.matches="Clipboard content matches"
|
AdvSceneSwitcher.condition.clipboard.condition.matches="Clipboard content matches"
|
||||||
AdvSceneSwitcher.condition.clipboard.condition.entry="{{conditions}}{{regex}}{{urlInfo}}"
|
AdvSceneSwitcher.condition.clipboard.condition.entry="{{conditions}}{{regex}}{{urlInfo}}"
|
||||||
AdvSceneSwitcher.condition.folder="Folder watch"
|
|
||||||
AdvSceneSwitcher.condition.folder.tooltip="This condition type will allow you to monitor the contents of a folder.\nNote that the monitoring will *not* recursively scan for changes in sub directories within directories of the selected folder!\nNote that if there are several changes during a short period of time, some of the changes might not emit this signal.\nHowever, the last change in the sequence of changes always will."
|
|
||||||
AdvSceneSwitcher.condition.folder.condition.any="Any change happened"
|
|
||||||
AdvSceneSwitcher.condition.folder.condition.fileAdd="A file was added"
|
|
||||||
AdvSceneSwitcher.condition.folder.condition.fileChange="A file was modified"
|
|
||||||
AdvSceneSwitcher.condition.folder.condition.fileRemove="A file was removed"
|
|
||||||
AdvSceneSwitcher.condition.folder.condition.folderAdd="A directory was added"
|
|
||||||
AdvSceneSwitcher.condition.folder.condition.folderRemove="A directory was removed"
|
|
||||||
AdvSceneSwitcher.condition.folder.entry="{{conditions}}in{{folder}}{{tooltip}}"
|
|
||||||
AdvSceneSwitcher.condition.folder.enableFilter="Only evaluate to true, if the changed path matches a patern"
|
|
||||||
AdvSceneSwitcher.condition.folder.entry.filter="{{filter}}{{regex}}"
|
|
||||||
|
|
||||||
; Macro Actions
|
; Macro Actions
|
||||||
AdvSceneSwitcher.action.scene="Switch scene"
|
AdvSceneSwitcher.action.scene="Switch scene"
|
||||||
@@ -834,24 +820,12 @@ AdvSceneSwitcher.action.macro="Macro"
|
|||||||
AdvSceneSwitcher.action.macro.type.pause="Pause"
|
AdvSceneSwitcher.action.macro.type.pause="Pause"
|
||||||
AdvSceneSwitcher.action.macro.type.unpause="Unpause"
|
AdvSceneSwitcher.action.macro.type.unpause="Unpause"
|
||||||
AdvSceneSwitcher.action.macro.type.resetCounter="Reset counter"
|
AdvSceneSwitcher.action.macro.type.resetCounter="Reset counter"
|
||||||
AdvSceneSwitcher.action.macro.type.run="Run macro"
|
AdvSceneSwitcher.action.macro.type.run="Run 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="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"
|
|
||||||
AdvSceneSwitcher.action.macro.type.run.setInputs="Set inputs"
|
|
||||||
AdvSceneSwitcher.action.macro.type.run.setInputs.description="Input variables can be defined in the macro settings.\nDefining input variables will allow you to modify the values of variables before an action is executed."
|
|
||||||
AdvSceneSwitcher.action.macro.type.stop="Stop actions"
|
AdvSceneSwitcher.action.macro.type.stop="Stop actions"
|
||||||
AdvSceneSwitcher.action.macro.type.disableAction="Disable action"
|
AdvSceneSwitcher.action.macro.type.disableAction="Disable action"
|
||||||
AdvSceneSwitcher.action.macro.type.enableAction="Enable action"
|
AdvSceneSwitcher.action.macro.type.enableAction="Enable action"
|
||||||
AdvSceneSwitcher.action.macro.type.toggleAction="Toggle action"
|
AdvSceneSwitcher.action.macro.type.toggleAction="Toggle action"
|
||||||
AdvSceneSwitcher.action.macro.entry.run="{{actions}}{{actionTypes}}of{{macros}}"
|
AdvSceneSwitcher.action.macro.entry="{{actions}}{{actionIndex}}{{macros}}"
|
||||||
AdvSceneSwitcher.action.macro.entry.run.condition="{{conditionBehaviors}}of{{conditionMacros}}"
|
|
||||||
AdvSceneSwitcher.action.macro.entry.other="{{actions}}{{actionIndex}}{{macros}}"
|
|
||||||
AdvSceneSwitcher.action.pluginState="Plugin state"
|
AdvSceneSwitcher.action.pluginState="Plugin state"
|
||||||
AdvSceneSwitcher.action.pluginState.type.stop="Stop the Advanced Scene Switcher plugin"
|
AdvSceneSwitcher.action.pluginState.type.stop="Stop the Advanced Scene Switcher plugin"
|
||||||
AdvSceneSwitcher.action.pluginState.type.noMatch="Change the no-match behaviour:"
|
AdvSceneSwitcher.action.pluginState.type.noMatch="Change the no-match behaviour:"
|
||||||
@@ -996,11 +970,9 @@ AdvSceneSwitcher.action.variable.type.sceneItemCount="Set to scene item count of
|
|||||||
AdvSceneSwitcher.action.variable.type.stringLength="Set to length of string"
|
AdvSceneSwitcher.action.variable.type.stringLength="Set to length of string"
|
||||||
AdvSceneSwitcher.action.variable.type.extractJson="Extract json field with name"
|
AdvSceneSwitcher.action.variable.type.extractJson="Extract json field with name"
|
||||||
AdvSceneSwitcher.action.variable.type.setToTempvar="Set to macro property"
|
AdvSceneSwitcher.action.variable.type.setToTempvar="Set to macro property"
|
||||||
AdvSceneSwitcher.action.variable.type.setToTempvar.help="This action type will allow you to extract values out of segments of the current macro and assign those values to the selected variable.\nFor example, you can get the current scene name from a scene condition and assign this name to a variable."
|
|
||||||
AdvSceneSwitcher.action.variable.type.sceneItemName="Set to scene item name at index"
|
AdvSceneSwitcher.action.variable.type.sceneItemName="Set to scene item name at index"
|
||||||
AdvSceneSwitcher.action.variable.type.padValue="Pad current value"
|
AdvSceneSwitcher.action.variable.type.padValue="Pad current value"
|
||||||
AdvSceneSwitcher.action.variable.type.truncateValue="Truncate current value"
|
AdvSceneSwitcher.action.variable.type.truncateValue="Truncate current value"
|
||||||
AdvSceneSwitcher.action.variable.type.swapValues="Swap variable values"
|
|
||||||
AdvSceneSwitcher.action.variable.truncateOrPadDirection.left="Left"
|
AdvSceneSwitcher.action.variable.truncateOrPadDirection.left="Left"
|
||||||
AdvSceneSwitcher.action.variable.truncateOrPadDirection.right="Right"
|
AdvSceneSwitcher.action.variable.truncateOrPadDirection.right="Right"
|
||||||
AdvSceneSwitcher.action.variable.askForValuePromptDefault="Assign value to variable \"%1\":"
|
AdvSceneSwitcher.action.variable.askForValuePromptDefault="Assign value to variable \"%1\":"
|
||||||
@@ -1014,7 +986,7 @@ AdvSceneSwitcher.action.variable.invalidSelection="Invalid selection!"
|
|||||||
AdvSceneSwitcher.action.variable.actionNoVariableSupport="Getting variable values from %1 actions is not supported!"
|
AdvSceneSwitcher.action.variable.actionNoVariableSupport="Getting variable values from %1 actions is not supported!"
|
||||||
AdvSceneSwitcher.action.variable.conditionNoVariableSupport="Getting variable values from %1 conditions is not supported!"
|
AdvSceneSwitcher.action.variable.conditionNoVariableSupport="Getting variable values from %1 conditions is not supported!"
|
||||||
AdvSceneSwitcher.action.variable.currentSegmentValue="Current value:"
|
AdvSceneSwitcher.action.variable.currentSegmentValue="Current value:"
|
||||||
AdvSceneSwitcher.action.variable.entry.other="{{actions}}{{variables}}{{variables2}}{{strValue}}{{numValue}}{{segmentIndex}}{{mathExpression}}{{envVariableName}}{{scenes}}{{tempVars}}{{tempVarsHelp}}{{sceneItemIndex}}{{direction}}{{stringLength}}{{paddingCharSelection}}"
|
AdvSceneSwitcher.action.variable.entry.other="{{actions}}{{variables}}{{variables2}}{{strValue}}{{numValue}}{{segmentIndex}}{{mathExpression}}{{envVariableName}}{{scenes}}{{tempVars}}{{sceneItemIndex}}{{direction}}{{stringLength}}{{paddingCharSelection}}"
|
||||||
AdvSceneSwitcher.action.variable.entry.pad="{{actions}}of{{variables}}to length{{stringLength}}by adding{{paddingCharSelection}}to the{{direction}}"
|
AdvSceneSwitcher.action.variable.entry.pad="{{actions}}of{{variables}}to length{{stringLength}}by adding{{paddingCharSelection}}to the{{direction}}"
|
||||||
AdvSceneSwitcher.action.variable.entry.truncate="{{actions}}of{{variables}}to length{{stringLength}}by removing characters from the{{direction}}"
|
AdvSceneSwitcher.action.variable.entry.truncate="{{actions}}of{{variables}}to length{{stringLength}}by removing characters from the{{direction}}"
|
||||||
AdvSceneSwitcher.action.variable.entry.substringIndex="Substring start:{{subStringStart}}Substring size:{{subStringSize}}"
|
AdvSceneSwitcher.action.variable.entry.substringIndex="Substring start:{{subStringStart}}Substring size:{{subStringSize}}"
|
||||||
@@ -1080,8 +1052,6 @@ AdvSceneSwitcher.action.queue.entry.add="{{actions}}actions of macro{{macros}}to
|
|||||||
AdvSceneSwitcher.action.queue.entry.other="{{actions}}queue{{queues}}"
|
AdvSceneSwitcher.action.queue.entry.other="{{actions}}queue{{queues}}"
|
||||||
AdvSceneSwitcher.action.window="Window"
|
AdvSceneSwitcher.action.window="Window"
|
||||||
AdvSceneSwitcher.action.window.type.setFocusWindow="Focus window"
|
AdvSceneSwitcher.action.window.type.setFocusWindow="Focus window"
|
||||||
AdvSceneSwitcher.action.window.type.setFocusWindow.limitation="The focus action can only be performed under certain circumstances"
|
|
||||||
AdvSceneSwitcher.action.window.type.setFocusWindow.limitation.details="At least one of the following conditions must be true:\n OBS is the foreground process.\n There is currently no foreground window, and thus no foreground process.\n OBS received the last input event."
|
|
||||||
AdvSceneSwitcher.action.window.type.maximizeWindow="Maximize window"
|
AdvSceneSwitcher.action.window.type.maximizeWindow="Maximize window"
|
||||||
AdvSceneSwitcher.action.window.type.minimizeWindow="Minimize window"
|
AdvSceneSwitcher.action.window.type.minimizeWindow="Minimize window"
|
||||||
AdvSceneSwitcher.action.window.type.closeWindow="Close window"
|
AdvSceneSwitcher.action.window.type.closeWindow="Close window"
|
||||||
@@ -1131,7 +1101,6 @@ AdvSceneSwitcher.variable.save="Save / load behavior"
|
|||||||
AdvSceneSwitcher.variable.save.dontSave="Don't save variable value"
|
AdvSceneSwitcher.variable.save.dontSave="Don't save variable value"
|
||||||
AdvSceneSwitcher.variable.save.save="Save variable value"
|
AdvSceneSwitcher.variable.save.save="Save variable value"
|
||||||
AdvSceneSwitcher.variable.save.default="Set to value"
|
AdvSceneSwitcher.variable.save.default="Set to value"
|
||||||
AdvSceneSwitcher.variable.selectionDialog="Select variable:"
|
|
||||||
|
|
||||||
AdvSceneSwitcher.tooltip.availableVariables="Variables are supported, use ${VarName} to retrieve the value of VarName"
|
AdvSceneSwitcher.tooltip.availableVariables="Variables are supported, use ${VarName} to retrieve the value of VarName"
|
||||||
|
|
||||||
@@ -1761,20 +1730,6 @@ AdvSceneSwitcher.tempVar.clipboard.text.description="The text contained in the c
|
|||||||
AdvSceneSwitcher.tempVar.file.content="File content"
|
AdvSceneSwitcher.tempVar.file.content="File content"
|
||||||
AdvSceneSwitcher.tempVar.file.date="File modification date"
|
AdvSceneSwitcher.tempVar.file.date="File modification date"
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.folder.newFiles="New files"
|
|
||||||
AdvSceneSwitcher.tempVar.folder.changedFiles="Changed files"
|
|
||||||
AdvSceneSwitcher.tempVar.folder.removedFiles="Removed files"
|
|
||||||
AdvSceneSwitcher.tempVar.folder.newDirs="New directories"
|
|
||||||
AdvSceneSwitcher.tempVar.folder.removedDirs="Removed directories"
|
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.source.width="Source width"
|
|
||||||
AdvSceneSwitcher.tempVar.source.height="Source height"
|
|
||||||
AdvSceneSwitcher.tempVar.source.setting="Setting value"
|
|
||||||
AdvSceneSwitcher.tempVar.source.settings="Settings string"
|
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.filter.setting="Setting value"
|
|
||||||
AdvSceneSwitcher.tempVar.filter.settings="Settings string"
|
|
||||||
|
|
||||||
AdvSceneSwitcher.selectScene="--select scene--"
|
AdvSceneSwitcher.selectScene="--select scene--"
|
||||||
AdvSceneSwitcher.selectPreviousScene="Previous Scene"
|
AdvSceneSwitcher.selectPreviousScene="Previous Scene"
|
||||||
AdvSceneSwitcher.selectCurrentScene="Current Scene"
|
AdvSceneSwitcher.selectCurrentScene="Current Scene"
|
||||||
|
|||||||
@@ -386,6 +386,7 @@ AdvSceneSwitcher.action.macro.type.unpause="Reanudar"
|
|||||||
AdvSceneSwitcher.action.macro.type.resetCounter="Reiniciar contador"
|
AdvSceneSwitcher.action.macro.type.resetCounter="Reiniciar contador"
|
||||||
AdvSceneSwitcher.action.macro.type.run="Ejecutar"
|
AdvSceneSwitcher.action.macro.type.run="Ejecutar"
|
||||||
AdvSceneSwitcher.action.macro.type.stop="Detener"
|
AdvSceneSwitcher.action.macro.type.stop="Detener"
|
||||||
|
AdvSceneSwitcher.action.macro.entry="{{actions}}{{actionIndex}}{{macros}}"
|
||||||
AdvSceneSwitcher.action.pluginState="Estado del complemento"
|
AdvSceneSwitcher.action.pluginState="Estado del complemento"
|
||||||
AdvSceneSwitcher.action.pluginState.type.stop="Detener el complemento Advanced Scene Switcher"
|
AdvSceneSwitcher.action.pluginState.type.stop="Detener el complemento Advanced Scene Switcher"
|
||||||
AdvSceneSwitcher.action.pluginState.type.noMatch="Cambiar el comportamiento de no coincidencia:"
|
AdvSceneSwitcher.action.pluginState.type.noMatch="Cambiar el comportamiento de no coincidencia:"
|
||||||
|
|||||||
@@ -446,7 +446,6 @@ AdvSceneSwitcher.condition.run="Exécution"
|
|||||||
AdvSceneSwitcher.condition.run.entry="Le processus se termine avant le délai de{{timeout}}secondes"
|
AdvSceneSwitcher.condition.run.entry="Le processus se termine avant le délai de{{timeout}}secondes"
|
||||||
AdvSceneSwitcher.condition.run.entry.exit="{{checkExitCode}}Vérifier le code de sortie{{exitCode}}
|
AdvSceneSwitcher.condition.run.entry.exit="{{checkExitCode}}Vérifier le code de sortie{{exitCode}}
|
||||||
AdvSceneSwitcher.condition.midi="MIDI"
|
AdvSceneSwitcher.condition.midi="MIDI"
|
||||||
AdvSceneSwitcher.condition.midi.entry="Message reçu depuis{{device}}qui correspond à :"
|
|
||||||
AdvSceneSwitcher.condition.midi.entry.listen="Définir la sélection des messages MIDI pour les messages entrants sur l'appareil sélectionné :{{listenButton}}"
|
AdvSceneSwitcher.condition.midi.entry.listen="Définir la sélection des messages MIDI pour les messages entrants sur l'appareil sélectionné :{{listenButton}}"
|
||||||
AdvSceneSwitcher.condition.display="Affichage"
|
AdvSceneSwitcher.condition.display="Affichage"
|
||||||
AdvSceneSwitcher.condition.display.type.displayName="Le nom des écrans connectés correspond à"
|
AdvSceneSwitcher.condition.display.type.displayName="Le nom des écrans connectés correspond à"
|
||||||
|
|||||||
@@ -315,6 +315,7 @@ AdvSceneSwitcher.action.macro.type.pause="Duraklat"
|
|||||||
AdvSceneSwitcher.action.macro.type.unpause="Duraklatma"
|
AdvSceneSwitcher.action.macro.type.unpause="Duraklatma"
|
||||||
AdvSceneSwitcher.action.macro.type.resetCounter="Sayacı sıfırla"
|
AdvSceneSwitcher.action.macro.type.resetCounter="Sayacı sıfırla"
|
||||||
AdvSceneSwitcher.action.macro.type.run="Çalıştır"
|
AdvSceneSwitcher.action.macro.type.run="Çalıştır"
|
||||||
|
AdvSceneSwitcher.action.macro.entry="{{actions}}{{actionIndex}}{{macros}}"
|
||||||
AdvSceneSwitcher.action.pluginState="Eklenti durumu"
|
AdvSceneSwitcher.action.pluginState="Eklenti durumu"
|
||||||
AdvSceneSwitcher.action.pluginState.type.stop="Advanced Scene Switcher eklentisini durdurun"
|
AdvSceneSwitcher.action.pluginState.type.stop="Advanced Scene Switcher eklentisini durdurun"
|
||||||
AdvSceneSwitcher.action.pluginState.type.noMatch="Eşleşmeme davranışını değiştirin:"
|
AdvSceneSwitcher.action.pluginState.type.noMatch="Eşleşmeme davranışını değiştirin:"
|
||||||
|
|||||||
@@ -434,7 +434,6 @@ AdvSceneSwitcher.condition.run="运行"
|
|||||||
AdvSceneSwitcher.condition.run.entry="进程在超时 {{timeout}} 秒之前退出"
|
AdvSceneSwitcher.condition.run.entry="进程在超时 {{timeout}} 秒之前退出"
|
||||||
AdvSceneSwitcher.condition.run.entry.exit="{{checkExitCode}}检查退出代码{{exitCode}}"
|
AdvSceneSwitcher.condition.run.entry.exit="{{checkExitCode}}检查退出代码{{exitCode}}"
|
||||||
AdvSceneSwitcher.condition.midi="MIDI"
|
AdvSceneSwitcher.condition.midi="MIDI"
|
||||||
AdvSceneSwitcher.condition.midi.entry="从{{device}} 收到的信息,符合:(从不咕咕的阿坤:这个好像是声卡工作是录音相关的功能,英文太抽象了,我就硬译过来了,如有相关设备,音乐好的,可以根据英文翻译好发给我!)"
|
|
||||||
AdvSceneSwitcher.condition.midi.entry.listen="将MIDI信息选择设置为从选定设备上接收的信息: {{listenButton}}"
|
AdvSceneSwitcher.condition.midi.entry.listen="将MIDI信息选择设置为从选定设备上接收的信息: {{listenButton}}"
|
||||||
AdvSceneSwitcher.condition.display="显示器"
|
AdvSceneSwitcher.condition.display="显示器"
|
||||||
AdvSceneSwitcher.condition.display.type.displayName="连接的显示器的名称匹配"
|
AdvSceneSwitcher.condition.display.type.displayName="连接的显示器的名称匹配"
|
||||||
@@ -524,6 +523,7 @@ AdvSceneSwitcher.action.macro.type.unpause="取消暂停"
|
|||||||
AdvSceneSwitcher.action.macro.type.resetCounter="复位计数器"
|
AdvSceneSwitcher.action.macro.type.resetCounter="复位计数器"
|
||||||
AdvSceneSwitcher.action.macro.type.run="运行操作"
|
AdvSceneSwitcher.action.macro.type.run="运行操作"
|
||||||
AdvSceneSwitcher.action.macro.type.stop="停止操作"
|
AdvSceneSwitcher.action.macro.type.stop="停止操作"
|
||||||
|
AdvSceneSwitcher.action.macro.entry="{{actions}}{{actionIndex}}{{macros}}"
|
||||||
AdvSceneSwitcher.action.pluginState="插件状态"
|
AdvSceneSwitcher.action.pluginState="插件状态"
|
||||||
AdvSceneSwitcher.action.pluginState.type.stop="停止高级场景切换插件"
|
AdvSceneSwitcher.action.pluginState.type.stop="停止高级场景切换插件"
|
||||||
AdvSceneSwitcher.action.pluginState.type.noMatch="没有匹配项时:"
|
AdvSceneSwitcher.action.pluginState.type.noMatch="没有匹配项时:"
|
||||||
|
|||||||
2
deps/opencv
vendored
2
deps/opencv
vendored
Submodule deps/opencv updated: 71d3237a09...b0dc474160
@@ -960,7 +960,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="macroSettings">
|
<widget class="QPushButton" name="macroProperties">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>22</width>
|
<width>22</width>
|
||||||
@@ -968,7 +968,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>AdvSceneSwitcher.macroTab.tooltip.openMacroSettingsButton</string>
|
<string>AdvSceneSwitcher.macroTab.tooltip.openMacroPropertiesButton</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@@ -5033,7 +5033,7 @@
|
|||||||
<tabstop>runMacro</tabstop>
|
<tabstop>runMacro</tabstop>
|
||||||
<tabstop>runMacroInParallel</tabstop>
|
<tabstop>runMacroInParallel</tabstop>
|
||||||
<tabstop>runMacroOnChange</tabstop>
|
<tabstop>runMacroOnChange</tabstop>
|
||||||
<tabstop>macroSettings</tabstop>
|
<tabstop>macroProperties</tabstop>
|
||||||
<tabstop>conditionsList</tabstop>
|
<tabstop>conditionsList</tabstop>
|
||||||
<tabstop>conditionAdd</tabstop>
|
<tabstop>conditionAdd</tabstop>
|
||||||
<tabstop>conditionRemove</tabstop>
|
<tabstop>conditionRemove</tabstop>
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ void SwitcherData::Thread()
|
|||||||
if (duration.count() < 1) {
|
if (duration.count() < 1) {
|
||||||
blog(LOG_INFO,
|
blog(LOG_INFO,
|
||||||
"detected busy loop - refusing to sleep less than 1ms");
|
"detected busy loop - refusing to sleep less than 1ms");
|
||||||
duration = std::chrono::milliseconds(10);
|
duration = std::chrono::milliseconds(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,36 +750,6 @@ QWidget *GetSettingsWindow()
|
|||||||
return SettingsWindowIsOpened() ? AdvSceneSwitcher::window : nullptr;
|
return SettingsWindowIsOpened() ? AdvSceneSwitcher::window : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::HighligthMacroSettingsButton(bool enable)
|
|
||||||
{
|
|
||||||
static QObject *highlight = nullptr;
|
|
||||||
if ((highlight && enable) || (!highlight && !enable)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (highlight && !enable) {
|
|
||||||
highlight->deleteLater();
|
|
||||||
highlight = nullptr;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!HighlightUIElementsEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
highlight = HighlightWidget(ui->macroSettings, Qt::green);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HighligthMacroSettingsButton(bool enable)
|
|
||||||
{
|
|
||||||
auto window = GetSettingsWindow();
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
static_cast<AdvSceneSwitcher *>(window)->HighligthMacroSettingsButton(
|
|
||||||
enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetupActionQueues();
|
void SetupActionQueues();
|
||||||
|
|
||||||
extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
|
extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class MacroActionEdit;
|
|||||||
class MacroConditionEdit;
|
class MacroConditionEdit;
|
||||||
class Duration;
|
class Duration;
|
||||||
class SequenceWidget;
|
class SequenceWidget;
|
||||||
enum class LogicType;
|
|
||||||
struct SceneGroup;
|
struct SceneGroup;
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@@ -96,7 +95,6 @@ public:
|
|||||||
void SetConditionData(Macro &m);
|
void SetConditionData(Macro &m);
|
||||||
void SwapActions(Macro *m, int pos1, int pos2);
|
void SwapActions(Macro *m, int pos1, int pos2);
|
||||||
void SwapConditions(Macro *m, int pos1, int pos2);
|
void SwapConditions(Macro *m, int pos1, int pos2);
|
||||||
void HighligthMacroSettingsButton(bool enable = true);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void on_macroAdd_clicked();
|
void on_macroAdd_clicked();
|
||||||
@@ -154,16 +152,12 @@ public slots:
|
|||||||
void SetElseActionsStateToVisible();
|
void SetElseActionsStateToVisible();
|
||||||
void MacroActionSelectionChanged(int idx);
|
void MacroActionSelectionChanged(int idx);
|
||||||
void MacroActionReorder(int to, int target);
|
void MacroActionReorder(int to, int target);
|
||||||
void AddMacroAction(Macro *macro, int idx, const std::string &id,
|
|
||||||
obs_data_t *data);
|
|
||||||
void AddMacroAction(int idx);
|
void AddMacroAction(int idx);
|
||||||
void RemoveMacroAction(int idx);
|
void RemoveMacroAction(int idx);
|
||||||
void MoveMacroActionUp(int idx);
|
void MoveMacroActionUp(int idx);
|
||||||
void MoveMacroActionDown(int idx);
|
void MoveMacroActionDown(int idx);
|
||||||
void MacroElseActionSelectionChanged(int idx);
|
void MacroElseActionSelectionChanged(int idx);
|
||||||
void MacroElseActionReorder(int to, int target);
|
void MacroElseActionReorder(int to, int target);
|
||||||
void AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
|
||||||
obs_data_t *data);
|
|
||||||
void AddMacroElseAction(int idx);
|
void AddMacroElseAction(int idx);
|
||||||
void RemoveMacroElseAction(int idx);
|
void RemoveMacroElseAction(int idx);
|
||||||
void SwapElseActions(Macro *m, int pos1, int pos2);
|
void SwapElseActions(Macro *m, int pos1, int pos2);
|
||||||
@@ -172,16 +166,16 @@ public slots:
|
|||||||
void MacroConditionSelectionChanged(int idx);
|
void MacroConditionSelectionChanged(int idx);
|
||||||
void MacroConditionReorder(int to, int target);
|
void MacroConditionReorder(int to, int target);
|
||||||
void AddMacroCondition(int idx);
|
void AddMacroCondition(int idx);
|
||||||
void AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
|
||||||
obs_data_t *data, LogicType logic);
|
|
||||||
void RemoveMacroCondition(int idx);
|
void RemoveMacroCondition(int idx);
|
||||||
void MoveMacroConditionUp(int idx);
|
void MoveMacroConditionUp(int idx);
|
||||||
void MoveMacroConditionDown(int idx);
|
void MoveMacroConditionDown(int idx);
|
||||||
|
void FadeOutActionControls();
|
||||||
|
void FadeOutConditionControls();
|
||||||
|
void ResetOpacityActionControls();
|
||||||
|
void ResetOpacityConditionControls();
|
||||||
void HighlightControls();
|
void HighlightControls();
|
||||||
void HighlightOnChange();
|
void HighlightOnChange();
|
||||||
void on_macroSettings_clicked();
|
void on_macroProperties_clicked();
|
||||||
void CopyMacroSegment();
|
|
||||||
void PasteMacroSegment();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MacroAdded(const QString &name);
|
void MacroAdded(const QString &name);
|
||||||
@@ -190,6 +184,9 @@ signals:
|
|||||||
void MacroSegmentOrderChanged();
|
void MacroSegmentOrderChanged();
|
||||||
void SegmentTempVarsChanged();
|
void SegmentTempVarsChanged();
|
||||||
void HighlightMacrosChanged(bool value);
|
void HighlightMacrosChanged(bool value);
|
||||||
|
void HighlightActionsChanged(bool value);
|
||||||
|
void HighlightElseActionsChanged(bool value);
|
||||||
|
void HighlightConditionsChanged(bool value);
|
||||||
|
|
||||||
void ConnectionAdded(const QString &);
|
void ConnectionAdded(const QString &);
|
||||||
void ConnectionRenamed(const QString &oldName, const QString &newName);
|
void ConnectionRenamed(const QString &oldName, const QString &newName);
|
||||||
@@ -411,6 +408,5 @@ public slots:
|
|||||||
|
|
||||||
void OpenSettingsWindow();
|
void OpenSettingsWindow();
|
||||||
QWidget *GetSettingsWindow();
|
QWidget *GetSettingsWindow();
|
||||||
void HighligthMacroSettingsButton(bool enable);
|
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoadMacros(obj);
|
LoadMacros(obj);
|
||||||
LoadGlobalMacroSettings(obj);
|
LoadGlobalMacroProperties(obj);
|
||||||
loadWindowTitleSwitches(obj);
|
loadWindowTitleSwitches(obj);
|
||||||
loadScreenRegionSwitches(obj);
|
loadScreenRegionSwitches(obj);
|
||||||
loadPauseSwitches(obj);
|
loadPauseSwitches(obj);
|
||||||
@@ -466,7 +466,7 @@ void SwitcherData::SaveSettings(obs_data_t *obj)
|
|||||||
|
|
||||||
saveSceneGroups(obj);
|
saveSceneGroups(obj);
|
||||||
SaveMacros(obj);
|
SaveMacros(obj);
|
||||||
SaveGlobalMacroSettings(obj);
|
SaveGlobalMacroProperties(obj);
|
||||||
SaveVariables(obj);
|
SaveVariables(obj);
|
||||||
saveWindowTitleSwitches(obj);
|
saveWindowTitleSwitches(obj);
|
||||||
saveScreenRegionSwitches(obj);
|
saveScreenRegionSwitches(obj);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
SceneGroupEditWidget *typeEdit = nullptr;
|
SceneGroupEditWidget *typeEdit = nullptr;
|
||||||
|
|
||||||
std::deque<SceneGroup> &GetSceneGroups()
|
std::deque<SceneGroup> &GetSceneGroups()
|
||||||
@@ -170,8 +170,7 @@ void AdvSceneSwitcher::on_sceneGroupAdd_clicked()
|
|||||||
item->setData(Qt::UserRole, text);
|
item->setData(Qt::UserRole, text);
|
||||||
ui->sceneGroups->setCurrentItem(item);
|
ui->sceneGroups->setCurrentItem(item);
|
||||||
|
|
||||||
addPulse->deleteLater();
|
ui->sceneGroupAdd->disconnect(addPulse);
|
||||||
addPulse = nullptr;
|
|
||||||
ui->sceneGroupHelp->setVisible(false);
|
ui->sceneGroupHelp->setVisible(false);
|
||||||
|
|
||||||
emit SceneGroupAdded(QString::fromStdString(name));
|
emit SceneGroupAdded(QString::fromStdString(name));
|
||||||
@@ -513,8 +512,8 @@ void AdvSceneSwitcher::SetupSceneGroupTab()
|
|||||||
|
|
||||||
if (switcher->sceneGroups.size() == 0) {
|
if (switcher->sceneGroups.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->sceneGroupAdd,
|
addPulse = PulseWidget(ui->sceneGroupAdd,
|
||||||
QColor(Qt::green));
|
QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->sceneGroupHelp->setVisible(true);
|
ui->sceneGroupHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool SceneTrigger::pause = false;
|
bool SceneTrigger::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_triggerAdd_clicked()
|
void AdvSceneSwitcher::on_triggerAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ void AdvSceneSwitcher::on_triggerAdd_clicked()
|
|||||||
listAddClicked(ui->sceneTriggers,
|
listAddClicked(ui->sceneTriggers,
|
||||||
new SceneTriggerWidget(this,
|
new SceneTriggerWidget(this,
|
||||||
&switcher->sceneTriggers.back()),
|
&switcher->sceneTriggers.back()),
|
||||||
ui->triggerAdd, addPulse);
|
ui->triggerAdd, &addPulse);
|
||||||
|
|
||||||
ui->triggerHelp->setVisible(false);
|
ui->triggerHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -370,8 +370,8 @@ void AdvSceneSwitcher::SetupTriggerTab()
|
|||||||
|
|
||||||
if (switcher->sceneTriggers.size() == 0) {
|
if (switcher->sceneTriggers.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->triggerAdd,
|
addPulse =
|
||||||
QColor(Qt::green));
|
PulseWidget(ui->triggerAdd, QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->triggerHelp->setVisible(true);
|
ui->triggerHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool AudioSwitch::pause = false;
|
bool AudioSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_audioAdd_clicked()
|
void AdvSceneSwitcher::on_audioAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ void AdvSceneSwitcher::on_audioAdd_clicked()
|
|||||||
AudioSwitchWidget *sw =
|
AudioSwitchWidget *sw =
|
||||||
new AudioSwitchWidget(this, &switcher->audioSwitches.back());
|
new AudioSwitchWidget(this, &switcher->audioSwitches.back());
|
||||||
|
|
||||||
listAddClicked(ui->audioSwitches, sw, ui->audioAdd, addPulse);
|
listAddClicked(ui->audioSwitches, sw, ui->audioAdd, &addPulse);
|
||||||
|
|
||||||
ui->audioHelp->setVisible(false);
|
ui->audioHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -232,8 +232,7 @@ void AdvSceneSwitcher::SetupAudioTab()
|
|||||||
|
|
||||||
if (switcher->audioSwitches.size() == 0) {
|
if (switcher->audioSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->audioAdd,
|
addPulse = PulseWidget(ui->audioAdd, QColor(Qt::green));
|
||||||
QColor(Qt::green));
|
|
||||||
}
|
}
|
||||||
ui->audioHelp->setVisible(true);
|
ui->audioHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool ExecutableSwitch::pause = false;
|
bool ExecutableSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_executableAdd_clicked()
|
void AdvSceneSwitcher::on_executableAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -19,7 +19,7 @@ void AdvSceneSwitcher::on_executableAdd_clicked()
|
|||||||
listAddClicked(ui->executables,
|
listAddClicked(ui->executables,
|
||||||
new ExecutableSwitchWidget(
|
new ExecutableSwitchWidget(
|
||||||
this, &switcher->executableSwitches.back()),
|
this, &switcher->executableSwitches.back()),
|
||||||
ui->executableAdd, addPulse);
|
ui->executableAdd, &addPulse);
|
||||||
|
|
||||||
ui->exeHelp->setVisible(false);
|
ui->exeHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -177,8 +177,8 @@ void AdvSceneSwitcher::SetupExecutableTab()
|
|||||||
|
|
||||||
if (switcher->executableSwitches.size() == 0) {
|
if (switcher->executableSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->executableAdd,
|
addPulse = PulseWidget(ui->executableAdd,
|
||||||
QColor(Qt::green));
|
QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->exeHelp->setVisible(true);
|
ui->exeHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool FileSwitch::pause = false;
|
bool FileSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
static std::hash<std::string> strHash;
|
static std::hash<std::string> strHash;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_browseButton_clicked()
|
void AdvSceneSwitcher::on_browseButton_clicked()
|
||||||
@@ -291,7 +291,7 @@ void AdvSceneSwitcher::on_fileAdd_clicked()
|
|||||||
listAddClicked(ui->fileSwitches,
|
listAddClicked(ui->fileSwitches,
|
||||||
new FileSwitchWidget(this,
|
new FileSwitchWidget(this,
|
||||||
&switcher->fileSwitches.back()),
|
&switcher->fileSwitches.back()),
|
||||||
ui->fileAdd, addPulse);
|
ui->fileAdd, &addPulse);
|
||||||
|
|
||||||
ui->fileHelp->setVisible(false);
|
ui->fileHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -441,8 +441,7 @@ void AdvSceneSwitcher::SetupFileTab()
|
|||||||
|
|
||||||
if (switcher->fileSwitches.size() == 0) {
|
if (switcher->fileSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse =
|
addPulse = PulseWidget(ui->fileAdd, QColor(Qt::green));
|
||||||
HighlightWidget(ui->fileAdd, QColor(Qt::green));
|
|
||||||
}
|
}
|
||||||
ui->fileHelp->setVisible(true);
|
ui->fileHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool MediaSwitch::pause = false;
|
bool MediaSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
constexpr auto media_played_to_end_idx = 8;
|
constexpr auto media_played_to_end_idx = 8;
|
||||||
constexpr auto media_any_idx = 9;
|
constexpr auto media_any_idx = 9;
|
||||||
@@ -22,7 +22,7 @@ void AdvSceneSwitcher::on_mediaAdd_clicked()
|
|||||||
listAddClicked(ui->mediaSwitches,
|
listAddClicked(ui->mediaSwitches,
|
||||||
new MediaSwitchWidget(this,
|
new MediaSwitchWidget(this,
|
||||||
&switcher->mediaSwitches.back()),
|
&switcher->mediaSwitches.back()),
|
||||||
ui->mediaAdd, addPulse);
|
ui->mediaAdd, &addPulse);
|
||||||
|
|
||||||
ui->mediaHelp->setVisible(false);
|
ui->mediaHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -252,8 +252,7 @@ void AdvSceneSwitcher::SetupMediaTab()
|
|||||||
|
|
||||||
if (switcher->mediaSwitches.size() == 0) {
|
if (switcher->mediaSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->mediaAdd,
|
addPulse = PulseWidget(ui->mediaAdd, QColor(Qt::green));
|
||||||
QColor(Qt::green));
|
|
||||||
}
|
}
|
||||||
ui->mediaHelp->setVisible(true);
|
ui->mediaHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_pauseAdd_clicked()
|
void AdvSceneSwitcher::on_pauseAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ void AdvSceneSwitcher::on_pauseAdd_clicked()
|
|||||||
listAddClicked(ui->pauseEntries,
|
listAddClicked(ui->pauseEntries,
|
||||||
new PauseEntryWidget(this,
|
new PauseEntryWidget(this,
|
||||||
&switcher->pauseEntries.back()),
|
&switcher->pauseEntries.back()),
|
||||||
ui->pauseAdd, addPulse);
|
ui->pauseAdd, &addPulse);
|
||||||
|
|
||||||
ui->pauseHelp->setVisible(false);
|
ui->pauseHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -264,8 +264,7 @@ void AdvSceneSwitcher::SetupPauseTab()
|
|||||||
|
|
||||||
if (switcher->pauseEntries.size() == 0) {
|
if (switcher->pauseEntries.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->pauseAdd,
|
addPulse = PulseWidget(ui->pauseAdd, QColor(Qt::green));
|
||||||
QColor(Qt::green));
|
|
||||||
}
|
}
|
||||||
ui->pauseHelp->setVisible(true);
|
ui->pauseHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool RandomSwitch::pause = false;
|
bool RandomSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_randomAdd_clicked()
|
void AdvSceneSwitcher::on_randomAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -19,7 +19,7 @@ void AdvSceneSwitcher::on_randomAdd_clicked()
|
|||||||
listAddClicked(ui->randomSwitches,
|
listAddClicked(ui->randomSwitches,
|
||||||
new RandomSwitchWidget(this,
|
new RandomSwitchWidget(this,
|
||||||
&switcher->randomSwitches.back()),
|
&switcher->randomSwitches.back()),
|
||||||
ui->randomAdd, addPulse);
|
ui->randomAdd, &addPulse);
|
||||||
|
|
||||||
ui->randomHelp->setVisible(false);
|
ui->randomHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -131,8 +131,8 @@ void AdvSceneSwitcher::SetupRandomTab()
|
|||||||
|
|
||||||
if (switcher->randomSwitches.size() == 0) {
|
if (switcher->randomSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->randomAdd,
|
addPulse =
|
||||||
QColor(Qt::green));
|
PulseWidget(ui->randomAdd, QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->randomHelp->setVisible(true);
|
ui->randomHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -147,8 +147,8 @@ void AdvSceneSwitcher::SetupRandomTab()
|
|||||||
}");
|
}");
|
||||||
if (switcher->switchIfNotMatching != NoMatchBehavior::RANDOM_SWITCH) {
|
if (switcher->switchIfNotMatching != NoMatchBehavior::RANDOM_SWITCH) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
HighlightWidget(ui->randomDisabledWarning,
|
PulseWidget(ui->randomDisabledWarning, QColor(Qt::red),
|
||||||
QColor(Qt::red), QColor(0, 0, 0, 0));
|
QColor(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ui->randomDisabledWarning->setVisible(false);
|
ui->randomDisabledWarning->setVisible(false);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool ScreenRegionSwitch::pause = false;
|
bool ScreenRegionSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::ClearFrames(QListWidget *list)
|
void AdvSceneSwitcher::ClearFrames(QListWidget *list)
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ void AdvSceneSwitcher::on_screenRegionAdd_clicked()
|
|||||||
listAddClicked(ui->screenRegionSwitches,
|
listAddClicked(ui->screenRegionSwitches,
|
||||||
new ScreenRegionWidget(
|
new ScreenRegionWidget(
|
||||||
this, &switcher->screenRegionSwitches.back()),
|
this, &switcher->screenRegionSwitches.back()),
|
||||||
ui->screenRegionAdd, addPulse);
|
ui->screenRegionAdd, &addPulse);
|
||||||
|
|
||||||
ui->regionHelp->setVisible(false);
|
ui->regionHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -248,8 +248,8 @@ void AdvSceneSwitcher::SetupRegionTab()
|
|||||||
|
|
||||||
if (switcher->screenRegionSwitches.size() == 0) {
|
if (switcher->screenRegionSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->screenRegionAdd,
|
addPulse = PulseWidget(ui->screenRegionAdd,
|
||||||
QColor(Qt::green));
|
QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->regionHelp->setVisible(true);
|
ui->regionHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace advss {
|
|||||||
constexpr auto max_extend_text_size = 150;
|
constexpr auto max_extend_text_size = 150;
|
||||||
|
|
||||||
bool SceneSequenceSwitch::pause = false;
|
bool SceneSequenceSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_sceneSequenceAdd_clicked()
|
void AdvSceneSwitcher::on_sceneSequenceAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,7 @@ void AdvSceneSwitcher::on_sceneSequenceAdd_clicked()
|
|||||||
listAddClicked(ui->sceneSequenceSwitches,
|
listAddClicked(ui->sceneSequenceSwitches,
|
||||||
new SequenceWidget(
|
new SequenceWidget(
|
||||||
this, &switcher->sceneSequenceSwitches.back()),
|
this, &switcher->sceneSequenceSwitches.back()),
|
||||||
ui->sceneSequenceAdd, addPulse);
|
ui->sceneSequenceAdd, &addPulse);
|
||||||
|
|
||||||
ui->sequenceHelp->setVisible(false);
|
ui->sequenceHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -299,8 +299,8 @@ void AdvSceneSwitcher::SetupSequenceTab()
|
|||||||
|
|
||||||
if (switcher->sceneSequenceSwitches.size() == 0) {
|
if (switcher->sceneSequenceSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->sceneSequenceAdd,
|
addPulse = PulseWidget(ui->sceneSequenceAdd,
|
||||||
QColor(Qt::green));
|
QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->sequenceHelp->setVisible(true);
|
ui->sequenceHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool TimeSwitch::pause = false;
|
bool TimeSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_timeAdd_clicked()
|
void AdvSceneSwitcher::on_timeAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ void AdvSceneSwitcher::on_timeAdd_clicked()
|
|||||||
listAddClicked(ui->timeSwitches,
|
listAddClicked(ui->timeSwitches,
|
||||||
new TimeSwitchWidget(this,
|
new TimeSwitchWidget(this,
|
||||||
&switcher->timeSwitches.back()),
|
&switcher->timeSwitches.back()),
|
||||||
ui->timeAdd, addPulse);
|
ui->timeAdd, &addPulse);
|
||||||
|
|
||||||
ui->timeHelp->setVisible(false);
|
ui->timeHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -197,8 +197,7 @@ void AdvSceneSwitcher::SetupTimeTab()
|
|||||||
|
|
||||||
if (switcher->timeSwitches.size() == 0) {
|
if (switcher->timeSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse =
|
addPulse = PulseWidget(ui->timeAdd, QColor(Qt::green));
|
||||||
HighlightWidget(ui->timeAdd, QColor(Qt::green));
|
|
||||||
}
|
}
|
||||||
ui->timeHelp->setVisible(true);
|
ui->timeHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool VideoSwitch::pause = false;
|
bool VideoSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_videoAdd_clicked()
|
void AdvSceneSwitcher::on_videoAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -24,7 +24,7 @@ void AdvSceneSwitcher::on_videoAdd_clicked()
|
|||||||
VideoSwitchWidget *sw =
|
VideoSwitchWidget *sw =
|
||||||
new VideoSwitchWidget(this, &switcher->videoSwitches.back());
|
new VideoSwitchWidget(this, &switcher->videoSwitches.back());
|
||||||
|
|
||||||
listAddClicked(ui->videoSwitches, sw, ui->videoAdd, addPulse);
|
listAddClicked(ui->videoSwitches, sw, ui->videoAdd, &addPulse);
|
||||||
|
|
||||||
ui->videoHelp->setVisible(false);
|
ui->videoHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -202,8 +202,7 @@ void AdvSceneSwitcher::SetupVideoTab()
|
|||||||
|
|
||||||
if (switcher->videoSwitches.size() == 0) {
|
if (switcher->videoSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->videoAdd,
|
addPulse = PulseWidget(ui->videoAdd, QColor(Qt::green));
|
||||||
QColor(Qt::green));
|
|
||||||
}
|
}
|
||||||
ui->videoHelp->setVisible(true);
|
ui->videoHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
bool WindowSwitch::pause = false;
|
bool WindowSwitch::pause = false;
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_windowAdd_clicked()
|
void AdvSceneSwitcher::on_windowAdd_clicked()
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ void AdvSceneSwitcher::on_windowAdd_clicked()
|
|||||||
listAddClicked(ui->windowSwitches,
|
listAddClicked(ui->windowSwitches,
|
||||||
new WindowSwitchWidget(this,
|
new WindowSwitchWidget(this,
|
||||||
&switcher->windowSwitches.back()),
|
&switcher->windowSwitches.back()),
|
||||||
ui->windowAdd, addPulse);
|
ui->windowAdd, &addPulse);
|
||||||
|
|
||||||
ui->windowHelp->setVisible(false);
|
ui->windowHelp->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -335,8 +335,8 @@ void AdvSceneSwitcher::SetupTitleTab()
|
|||||||
|
|
||||||
if (switcher->windowSwitches.size() == 0) {
|
if (switcher->windowSwitches.size() == 0) {
|
||||||
if (!switcher->disableHints) {
|
if (!switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->windowAdd,
|
addPulse =
|
||||||
QColor(Qt::green));
|
PulseWidget(ui->windowAdd, QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->windowHelp->setVisible(true);
|
ui->windowHelp->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "advanced-scene-switcher.hpp"
|
#include "advanced-scene-switcher.hpp"
|
||||||
#include "macro-helpers.hpp"
|
#include "macro-helpers.hpp"
|
||||||
#include "macro-settings.hpp"
|
#include "macro-properties.hpp"
|
||||||
#include "macro.hpp"
|
#include "macro.hpp"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
#include "section.hpp"
|
#include "section.hpp"
|
||||||
@@ -29,7 +29,8 @@ static inline void populateActionSelection(QComboBox *list)
|
|||||||
MacroActionEdit::MacroActionEdit(QWidget *parent,
|
MacroActionEdit::MacroActionEdit(QWidget *parent,
|
||||||
std::shared_ptr<MacroAction> *entryData,
|
std::shared_ptr<MacroAction> *entryData,
|
||||||
const std::string &id)
|
const std::string &id)
|
||||||
: MacroSegmentEdit(parent),
|
: MacroSegmentEdit(GetGlobalMacroProperties()._highlightActions,
|
||||||
|
parent),
|
||||||
_actionSelection(new FilterComboBox()),
|
_actionSelection(new FilterComboBox()),
|
||||||
_enable(new SwitchButton()),
|
_enable(new SwitchButton()),
|
||||||
_entryData(entryData)
|
_entryData(entryData)
|
||||||
@@ -39,6 +40,8 @@ MacroActionEdit::MacroActionEdit(QWidget *parent,
|
|||||||
SLOT(ActionSelectionChanged(const QString &)));
|
SLOT(ActionSelectionChanged(const QString &)));
|
||||||
QWidget::connect(_enable, SIGNAL(checked(bool)), this,
|
QWidget::connect(_enable, SIGNAL(checked(bool)), this,
|
||||||
SLOT(ActionEnableChanged(bool)));
|
SLOT(ActionEnableChanged(bool)));
|
||||||
|
QWidget::connect(window(), SIGNAL(HighlightActionsChanged(bool)), this,
|
||||||
|
SLOT(EnableHighlight(bool)));
|
||||||
QWidget::connect(&_actionStateTimer, SIGNAL(timeout()), this,
|
QWidget::connect(&_actionStateTimer, SIGNAL(timeout()), this,
|
||||||
SLOT(UpdateActionState()));
|
SLOT(UpdateActionState()));
|
||||||
|
|
||||||
@@ -158,20 +161,33 @@ std::shared_ptr<MacroSegment> MacroActionEdit::Data() const
|
|||||||
return *_entryData;
|
return *_entryData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::AddMacroAction(Macro *macro, int idx,
|
void AdvSceneSwitcher::AddMacroAction(int idx)
|
||||||
const std::string &id, obs_data_t *data)
|
|
||||||
{
|
{
|
||||||
if (idx < 0 || idx > (int)macro->Actions().size()) {
|
auto macro = GetSelectedMacro();
|
||||||
assert(false);
|
if (!macro) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (idx < 0 || idx > (int)macro->Actions().size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string id;
|
||||||
|
if (idx - 1 >= 0) {
|
||||||
|
id = macro->Actions().at(idx - 1)->GetId();
|
||||||
|
} else {
|
||||||
|
id = MacroAction::GetDefaultID();
|
||||||
|
}
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
macro->Actions().emplace(macro->Actions().begin() + idx,
|
macro->Actions().emplace(
|
||||||
MacroActionFactory::Create(id, macro));
|
macro->Actions().begin() + idx,
|
||||||
if (data) {
|
MacroActionFactory::Create(id, macro.get()));
|
||||||
|
if (idx - 1 >= 0) {
|
||||||
|
auto data = obs_data_create();
|
||||||
|
macro->Actions().at(idx - 1)->Save(data);
|
||||||
macro->Actions().at(idx)->Load(data);
|
macro->Actions().at(idx)->Load(data);
|
||||||
|
obs_data_release(data);
|
||||||
}
|
}
|
||||||
macro->Actions().at(idx)->PostLoad();
|
macro->Actions().at(idx)->PostLoad();
|
||||||
RunPostLoadSteps();
|
RunPostLoadSteps();
|
||||||
@@ -182,37 +198,9 @@ void AdvSceneSwitcher::AddMacroAction(Macro *macro, int idx,
|
|||||||
SetActionData(*macro);
|
SetActionData(*macro);
|
||||||
}
|
}
|
||||||
HighlightAction(idx);
|
HighlightAction(idx);
|
||||||
ui->actionsList->SetHelpMsgVisible(false);
|
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::AddMacroAction(int idx)
|
|
||||||
{
|
|
||||||
auto macro = GetSelectedMacro();
|
|
||||||
if (!macro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx < 0 || idx > (int)macro->Actions().size()) {
|
|
||||||
assert(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string id;
|
|
||||||
if (idx - 1 >= 0) {
|
|
||||||
id = macro->Actions().at(idx - 1)->GetId();
|
|
||||||
} else {
|
|
||||||
id = MacroAction::GetDefaultID();
|
|
||||||
}
|
|
||||||
|
|
||||||
OBSDataAutoRelease data;
|
|
||||||
if (idx - 1 >= 0) {
|
|
||||||
data = obs_data_create();
|
|
||||||
macro->Actions().at(idx - 1)->Save(data);
|
|
||||||
}
|
|
||||||
AddMacroAction(macro.get(), idx, id, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_actionAdd_clicked()
|
void AdvSceneSwitcher::on_actionAdd_clicked()
|
||||||
{
|
{
|
||||||
auto macro = GetSelectedMacro();
|
auto macro = GetSelectedMacro();
|
||||||
@@ -228,6 +216,7 @@ void AdvSceneSwitcher::on_actionAdd_clicked()
|
|||||||
if (currentActionIdx != -1) {
|
if (currentActionIdx != -1) {
|
||||||
MacroActionSelectionChanged(currentActionIdx + 1);
|
MacroActionSelectionChanged(currentActionIdx + 1);
|
||||||
}
|
}
|
||||||
|
ui->actionsList->SetHelpMsgVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::RemoveMacroAction(int idx)
|
void AdvSceneSwitcher::RemoveMacroAction(int idx)
|
||||||
@@ -322,6 +311,7 @@ void AdvSceneSwitcher::on_elseActionAdd_clicked()
|
|||||||
if (currentElseActionIdx != -1) {
|
if (currentElseActionIdx != -1) {
|
||||||
MacroElseActionSelectionChanged(currentElseActionIdx + 1);
|
MacroElseActionSelectionChanged(currentElseActionIdx + 1);
|
||||||
}
|
}
|
||||||
|
ui->elseActionsList->SetHelpMsgVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_elseActionRemove_clicked()
|
void AdvSceneSwitcher::on_elseActionRemove_clicked()
|
||||||
@@ -460,21 +450,31 @@ void AdvSceneSwitcher::MacroElseActionReorder(int to, int from)
|
|||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::AddMacroElseAction(Macro *macro, int idx,
|
void AdvSceneSwitcher::AddMacroElseAction(int idx)
|
||||||
const std::string &id,
|
|
||||||
obs_data_t *data)
|
|
||||||
{
|
{
|
||||||
if (idx < 0 || idx > (int)macro->ElseActions().size()) {
|
auto macro = GetSelectedMacro();
|
||||||
assert(false);
|
if (!macro) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (idx < 0 || idx > (int)macro->ElseActions().size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string id;
|
||||||
|
if (idx - 1 >= 0) {
|
||||||
|
id = macro->ElseActions().at(idx - 1)->GetId();
|
||||||
|
} else {
|
||||||
|
id = MacroAction::GetDefaultID();
|
||||||
|
}
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
macro->ElseActions().emplace(macro->ElseActions().begin() + idx,
|
macro->ElseActions().emplace(
|
||||||
MacroActionFactory::Create(id,
|
macro->ElseActions().begin() + idx,
|
||||||
macro));
|
MacroActionFactory::Create(id, macro.get()));
|
||||||
if (data) {
|
if (idx - 1 >= 0) {
|
||||||
|
OBSDataAutoRelease data = obs_data_create();
|
||||||
|
macro->ElseActions().at(idx - 1)->Save(data);
|
||||||
macro->ElseActions().at(idx)->Load(data);
|
macro->ElseActions().at(idx)->Load(data);
|
||||||
}
|
}
|
||||||
macro->ElseActions().at(idx)->PostLoad();
|
macro->ElseActions().at(idx)->PostLoad();
|
||||||
@@ -486,37 +486,9 @@ void AdvSceneSwitcher::AddMacroElseAction(Macro *macro, int idx,
|
|||||||
SetElseActionData(*macro);
|
SetElseActionData(*macro);
|
||||||
}
|
}
|
||||||
HighlightElseAction(idx);
|
HighlightElseAction(idx);
|
||||||
ui->elseActionsList->SetHelpMsgVisible(false);
|
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::AddMacroElseAction(int idx)
|
|
||||||
{
|
|
||||||
auto macro = GetSelectedMacro();
|
|
||||||
if (!macro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx < 0 || idx > (int)macro->ElseActions().size()) {
|
|
||||||
assert(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string id;
|
|
||||||
if (idx - 1 >= 0) {
|
|
||||||
id = macro->ElseActions().at(idx - 1)->GetId();
|
|
||||||
} else {
|
|
||||||
id = MacroAction::GetDefaultID();
|
|
||||||
}
|
|
||||||
|
|
||||||
OBSDataAutoRelease data;
|
|
||||||
if (idx - 1 >= 0) {
|
|
||||||
data = obs_data_create();
|
|
||||||
macro->ElseActions().at(idx - 1)->Save(data);
|
|
||||||
}
|
|
||||||
AddMacroElseAction(macro.get(), idx, id, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvSceneSwitcher::RemoveMacroElseAction(int idx)
|
void AdvSceneSwitcher::RemoveMacroElseAction(int idx)
|
||||||
{
|
{
|
||||||
auto macro = GetSelectedMacro();
|
auto macro = GetSelectedMacro();
|
||||||
@@ -535,7 +507,7 @@ void AdvSceneSwitcher::RemoveMacroElseAction(int idx)
|
|||||||
SetMacroAbortWait(true);
|
SetMacroAbortWait(true);
|
||||||
GetMacroWaitCV().notify_all();
|
GetMacroWaitCV().notify_all();
|
||||||
macro->UpdateElseActionIndices();
|
macro->UpdateElseActionIndices();
|
||||||
SetElseActionData(*macro);
|
SetActionData(*macro);
|
||||||
}
|
}
|
||||||
MacroElseActionSelectionChanged(-1);
|
MacroElseActionSelectionChanged(-1);
|
||||||
lastInteracted = MacroSection::ELSE_ACTIONS;
|
lastInteracted = MacroSection::ELSE_ACTIONS;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "macro-action-macro.hpp"
|
#include "macro-action-macro.hpp"
|
||||||
#include "help-icon.hpp"
|
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
#include "macro.hpp"
|
#include "macro.hpp"
|
||||||
|
|
||||||
@@ -49,7 +48,9 @@ bool MacroActionMacro::PerformAction()
|
|||||||
macro->ResetRunCount();
|
macro->ResetRunCount();
|
||||||
break;
|
break;
|
||||||
case Action::RUN:
|
case Action::RUN:
|
||||||
RunActions(macro.get());
|
if (!macro->Paused()) {
|
||||||
|
macro->PerformActions(true, false, true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Action::STOP:
|
case Action::STOP:
|
||||||
macro->Stop();
|
macro->Stop();
|
||||||
@@ -126,7 +127,6 @@ bool MacroActionMacro::Save(obs_data_t *obj) const
|
|||||||
_macro.Save(obj);
|
_macro.Save(obj);
|
||||||
_actionIndex.Save(obj, "actionIndex");
|
_actionIndex.Save(obj, "actionIndex");
|
||||||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||||
_runOptions.Save(obj);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,15 +137,6 @@ bool MacroActionMacro::Load(obs_data_t *obj)
|
|||||||
_actionIndex.Load(obj, "actionIndex");
|
_actionIndex.Load(obj, "actionIndex");
|
||||||
_action = static_cast<MacroActionMacro::Action>(
|
_action = static_cast<MacroActionMacro::Action>(
|
||||||
obs_data_get_int(obj, "action"));
|
obs_data_get_int(obj, "action"));
|
||||||
_runOptions.Load(obj);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroActionMacro::PostLoad()
|
|
||||||
{
|
|
||||||
MacroRefAction::PostLoad();
|
|
||||||
MacroAction::PostLoad();
|
|
||||||
_runOptions.macro.PostLoad();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,68 +160,11 @@ void MacroActionMacro::ResolveVariablesToFixedValues()
|
|||||||
_actionIndex.ResolveVariables();
|
_actionIndex.ResolveVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runActionsHelper(Macro *macro, bool runElseActions, bool setInputs,
|
static inline void populateActionSelection(QComboBox *list)
|
||||||
const StringList &inputs)
|
|
||||||
{
|
{
|
||||||
if (setInputs) {
|
for (auto entry : actionTypes) {
|
||||||
macro->GetInputVariables().SetValues(inputs);
|
list->addItem(obs_module_text(entry.second.c_str()));
|
||||||
}
|
}
|
||||||
macro->PerformActions(!runElseActions, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacro::RunActions(Macro *actionMacro) const
|
|
||||||
{
|
|
||||||
if (_runOptions.skipWhenPaused && actionMacro->Paused()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_runOptions.logic == RunOptions::Logic::IGNORE_CONDITIONS) {
|
|
||||||
runActionsHelper(actionMacro, _runOptions.runElseActions,
|
|
||||||
_runOptions.setInputs, _runOptions.inputs);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto conditionMacro = _runOptions.macro.GetMacro();
|
|
||||||
if (!conditionMacro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_runOptions.reevaluateConditionState) {
|
|
||||||
conditionMacro->CeckMatch(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((_runOptions.logic == RunOptions::Logic::CONDITIONS &&
|
|
||||||
conditionMacro->Matched()) ||
|
|
||||||
(_runOptions.logic == RunOptions::Logic::INVERT_CONDITIONS &&
|
|
||||||
!conditionMacro->Matched())) {
|
|
||||||
runActionsHelper(actionMacro, _runOptions.runElseActions,
|
|
||||||
_runOptions.setInputs, _runOptions.inputs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void populateActionSelection(QComboBox *list)
|
|
||||||
{
|
|
||||||
for (const auto &[_, name] : actionTypes) {
|
|
||||||
list->addItem(obs_module_text(name.c_str()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void populateConditionBehaviorSelection(QComboBox *list)
|
|
||||||
{
|
|
||||||
list->addItem(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.conditions.ignore"));
|
|
||||||
list->addItem(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.conditions.true"));
|
|
||||||
list->addItem(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.conditions.false"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void populateActionTypeSelection(QComboBox *list)
|
|
||||||
{
|
|
||||||
list->addItem(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.actionType.regular"));
|
|
||||||
list->addItem(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.actionType.else"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroActionMacroEdit::MacroActionMacroEdit(
|
MacroActionMacroEdit::MacroActionMacroEdit(
|
||||||
@@ -239,28 +173,9 @@ MacroActionMacroEdit::MacroActionMacroEdit(
|
|||||||
_macros(new MacroSelection(parent)),
|
_macros(new MacroSelection(parent)),
|
||||||
_actionIndex(new MacroSegmentSelection(
|
_actionIndex(new MacroSegmentSelection(
|
||||||
this, MacroSegmentSelection::Type::ACTION)),
|
this, MacroSegmentSelection::Type::ACTION)),
|
||||||
_actions(new QComboBox()),
|
_actions(new QComboBox())
|
||||||
_conditionMacros(new MacroSelection(parent)),
|
|
||||||
_conditionBehaviors(new QComboBox()),
|
|
||||||
_reevaluateConditionState(new QCheckBox(
|
|
||||||
obs_module_text("AdvSceneSwitcher.action.macro.type.run."
|
|
||||||
"updateConditionMatchState"))),
|
|
||||||
_actionTypes(new QComboBox()),
|
|
||||||
_skipWhenPaused(new QCheckBox(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.skipWhenPaused"))),
|
|
||||||
_setInputs(new QCheckBox(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.setInputs"))),
|
|
||||||
_inputs(new MacroInputEdit()),
|
|
||||||
_entryLayout(new QHBoxLayout()),
|
|
||||||
_conditionLayout(new QHBoxLayout()),
|
|
||||||
_reevaluateConditionStateLayout(new QHBoxLayout()),
|
|
||||||
_setInputsLayout(new QHBoxLayout())
|
|
||||||
{
|
{
|
||||||
populateActionSelection(_actions);
|
populateActionSelection(_actions);
|
||||||
populateConditionBehaviorSelection(_conditionBehaviors);
|
|
||||||
populateActionTypeSelection(_actionTypes);
|
|
||||||
|
|
||||||
_conditionMacros->HideSelectedMacro();
|
|
||||||
|
|
||||||
QWidget::connect(_macros, SIGNAL(currentTextChanged(const QString &)),
|
QWidget::connect(_macros, SIGNAL(currentTextChanged(const QString &)),
|
||||||
this, SLOT(MacroChanged(const QString &)));
|
this, SLOT(MacroChanged(const QString &)));
|
||||||
@@ -269,53 +184,20 @@ MacroActionMacroEdit::MacroActionMacroEdit(
|
|||||||
QWidget::connect(_actionIndex,
|
QWidget::connect(_actionIndex,
|
||||||
SIGNAL(SelectionChanged(const IntVariable &)), this,
|
SIGNAL(SelectionChanged(const IntVariable &)), this,
|
||||||
SLOT(ActionIndexChanged(const IntVariable &)));
|
SLOT(ActionIndexChanged(const IntVariable &)));
|
||||||
QWidget::connect(_conditionMacros,
|
|
||||||
SIGNAL(currentTextChanged(const QString &)), this,
|
|
||||||
SLOT(ConditionMacroChanged(const QString &)));
|
|
||||||
QWidget::connect(_conditionBehaviors, SIGNAL(currentIndexChanged(int)),
|
|
||||||
this, SLOT(ConditionBehaviorChanged(int)));
|
|
||||||
QWidget::connect(_actionTypes, SIGNAL(currentIndexChanged(int)), this,
|
|
||||||
SLOT(ActionTypeChanged(int)));
|
|
||||||
QWidget::connect(_skipWhenPaused, SIGNAL(stateChanged(int)), this,
|
|
||||||
SLOT(SkipWhenPausedChanged(int)));
|
|
||||||
QWidget::connect(_setInputs, SIGNAL(stateChanged(int)), this,
|
|
||||||
SLOT(SetInputsChanged(int)));
|
|
||||||
QWidget::connect(_inputs,
|
|
||||||
SIGNAL(MacroInputValuesChanged(const StringList &)),
|
|
||||||
this, SLOT(InputsChanged(const StringList &)));
|
|
||||||
QWidget::connect(_reevaluateConditionState, SIGNAL(stateChanged(int)),
|
|
||||||
this, SLOT(ReevaluateConditionStateChanged(int)));
|
|
||||||
|
|
||||||
_setInputsLayout->addWidget(_setInputs);
|
auto mainLayout = new QHBoxLayout;
|
||||||
_setInputsLayout->addWidget(new HelpIcon(obs_module_text(
|
PlaceWidgets(obs_module_text("AdvSceneSwitcher.action.macro.entry"),
|
||||||
"AdvSceneSwitcher.action.macro.type.run.setInputs.description")));
|
mainLayout,
|
||||||
_setInputsLayout->addStretch();
|
{{"{{actions}}", _actions},
|
||||||
|
{"{{actionIndex}}", _actionIndex},
|
||||||
|
{"{{macros}}", _macros}});
|
||||||
|
setLayout(mainLayout);
|
||||||
|
|
||||||
_reevaluateConditionStateLayout->addWidget(_reevaluateConditionState);
|
|
||||||
_reevaluateConditionStateLayout->addWidget(new HelpIcon(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState.help")));
|
|
||||||
_reevaluateConditionStateLayout->addStretch();
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout();
|
|
||||||
layout->addLayout(_entryLayout);
|
|
||||||
layout->addLayout(_conditionLayout);
|
|
||||||
layout->addLayout(_reevaluateConditionStateLayout);
|
|
||||||
layout->addLayout(_setInputsLayout);
|
|
||||||
layout->addWidget(_inputs);
|
|
||||||
layout->addWidget(_skipWhenPaused);
|
|
||||||
setLayout(layout);
|
|
||||||
_entryData = entryData;
|
_entryData = entryData;
|
||||||
UpdateEntryData();
|
UpdateEntryData();
|
||||||
_loading = false;
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighligthMacroSettingsButton(bool enable);
|
|
||||||
|
|
||||||
MacroActionMacroEdit::~MacroActionMacroEdit()
|
|
||||||
{
|
|
||||||
HighligthMacroSettingsButton(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::UpdateEntryData()
|
void MacroActionMacroEdit::UpdateEntryData()
|
||||||
{
|
{
|
||||||
if (!_entryData) {
|
if (!_entryData) {
|
||||||
@@ -325,132 +207,45 @@ void MacroActionMacroEdit::UpdateEntryData()
|
|||||||
_actionIndex->SetValue(_entryData->_actionIndex);
|
_actionIndex->SetValue(_entryData->_actionIndex);
|
||||||
_actionIndex->SetMacro(_entryData->_macro.GetMacro());
|
_actionIndex->SetMacro(_entryData->_macro.GetMacro());
|
||||||
_macros->SetCurrentMacro(_entryData->_macro);
|
_macros->SetCurrentMacro(_entryData->_macro);
|
||||||
_conditionMacros->SetCurrentMacro(_entryData->_runOptions.macro);
|
|
||||||
_conditionBehaviors->setCurrentIndex(
|
|
||||||
static_cast<int>(_entryData->_runOptions.logic));
|
|
||||||
_reevaluateConditionState->setChecked(
|
|
||||||
_entryData->_runOptions.reevaluateConditionState);
|
|
||||||
_actionTypes->setCurrentIndex(
|
|
||||||
_entryData->_runOptions.runElseActions ? 1 : 0);
|
|
||||||
_skipWhenPaused->setChecked(_entryData->_runOptions.skipWhenPaused);
|
|
||||||
_setInputs->setChecked(_entryData->_runOptions.setInputs);
|
|
||||||
SetupMacroInput(_entryData->_macro.GetMacro().get());
|
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionMacroEdit::MacroChanged(const QString &text)
|
void MacroActionMacroEdit::MacroChanged(const QString &text)
|
||||||
{
|
{
|
||||||
GUARD_LOADING_AND_LOCK();
|
if (_loading || !_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lock = LockContext();
|
||||||
_entryData->_macro = text;
|
_entryData->_macro = text;
|
||||||
const auto ¯o = _entryData->_macro.GetMacro();
|
_actionIndex->SetMacro(_entryData->_macro.GetMacro());
|
||||||
_actionIndex->SetMacro(macro);
|
|
||||||
SetupMacroInput(macro.get());
|
|
||||||
emit HeaderInfoChanged(
|
emit HeaderInfoChanged(
|
||||||
QString::fromStdString(_entryData->GetShortDesc()));
|
QString::fromStdString(_entryData->GetShortDesc()));
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionMacroEdit::ActionChanged(int value)
|
void MacroActionMacroEdit::ActionChanged(int value)
|
||||||
{
|
{
|
||||||
GUARD_LOADING_AND_LOCK();
|
if (_loading || !_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lock = LockContext();
|
||||||
_entryData->_action = static_cast<MacroActionMacro::Action>(value);
|
_entryData->_action = static_cast<MacroActionMacro::Action>(value);
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionMacroEdit::ActionIndexChanged(const IntVariable &value)
|
void MacroActionMacroEdit::ActionIndexChanged(const IntVariable &value)
|
||||||
{
|
{
|
||||||
GUARD_LOADING_AND_LOCK();
|
if (_loading || !_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lock = LockContext();
|
||||||
_entryData->_actionIndex = value;
|
_entryData->_actionIndex = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionMacroEdit::ConditionMacroChanged(const QString &text)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.macro = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::ConditionBehaviorChanged(int value)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.logic =
|
|
||||||
static_cast<MacroActionMacro::RunOptions::Logic>(value);
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::ReevaluateConditionStateChanged(int value)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.reevaluateConditionState = value;
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::ActionTypeChanged(int value)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.runElseActions = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::SkipWhenPausedChanged(int value)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.skipWhenPaused = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::SetInputsChanged(int value)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.setInputs = value;
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::InputsChanged(const StringList &inputs)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_runOptions.inputs = inputs;
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::SetWidgetVisibility()
|
void MacroActionMacroEdit::SetWidgetVisibility()
|
||||||
{
|
{
|
||||||
_entryLayout->removeWidget(_actions);
|
|
||||||
_entryLayout->removeWidget(_actionIndex);
|
|
||||||
_entryLayout->removeWidget(_macros);
|
|
||||||
_entryLayout->removeWidget(_actionTypes);
|
|
||||||
_conditionLayout->removeWidget(_conditionBehaviors);
|
|
||||||
_conditionLayout->removeWidget(_conditionMacros);
|
|
||||||
|
|
||||||
ClearLayout(_entryLayout);
|
|
||||||
ClearLayout(_conditionLayout);
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, QWidget *> placeholders = {
|
|
||||||
{"{{actions}}", _actions},
|
|
||||||
{"{{actionIndex}}", _actionIndex},
|
|
||||||
{"{{macros}}", _macros},
|
|
||||||
{"{{actionTypes}}", _actionTypes},
|
|
||||||
{"{{conditionBehaviors}}", _conditionBehaviors},
|
|
||||||
{"{{conditionMacros}}", _conditionMacros},
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
PlaceWidgets(
|
|
||||||
obs_module_text(
|
|
||||||
_entryData->_action == MacroActionMacro::Action::RUN
|
|
||||||
? "AdvSceneSwitcher.action.macro.entry.run"
|
|
||||||
: "AdvSceneSwitcher.action.macro.entry.other"),
|
|
||||||
_entryLayout, placeholders);
|
|
||||||
|
|
||||||
if (_entryData->_runOptions.logic ==
|
|
||||||
MacroActionMacro::RunOptions::Logic::IGNORE_CONDITIONS) {
|
|
||||||
_conditionLayout->addWidget(_conditionBehaviors);
|
|
||||||
_conditionLayout->addStretch();
|
|
||||||
} else {
|
|
||||||
PlaceWidgets(
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.macro.entry.run.condition"),
|
|
||||||
_conditionLayout, placeholders);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_entryData->_action == MacroActionMacro::Action::RUN ||
|
if (_entryData->_action == MacroActionMacro::Action::RUN ||
|
||||||
_entryData->_action == MacroActionMacro::Action::STOP) {
|
_entryData->_action == MacroActionMacro::Action::STOP) {
|
||||||
_macros->HideSelectedMacro();
|
_macros->HideSelectedMacro();
|
||||||
@@ -465,73 +260,6 @@ void MacroActionMacroEdit::SetWidgetVisibility()
|
|||||||
MacroActionMacro::Action::ENABLE_ACTION ||
|
MacroActionMacro::Action::ENABLE_ACTION ||
|
||||||
_entryData->_action == MacroActionMacro::Action::TOGGLE_ACTION;
|
_entryData->_action == MacroActionMacro::Action::TOGGLE_ACTION;
|
||||||
_actionIndex->setVisible(isModifyingActionState);
|
_actionIndex->setVisible(isModifyingActionState);
|
||||||
|
|
||||||
SetLayoutVisible(_conditionLayout,
|
|
||||||
_entryData->_action == MacroActionMacro::Action::RUN);
|
|
||||||
const bool needsAdditionalConditionWidgets =
|
|
||||||
_entryData->_action == MacroActionMacro::Action::RUN &&
|
|
||||||
_entryData->_runOptions.logic !=
|
|
||||||
MacroActionMacro::RunOptions::Logic::IGNORE_CONDITIONS;
|
|
||||||
_conditionMacros->setVisible(needsAdditionalConditionWidgets);
|
|
||||||
SetLayoutVisible(_reevaluateConditionStateLayout,
|
|
||||||
needsAdditionalConditionWidgets);
|
|
||||||
SetLayoutVisible(_setInputsLayout,
|
|
||||||
_entryData->_action == MacroActionMacro::Action::RUN);
|
|
||||||
_inputs->setVisible(_entryData->_action ==
|
|
||||||
MacroActionMacro::Action::RUN &&
|
|
||||||
_entryData->_runOptions.setInputs);
|
|
||||||
HighligthMacroSettingsButton(_entryData->_action ==
|
|
||||||
MacroActionMacro::Action::RUN &&
|
|
||||||
_entryData->_runOptions.setInputs &&
|
|
||||||
!_inputs->HasInputsToSet());
|
|
||||||
_actionTypes->setVisible(_entryData->_action ==
|
|
||||||
MacroActionMacro::Action::RUN);
|
|
||||||
_skipWhenPaused->setVisible(_entryData->_action ==
|
|
||||||
MacroActionMacro::Action::RUN);
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacroEdit::SetupMacroInput(Macro *macro) const
|
|
||||||
{
|
|
||||||
if (macro) {
|
|
||||||
_inputs->SetInputVariablesAndValues(
|
|
||||||
macro->GetInputVariables(),
|
|
||||||
_entryData->_runOptions.inputs);
|
|
||||||
} else {
|
|
||||||
_inputs->SetInputVariablesAndValues({}, {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacro::RunOptions::Save(obs_data_t *obj) const
|
|
||||||
{
|
|
||||||
OBSDataAutoRelease data = obs_data_create();
|
|
||||||
obs_data_set_int(data, "logic", static_cast<int>(logic));
|
|
||||||
obs_data_set_bool(data, "reevaluateConditionState",
|
|
||||||
reevaluateConditionState);
|
|
||||||
obs_data_set_bool(data, "runElseActions", runElseActions);
|
|
||||||
obs_data_set_bool(data, "skipWhenPaused", skipWhenPaused);
|
|
||||||
obs_data_set_bool(data, "setInputs", setInputs);
|
|
||||||
inputs.Save(data, "inputs");
|
|
||||||
macro.Save(data);
|
|
||||||
obs_data_set_obj(obj, "runOptions", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionMacro::RunOptions::Load(obs_data_t *obj)
|
|
||||||
{
|
|
||||||
if (!obs_data_has_user_value(obj, "runOptions")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OBSDataAutoRelease data = obs_data_get_obj(obj, "runOptions");
|
|
||||||
logic = static_cast<Logic>(obs_data_get_int(data, "logic"));
|
|
||||||
reevaluateConditionState =
|
|
||||||
obs_data_get_bool(data, "reevaluateConditionState");
|
|
||||||
runElseActions = obs_data_get_bool(data, "runElseActions");
|
|
||||||
skipWhenPaused = obs_data_get_bool(data, "skipWhenPaused");
|
|
||||||
setInputs = obs_data_get_bool(data, "setInputs");
|
|
||||||
inputs.Load(data, "inputs");
|
|
||||||
macro.Load(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -1,45 +1,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "macro-input.hpp"
|
|
||||||
#include "macro-selection.hpp"
|
#include "macro-selection.hpp"
|
||||||
#include "macro-segment-selection.hpp"
|
#include "macro-segment-selection.hpp"
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
class MacroActionMacro final : public MacroRefAction {
|
class MacroActionMacro : public MacroRefAction {
|
||||||
public:
|
public:
|
||||||
MacroActionMacro(Macro *m) : MacroAction(m), MacroRefAction(m) {}
|
MacroActionMacro(Macro *m) : MacroAction(m), MacroRefAction(m) {}
|
||||||
bool PerformAction();
|
bool PerformAction();
|
||||||
void LogAction() const;
|
void LogAction() const;
|
||||||
bool Save(obs_data_t *obj) const;
|
bool Save(obs_data_t *obj) const;
|
||||||
bool Load(obs_data_t *obj);
|
bool Load(obs_data_t *obj);
|
||||||
bool PostLoad();
|
|
||||||
std::string GetShortDesc() const;
|
std::string GetShortDesc() const;
|
||||||
std::string GetId() const { return id; };
|
std::string GetId() const { return id; };
|
||||||
static std::shared_ptr<MacroAction> Create(Macro *m);
|
static std::shared_ptr<MacroAction> Create(Macro *m);
|
||||||
std::shared_ptr<MacroAction> Copy() const;
|
std::shared_ptr<MacroAction> Copy() const;
|
||||||
void ResolveVariablesToFixedValues();
|
void ResolveVariablesToFixedValues();
|
||||||
|
|
||||||
struct RunOptions {
|
|
||||||
void Save(obs_data_t *obj) const;
|
|
||||||
void Load(obs_data_t *obj);
|
|
||||||
enum class Logic {
|
|
||||||
IGNORE_CONDITIONS,
|
|
||||||
CONDITIONS,
|
|
||||||
INVERT_CONDITIONS,
|
|
||||||
};
|
|
||||||
Logic logic;
|
|
||||||
bool reevaluateConditionState = false;
|
|
||||||
bool runElseActions = false;
|
|
||||||
bool skipWhenPaused = true;
|
|
||||||
bool setInputs = false;
|
|
||||||
StringList inputs;
|
|
||||||
MacroRef macro;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class Action {
|
enum class Action {
|
||||||
PAUSE,
|
PAUSE,
|
||||||
UNPAUSE,
|
UNPAUSE,
|
||||||
@@ -50,25 +30,21 @@ public:
|
|||||||
ENABLE_ACTION,
|
ENABLE_ACTION,
|
||||||
TOGGLE_ACTION,
|
TOGGLE_ACTION,
|
||||||
};
|
};
|
||||||
Action _action = Action::RUN;
|
Action _action = Action::PAUSE;
|
||||||
IntVariable _actionIndex = 1;
|
IntVariable _actionIndex = 1;
|
||||||
RunOptions _runOptions = {};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RunActions(Macro *actionMacro) const;
|
|
||||||
|
|
||||||
static bool _registered;
|
static bool _registered;
|
||||||
static const std::string id;
|
static const std::string id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MacroActionMacroEdit final : public QWidget {
|
class MacroActionMacroEdit : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacroActionMacroEdit(
|
MacroActionMacroEdit(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
std::shared_ptr<MacroActionMacro> entryData = nullptr);
|
std::shared_ptr<MacroActionMacro> entryData = nullptr);
|
||||||
~MacroActionMacroEdit();
|
|
||||||
void UpdateEntryData();
|
void UpdateEntryData();
|
||||||
static QWidget *Create(QWidget *parent,
|
static QWidget *Create(QWidget *parent,
|
||||||
std::shared_ptr<MacroAction> action)
|
std::shared_ptr<MacroAction> action)
|
||||||
@@ -82,37 +58,18 @@ private slots:
|
|||||||
void MacroChanged(const QString &text);
|
void MacroChanged(const QString &text);
|
||||||
void ActionChanged(int value);
|
void ActionChanged(int value);
|
||||||
void ActionIndexChanged(const IntVariable &value);
|
void ActionIndexChanged(const IntVariable &value);
|
||||||
void ConditionMacroChanged(const QString &text);
|
|
||||||
void ConditionBehaviorChanged(int value);
|
|
||||||
void ReevaluateConditionStateChanged(int value);
|
|
||||||
void ActionTypeChanged(int value);
|
|
||||||
void SkipWhenPausedChanged(int value);
|
|
||||||
void SetInputsChanged(int value);
|
|
||||||
void InputsChanged(const StringList &);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void SetWidgetVisibility();
|
|
||||||
void SetupMacroInput(Macro *) const;
|
|
||||||
|
|
||||||
MacroSelection *_macros;
|
MacroSelection *_macros;
|
||||||
MacroSegmentSelection *_actionIndex;
|
MacroSegmentSelection *_actionIndex;
|
||||||
QComboBox *_actions;
|
QComboBox *_actions;
|
||||||
MacroSelection *_conditionMacros;
|
|
||||||
QComboBox *_conditionBehaviors;
|
|
||||||
QCheckBox *_reevaluateConditionState;
|
|
||||||
QComboBox *_actionTypes;
|
|
||||||
QCheckBox *_skipWhenPaused;
|
|
||||||
QCheckBox *_setInputs;
|
|
||||||
MacroInputEdit *_inputs;
|
|
||||||
QHBoxLayout *_entryLayout;
|
|
||||||
QHBoxLayout *_conditionLayout;
|
|
||||||
QHBoxLayout *_reevaluateConditionStateLayout;
|
|
||||||
QHBoxLayout *_setInputsLayout;
|
|
||||||
|
|
||||||
std::shared_ptr<MacroActionMacro> _entryData;
|
std::shared_ptr<MacroActionMacro> _entryData;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetWidgetVisibility();
|
||||||
|
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ const static std::map<MacroActionVariable::Type, std::string> actionTypes = {
|
|||||||
"AdvSceneSwitcher.action.variable.type.padValue"},
|
"AdvSceneSwitcher.action.variable.type.padValue"},
|
||||||
{MacroActionVariable::Type::TRUNCATE,
|
{MacroActionVariable::Type::TRUNCATE,
|
||||||
"AdvSceneSwitcher.action.variable.type.truncateValue"},
|
"AdvSceneSwitcher.action.variable.type.truncateValue"},
|
||||||
{MacroActionVariable::Type::SWAP_VALUES,
|
|
||||||
"AdvSceneSwitcher.action.variable.type.swapValues"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void apppend(Variable &var, const std::string &value)
|
static void apppend(Variable &var, const std::string &value)
|
||||||
@@ -394,17 +392,6 @@ bool MacroActionVariable::PerformAction()
|
|||||||
var->SetValue(
|
var->SetValue(
|
||||||
truncate(var->Value(), _direction, _stringLength));
|
truncate(var->Value(), _direction, _stringLength));
|
||||||
return true;
|
return true;
|
||||||
case Type::SWAP_VALUES: {
|
|
||||||
auto var2 = _variable2.lock();
|
|
||||||
if (!var2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tempValue = var->Value();
|
|
||||||
var->SetValue(var2->Value());
|
|
||||||
var2->SetValue(tempValue);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -643,8 +630,6 @@ MacroActionVariableEdit::MacroActionVariableEdit(
|
|||||||
_scenes(new SceneSelectionWidget(this, true, false, true, true,
|
_scenes(new SceneSelectionWidget(this, true, false, true, true,
|
||||||
true)),
|
true)),
|
||||||
_tempVars(new TempVariableSelection(this)),
|
_tempVars(new TempVariableSelection(this)),
|
||||||
_tempVarsHelp(new HelpIcon(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.variable.type.setToTempvar.help"))),
|
|
||||||
_sceneItemIndex(new VariableSpinBox()),
|
_sceneItemIndex(new VariableSpinBox()),
|
||||||
_direction(new QComboBox()),
|
_direction(new QComboBox()),
|
||||||
_stringLength(new VariableSpinBox()),
|
_stringLength(new VariableSpinBox()),
|
||||||
@@ -757,7 +742,6 @@ MacroActionVariableEdit::MacroActionVariableEdit(
|
|||||||
{"{{envVariableName}}", _envVariable},
|
{"{{envVariableName}}", _envVariable},
|
||||||
{"{{scenes}}", _scenes},
|
{"{{scenes}}", _scenes},
|
||||||
{"{{tempVars}}", _tempVars},
|
{"{{tempVars}}", _tempVars},
|
||||||
{"{{tempVarsHelp}}", _tempVarsHelp},
|
|
||||||
{"{{sceneItemIndex}}", _sceneItemIndex},
|
{"{{sceneItemIndex}}", _sceneItemIndex},
|
||||||
{"{{direction}}", _direction},
|
{"{{direction}}", _direction},
|
||||||
{"{{stringLength}}", _stringLength},
|
{"{{stringLength}}", _stringLength},
|
||||||
@@ -1218,7 +1202,6 @@ void MacroActionVariableEdit::SelectionChanged(const TempVariableRef &var)
|
|||||||
|
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
_entryData->_tempVar = var;
|
_entryData->_tempVar = var;
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionVariableEdit::SceneItemIndexChanged(
|
void MacroActionVariableEdit::SceneItemIndexChanged(
|
||||||
@@ -1285,7 +1268,6 @@ void MacroActionVariableEdit::SetWidgetVisibility()
|
|||||||
{"{{envVariableName}}", _envVariable},
|
{"{{envVariableName}}", _envVariable},
|
||||||
{"{{scenes}}", _scenes},
|
{"{{scenes}}", _scenes},
|
||||||
{"{{tempVars}}", _tempVars},
|
{"{{tempVars}}", _tempVars},
|
||||||
{"{{tempVarsHelp}}", _tempVarsHelp},
|
|
||||||
{"{{sceneItemIndex}}", _sceneItemIndex},
|
{"{{sceneItemIndex}}", _sceneItemIndex},
|
||||||
{"{{direction}}", _direction},
|
{"{{direction}}", _direction},
|
||||||
{"{{stringLength}}", _stringLength},
|
{"{{stringLength}}", _stringLength},
|
||||||
@@ -1322,9 +1304,8 @@ void MacroActionVariableEdit::SetWidgetVisibility()
|
|||||||
AddStretchIfNecessary(_entryLayout);
|
AddStretchIfNecessary(_entryLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
_variables2->setVisible(
|
_variables2->setVisible(_entryData->_type ==
|
||||||
_entryData->_type == MacroActionVariable::Type::APPEND_VAR ||
|
MacroActionVariable::Type::APPEND_VAR);
|
||||||
_entryData->_type == MacroActionVariable::Type::SWAP_VALUES);
|
|
||||||
_strValue->setVisible(
|
_strValue->setVisible(
|
||||||
_entryData->_type ==
|
_entryData->_type ==
|
||||||
MacroActionVariable::Type::SET_FIXED_VALUE ||
|
MacroActionVariable::Type::SET_FIXED_VALUE ||
|
||||||
@@ -1400,10 +1381,6 @@ void MacroActionVariableEdit::SetWidgetVisibility()
|
|||||||
MacroActionVariable::Type::SCENE_ITEM_NAME);
|
MacroActionVariable::Type::SCENE_ITEM_NAME);
|
||||||
_tempVars->setVisible(_entryData->_type ==
|
_tempVars->setVisible(_entryData->_type ==
|
||||||
MacroActionVariable::Type::SET_TO_TEMPVAR);
|
MacroActionVariable::Type::SET_TO_TEMPVAR);
|
||||||
_tempVarsHelp->setVisible(
|
|
||||||
_entryData->_type ==
|
|
||||||
MacroActionVariable::Type::SET_TO_TEMPVAR &&
|
|
||||||
!_entryData->_tempVar.HasValidID());
|
|
||||||
_sceneItemIndex->setVisible(_entryData->_type ==
|
_sceneItemIndex->setVisible(_entryData->_type ==
|
||||||
MacroActionVariable::Type::SCENE_ITEM_NAME);
|
MacroActionVariable::Type::SCENE_ITEM_NAME);
|
||||||
_direction->setVisible(
|
_direction->setVisible(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "help-icon.hpp"
|
|
||||||
#include "macro-segment-selection.hpp"
|
#include "macro-segment-selection.hpp"
|
||||||
#include "regex-config.hpp"
|
#include "regex-config.hpp"
|
||||||
#include "resizing-text-edit.hpp"
|
#include "resizing-text-edit.hpp"
|
||||||
@@ -49,7 +48,6 @@ public:
|
|||||||
SCENE_ITEM_NAME,
|
SCENE_ITEM_NAME,
|
||||||
PAD,
|
PAD,
|
||||||
TRUNCATE,
|
TRUNCATE,
|
||||||
SWAP_VALUES,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Type _type = Type::SET_FIXED_VALUE;
|
Type _type = Type::SET_FIXED_VALUE;
|
||||||
@@ -187,7 +185,6 @@ private:
|
|||||||
VariableLineEdit *_envVariable;
|
VariableLineEdit *_envVariable;
|
||||||
SceneSelectionWidget *_scenes;
|
SceneSelectionWidget *_scenes;
|
||||||
TempVariableSelection *_tempVars;
|
TempVariableSelection *_tempVars;
|
||||||
HelpIcon *_tempVarsHelp;
|
|
||||||
VariableSpinBox *_sceneItemIndex;
|
VariableSpinBox *_sceneItemIndex;
|
||||||
QComboBox *_direction;
|
QComboBox *_direction;
|
||||||
VariableSpinBox *_stringLength;
|
VariableSpinBox *_stringLength;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "macro-condition-edit.hpp"
|
#include "macro-condition-edit.hpp"
|
||||||
#include "advanced-scene-switcher.hpp"
|
#include "advanced-scene-switcher.hpp"
|
||||||
#include "macro-settings.hpp"
|
#include "macro-properties.hpp"
|
||||||
#include "macro.hpp"
|
#include "macro.hpp"
|
||||||
#include "path-helpers.hpp"
|
#include "path-helpers.hpp"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
@@ -121,7 +121,8 @@ void DurationModifierEdit::Collapse(bool collapse)
|
|||||||
MacroConditionEdit::MacroConditionEdit(
|
MacroConditionEdit::MacroConditionEdit(
|
||||||
QWidget *parent, std::shared_ptr<MacroCondition> *entryData,
|
QWidget *parent, std::shared_ptr<MacroCondition> *entryData,
|
||||||
const std::string &id, bool root)
|
const std::string &id, bool root)
|
||||||
: MacroSegmentEdit(parent),
|
: MacroSegmentEdit(GetGlobalMacroProperties()._highlightConditions,
|
||||||
|
parent),
|
||||||
_logicSelection(new QComboBox()),
|
_logicSelection(new QComboBox()),
|
||||||
_conditionSelection(new FilterComboBox()),
|
_conditionSelection(new FilterComboBox()),
|
||||||
_dur(new DurationModifierEdit()),
|
_dur(new DurationModifierEdit()),
|
||||||
@@ -138,6 +139,8 @@ MacroConditionEdit::MacroConditionEdit(
|
|||||||
QWidget::connect(_dur, SIGNAL(ModifierChanged(DurationModifier::Type)),
|
QWidget::connect(_dur, SIGNAL(ModifierChanged(DurationModifier::Type)),
|
||||||
this,
|
this,
|
||||||
SLOT(DurationModifierChanged(DurationModifier::Type)));
|
SLOT(DurationModifierChanged(DurationModifier::Type)));
|
||||||
|
QWidget::connect(window(), SIGNAL(HighlightConditionsChanged(bool)),
|
||||||
|
this, SLOT(EnableHighlight(bool)));
|
||||||
|
|
||||||
populateLogicSelection(_logicSelection, root);
|
populateLogicSelection(_logicSelection, root);
|
||||||
populateConditionSelection(_conditionSelection);
|
populateConditionSelection(_conditionSelection);
|
||||||
@@ -296,7 +299,6 @@ void AdvSceneSwitcher::AddMacroCondition(int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idx < 0 || idx > (int)macro->Conditions().size()) {
|
if (idx < 0 || idx > (int)macro->Conditions().size()) {
|
||||||
assert(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,31 +315,16 @@ void AdvSceneSwitcher::AddMacroCondition(int idx)
|
|||||||
id = MacroCondition::GetDefaultID();
|
id = MacroCondition::GetDefaultID();
|
||||||
logic = LogicType::ROOT_NONE;
|
logic = LogicType::ROOT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSDataAutoRelease data;
|
|
||||||
if (idx - 1 >= 0) {
|
|
||||||
data = obs_data_create();
|
|
||||||
macro->Conditions().at(idx - 1)->Save(data);
|
|
||||||
}
|
|
||||||
AddMacroCondition(macro.get(), idx, id, data.Get(), logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvSceneSwitcher::AddMacroCondition(Macro *macro, int idx,
|
|
||||||
const std::string &id,
|
|
||||||
obs_data_t *data, LogicType logic)
|
|
||||||
{
|
|
||||||
if (idx < 0 || idx > (int)macro->Conditions().size()) {
|
|
||||||
assert(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
auto cond = macro->Conditions().emplace(
|
auto cond = macro->Conditions().emplace(
|
||||||
macro->Conditions().begin() + idx,
|
macro->Conditions().begin() + idx,
|
||||||
MacroConditionFactory::Create(id, macro));
|
MacroConditionFactory::Create(id, macro.get()));
|
||||||
if (data) {
|
if (idx - 1 >= 0) {
|
||||||
|
auto data = obs_data_create();
|
||||||
|
macro->Conditions().at(idx - 1)->Save(data);
|
||||||
macro->Conditions().at(idx)->Load(data);
|
macro->Conditions().at(idx)->Load(data);
|
||||||
|
obs_data_release(data);
|
||||||
}
|
}
|
||||||
macro->Conditions().at(idx)->PostLoad();
|
macro->Conditions().at(idx)->PostLoad();
|
||||||
RunPostLoadSteps();
|
RunPostLoadSteps();
|
||||||
@@ -350,7 +337,6 @@ void AdvSceneSwitcher::AddMacroCondition(Macro *macro, int idx,
|
|||||||
SetConditionData(*macro);
|
SetConditionData(*macro);
|
||||||
}
|
}
|
||||||
HighlightCondition(idx);
|
HighlightCondition(idx);
|
||||||
ui->conditionsList->SetHelpMsgVisible(false);
|
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,6 +355,7 @@ void AdvSceneSwitcher::on_conditionAdd_clicked()
|
|||||||
if (currentConditionIdx != -1) {
|
if (currentConditionIdx != -1) {
|
||||||
MacroConditionSelectionChanged(currentConditionIdx + 1);
|
MacroConditionSelectionChanged(currentConditionIdx + 1);
|
||||||
}
|
}
|
||||||
|
ui->conditionsList->SetHelpMsgVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::RemoveMacroCondition(int idx)
|
void AdvSceneSwitcher::RemoveMacroCondition(int idx)
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ void MacroDock::Highlight()
|
|||||||
}
|
}
|
||||||
if (_lastHighlightCheckTime.time_since_epoch().count() != 0 &&
|
if (_lastHighlightCheckTime.time_since_epoch().count() != 0 &&
|
||||||
macro->WasExecutedSince(_lastHighlightCheckTime)) {
|
macro->WasExecutedSince(_lastHighlightCheckTime)) {
|
||||||
HighlightWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
PulseWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
||||||
}
|
}
|
||||||
_lastHighlightCheckTime = std::chrono::high_resolution_clock::now();
|
_lastHighlightCheckTime = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,247 +0,0 @@
|
|||||||
#include "macro-input.hpp"
|
|
||||||
#include "layout-helpers.hpp"
|
|
||||||
#include "log-helper.hpp"
|
|
||||||
#include "obs-module-helper.hpp"
|
|
||||||
#include "variable-line-edit.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <obs.hpp>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
void MacroInputVariables::Save(obs_data_t *obj) const
|
|
||||||
{
|
|
||||||
OBSDataArrayAutoRelease array = obs_data_array_create();
|
|
||||||
for (auto &var : _inputVariables) {
|
|
||||||
OBSDataAutoRelease arrayObj = obs_data_create();
|
|
||||||
auto variable = var.lock();
|
|
||||||
if (variable) {
|
|
||||||
obs_data_set_string(arrayObj, "variableName",
|
|
||||||
variable->Name().c_str());
|
|
||||||
} else {
|
|
||||||
obs_data_set_bool(arrayObj, "invalidVariable", true);
|
|
||||||
}
|
|
||||||
obs_data_array_push_back(array, arrayObj);
|
|
||||||
}
|
|
||||||
obs_data_set_array(obj, "inputVariables", array);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputVariables::Load(obs_data_t *obj)
|
|
||||||
{
|
|
||||||
OBSDataArrayAutoRelease array =
|
|
||||||
obs_data_get_array(obj, "inputVariables");
|
|
||||||
const size_t count = obs_data_array_count(array);
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
OBSDataAutoRelease arrayObj = obs_data_array_item(array, i);
|
|
||||||
const bool isInvalid =
|
|
||||||
obs_data_get_bool(arrayObj, "invalidVariable");
|
|
||||||
if (isInvalid) {
|
|
||||||
_inputVariables.emplace_back();
|
|
||||||
} else {
|
|
||||||
const auto name =
|
|
||||||
obs_data_get_string(arrayObj, "variableName");
|
|
||||||
_inputVariables.emplace_back(
|
|
||||||
GetWeakVariableByName(name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputVariables::SetValues(const StringList &values)
|
|
||||||
{
|
|
||||||
if (_inputVariables.size() != (size_t)values.size()) {
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
blog(LOG_WARNING,
|
|
||||||
"%s - sizes do not match (variables: %ld, values %d)",
|
|
||||||
__func__, _inputVariables.size(), values.size());
|
|
||||||
#else
|
|
||||||
blog(LOG_WARNING,
|
|
||||||
"%s - sizes do not match (variables: %ld, values %lld)",
|
|
||||||
__func__, _inputVariables.size(), values.size());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0;
|
|
||||||
index < _inputVariables.size() && index < (size_t)values.size();
|
|
||||||
index++) {
|
|
||||||
auto variable = _inputVariables.at(index).lock();
|
|
||||||
if (!variable) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
variable->SetValue(values.at(index));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MacroInputSelection::MacroInputSelection(QWidget *parent) : ListEditor(parent)
|
|
||||||
{
|
|
||||||
_list->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputSelection::SetInputs(const MacroInputVariables &inputs)
|
|
||||||
{
|
|
||||||
_currentSelection = inputs;
|
|
||||||
for (const auto &var : inputs._inputVariables) {
|
|
||||||
auto variable = var.lock();
|
|
||||||
const auto name =
|
|
||||||
variable
|
|
||||||
? QString::fromStdString(variable->Name())
|
|
||||||
: obs_module_text(
|
|
||||||
"AdvSceneSwitcher.macroTab.inputSettings.invalid");
|
|
||||||
|
|
||||||
QVariant v = QVariant::fromValue(name);
|
|
||||||
auto item = new QListWidgetItem(name, _list);
|
|
||||||
item->setData(Qt::UserRole, name);
|
|
||||||
}
|
|
||||||
UpdateListSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputSelection::Add()
|
|
||||||
{
|
|
||||||
std::string varName;
|
|
||||||
bool accepted = VariableSelectionDialog::AskForVariable(this, varName);
|
|
||||||
|
|
||||||
if (!accepted || varName.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentSelection._inputVariables.emplace_back(
|
|
||||||
GetWeakVariableByName(varName));
|
|
||||||
|
|
||||||
QVariant v = QVariant::fromValue(QString::fromStdString(varName));
|
|
||||||
auto item = new QListWidgetItem(QString::fromStdString(varName), _list);
|
|
||||||
item->setData(Qt::UserRole, QString::fromStdString(varName));
|
|
||||||
UpdateListSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputSelection::Remove()
|
|
||||||
{
|
|
||||||
auto item = _list->currentItem();
|
|
||||||
int idx = _list->currentRow();
|
|
||||||
if (!item || idx == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentSelection._inputVariables.erase(
|
|
||||||
std::next(_currentSelection._inputVariables.begin(), idx));
|
|
||||||
|
|
||||||
delete item;
|
|
||||||
UpdateListSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputSelection::Up()
|
|
||||||
{
|
|
||||||
int idx = _list->currentRow();
|
|
||||||
if (idx < 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_list->insertItem(idx - 1, _list->takeItem(idx));
|
|
||||||
_list->setCurrentRow(idx - 1);
|
|
||||||
|
|
||||||
std::iter_swap(
|
|
||||||
std::next(_currentSelection._inputVariables.begin(), idx),
|
|
||||||
std::next(_currentSelection._inputVariables.begin(), idx - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputSelection::Down()
|
|
||||||
{
|
|
||||||
int idx = _list->currentRow();
|
|
||||||
if (idx < 0 || idx >= _list->count()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_list->insertItem(idx + 1, _list->takeItem(idx));
|
|
||||||
_list->setCurrentRow(idx + 1);
|
|
||||||
|
|
||||||
std::iter_swap(
|
|
||||||
std::next(_currentSelection._inputVariables.begin(), idx + 1),
|
|
||||||
std::next(_currentSelection._inputVariables.begin(), idx));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputSelection::Clicked(QListWidgetItem *item)
|
|
||||||
{
|
|
||||||
std::string varName;
|
|
||||||
bool accepted = VariableSelectionDialog::AskForVariable(this, varName);
|
|
||||||
|
|
||||||
if (!accepted || varName.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->setText(QString::fromStdString(varName));
|
|
||||||
int idx = _list->currentRow();
|
|
||||||
|
|
||||||
_currentSelection._inputVariables.at(idx) =
|
|
||||||
GetWeakVariableByName(varName);
|
|
||||||
}
|
|
||||||
|
|
||||||
MacroInputEdit::MacroInputEdit(QWidget *parent)
|
|
||||||
: QWidget(parent),
|
|
||||||
_layout(new QGridLayout())
|
|
||||||
{
|
|
||||||
setLayout(_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroInputEdit::SetInputVariablesAndValues(
|
|
||||||
const MacroInputVariables &inputs, const StringList &values)
|
|
||||||
{
|
|
||||||
_variables = inputs;
|
|
||||||
_values = values;
|
|
||||||
if ((size_t)_values.size() < _variables._inputVariables.size()) {
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
for (int i = 0;
|
|
||||||
_variables._inputVariables.size() - (size_t)_values.size();
|
|
||||||
i++) {
|
|
||||||
_values.push_back({});
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
_values.resize(_variables._inputVariables.size());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
SetupWidgets();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroInputEdit::HasInputsToSet() const
|
|
||||||
{
|
|
||||||
return !_variables._inputVariables.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HighligthMacroSettingsButton(bool enable);
|
|
||||||
|
|
||||||
void MacroInputEdit::SetupWidgets()
|
|
||||||
{
|
|
||||||
ClearLayout(_layout);
|
|
||||||
|
|
||||||
auto &vars = _variables._inputVariables;
|
|
||||||
if (vars.empty()) {
|
|
||||||
_layout->addWidget(new QLabel(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.macroTab.inputSettings.noInputs")));
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < vars.size(); index++) {
|
|
||||||
auto variable = vars.at(index).lock();
|
|
||||||
QLabel *label = new QLabel(
|
|
||||||
variable
|
|
||||||
? QString::fromStdString(variable->Name())
|
|
||||||
: obs_module_text(
|
|
||||||
"AdvSceneSwitcher.macroTab.inputSettings.invalid"));
|
|
||||||
_layout->addWidget(label, index, 0);
|
|
||||||
auto valueEdit = new VariableLineEdit(this);
|
|
||||||
valueEdit->setEnabled(!!variable);
|
|
||||||
valueEdit->setText(_values.at(index));
|
|
||||||
connect(valueEdit, &VariableLineEdit::editingFinished,
|
|
||||||
[this, valueEdit, index]() {
|
|
||||||
_values[index] =
|
|
||||||
valueEdit->text().toStdString();
|
|
||||||
emit MacroInputValuesChanged(_values);
|
|
||||||
});
|
|
||||||
_layout->addWidget(valueEdit, index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "list-editor.hpp"
|
|
||||||
#include "string-list.hpp"
|
|
||||||
#include "variable.hpp"
|
|
||||||
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
class MacroInputVariables {
|
|
||||||
public:
|
|
||||||
void Save(obs_data_t *obj) const;
|
|
||||||
void Load(obs_data_t *obj);
|
|
||||||
void SetValues(const StringList &values);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::weak_ptr<Variable>> _inputVariables;
|
|
||||||
friend class MacroInputSelection;
|
|
||||||
friend class MacroInputEdit;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MacroInputSelection final : public ListEditor {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MacroInputSelection(QWidget *parent = nullptr);
|
|
||||||
void SetInputs(const MacroInputVariables &inputs);
|
|
||||||
MacroInputVariables GetInputs() const { return _currentSelection; }
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void Add();
|
|
||||||
void Remove();
|
|
||||||
void Up();
|
|
||||||
void Down();
|
|
||||||
void Clicked(QListWidgetItem *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
MacroInputVariables _currentSelection;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MacroInputEdit final : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MacroInputEdit(QWidget *parent = nullptr);
|
|
||||||
void SetInputVariablesAndValues(const MacroInputVariables &inputs,
|
|
||||||
const StringList &values);
|
|
||||||
bool HasInputsToSet() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void MacroInputValuesChanged(const StringList &);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SetupWidgets();
|
|
||||||
|
|
||||||
MacroInputVariables _variables;
|
|
||||||
StringList _values;
|
|
||||||
QGridLayout *_layout;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -7,16 +7,68 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
MacroList::MacroList(QWidget *parent, bool allowDuplicates, bool reorder)
|
MacroList::MacroList(QWidget *parent, bool allowDuplicates, bool reorder)
|
||||||
: ListEditor(parent, reorder),
|
: QWidget(parent),
|
||||||
_allowDuplicates(allowDuplicates)
|
_list(new QListWidget()),
|
||||||
|
_add(new QPushButton()),
|
||||||
|
_remove(new QPushButton()),
|
||||||
|
_up(new QPushButton()),
|
||||||
|
_down(new QPushButton()),
|
||||||
|
_controlsLayout(new QHBoxLayout()),
|
||||||
|
_allowDuplicates(allowDuplicates),
|
||||||
|
_reorder(reorder)
|
||||||
{
|
{
|
||||||
|
_add->setMaximumWidth(22);
|
||||||
|
_add->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("addIconSmall")));
|
||||||
|
_add->setFlat(true);
|
||||||
|
_remove->setMaximumWidth(22);
|
||||||
|
_remove->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||||
|
_remove->setFlat(true);
|
||||||
|
_up->setMaximumWidth(22);
|
||||||
|
_up->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
||||||
|
_up->setFlat(true);
|
||||||
|
_down->setMaximumWidth(22);
|
||||||
|
_down->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
||||||
|
_down->setFlat(true);
|
||||||
|
|
||||||
|
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
|
||||||
|
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
|
||||||
|
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
|
||||||
|
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
|
||||||
|
QWidget::connect(_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
||||||
|
this, SLOT(MacroItemClicked(QListWidgetItem *)));
|
||||||
QWidget::connect(window(),
|
QWidget::connect(window(),
|
||||||
SIGNAL(MacroRenamed(const QString &, const QString &)),
|
SIGNAL(MacroRenamed(const QString &, const QString &)),
|
||||||
this,
|
this,
|
||||||
SLOT(MacroRename(const QString &, const QString &)));
|
SLOT(MacroRename(const QString &, const QString &)));
|
||||||
QWidget::connect(window(), SIGNAL(MacroRemoved(const QString &)), this,
|
QWidget::connect(window(), SIGNAL(MacroRemoved(const QString &)), this,
|
||||||
SLOT(MacroRemove(const QString &)));
|
SLOT(MacroRemove(const QString &)));
|
||||||
UpdateListSize();
|
|
||||||
|
_controlsLayout->addWidget(_add);
|
||||||
|
_controlsLayout->addWidget(_remove);
|
||||||
|
if (reorder) {
|
||||||
|
QFrame *line = new QFrame();
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
_controlsLayout->addWidget(line);
|
||||||
|
}
|
||||||
|
_controlsLayout->addWidget(_up);
|
||||||
|
_controlsLayout->addWidget(_down);
|
||||||
|
_controlsLayout->addStretch();
|
||||||
|
|
||||||
|
auto mainLayout = new QVBoxLayout;
|
||||||
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
mainLayout->addWidget(_list);
|
||||||
|
mainLayout->addLayout(_controlsLayout);
|
||||||
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
_up->setVisible(reorder);
|
||||||
|
_down->setVisible(reorder);
|
||||||
|
|
||||||
|
SetMacroListSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroList::SetContent(const std::vector<MacroRef> ¯os)
|
void MacroList::SetContent(const std::vector<MacroRef> ¯os)
|
||||||
@@ -37,7 +89,7 @@ void MacroList::SetContent(const std::vector<MacroRef> ¯os)
|
|||||||
new QListWidgetItem(listEntryName, _list);
|
new QListWidgetItem(listEntryName, _list);
|
||||||
item->setData(Qt::UserRole, listEntryName);
|
item->setData(Qt::UserRole, listEntryName);
|
||||||
}
|
}
|
||||||
UpdateListSize();
|
SetMacroListSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroList::AddControl(QWidget *widget)
|
void MacroList::AddControl(QWidget *widget)
|
||||||
@@ -70,7 +122,7 @@ void MacroList::MacroRemove(const QString &name)
|
|||||||
delete _list->item(idx);
|
delete _list->item(idx);
|
||||||
idx = FindEntry(name.toStdString());
|
idx = FindEntry(name.toStdString());
|
||||||
}
|
}
|
||||||
UpdateListSize();
|
SetMacroListSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroList::Add()
|
void MacroList::Add()
|
||||||
@@ -90,7 +142,7 @@ void MacroList::Add()
|
|||||||
auto item =
|
auto item =
|
||||||
new QListWidgetItem(QString::fromStdString(macroName), _list);
|
new QListWidgetItem(QString::fromStdString(macroName), _list);
|
||||||
item->setData(Qt::UserRole, QString::fromStdString(macroName));
|
item->setData(Qt::UserRole, QString::fromStdString(macroName));
|
||||||
UpdateListSize();
|
SetMacroListSize();
|
||||||
emit Added(macroName);
|
emit Added(macroName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +154,7 @@ void MacroList::Remove()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete item;
|
delete item;
|
||||||
UpdateListSize();
|
SetMacroListSize();
|
||||||
emit Removed(idx);
|
emit Removed(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +178,7 @@ void MacroList::Down()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroList::Clicked(QListWidgetItem *item)
|
void MacroList::MacroItemClicked(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
std::string macroName;
|
std::string macroName;
|
||||||
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
|
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
|
||||||
@@ -164,4 +216,10 @@ int MacroList::FindEntry(const std::string ¯o)
|
|||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroList::SetMacroListSize()
|
||||||
|
{
|
||||||
|
SetHeightToContentHeight(_list);
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "list-editor.hpp"
|
|
||||||
#include "macro-ref.hpp"
|
#include "macro-ref.hpp"
|
||||||
|
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
class ADVSS_EXPORT MacroList final : public ListEditor {
|
class ADVSS_EXPORT MacroList : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MacroList(QWidget *parent, bool allowDuplicates, bool reorder);
|
MacroList(QWidget *parent, bool allowDuplicates, bool reorder);
|
||||||
@@ -19,7 +22,7 @@ private slots:
|
|||||||
void Remove();
|
void Remove();
|
||||||
void Up();
|
void Up();
|
||||||
void Down();
|
void Down();
|
||||||
void Clicked(QListWidgetItem *);
|
void MacroItemClicked(QListWidgetItem *);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Added(const std::string &);
|
void Added(const std::string &);
|
||||||
@@ -30,8 +33,16 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int FindEntry(const std::string ¯o);
|
int FindEntry(const std::string ¯o);
|
||||||
|
void SetMacroListSize();
|
||||||
|
|
||||||
|
QListWidget *_list;
|
||||||
|
QPushButton *_add;
|
||||||
|
QPushButton *_remove;
|
||||||
|
QPushButton *_up;
|
||||||
|
QPushButton *_down;
|
||||||
|
QHBoxLayout *_controlsLayout;
|
||||||
const bool _allowDuplicates;
|
const bool _allowDuplicates;
|
||||||
|
const bool _reorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "macro-settings.hpp"
|
#include "macro-properties.hpp"
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
#include "obs-module-helper.hpp"
|
#include "obs-module-helper.hpp"
|
||||||
#include "macro.hpp"
|
#include "macro.hpp"
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
static GlobalMacroSettings macroSettings;
|
static MacroProperties macroProperties;
|
||||||
|
|
||||||
void GlobalMacroSettings::Save(obs_data_t *obj) const
|
void MacroProperties::Save(obs_data_t *obj) const
|
||||||
{
|
{
|
||||||
auto data = obs_data_create();
|
auto data = obs_data_create();
|
||||||
obs_data_set_bool(data, "highlightExecuted", _highlightExecuted);
|
obs_data_set_bool(data, "highlightExecuted", _highlightExecuted);
|
||||||
@@ -20,16 +20,13 @@ void GlobalMacroSettings::Save(obs_data_t *obj) const
|
|||||||
obs_data_set_bool(data, "highlightActions", _highlightActions);
|
obs_data_set_bool(data, "highlightActions", _highlightActions);
|
||||||
obs_data_set_bool(data, "newMacroRegisterHotkey",
|
obs_data_set_bool(data, "newMacroRegisterHotkey",
|
||||||
_newMacroRegisterHotkeys);
|
_newMacroRegisterHotkeys);
|
||||||
obs_data_set_obj(obj, "macroSettings", data);
|
obs_data_set_obj(obj, "macroProperties", data);
|
||||||
obs_data_release(data);
|
obs_data_release(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalMacroSettings::Load(obs_data_t *obj)
|
void MacroProperties::Load(obs_data_t *obj)
|
||||||
{
|
{
|
||||||
auto data = obs_data_get_obj(
|
auto data = obs_data_get_obj(obj, "macroProperties");
|
||||||
obj, obs_data_has_user_value(obj, "macroProperties")
|
|
||||||
? "macroProperties"
|
|
||||||
: "macroSettings");
|
|
||||||
obs_data_set_default_bool(data, "highlightExecuted", true);
|
obs_data_set_default_bool(data, "highlightExecuted", true);
|
||||||
obs_data_set_default_bool(data, "highlightConditions", true);
|
obs_data_set_default_bool(data, "highlightConditions", true);
|
||||||
obs_data_set_default_bool(data, "highlightActions", true);
|
obs_data_set_default_bool(data, "highlightActions", true);
|
||||||
@@ -41,9 +38,9 @@ void GlobalMacroSettings::Load(obs_data_t *obj)
|
|||||||
obs_data_release(data);
|
obs_data_release(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
||||||
const GlobalMacroSettings &settings,
|
const MacroProperties &prop,
|
||||||
Macro *macro)
|
Macro *macro)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
_executed(new QCheckBox(obs_module_text(
|
_executed(new QCheckBox(obs_module_text(
|
||||||
"AdvSceneSwitcher.macroTab.highlightExecutedMacros"))),
|
"AdvSceneSwitcher.macroTab.highlightExecutedMacros"))),
|
||||||
@@ -59,7 +56,6 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
"AdvSceneSwitcher.macroTab.currentSkipExecutionOnStartup"))),
|
"AdvSceneSwitcher.macroTab.currentSkipExecutionOnStartup"))),
|
||||||
_currentStopActionsIfNotDone(new QCheckBox(obs_module_text(
|
_currentStopActionsIfNotDone(new QCheckBox(obs_module_text(
|
||||||
"AdvSceneSwitcher.macroTab.currentStopActionsIfNotDone"))),
|
"AdvSceneSwitcher.macroTab.currentStopActionsIfNotDone"))),
|
||||||
_currentInputs(new MacroInputSelection()),
|
|
||||||
_currentMacroRegisterDock(new QCheckBox(obs_module_text(
|
_currentMacroRegisterDock(new QCheckBox(obs_module_text(
|
||||||
"AdvSceneSwitcher.macroTab.currentRegisterDock"))),
|
"AdvSceneSwitcher.macroTab.currentRegisterDock"))),
|
||||||
_currentMacroDockAddRunButton(new QCheckBox(obs_module_text(
|
_currentMacroDockAddRunButton(new QCheckBox(obs_module_text(
|
||||||
@@ -105,16 +101,6 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
generalLayout->addWidget(_currentStopActionsIfNotDone);
|
generalLayout->addWidget(_currentStopActionsIfNotDone);
|
||||||
generalOptions->setLayout(generalLayout);
|
generalOptions->setLayout(generalLayout);
|
||||||
|
|
||||||
auto inputOptions = new QGroupBox(
|
|
||||||
obs_module_text("AdvSceneSwitcher.macroTab.inputSettings"));
|
|
||||||
auto description = new QLabel(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.macroTab.inputSettings.description"));
|
|
||||||
description->setWordWrap(true);
|
|
||||||
auto inputLayout = new QVBoxLayout();
|
|
||||||
inputLayout->addWidget(description);
|
|
||||||
inputLayout->addWidget(_currentInputs);
|
|
||||||
inputOptions->setLayout(inputLayout);
|
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
_dockLayout->addWidget(_currentMacroRegisterDock, row, 1, 1, 2);
|
_dockLayout->addWidget(_currentMacroRegisterDock, row, 1, 1, 2);
|
||||||
row++;
|
row++;
|
||||||
@@ -171,13 +157,13 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
connect(_currentMacroRegisterDock, &QCheckBox::stateChanged, this,
|
connect(_currentMacroRegisterDock, &QCheckBox::stateChanged, this,
|
||||||
&MacroSettingsDialog::DockEnableChanged);
|
&MacroPropertiesDialog::DockEnableChanged);
|
||||||
connect(_currentMacroDockAddRunButton, &QCheckBox::stateChanged, this,
|
connect(_currentMacroDockAddRunButton, &QCheckBox::stateChanged, this,
|
||||||
&MacroSettingsDialog::RunButtonEnableChanged);
|
&MacroPropertiesDialog::RunButtonEnableChanged);
|
||||||
connect(_currentMacroDockAddPauseButton, &QCheckBox::stateChanged, this,
|
connect(_currentMacroDockAddPauseButton, &QCheckBox::stateChanged, this,
|
||||||
&MacroSettingsDialog::PauseButtonEnableChanged);
|
&MacroPropertiesDialog::PauseButtonEnableChanged);
|
||||||
connect(_currentMacroDockAddStatusLabel, &QCheckBox::stateChanged, this,
|
connect(_currentMacroDockAddStatusLabel, &QCheckBox::stateChanged, this,
|
||||||
&MacroSettingsDialog::StatusLabelEnableChanged);
|
&MacroPropertiesDialog::StatusLabelEnableChanged);
|
||||||
|
|
||||||
auto scrollArea = new QScrollArea(this);
|
auto scrollArea = new QScrollArea(this);
|
||||||
scrollArea->setWidgetResizable(true);
|
scrollArea->setWidgetResizable(true);
|
||||||
@@ -188,7 +174,6 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
layout->addWidget(highlightOptions);
|
layout->addWidget(highlightOptions);
|
||||||
layout->addWidget(hotkeyOptions);
|
layout->addWidget(hotkeyOptions);
|
||||||
layout->addWidget(generalOptions);
|
layout->addWidget(generalOptions);
|
||||||
layout->addWidget(inputOptions);
|
|
||||||
layout->addWidget(_dockOptions);
|
layout->addWidget(_dockOptions);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
scrollArea->setWidget(contentWidget);
|
scrollArea->setWidget(contentWidget);
|
||||||
@@ -198,15 +183,14 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
dialogLayout->addWidget(buttonbox);
|
dialogLayout->addWidget(buttonbox);
|
||||||
setLayout(dialogLayout);
|
setLayout(dialogLayout);
|
||||||
|
|
||||||
_executed->setChecked(settings._highlightExecuted);
|
_executed->setChecked(prop._highlightExecuted);
|
||||||
_conditions->setChecked(settings._highlightConditions);
|
_conditions->setChecked(prop._highlightConditions);
|
||||||
_actions->setChecked(settings._highlightActions);
|
_actions->setChecked(prop._highlightActions);
|
||||||
_newMacroRegisterHotkeys->setChecked(settings._newMacroRegisterHotkeys);
|
_newMacroRegisterHotkeys->setChecked(prop._newMacroRegisterHotkeys);
|
||||||
|
|
||||||
if (!macro || macro->IsGroup()) {
|
if (!macro || macro->IsGroup()) {
|
||||||
hotkeyOptions->hide();
|
hotkeyOptions->hide();
|
||||||
generalOptions->hide();
|
generalOptions->hide();
|
||||||
inputOptions->hide();
|
|
||||||
_dockOptions->hide();
|
_dockOptions->hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -214,7 +198,6 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
_currentMacroRegisterHotkeys->setChecked(macro->PauseHotkeysEnabled());
|
_currentMacroRegisterHotkeys->setChecked(macro->PauseHotkeysEnabled());
|
||||||
_currentSkipOnStartup->setChecked(macro->SkipExecOnStart());
|
_currentSkipOnStartup->setChecked(macro->SkipExecOnStart());
|
||||||
_currentStopActionsIfNotDone->setChecked(macro->StopActionsIfNotDone());
|
_currentStopActionsIfNotDone->setChecked(macro->StopActionsIfNotDone());
|
||||||
_currentInputs->SetInputs(macro->GetInputVariables());
|
|
||||||
const bool dockEnabled = macro->DockEnabled();
|
const bool dockEnabled = macro->DockEnabled();
|
||||||
_currentMacroRegisterDock->setChecked(dockEnabled);
|
_currentMacroRegisterDock->setChecked(dockEnabled);
|
||||||
_currentMacroDockAddRunButton->setChecked(macro->DockHasRunButton());
|
_currentMacroDockAddRunButton->setChecked(macro->DockHasRunButton());
|
||||||
@@ -262,7 +245,7 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||||||
20);
|
20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSettingsDialog::DockEnableChanged(int enabled)
|
void MacroPropertiesDialog::DockEnableChanged(int enabled)
|
||||||
{
|
{
|
||||||
_currentMacroDockAddRunButton->setVisible(enabled);
|
_currentMacroDockAddRunButton->setVisible(enabled);
|
||||||
_currentMacroDockAddPauseButton->setVisible(enabled);
|
_currentMacroDockAddPauseButton->setVisible(enabled);
|
||||||
@@ -287,37 +270,37 @@ void MacroSettingsDialog::DockEnableChanged(int enabled)
|
|||||||
Resize();
|
Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSettingsDialog::RunButtonEnableChanged(int enabled)
|
void MacroPropertiesDialog::RunButtonEnableChanged(int enabled)
|
||||||
{
|
{
|
||||||
SetGridLayoutRowVisible(_dockLayout, _runButtonTextRow, enabled);
|
SetGridLayoutRowVisible(_dockLayout, _runButtonTextRow, enabled);
|
||||||
Resize();
|
Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSettingsDialog::PauseButtonEnableChanged(int enabled)
|
void MacroPropertiesDialog::PauseButtonEnableChanged(int enabled)
|
||||||
{
|
{
|
||||||
SetGridLayoutRowVisible(_dockLayout, _pauseButtonTextRow, enabled);
|
SetGridLayoutRowVisible(_dockLayout, _pauseButtonTextRow, enabled);
|
||||||
SetGridLayoutRowVisible(_dockLayout, _unpauseButtonTextRow, enabled);
|
SetGridLayoutRowVisible(_dockLayout, _unpauseButtonTextRow, enabled);
|
||||||
Resize();
|
Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSettingsDialog::StatusLabelEnableChanged(int enabled)
|
void MacroPropertiesDialog::StatusLabelEnableChanged(int enabled)
|
||||||
{
|
{
|
||||||
SetGridLayoutRowVisible(_dockLayout, _conditionsTrueTextRow, enabled);
|
SetGridLayoutRowVisible(_dockLayout, _conditionsTrueTextRow, enabled);
|
||||||
SetGridLayoutRowVisible(_dockLayout, _conditionsFalseTextRow, enabled);
|
SetGridLayoutRowVisible(_dockLayout, _conditionsFalseTextRow, enabled);
|
||||||
Resize();
|
Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSettingsDialog::Resize()
|
void MacroPropertiesDialog::Resize()
|
||||||
{
|
{
|
||||||
_dockOptions->adjustSize();
|
_dockOptions->adjustSize();
|
||||||
_dockOptions->updateGeometry();
|
_dockOptions->updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroSettingsDialog::AskForSettings(QWidget *parent,
|
bool MacroPropertiesDialog::AskForSettings(QWidget *parent,
|
||||||
GlobalMacroSettings &userInput,
|
MacroProperties &userInput,
|
||||||
Macro *macro)
|
Macro *macro)
|
||||||
{
|
{
|
||||||
MacroSettingsDialog dialog(parent, userInput, macro);
|
MacroPropertiesDialog dialog(parent, userInput, macro);
|
||||||
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
||||||
if (dialog.exec() != DialogCode::Accepted) {
|
if (dialog.exec() != DialogCode::Accepted) {
|
||||||
return false;
|
return false;
|
||||||
@@ -354,23 +337,23 @@ bool MacroSettingsDialog::AskForSettings(QWidget *parent,
|
|||||||
dialog._conditionsTrueStatusText->text().toStdString());
|
dialog._conditionsTrueStatusText->text().toStdString());
|
||||||
macro->SetConditionsFalseStatusText(
|
macro->SetConditionsFalseStatusText(
|
||||||
dialog._conditionsFalseStatusText->text().toStdString());
|
dialog._conditionsFalseStatusText->text().toStdString());
|
||||||
macro->SetInputVariables(dialog._currentInputs->GetInputs());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalMacroSettings &GetGlobalMacroSettings()
|
MacroProperties &GetGlobalMacroProperties()
|
||||||
{
|
{
|
||||||
return macroSettings;
|
return macroProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveGlobalMacroSettings(obs_data_t *obj)
|
void SaveGlobalMacroProperties(obs_data_t *obj)
|
||||||
{
|
{
|
||||||
macroSettings.Save(obj);
|
macroProperties.Save(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGlobalMacroSettings(obs_data_t *obj)
|
void LoadGlobalMacroProperties(obs_data_t *obj)
|
||||||
{
|
{
|
||||||
macroSettings.Load(obj);
|
macroProperties.Load(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "variable-line-edit.hpp"
|
#include "variable-line-edit.hpp"
|
||||||
#include "macro-input.hpp"
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@@ -14,7 +13,7 @@ namespace advss {
|
|||||||
|
|
||||||
class Macro;
|
class Macro;
|
||||||
|
|
||||||
class GlobalMacroSettings {
|
class MacroProperties {
|
||||||
public:
|
public:
|
||||||
void Save(obs_data_t *obj) const;
|
void Save(obs_data_t *obj) const;
|
||||||
void Load(obs_data_t *obj);
|
void Load(obs_data_t *obj);
|
||||||
@@ -26,14 +25,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Dialog for configuring global and individual macro specific settings
|
// Dialog for configuring global and individual macro specific settings
|
||||||
class MacroSettingsDialog : public QDialog {
|
class MacroPropertiesDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacroSettingsDialog(QWidget *parent, const GlobalMacroSettings &,
|
MacroPropertiesDialog(QWidget *parent, const MacroProperties &,
|
||||||
Macro *macro);
|
Macro *macro);
|
||||||
static bool AskForSettings(QWidget *parent,
|
static bool AskForSettings(QWidget *parent, MacroProperties &userInput,
|
||||||
GlobalMacroSettings &userInput,
|
|
||||||
Macro *macro);
|
Macro *macro);
|
||||||
private slots:
|
private slots:
|
||||||
void DockEnableChanged(int);
|
void DockEnableChanged(int);
|
||||||
@@ -52,7 +50,6 @@ private:
|
|||||||
QCheckBox *_currentMacroRegisterHotkeys;
|
QCheckBox *_currentMacroRegisterHotkeys;
|
||||||
QCheckBox *_currentSkipOnStartup;
|
QCheckBox *_currentSkipOnStartup;
|
||||||
QCheckBox *_currentStopActionsIfNotDone;
|
QCheckBox *_currentStopActionsIfNotDone;
|
||||||
MacroInputSelection *_currentInputs;
|
|
||||||
QCheckBox *_currentMacroRegisterDock;
|
QCheckBox *_currentMacroRegisterDock;
|
||||||
QCheckBox *_currentMacroDockAddRunButton;
|
QCheckBox *_currentMacroDockAddRunButton;
|
||||||
QCheckBox *_currentMacroDockAddPauseButton;
|
QCheckBox *_currentMacroDockAddPauseButton;
|
||||||
@@ -73,8 +70,8 @@ private:
|
|||||||
int _conditionsFalseTextRow = -1;
|
int _conditionsFalseTextRow = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
GlobalMacroSettings &GetGlobalMacroSettings();
|
MacroProperties &GetGlobalMacroProperties();
|
||||||
void SaveGlobalMacroSettings(obs_data_t *obj);
|
void SaveGlobalMacroProperties(obs_data_t *obj);
|
||||||
void LoadGlobalMacroSettings(obs_data_t *obj);
|
void LoadGlobalMacroProperties(obs_data_t *obj);
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
#include "advanced-scene-switcher.hpp"
|
|
||||||
#include "macro.hpp"
|
|
||||||
|
|
||||||
#include <QShortcut>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
struct MacroSegmentCopyInfo {
|
|
||||||
enum class Type { NONE, CONDITION, ACTION, ELSE };
|
|
||||||
Type type = Type::NONE;
|
|
||||||
std::shared_ptr<MacroSegment> segment;
|
|
||||||
};
|
|
||||||
static MacroSegmentCopyInfo copyInfo;
|
|
||||||
|
|
||||||
void AdvSceneSwitcher::CopyMacroSegment()
|
|
||||||
{
|
|
||||||
copyInfo.segment.reset();
|
|
||||||
copyInfo.type = MacroSegmentCopyInfo::Type::NONE;
|
|
||||||
|
|
||||||
if (currentConditionIdx == -1 && currentActionIdx == -1 &&
|
|
||||||
currentElseActionIdx == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto macro = GetSelectedMacro();
|
|
||||||
if (!macro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentConditionIdx != -1) {
|
|
||||||
copyInfo.type = MacroSegmentCopyInfo::Type::CONDITION;
|
|
||||||
copyInfo.segment = macro->Conditions().at(currentConditionIdx);
|
|
||||||
} else if (currentActionIdx != -1) {
|
|
||||||
copyInfo.type = MacroSegmentCopyInfo::Type::ACTION;
|
|
||||||
copyInfo.segment = macro->Actions().at(currentActionIdx);
|
|
||||||
} else if (currentElseActionIdx != -1) {
|
|
||||||
copyInfo.type = MacroSegmentCopyInfo::Type::ELSE;
|
|
||||||
copyInfo.segment =
|
|
||||||
macro->ElseActions().at(currentElseActionIdx);
|
|
||||||
} else {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvSceneSwitcher::PasteMacroSegment()
|
|
||||||
{
|
|
||||||
if (copyInfo.type == MacroSegmentCopyInfo::Type::NONE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto macro = GetSelectedMacro();
|
|
||||||
if (!macro || !copyInfo.segment) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OBSDataAutoRelease data = obs_data_create();
|
|
||||||
copyInfo.segment->Save(data);
|
|
||||||
|
|
||||||
switch (copyInfo.type) {
|
|
||||||
case MacroSegmentCopyInfo::Type::CONDITION: {
|
|
||||||
const auto condition = std::static_pointer_cast<MacroCondition>(
|
|
||||||
copyInfo.segment);
|
|
||||||
auto logic = condition->GetLogicType();
|
|
||||||
if (logic > LogicType::ROOT_LAST &&
|
|
||||||
macro->Conditions().empty()) {
|
|
||||||
logic = LogicType::ROOT_NONE;
|
|
||||||
}
|
|
||||||
if (logic < LogicType::ROOT_LAST &&
|
|
||||||
!macro->Conditions().empty()) {
|
|
||||||
logic = LogicType::OR;
|
|
||||||
}
|
|
||||||
AddMacroCondition(macro.get(), macro->Conditions().size(),
|
|
||||||
copyInfo.segment->GetId(), data.Get(), logic);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MacroSegmentCopyInfo::Type::ACTION:
|
|
||||||
AddMacroAction(macro.get(), macro->Actions().size(),
|
|
||||||
copyInfo.segment->GetId(), data.Get());
|
|
||||||
break;
|
|
||||||
case MacroSegmentCopyInfo::Type::ELSE:
|
|
||||||
AddMacroElseAction(macro.get(), macro->ElseActions().size(),
|
|
||||||
copyInfo.segment->GetId(), data.Get());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroSegmentIsInClipboard()
|
|
||||||
{
|
|
||||||
return copyInfo.type != MacroSegmentCopyInfo::Type::NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetupSegmentCopyPasteShortcutHandlers(AdvSceneSwitcher *window)
|
|
||||||
{
|
|
||||||
auto copyShortcut = new QShortcut(QKeySequence("Ctrl+C"), window);
|
|
||||||
QWidget::connect(copyShortcut, &QShortcut::activated, window,
|
|
||||||
&AdvSceneSwitcher::CopyMacroSegment);
|
|
||||||
auto pasteShortcut = new QShortcut(QKeySequence("Ctrl+V"), window);
|
|
||||||
QWidget::connect(pasteShortcut, &QShortcut::activated, window,
|
|
||||||
&AdvSceneSwitcher::PasteMacroSegment);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace advss {
|
|
||||||
|
|
||||||
class AdvSceneSwitcher;
|
|
||||||
|
|
||||||
bool MacroSegmentIsInClipboard();
|
|
||||||
void SetupSegmentCopyPasteShortcutHandlers(AdvSceneSwitcher *window);
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -130,7 +130,7 @@ void MacroSegmentList::Highlight(int idx, QColor color)
|
|||||||
if (!widget) {
|
if (!widget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HighlightWidget(widget, color, QColor(0, 0, 0, 0), true);
|
PulseWidget(widget, color, QColor(0, 0, 0, 0), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSegmentList::SetCollapsed(bool collapse)
|
void MacroSegmentList::SetCollapsed(bool collapse)
|
||||||
@@ -176,8 +176,7 @@ bool MacroSegmentList::eventFilter(QObject *object, QEvent *event)
|
|||||||
|
|
||||||
void MacroSegmentList::mousePressEvent(QMouseEvent *event)
|
void MacroSegmentList::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton ||
|
if (event->button() == Qt::LeftButton) {
|
||||||
event->button() == Qt::RightButton) {
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
_dragPosition = GetDragIndex(event->globalPos());
|
_dragPosition = GetDragIndex(event->globalPos());
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ void MacroSegmentSelection::MarkSelectedSegment()
|
|||||||
index - 1, QColor(Qt::lightGray));
|
index - 1, QColor(Qt::lightGray));
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightWidget(this, QColor(Qt::lightGray), QColor(0, 0, 0, 0), true);
|
PulseWidget(this, QColor(Qt::lightGray), QColor(0, 0, 0, 0), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ std::string MacroSegment::GetShortDesc() const
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroSegment::EnableHighlight()
|
void MacroSegment::SetHighlight()
|
||||||
{
|
{
|
||||||
_highlight = true;
|
_highlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroSegment::GetHighlightAndReset()
|
bool MacroSegment::Highlight()
|
||||||
{
|
{
|
||||||
if (_highlight) {
|
if (_highlight) {
|
||||||
_highlight = false;
|
_highlight = false;
|
||||||
@@ -194,7 +194,7 @@ void DecrementVariableRef(MacroSegment *segment)
|
|||||||
segment->_variableRefs--;
|
segment->_variableRefs--;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroSegmentEdit::MacroSegmentEdit(QWidget *parent)
|
MacroSegmentEdit::MacroSegmentEdit(bool highlight, QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_section(new Section(300)),
|
_section(new Section(300)),
|
||||||
_headerInfo(new QLabel()),
|
_headerInfo(new QLabel()),
|
||||||
@@ -203,7 +203,8 @@ MacroSegmentEdit::MacroSegmentEdit(QWidget *parent)
|
|||||||
_noBorderframe(new QFrame),
|
_noBorderframe(new QFrame),
|
||||||
_borderFrame(new QFrame),
|
_borderFrame(new QFrame),
|
||||||
_dropLineAbove(new QFrame),
|
_dropLineAbove(new QFrame),
|
||||||
_dropLineBelow(new QFrame)
|
_dropLineBelow(new QFrame),
|
||||||
|
_showHighlight(highlight)
|
||||||
{
|
{
|
||||||
_dropLineAbove->setLineWidth(3);
|
_dropLineAbove->setLineWidth(3);
|
||||||
_dropLineAbove->setFixedHeight(11);
|
_dropLineAbove->setFixedHeight(11);
|
||||||
@@ -281,6 +282,10 @@ MacroSegmentEdit::MacroSegmentEdit(QWidget *parent)
|
|||||||
|
|
||||||
// Enable dragging while clicking on the header text
|
// Enable dragging while clicking on the header text
|
||||||
_headerInfo->installEventFilter(this);
|
_headerInfo->installEventFilter(this);
|
||||||
|
|
||||||
|
_timer.setInterval(1500);
|
||||||
|
connect(&_timer, SIGNAL(timeout()), this, SLOT(Highlight()));
|
||||||
|
_timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroSegmentEdit::eventFilter(QObject *obj, QEvent *ev)
|
bool MacroSegmentEdit::eventFilter(QObject *obj, QEvent *ev)
|
||||||
@@ -325,6 +330,22 @@ void MacroSegmentEdit::Collapsed(bool collapsed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroSegmentEdit::Highlight()
|
||||||
|
{
|
||||||
|
if (!Data()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_showHighlight && Data()->Highlight()) {
|
||||||
|
PulseWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroSegmentEdit::EnableHighlight(bool value)
|
||||||
|
{
|
||||||
|
_showHighlight = value;
|
||||||
|
}
|
||||||
|
|
||||||
void MacroSegmentEdit::SetFocusPolicyOfWidgets()
|
void MacroSegmentEdit::SetFocusPolicyOfWidgets()
|
||||||
{
|
{
|
||||||
QList<QWidget *> widgets = this->findChildren<QWidget *>();
|
QList<QWidget *> widgets = this->findChildren<QWidget *>();
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ public:
|
|||||||
virtual bool PostLoad();
|
virtual bool PostLoad();
|
||||||
virtual std::string GetShortDesc() const;
|
virtual std::string GetShortDesc() const;
|
||||||
virtual std::string GetId() const = 0;
|
virtual std::string GetId() const = 0;
|
||||||
void EnableHighlight();
|
void SetHighlight();
|
||||||
bool GetHighlightAndReset();
|
bool Highlight();
|
||||||
virtual std::string GetVariableValue() const;
|
virtual std::string GetVariableValue() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -87,7 +87,7 @@ class MacroSegmentEdit : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacroSegmentEdit(QWidget *parent = nullptr);
|
MacroSegmentEdit(bool highlight, QWidget *parent = nullptr);
|
||||||
// Use this function to avoid accidental edits when scrolling through
|
// Use this function to avoid accidental edits when scrolling through
|
||||||
// list of actions and conditions
|
// list of actions and conditions
|
||||||
void SetFocusPolicyOfWidgets();
|
void SetFocusPolicyOfWidgets();
|
||||||
@@ -100,6 +100,8 @@ public slots:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void Collapsed(bool);
|
void Collapsed(bool);
|
||||||
|
void Highlight();
|
||||||
|
void EnableHighlight(bool);
|
||||||
signals:
|
signals:
|
||||||
void MacroAdded(const QString &name);
|
void MacroAdded(const QString &name);
|
||||||
void MacroRemoved(const QString &name);
|
void MacroRemoved(const QString &name);
|
||||||
@@ -141,6 +143,9 @@ private:
|
|||||||
QFrame *_dropLineAbove;
|
QFrame *_dropLineAbove;
|
||||||
QFrame *_dropLineBelow;
|
QFrame *_dropLineBelow;
|
||||||
|
|
||||||
|
bool _showHighlight;
|
||||||
|
QTimer _timer;
|
||||||
|
|
||||||
friend class MacroSegmentList;
|
friend class MacroSegmentList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "macro-condition-edit.hpp"
|
#include "macro-condition-edit.hpp"
|
||||||
#include "macro-export-import-dialog.hpp"
|
#include "macro-export-import-dialog.hpp"
|
||||||
#include "macro-settings.hpp"
|
#include "macro-properties.hpp"
|
||||||
#include "macro-segment-copy-paste.hpp"
|
|
||||||
#include "macro-tree.hpp"
|
#include "macro-tree.hpp"
|
||||||
#include "macro.hpp"
|
#include "macro.hpp"
|
||||||
#include "math-helpers.hpp"
|
#include "math-helpers.hpp"
|
||||||
@@ -23,7 +22,7 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
static QObject *addPulse = nullptr;
|
static QMetaObject::Connection addPulse;
|
||||||
static QTimer onChangeHighlightTimer;
|
static QTimer onChangeHighlightTimer;
|
||||||
|
|
||||||
static bool macroNameExists(const std::string &name)
|
static bool macroNameExists(const std::string &name)
|
||||||
@@ -86,7 +85,7 @@ bool AdvSceneSwitcher::AddNewMacro(std::shared_ptr<Macro> &res,
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = std::make_shared<Macro>(
|
res = std::make_shared<Macro>(
|
||||||
name, GetGlobalMacroSettings()._newMacroRegisterHotkeys);
|
name, GetGlobalMacroProperties()._newMacroRegisterHotkeys);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +98,7 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui->macros->Add(newMacro);
|
ui->macros->Add(newMacro);
|
||||||
addPulse->deleteLater();
|
ui->macroAdd->disconnect(addPulse);
|
||||||
addPulse = nullptr;
|
|
||||||
emit MacroAdded(QString::fromStdString(name));
|
emit MacroAdded(QString::fromStdString(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +461,7 @@ void AdvSceneSwitcher::ImportMacros()
|
|||||||
RunPostLoadSteps();
|
RunPostLoadSteps();
|
||||||
|
|
||||||
ui->macros->Reset(GetMacros(),
|
ui->macros->Reset(GetMacros(),
|
||||||
GetGlobalMacroSettings()._highlightExecuted);
|
GetGlobalMacroProperties()._highlightExecuted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_macroName_editingFinished()
|
void AdvSceneSwitcher::on_macroName_editingFinished()
|
||||||
@@ -743,8 +741,8 @@ void AdvSceneSwitcher::MacroSelectionChanged()
|
|||||||
|
|
||||||
void AdvSceneSwitcher::HighlightOnChange()
|
void AdvSceneSwitcher::HighlightOnChange()
|
||||||
{
|
{
|
||||||
if (!GetGlobalMacroSettings()._highlightActions &&
|
if (!GetGlobalMacroProperties()._highlightActions &&
|
||||||
!GetGlobalMacroSettings()._highlightExecuted) {
|
!GetGlobalMacroProperties()._highlightExecuted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,21 +752,23 @@ void AdvSceneSwitcher::HighlightOnChange()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (macro->OnChangePreventedActionsRecently()) {
|
if (macro->OnChangePreventedActionsRecently()) {
|
||||||
HighlightWidget(ui->runMacroOnChange, Qt::yellow,
|
PulseWidget(ui->runMacroOnChange, Qt::yellow, Qt::transparent,
|
||||||
Qt::transparent, true);
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_macroSettings_clicked()
|
void AdvSceneSwitcher::on_macroProperties_clicked()
|
||||||
{
|
{
|
||||||
GlobalMacroSettings prop = GetGlobalMacroSettings();
|
MacroProperties prop = GetGlobalMacroProperties();
|
||||||
bool accepted = MacroSettingsDialog::AskForSettings(
|
bool accepted = MacroPropertiesDialog::AskForSettings(
|
||||||
this, prop, GetSelectedMacro().get());
|
this, prop, GetSelectedMacro().get());
|
||||||
if (!accepted) {
|
if (!accepted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GetGlobalMacroSettings() = prop;
|
GetGlobalMacroProperties() = prop;
|
||||||
emit HighlightMacrosChanged(prop._highlightExecuted);
|
emit HighlightMacrosChanged(prop._highlightExecuted);
|
||||||
|
emit HighlightActionsChanged(prop._highlightActions);
|
||||||
|
emit HighlightConditionsChanged(prop._highlightConditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void moveControlsToSplitter(QSplitter *splitter, int idx,
|
static void moveControlsToSplitter(QSplitter *splitter, int idx,
|
||||||
@@ -783,7 +783,7 @@ static void moveControlsToSplitter(QSplitter *splitter, int idx,
|
|||||||
splitter->setStyleSheet("QSplitter::handle {background: transparent;}");
|
splitter->setStyleSheet("QSplitter::handle {background: transparent;}");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shouldRestoreSplitter(const QList<int> &pos)
|
bool shouldRestoreSplitter(const QList<int> &pos)
|
||||||
{
|
{
|
||||||
if (pos.size() == 0) {
|
if (pos.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -797,46 +797,16 @@ static bool shouldRestoreSplitter(const QList<int> &pos)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runSegmentHighligtChecksHelper(MacroSegmentList *list)
|
|
||||||
{
|
|
||||||
MacroSegmentEdit *widget = nullptr;
|
|
||||||
for (int i = 0; (widget = list->WidgetAt(i)); i++) {
|
|
||||||
if (widget->Data() && widget->Data()->GetHighlightAndReset()) {
|
|
||||||
list->Highlight(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void runSegmentHighligtChecks(AdvSceneSwitcher *ss)
|
|
||||||
{
|
|
||||||
if (!ss || !HighlightUIElementsEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto macro = ss->GetSelectedMacro();
|
|
||||||
if (!macro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &settings = GetGlobalMacroSettings();
|
|
||||||
if (settings._highlightConditions) {
|
|
||||||
runSegmentHighligtChecksHelper(ss->ui->conditionsList);
|
|
||||||
}
|
|
||||||
if (settings._highlightActions) {
|
|
||||||
runSegmentHighligtChecksHelper(ss->ui->actionsList);
|
|
||||||
runSegmentHighligtChecksHelper(ss->ui->elseActionsList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvSceneSwitcher::SetupMacroTab()
|
void AdvSceneSwitcher::SetupMacroTab()
|
||||||
{
|
{
|
||||||
ui->macroElseActions->installEventFilter(this);
|
ui->macroElseActions->installEventFilter(this);
|
||||||
ui->macros->installEventFilter(this);
|
ui->macros->installEventFilter(this);
|
||||||
|
|
||||||
if (GetMacros().size() == 0 && !switcher->disableHints) {
|
if (GetMacros().size() == 0 && !switcher->disableHints) {
|
||||||
addPulse = HighlightWidget(ui->macroAdd, QColor(Qt::green));
|
addPulse = PulseWidget(ui->macroAdd, QColor(Qt::green));
|
||||||
}
|
}
|
||||||
ui->macros->Reset(GetMacros(),
|
ui->macros->Reset(GetMacros(),
|
||||||
GetGlobalMacroSettings()._highlightExecuted);
|
GetGlobalMacroProperties()._highlightExecuted);
|
||||||
connect(ui->macros, SIGNAL(MacroSelectionAboutToChange()), this,
|
connect(ui->macros, SIGNAL(MacroSelectionAboutToChange()), this,
|
||||||
SLOT(MacroSelectionAboutToChange()));
|
SLOT(MacroSelectionAboutToChange()));
|
||||||
connect(ui->macros, SIGNAL(MacroSelectionChanged()), this,
|
connect(ui->macros, SIGNAL(MacroSelectionChanged()), this,
|
||||||
@@ -921,14 +891,6 @@ void AdvSceneSwitcher::SetupMacroTab()
|
|||||||
switcher->macroListMacroEditSplitterPosition);
|
switcher->macroListMacroEditSplitterPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupSegmentCopyPasteShortcutHandlers(this);
|
|
||||||
|
|
||||||
// Macro segment highlight
|
|
||||||
auto timer = new QTimer(this);
|
|
||||||
connect(timer, &QTimer::timeout,
|
|
||||||
[this]() { runSegmentHighligtChecks(this); });
|
|
||||||
timer->start(1500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::ShowMacroContextMenu(const QPoint &pos)
|
void AdvSceneSwitcher::ShowMacroContextMenu(const QPoint &pos)
|
||||||
@@ -1016,19 +978,16 @@ static void setupConextMenu(AdvSceneSwitcher *ss, const QPoint &pos,
|
|||||||
MacroSegmentList *list)
|
MacroSegmentList *list)
|
||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.expandAll"),
|
||||||
|
ss, [ss, expand]() { expand(ss); });
|
||||||
|
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.collapseAll"),
|
||||||
|
ss, [ss, collapse]() { collapse(ss); });
|
||||||
|
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.maximize"),
|
||||||
|
ss, [ss, maximize]() { maximize(ss); });
|
||||||
|
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.minimize"),
|
||||||
|
ss, [ss, minimize]() { minimize(ss); });
|
||||||
|
|
||||||
auto segmentEdit = list->WidgetAt(pos);
|
auto segmentEdit = list->WidgetAt(pos);
|
||||||
|
|
||||||
auto copy = menu.addAction(
|
|
||||||
obs_module_text("AdvSceneSwitcher.macroTab.segment.copy"), ss,
|
|
||||||
[ss]() { ss->CopyMacroSegment(); });
|
|
||||||
copy->setEnabled(!!segmentEdit);
|
|
||||||
auto paste = menu.addAction(
|
|
||||||
obs_module_text("AdvSceneSwitcher.macroTab.segment.paste"), ss,
|
|
||||||
[ss]() { ss->PasteMacroSegment(); });
|
|
||||||
paste->setEnabled(MacroSegmentIsInClipboard());
|
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
if (segmentEdit) {
|
if (segmentEdit) {
|
||||||
auto customLabel = menu.addAction(obs_module_text(
|
auto customLabel = menu.addAction(obs_module_text(
|
||||||
"AdvSceneSwitcher.macroTab.segment.useCustomLabel"));
|
"AdvSceneSwitcher.macroTab.segment.useCustomLabel"));
|
||||||
@@ -1040,21 +999,6 @@ static void setupConextMenu(AdvSceneSwitcher *ss, const QPoint &pos,
|
|||||||
std::bind(handleCustomLabelChange, segmentEdit,
|
std::bind(handleCustomLabelChange, segmentEdit,
|
||||||
customLabel));
|
customLabel));
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.expandAll"),
|
|
||||||
ss, [ss, expand]() { expand(ss); });
|
|
||||||
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.collapseAll"),
|
|
||||||
ss, [ss, collapse]() { collapse(ss); });
|
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.maximize"),
|
|
||||||
ss, [ss, maximize]() { maximize(ss); });
|
|
||||||
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.minimize"),
|
|
||||||
ss, [ss, minimize]() { minimize(ss); });
|
|
||||||
|
|
||||||
menu.exec(list->mapToGlobal(pos));
|
menu.exec(list->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1107,8 +1051,7 @@ void AdvSceneSwitcher::CopyMacro()
|
|||||||
Macro::PrepareMoveToGroup(macro->Parent(), newMacro);
|
Macro::PrepareMoveToGroup(macro->Parent(), newMacro);
|
||||||
|
|
||||||
ui->macros->Add(newMacro, macro);
|
ui->macros->Add(newMacro, macro);
|
||||||
addPulse->deleteLater();
|
ui->macroAdd->disconnect(addPulse);
|
||||||
addPulse = nullptr;
|
|
||||||
emit MacroAdded(QString::fromStdString(name));
|
emit MacroAdded(QString::fromStdString(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1400,47 +1343,58 @@ static void fade(QWidget *widget, bool fadeOut)
|
|||||||
animation->start(QPropertyAnimation::DeleteWhenStopped);
|
animation->start(QPropertyAnimation::DeleteWhenStopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fadeWidgets(const std::vector<QWidget *> &widgets, bool fadeOut)
|
void AdvSceneSwitcher::FadeOutActionControls()
|
||||||
{
|
{
|
||||||
for (const auto &widget : widgets) {
|
fade(ui->actionAdd, true);
|
||||||
fade(widget, fadeOut);
|
fade(ui->actionRemove, true);
|
||||||
}
|
fade(ui->actionTop, true);
|
||||||
|
fade(ui->actionUp, true);
|
||||||
|
fade(ui->actionDown, true);
|
||||||
|
fade(ui->actionBottom, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdvSceneSwitcher::FadeOutConditionControls()
|
||||||
|
{
|
||||||
|
fade(ui->conditionAdd, true);
|
||||||
|
fade(ui->conditionRemove, true);
|
||||||
|
fade(ui->conditionTop, true);
|
||||||
|
fade(ui->conditionUp, true);
|
||||||
|
fade(ui->conditionDown, true);
|
||||||
|
fade(ui->conditionBottom, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdvSceneSwitcher::ResetOpacityActionControls()
|
||||||
|
{
|
||||||
|
fade(ui->actionAdd, false);
|
||||||
|
fade(ui->actionRemove, false);
|
||||||
|
fade(ui->actionTop, false);
|
||||||
|
fade(ui->actionUp, false);
|
||||||
|
fade(ui->actionDown, false);
|
||||||
|
fade(ui->actionBottom, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdvSceneSwitcher::ResetOpacityConditionControls()
|
||||||
|
{
|
||||||
|
fade(ui->conditionAdd, false);
|
||||||
|
fade(ui->conditionRemove, false);
|
||||||
|
fade(ui->conditionTop, false);
|
||||||
|
fade(ui->conditionUp, false);
|
||||||
|
fade(ui->conditionDown, false);
|
||||||
|
fade(ui->conditionBottom, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::HighlightControls()
|
void AdvSceneSwitcher::HighlightControls()
|
||||||
{
|
{
|
||||||
const std::vector<QWidget *> conditionControls{
|
if ((currentActionIdx == -1 && currentConditionIdx == -1) ||
|
||||||
ui->conditionAdd, ui->conditionRemove, ui->conditionTop,
|
(currentActionIdx != -1 && currentConditionIdx != -1)) {
|
||||||
ui->conditionUp, ui->conditionDown, ui->conditionBottom,
|
ResetOpacityActionControls();
|
||||||
};
|
ResetOpacityConditionControls();
|
||||||
const std::vector<QWidget *> actionControls{
|
|
||||||
ui->actionAdd, ui->actionRemove, ui->actionTop,
|
|
||||||
ui->actionUp, ui->actionDown, ui->actionBottom,
|
|
||||||
};
|
|
||||||
const std::vector<QWidget *> elseActionControls{
|
|
||||||
ui->elseActionAdd, ui->elseActionRemove, ui->elseActionTop,
|
|
||||||
ui->elseActionUp, ui->elseActionDown, ui->elseActionBottom,
|
|
||||||
};
|
|
||||||
|
|
||||||
if ((currentActionIdx == -1 && currentConditionIdx == -1 &&
|
|
||||||
currentElseActionIdx == -1)) {
|
|
||||||
fadeWidgets(conditionControls, false);
|
|
||||||
fadeWidgets(actionControls, false);
|
|
||||||
fadeWidgets(elseActionControls, false);
|
|
||||||
} else if (currentConditionIdx != -1) {
|
|
||||||
fadeWidgets(conditionControls, false);
|
|
||||||
fadeWidgets(actionControls, true);
|
|
||||||
fadeWidgets(elseActionControls, true);
|
|
||||||
} else if (currentActionIdx != -1) {
|
} else if (currentActionIdx != -1) {
|
||||||
fadeWidgets(conditionControls, true);
|
FadeOutConditionControls();
|
||||||
fadeWidgets(actionControls, false);
|
ResetOpacityActionControls();
|
||||||
fadeWidgets(elseActionControls, true);
|
|
||||||
} else if (currentElseActionIdx != -1) {
|
|
||||||
fadeWidgets(conditionControls, true);
|
|
||||||
fadeWidgets(actionControls, true);
|
|
||||||
fadeWidgets(elseActionControls, false);
|
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
FadeOutActionControls();
|
||||||
|
ResetOpacityConditionControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void MacroTreeItem::HighlightIfExecuted()
|
|||||||
|
|
||||||
if (_lastHighlightCheckTime.time_since_epoch().count() != 0 &&
|
if (_lastHighlightCheckTime.time_since_epoch().count() != 0 &&
|
||||||
_macro->WasExecutedSince(_lastHighlightCheckTime)) {
|
_macro->WasExecutedSince(_lastHighlightCheckTime)) {
|
||||||
HighlightWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
PulseWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
||||||
}
|
}
|
||||||
_lastHighlightCheckTime = std::chrono::high_resolution_clock::now();
|
_lastHighlightCheckTime = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ void Macro::PrepareMoveToGroup(std::shared_ptr<Macro> group,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Macro::CeckMatch(bool ignorePause)
|
bool Macro::CeckMatch()
|
||||||
{
|
{
|
||||||
if (_isGroup) {
|
if (_isGroup) {
|
||||||
return false;
|
return false;
|
||||||
@@ -109,7 +109,7 @@ bool Macro::CeckMatch(bool ignorePause)
|
|||||||
|
|
||||||
_matched = false;
|
_matched = false;
|
||||||
for (auto &c : _conditions) {
|
for (auto &c : _conditions) {
|
||||||
if (_paused && !ignorePause) {
|
if (_paused) {
|
||||||
vblog(LOG_INFO, "Macro %s is paused", _name.c_str());
|
vblog(LOG_INFO, "Macro %s is paused", _name.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -137,37 +137,37 @@ bool Macro::CeckMatch(bool ignorePause)
|
|||||||
case LogicType::AND:
|
case LogicType::AND:
|
||||||
_matched = _matched && cond;
|
_matched = _matched && cond;
|
||||||
if (cond) {
|
if (cond) {
|
||||||
c->EnableHighlight();
|
c->SetHighlight();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LogicType::OR:
|
case LogicType::OR:
|
||||||
_matched = _matched || cond;
|
_matched = _matched || cond;
|
||||||
if (cond) {
|
if (cond) {
|
||||||
c->EnableHighlight();
|
c->SetHighlight();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LogicType::AND_NOT:
|
case LogicType::AND_NOT:
|
||||||
_matched = _matched && !cond;
|
_matched = _matched && !cond;
|
||||||
if (!cond) {
|
if (!cond) {
|
||||||
c->EnableHighlight();
|
c->SetHighlight();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LogicType::OR_NOT:
|
case LogicType::OR_NOT:
|
||||||
_matched = _matched || !cond;
|
_matched = _matched || !cond;
|
||||||
if (!cond) {
|
if (!cond) {
|
||||||
c->EnableHighlight();
|
c->SetHighlight();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LogicType::ROOT_NONE:
|
case LogicType::ROOT_NONE:
|
||||||
_matched = cond;
|
_matched = cond;
|
||||||
if (cond) {
|
if (cond) {
|
||||||
c->EnableHighlight();
|
c->SetHighlight();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LogicType::ROOT_NOT:
|
case LogicType::ROOT_NOT:
|
||||||
_matched = !cond;
|
_matched = !cond;
|
||||||
if (!cond) {
|
if (!cond) {
|
||||||
c->EnableHighlight();
|
c->SetHighlight();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -185,7 +185,6 @@ bool Macro::CeckMatch(bool ignorePause)
|
|||||||
if (!_conditionSateChanged && _performActionsOnChange) {
|
if (!_conditionSateChanged && _performActionsOnChange) {
|
||||||
_onPreventedActionExecution = true;
|
_onPreventedActionExecution = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastMatched = _matched;
|
_lastMatched = _matched;
|
||||||
_lastCheckTime = std::chrono::high_resolution_clock::now();
|
_lastCheckTime = std::chrono::high_resolution_clock::now();
|
||||||
return _matched;
|
return _matched;
|
||||||
@@ -314,7 +313,7 @@ bool Macro::RunActionsHelper(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (action->Enabled()) {
|
if (action->Enabled()) {
|
||||||
action->EnableHighlight();
|
action->SetHighlight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_done = true;
|
_done = true;
|
||||||
@@ -349,11 +348,6 @@ void Macro::SetMatchOnChange(bool onChange)
|
|||||||
_performActionsOnChange = onChange;
|
_performActionsOnChange = onChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Macro::SetStopActionsIfNotDone(bool stopActionsIfNotDone)
|
|
||||||
{
|
|
||||||
_stopActionsIfNotDone = stopActionsIfNotDone;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Macro::SetPaused(bool pause)
|
void Macro::SetPaused(bool pause)
|
||||||
{
|
{
|
||||||
if (_paused && !pause) {
|
if (_paused && !pause) {
|
||||||
@@ -388,16 +382,6 @@ void Macro::Stop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroInputVariables Macro::GetInputVariables() const
|
|
||||||
{
|
|
||||||
return _inputVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Macro::SetInputVariables(const MacroInputVariables &inputVariables)
|
|
||||||
{
|
|
||||||
_inputVariables = inputVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<TempVariable> Macro::GetTempVars(MacroSegment *filter) const
|
std::vector<TempVariable> Macro::GetTempVars(MacroSegment *filter) const
|
||||||
{
|
{
|
||||||
std::vector<TempVariable> res;
|
std::vector<TempVariable> res;
|
||||||
@@ -626,8 +610,6 @@ bool Macro::Save(obs_data_t *obj) const
|
|||||||
}
|
}
|
||||||
obs_data_set_array(obj, "elseActions", elseActions);
|
obs_data_set_array(obj, "elseActions", elseActions);
|
||||||
|
|
||||||
_inputVariables.Save(obj);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,8 +748,6 @@ bool Macro::Load(obs_data_t *obj)
|
|||||||
}
|
}
|
||||||
UpdateElseActionIndices();
|
UpdateElseActionIndices();
|
||||||
|
|
||||||
_inputVariables.Load(obj);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,10 +819,10 @@ void Macro::ResetUIHelpers()
|
|||||||
{
|
{
|
||||||
_onPreventedActionExecution = false;
|
_onPreventedActionExecution = false;
|
||||||
for (auto c : _conditions) {
|
for (auto c : _conditions) {
|
||||||
c->GetHighlightAndReset();
|
c->Highlight();
|
||||||
}
|
}
|
||||||
for (auto a : _actions) {
|
for (auto a : _actions) {
|
||||||
a->GetHighlightAndReset();
|
a->Highlight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "macro-action.hpp"
|
#include "macro-action.hpp"
|
||||||
#include "macro-condition.hpp"
|
#include "macro-condition.hpp"
|
||||||
#include "macro-helpers.hpp"
|
#include "macro-helpers.hpp"
|
||||||
#include "macro-input.hpp"
|
|
||||||
#include "macro-ref.hpp"
|
#include "macro-ref.hpp"
|
||||||
#include "variable-string.hpp"
|
#include "variable-string.hpp"
|
||||||
#include "temp-variable.hpp"
|
#include "temp-variable.hpp"
|
||||||
@@ -26,44 +25,35 @@ public:
|
|||||||
Macro(const std::string &name = "", const bool addHotkey = false);
|
Macro(const std::string &name = "", const bool addHotkey = false);
|
||||||
virtual ~Macro();
|
virtual ~Macro();
|
||||||
|
|
||||||
std::string Name() const { return _name; }
|
bool CeckMatch();
|
||||||
void SetName(const std::string &name);
|
|
||||||
|
|
||||||
bool CeckMatch(bool ignorePause = false);
|
|
||||||
bool Matched() const { return _matched; }
|
|
||||||
int64_t MsSinceLastCheck() const;
|
|
||||||
bool ShouldRunActions() const;
|
|
||||||
bool PerformActions(bool match, bool forceParallel = false,
|
bool PerformActions(bool match, bool forceParallel = false,
|
||||||
bool ignorePause = false);
|
bool ignorePause = false);
|
||||||
|
bool Matched() const { return _matched; }
|
||||||
|
bool ShouldRunActions() const;
|
||||||
|
int64_t MsSinceLastCheck() const;
|
||||||
|
std::string Name() const { return _name; }
|
||||||
|
void SetName(const std::string &name);
|
||||||
|
void SetRunInParallel(bool parallel) { _runInParallel = parallel; }
|
||||||
|
bool RunInParallel() const { return _runInParallel; }
|
||||||
void SetPaused(bool pause = true);
|
void SetPaused(bool pause = true);
|
||||||
bool Paused() const { return _paused; }
|
bool Paused() const { return _paused; }
|
||||||
bool WasPausedSince(
|
bool WasPausedSince(
|
||||||
const std::chrono::high_resolution_clock::time_point &) const;
|
const std::chrono::high_resolution_clock::time_point &) const;
|
||||||
|
|
||||||
void Stop();
|
|
||||||
bool GetStop() const { return _stop; }
|
|
||||||
void ResetTimers();
|
|
||||||
|
|
||||||
void SetMatchOnChange(bool onChange);
|
void SetMatchOnChange(bool onChange);
|
||||||
bool MatchOnChange() const { return _performActionsOnChange; }
|
bool MatchOnChange() const { return _performActionsOnChange; }
|
||||||
|
|
||||||
void SetSkipExecOnStart(bool skip) { _skipExecOnStart = skip; }
|
void SetSkipExecOnStart(bool skip) { _skipExecOnStart = skip; }
|
||||||
bool SkipExecOnStart() const { return _skipExecOnStart; }
|
bool SkipExecOnStart() const { return _skipExecOnStart; }
|
||||||
|
void SetStopActionsIfNotDone(bool stopActionsIfNotDone)
|
||||||
void SetStopActionsIfNotDone(bool stopActionsIfNotDone);
|
{
|
||||||
|
_stopActionsIfNotDone = stopActionsIfNotDone;
|
||||||
|
}
|
||||||
bool StopActionsIfNotDone() const { return _stopActionsIfNotDone; }
|
bool StopActionsIfNotDone() const { return _stopActionsIfNotDone; }
|
||||||
|
|
||||||
int RunCount() const { return _runCount; };
|
int RunCount() const { return _runCount; };
|
||||||
void ResetRunCount() { _runCount = 0; };
|
void ResetRunCount() { _runCount = 0; };
|
||||||
|
void ResetTimers();
|
||||||
void AddHelperThread(std::thread &&);
|
void AddHelperThread(std::thread &&);
|
||||||
void SetRunInParallel(bool parallel) { _runInParallel = parallel; }
|
bool GetStop() const { return _stop; }
|
||||||
bool RunInParallel() const { return _runInParallel; }
|
void Stop();
|
||||||
|
|
||||||
// Input variables
|
|
||||||
MacroInputVariables GetInputVariables() const;
|
|
||||||
void SetInputVariables(const MacroInputVariables &);
|
|
||||||
|
|
||||||
// Temporary variable helpers
|
// Temporary variable helpers
|
||||||
std::vector<TempVariable> GetTempVars(MacroSegment *filter) const;
|
std::vector<TempVariable> GetTempVars(MacroSegment *filter) const;
|
||||||
@@ -108,21 +98,19 @@ public:
|
|||||||
bool SwitchesScene() const;
|
bool SwitchesScene() const;
|
||||||
|
|
||||||
// UI helpers
|
// UI helpers
|
||||||
void SetActionConditionSplitterPosition(const QList<int>);
|
|
||||||
const QList<int> &GetActionConditionSplitterPosition() const;
|
const QList<int> &GetActionConditionSplitterPosition() const;
|
||||||
void SetElseActionSplitterPosition(const QList<int>);
|
void SetActionConditionSplitterPosition(const QList<int>);
|
||||||
const QList<int> &GetElseActionSplitterPosition() const;
|
const QList<int> &GetElseActionSplitterPosition() const;
|
||||||
|
void SetElseActionSplitterPosition(const QList<int>);
|
||||||
bool HasValidSplitterPositions() const;
|
bool HasValidSplitterPositions() const;
|
||||||
bool WasExecutedSince(
|
bool WasExecutedSince(
|
||||||
const std::chrono::high_resolution_clock::time_point &) const;
|
const std::chrono::high_resolution_clock::time_point &) const;
|
||||||
bool OnChangePreventedActionsRecently();
|
bool OnChangePreventedActionsRecently();
|
||||||
void ResetUIHelpers();
|
void ResetUIHelpers();
|
||||||
|
|
||||||
// Hotkeys
|
|
||||||
void EnablePauseHotkeys(bool);
|
void EnablePauseHotkeys(bool);
|
||||||
bool PauseHotkeysEnabled() const;
|
bool PauseHotkeysEnabled() const;
|
||||||
|
|
||||||
// Docks
|
|
||||||
void EnableDock(bool);
|
void EnableDock(bool);
|
||||||
bool DockEnabled() const { return _registerDock; }
|
bool DockEnabled() const { return _registerDock; }
|
||||||
void SetDockHasRunButton(bool value);
|
void SetDockHasRunButton(bool value);
|
||||||
@@ -194,8 +182,6 @@ private:
|
|||||||
obs_hotkey_id _unpauseHotkey = OBS_INVALID_HOTKEY_ID;
|
obs_hotkey_id _unpauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||||
obs_hotkey_id _togglePauseHotkey = OBS_INVALID_HOTKEY_ID;
|
obs_hotkey_id _togglePauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||||
|
|
||||||
MacroInputVariables _inputVariables;
|
|
||||||
|
|
||||||
// UI helpers
|
// UI helpers
|
||||||
bool _onPreventedActionExecution = false;
|
bool _onPreventedActionExecution = false;
|
||||||
|
|
||||||
|
|||||||
@@ -11,16 +11,19 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
|
static bool registerTab();
|
||||||
static void setupTab(QTabWidget *);
|
static void setupTab(QTabWidget *);
|
||||||
|
static bool registerTabDone = registerTab();
|
||||||
|
|
||||||
static ActionQueueTable *tabWidget = nullptr;
|
static ActionQueueTable *tabWidget = nullptr;
|
||||||
|
|
||||||
void RegisterActionQueueTab()
|
static bool registerTab()
|
||||||
{
|
{
|
||||||
AddPluginInitStep([]() {
|
AddPluginInitStep([]() {
|
||||||
AddSetupTabCallback("actionQueueTab", ActionQueueTable::Create,
|
AddSetupTabCallback("actionQueueTab", ActionQueueTable::Create,
|
||||||
setupTab);
|
setupTab);
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setTabVisible(QTabWidget *tabWidget, bool visible)
|
static void setTabVisible(QTabWidget *tabWidget, bool visible)
|
||||||
@@ -67,11 +70,11 @@ static QStringList getCellLabels(ActionQueue *queue, bool addName = true)
|
|||||||
<< QString::fromStdString(obs_module_text(
|
<< QString::fromStdString(obs_module_text(
|
||||||
queue->IsRunning()
|
queue->IsRunning()
|
||||||
? "AdvSceneSwitcher.actionQueueTab.yes"
|
? "AdvSceneSwitcher.actionQueueTab.yes"
|
||||||
: "AdvSceneSwitcher.actionQueueTab.no"))
|
: "AdvSceneSwitcher.actionQueueTab.yes"))
|
||||||
<< QString::fromStdString(obs_module_text(
|
<< QString::fromStdString(obs_module_text(
|
||||||
queue->RunsOnStartup()
|
queue->RunsOnStartup()
|
||||||
? "AdvSceneSwitcher.actionQueueTab.yes"
|
? "AdvSceneSwitcher.actionQueueTab.yes"
|
||||||
: "AdvSceneSwitcher.actionQueueTab.no"));
|
: "AdvSceneSwitcher.actionQueueTab.yes"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,15 +223,14 @@ static void setupTab(QTabWidget *tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget::connect(ActionQueueSignalManager::Instance(),
|
QWidget::connect(ActionQueueSignalManager::Instance(),
|
||||||
&ActionQueueSignalManager::Rename, tab,
|
&ActionQueueSignalManager::Rename,
|
||||||
[](const QString &oldName, const QString &newName) {
|
[](const QString &oldName, const QString &newName) {
|
||||||
RenameItemTableRow(tabWidget->Table(), oldName,
|
RenameItemTableRow(tabWidget->Table(), oldName,
|
||||||
newName);
|
newName);
|
||||||
});
|
});
|
||||||
QWidget::connect(
|
QWidget::connect(
|
||||||
ActionQueueSignalManager::Instance(),
|
ActionQueueSignalManager::Instance(),
|
||||||
&ActionQueueSignalManager::Add, tab,
|
&ActionQueueSignalManager::Add, [tab](const QString &name) {
|
||||||
[tab](const QString &name) {
|
|
||||||
AddItemTableRow(
|
AddItemTableRow(
|
||||||
tabWidget->Table(),
|
tabWidget->Table(),
|
||||||
getCellLabels(GetWeakActionQueueByQString(name)
|
getCellLabels(GetWeakActionQueueByQString(name)
|
||||||
@@ -239,7 +241,7 @@ static void setupTab(QTabWidget *tab)
|
|||||||
setTabVisible(tab, true);
|
setTabVisible(tab, true);
|
||||||
});
|
});
|
||||||
QWidget::connect(ActionQueueSignalManager::Instance(),
|
QWidget::connect(ActionQueueSignalManager::Instance(),
|
||||||
&ActionQueueSignalManager::Remove, tab,
|
&ActionQueueSignalManager::Remove,
|
||||||
[](const QString &name) {
|
[](const QString &name) {
|
||||||
RemoveItemTableRow(tabWidget->Table(), name);
|
RemoveItemTableRow(tabWidget->Table(), name);
|
||||||
if (tabWidget->Table()->rowCount() == 0) {
|
if (tabWidget->Table()->rowCount() == 0) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "action-queue.hpp"
|
#include "action-queue.hpp"
|
||||||
#include "obs-module-helper.hpp"
|
#include "obs-module-helper.hpp"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
#include "ui-helpers.hpp"
|
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
@@ -12,8 +11,6 @@ std::deque<std::shared_ptr<Item>> &GetActionQueues()
|
|||||||
return queues;
|
return queues;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterActionQueueTab();
|
|
||||||
|
|
||||||
void SetupActionQueues()
|
void SetupActionQueues()
|
||||||
{
|
{
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
@@ -22,7 +19,6 @@ void SetupActionQueues()
|
|||||||
}
|
}
|
||||||
AddSaveStep(SaveActionQueues);
|
AddSaveStep(SaveActionQueues);
|
||||||
AddLoadStep(LoadActionQueues);
|
AddLoadStep(LoadActionQueues);
|
||||||
RegisterActionQueueTab();
|
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,24 +376,11 @@ static bool queueWithNameExists(const std::string &name)
|
|||||||
return !GetWeakActionQueueByName(name).expired();
|
return !GetWeakActionQueueByName(name).expired();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void signalImportedQueues(void *varsPtr)
|
|
||||||
{
|
|
||||||
auto queues = std::unique_ptr<std::vector<std::shared_ptr<Item>>>(
|
|
||||||
static_cast<std::vector<std::shared_ptr<Item>> *>(varsPtr));
|
|
||||||
for (const auto &queue : *queues) {
|
|
||||||
ActionQueueSignalManager::Instance()->Add(
|
|
||||||
QString::fromStdString(queue->Name()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImportQueues(obs_data_t *data)
|
void ImportQueues(obs_data_t *data)
|
||||||
{
|
{
|
||||||
OBSDataArrayAutoRelease array =
|
OBSDataArrayAutoRelease array =
|
||||||
obs_data_get_array(data, "actionQueues");
|
obs_data_get_array(data, "actionQueues");
|
||||||
size_t count = obs_data_array_count(array);
|
size_t count = obs_data_array_count(array);
|
||||||
|
|
||||||
auto importedQueues = new std::vector<std::shared_ptr<Item>>;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
OBSDataAutoRelease arrayElement = obs_data_array_item(array, i);
|
OBSDataAutoRelease arrayElement = obs_data_array_item(array, i);
|
||||||
auto queue = ActionQueue::Create();
|
auto queue = ActionQueue::Create();
|
||||||
@@ -406,10 +389,7 @@ void ImportQueues(obs_data_t *data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
queues.emplace_back(queue);
|
queues.emplace_back(queue);
|
||||||
importedQueues->emplace_back(queue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QeueUITask(signalImportedQueues, importedQueues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::weak_ptr<ActionQueue> GetWeakActionQueueByName(const std::string &name)
|
std::weak_ptr<ActionQueue> GetWeakActionQueueByName(const std::string &name)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "switch-video.hpp"
|
#include "switch-video.hpp"
|
||||||
#include "switch-network.hpp"
|
#include "switch-network.hpp"
|
||||||
|
|
||||||
#include "macro-settings.hpp"
|
#include "macro-properties.hpp"
|
||||||
#include "duration-control.hpp"
|
#include "duration-control.hpp"
|
||||||
#include "priority-helper.hpp"
|
#include "priority-helper.hpp"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#include "help-icon.hpp"
|
|
||||||
#include "ui-helpers.hpp"
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
HelpIcon::HelpIcon(const QString &tooltip, QWidget *parent) : QLabel(parent)
|
|
||||||
{
|
|
||||||
auto path = GetThemeTypeName() == "Light"
|
|
||||||
? ":/res/images/help.svg"
|
|
||||||
: ":/res/images/help_light.svg";
|
|
||||||
QIcon icon(path);
|
|
||||||
QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
|
||||||
setPixmap(pixmap);
|
|
||||||
if (!tooltip.isEmpty()) {
|
|
||||||
setToolTip(tooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "export-symbol-helper.hpp"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
class ADVSS_EXPORT HelpIcon : public QLabel {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
HelpIcon(const QString &tooltip = "", QWidget *parent = nullptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -81,7 +81,6 @@ public:
|
|||||||
"AdvSceneSwitcher.item.nameNotAvailable",
|
"AdvSceneSwitcher.item.nameNotAvailable",
|
||||||
std::string_view configureTooltip = "", QWidget *parent = 0);
|
std::string_view configureTooltip = "", QWidget *parent = 0);
|
||||||
virtual ~ItemSelection() = default;
|
virtual ~ItemSelection() = default;
|
||||||
Item *GetCurrentItem();
|
|
||||||
void SetItem(const std::string &);
|
void SetItem(const std::string &);
|
||||||
void ShowRenameContextMenu(bool value);
|
void ShowRenameContextMenu(bool value);
|
||||||
|
|
||||||
@@ -100,6 +99,8 @@ signals:
|
|||||||
void ItemRenamed(const QString &oldName, const QString &name);
|
void ItemRenamed(const QString &oldName, const QString &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Item *GetCurrentItem();
|
||||||
|
|
||||||
FilterComboBox *_selection;
|
FilterComboBox *_selection;
|
||||||
QPushButton *_modify;
|
QPushButton *_modify;
|
||||||
CreateItemFunc _create;
|
CreateItemFunc _create;
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
#include "list-editor.hpp"
|
|
||||||
#include "ui-helpers.hpp"
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
ListEditor::ListEditor(QWidget *parent, bool reorder)
|
|
||||||
: QWidget(parent),
|
|
||||||
_list(new QListWidget()),
|
|
||||||
_add(new QPushButton()),
|
|
||||||
_remove(new QPushButton()),
|
|
||||||
_up(new QPushButton()),
|
|
||||||
_down(new QPushButton()),
|
|
||||||
_controlsLayout(new QHBoxLayout()),
|
|
||||||
_mainLayout(new QVBoxLayout())
|
|
||||||
{
|
|
||||||
_add->setMaximumWidth(22);
|
|
||||||
_add->setProperty("themeID",
|
|
||||||
QVariant(QString::fromUtf8("addIconSmall")));
|
|
||||||
_add->setFlat(true);
|
|
||||||
_remove->setMaximumWidth(22);
|
|
||||||
_remove->setProperty("themeID",
|
|
||||||
QVariant(QString::fromUtf8("removeIconSmall")));
|
|
||||||
_remove->setFlat(true);
|
|
||||||
_up->setMaximumWidth(22);
|
|
||||||
_up->setProperty("themeID",
|
|
||||||
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
|
||||||
_up->setFlat(true);
|
|
||||||
_down->setMaximumWidth(22);
|
|
||||||
_down->setProperty("themeID",
|
|
||||||
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
|
||||||
_down->setFlat(true);
|
|
||||||
|
|
||||||
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
|
|
||||||
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
|
|
||||||
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
|
|
||||||
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
|
|
||||||
QWidget::connect(_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
|
||||||
this, SLOT(Clicked(QListWidgetItem *)));
|
|
||||||
|
|
||||||
_controlsLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
_controlsLayout->addWidget(_add);
|
|
||||||
_controlsLayout->addWidget(_remove);
|
|
||||||
if (reorder) {
|
|
||||||
auto line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::VLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
_controlsLayout->addWidget(line);
|
|
||||||
_controlsLayout->addWidget(_up);
|
|
||||||
_controlsLayout->addWidget(_down);
|
|
||||||
}
|
|
||||||
_controlsLayout->addStretch();
|
|
||||||
|
|
||||||
_mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
_mainLayout->addWidget(_list);
|
|
||||||
_mainLayout->addLayout(_controlsLayout);
|
|
||||||
setLayout(_mainLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListEditor::showEvent(QShowEvent *e)
|
|
||||||
{
|
|
||||||
QWidget::showEvent(e);
|
|
||||||
// This is necessary as the list viewport might not be updated yet while
|
|
||||||
// the list was hidden.
|
|
||||||
// Thus, previous calls to UpdateListSize() might not have resized the
|
|
||||||
// widget correctly, for example due to not regarding the horizontal
|
|
||||||
// scrollbar yet.
|
|
||||||
UpdateListSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListEditor::UpdateListSize()
|
|
||||||
{
|
|
||||||
SetHeightToContentHeight(_list);
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "export-symbol-helper.hpp"
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <QLayout>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
class ADVSS_EXPORT ListEditor : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ListEditor(QWidget *parent = nullptr, bool reorder = true);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void showEvent(QShowEvent *);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
virtual void Add() = 0;
|
|
||||||
virtual void Remove() = 0;
|
|
||||||
virtual void Up(){};
|
|
||||||
virtual void Down(){};
|
|
||||||
virtual void Clicked(QListWidgetItem *) {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void UpdateListSize();
|
|
||||||
|
|
||||||
QListWidget *_list;
|
|
||||||
QPushButton *_add;
|
|
||||||
QPushButton *_remove;
|
|
||||||
QPushButton *_up;
|
|
||||||
QPushButton *_down;
|
|
||||||
QHBoxLayout *_controlsLayout;
|
|
||||||
QVBoxLayout *_mainLayout;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -81,13 +81,9 @@ void ResourceTable::SetHelpVisible(bool visible) const
|
|||||||
|
|
||||||
void ResourceTable::HighlightAddButton(bool enable)
|
void ResourceTable::HighlightAddButton(bool enable)
|
||||||
{
|
{
|
||||||
if (_highlightConnection) {
|
_add->disconnect(_highlightConnection);
|
||||||
_highlightConnection->deleteLater();
|
|
||||||
_highlightConnection = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enable && HighlightUIElementsEnabled()) {
|
if (enable && HighlightUIElementsEnabled()) {
|
||||||
_highlightConnection = HighlightWidget(_add, QColor(Qt::green));
|
_highlightConnection = PulseWidget(_add, QColor(Qt::green));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ private:
|
|||||||
QPushButton *_remove;
|
QPushButton *_remove;
|
||||||
QLabel *_help;
|
QLabel *_help;
|
||||||
|
|
||||||
QObject *_highlightConnection = nullptr;
|
QMetaObject::Connection _highlightConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT void AddItemTableRow(QTableWidget *table, const QStringList &cells);
|
EXPORT void AddItemTableRow(QTableWidget *table, const QStringList &cells);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QPalette>
|
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
@@ -16,50 +15,6 @@ namespace advss {
|
|||||||
void OpenSettingsWindow();
|
void OpenSettingsWindow();
|
||||||
StatusDock *dock = nullptr;
|
StatusDock *dock = nullptr;
|
||||||
|
|
||||||
static QString colorToString(const QColor &color)
|
|
||||||
{
|
|
||||||
return QString("rgba(") + QString::number(color.red()) + "," +
|
|
||||||
QString::number(color.green()) + "," +
|
|
||||||
QString::number(color.blue()) + "," +
|
|
||||||
QString::number(color.alpha()) + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString getDefaultBackgroundColorString()
|
|
||||||
{
|
|
||||||
static QString defaultColorString;
|
|
||||||
static bool cacheReady = false;
|
|
||||||
|
|
||||||
if (cacheReady) {
|
|
||||||
return defaultColorString;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget tempWidget;
|
|
||||||
const auto defaultColor =
|
|
||||||
tempWidget.palette().brush(QPalette::Window).color();
|
|
||||||
defaultColorString = colorToString(defaultColor);
|
|
||||||
|
|
||||||
cacheReady = true;
|
|
||||||
return defaultColorString;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString getDefaultTextColorString()
|
|
||||||
{
|
|
||||||
static QString defaultColorString;
|
|
||||||
static bool cacheReady = false;
|
|
||||||
|
|
||||||
if (cacheReady) {
|
|
||||||
return defaultColorString;
|
|
||||||
}
|
|
||||||
|
|
||||||
QLabel tempWidget;
|
|
||||||
const auto defaultColor =
|
|
||||||
tempWidget.palette().brush(QPalette::Text).color();
|
|
||||||
defaultColorString = colorToString(defaultColor);
|
|
||||||
|
|
||||||
cacheReady = true;
|
|
||||||
return defaultColorString;
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusControl::StatusControl(QWidget *parent, bool noLayout)
|
StatusControl::StatusControl(QWidget *parent, bool noLayout)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_button(new QPushButton("-", this)),
|
_button(new QPushButton("-", this)),
|
||||||
@@ -73,22 +28,30 @@ StatusControl::StatusControl(QWidget *parent, bool noLayout)
|
|||||||
_statusPrefix->setWordWrap(true);
|
_statusPrefix->setWordWrap(true);
|
||||||
_statusPrefix->setSizePolicy(QSizePolicy::Expanding,
|
_statusPrefix->setSizePolicy(QSizePolicy::Expanding,
|
||||||
QSizePolicy::Expanding);
|
QSizePolicy::Expanding);
|
||||||
|
_status->setStyleSheet("QLabel{ \
|
||||||
|
border-style: outset; \
|
||||||
|
border-width: 2px; \
|
||||||
|
border-radius: 7px; \
|
||||||
|
border-color: rgb(0,0,0,0) \
|
||||||
|
}");
|
||||||
|
_status->setSizePolicy(QSizePolicy::Maximum,
|
||||||
|
QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
QWidget::connect(_button, SIGNAL(clicked()), this,
|
QWidget::connect(_button, SIGNAL(clicked()), this,
|
||||||
SLOT(ButtonClicked()));
|
SLOT(ButtonClicked()));
|
||||||
|
|
||||||
if (!noLayout) {
|
if (!noLayout) {
|
||||||
|
QHBoxLayout *statusLayout = new QHBoxLayout();
|
||||||
|
statusLayout->addWidget(_statusPrefix);
|
||||||
|
statusLayout->addStretch();
|
||||||
|
statusLayout->addWidget(_status);
|
||||||
|
statusLayout->setStretch(0, 10);
|
||||||
_buttonLayout->setContentsMargins(0, 0, 0, 0);
|
_buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
_buttonLayout->addWidget(_button);
|
_buttonLayout->addWidget(_button);
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
_statusPrefix->setAlignment(Qt::AlignCenter);
|
layout->addLayout(statusLayout);
|
||||||
_status->setAlignment(Qt::AlignCenter);
|
|
||||||
layout->addWidget(_statusPrefix);
|
|
||||||
layout->addWidget(_status);
|
|
||||||
layout->addLayout(_buttonLayout);
|
layout->addLayout(_buttonLayout);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
} else {
|
|
||||||
_status->setSizePolicy(QSizePolicy::Maximum,
|
|
||||||
QSizePolicy::MinimumExpanding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PluginIsRunning()) {
|
if (PluginIsRunning()) {
|
||||||
@@ -131,8 +94,7 @@ void StatusControl::SetStarted()
|
|||||||
_button->setText(
|
_button->setText(
|
||||||
obs_module_text("AdvSceneSwitcher.generalTab.status.stop"));
|
obs_module_text("AdvSceneSwitcher.generalTab.status.stop"));
|
||||||
_status->setText(obs_module_text("AdvSceneSwitcher.status.active"));
|
_status->setText(obs_module_text("AdvSceneSwitcher.status.active"));
|
||||||
_pulse->deleteLater();
|
_status->disconnect(_pulse);
|
||||||
SetStatusStyleSheet(false);
|
|
||||||
_setToStopped = false;
|
_setToStopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,31 +103,13 @@ void StatusControl::SetStopped()
|
|||||||
_button->setText(
|
_button->setText(
|
||||||
obs_module_text("AdvSceneSwitcher.generalTab.status.start"));
|
obs_module_text("AdvSceneSwitcher.generalTab.status.start"));
|
||||||
_status->setText(obs_module_text("AdvSceneSwitcher.status.inactive"));
|
_status->setText(obs_module_text("AdvSceneSwitcher.status.inactive"));
|
||||||
SetStatusStyleSheet(true);
|
|
||||||
if (HighlightUIElementsEnabled()) {
|
if (HighlightUIElementsEnabled()) {
|
||||||
_pulse = HighlightWidget(_status, QColor(Qt::red),
|
_pulse = PulseWidget(_status, QColor(Qt::red),
|
||||||
QColor(0, 0, 0, 0));
|
QColor(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
_setToStopped = true;
|
_setToStopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusControl::SetStatusStyleSheet(bool stopped) const
|
|
||||||
{
|
|
||||||
auto style = QString("QLabel{ "
|
|
||||||
"background-color: ");
|
|
||||||
if (stopped) {
|
|
||||||
style += getDefaultBackgroundColorString() + "; ";
|
|
||||||
} else {
|
|
||||||
style += "transparent; ";
|
|
||||||
}
|
|
||||||
style += "border-style: outset; "
|
|
||||||
"border-width: 2px; "
|
|
||||||
"border-radius: 7px; "
|
|
||||||
"border-color: " +
|
|
||||||
getDefaultTextColorString() + "; }";
|
|
||||||
_status->setStyleSheet(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusDock::StatusDock(QWidget *parent) : OBSDock(parent)
|
StatusDock::StatusDock(QWidget *parent) : OBSDock(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
||||||
|
|||||||
@@ -26,14 +26,13 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void SetStopped();
|
void SetStopped();
|
||||||
void SetStarted();
|
void SetStarted();
|
||||||
void SetStatusStyleSheet(bool stopped) const;
|
|
||||||
|
|
||||||
QPushButton *_button;
|
QPushButton *_button;
|
||||||
QHBoxLayout *_buttonLayout;
|
QHBoxLayout *_buttonLayout;
|
||||||
QLabel *_status;
|
QLabel *_status;
|
||||||
QLabel *_statusPrefix;
|
QLabel *_statusPrefix;
|
||||||
QTimer _timer;
|
QTimer _timer;
|
||||||
QObject *_pulse = nullptr;
|
QMetaObject::Connection _pulse;
|
||||||
|
|
||||||
bool _setToStopped = true;
|
bool _setToStopped = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,15 +5,8 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
// Helper used in macro segment edit widgets
|
EXPORT std::mutex *GetMutex();
|
||||||
#define GUARD_LOADING_AND_LOCK() \
|
EXPORT std::lock_guard<std::mutex> LockContext();
|
||||||
if (_loading || !_entryData) { \
|
EXPORT std::unique_lock<std::mutex> *GetLoopLock();
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
auto lock = LockContext();
|
|
||||||
|
|
||||||
[[nodiscard]] EXPORT std::mutex *GetMutex();
|
|
||||||
[[nodiscard]] EXPORT std::lock_guard<std::mutex> LockContext();
|
|
||||||
[[nodiscard]] EXPORT std::unique_lock<std::mutex> *GetLoopLock();
|
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ void SetTabOrder(QTabWidget *tabWidget)
|
|||||||
|
|
||||||
void SetCurrentTab(QTabWidget *tabWidget)
|
void SetCurrentTab(QTabWidget *tabWidget)
|
||||||
{
|
{
|
||||||
if (lastOpenedTab >= 0 && tabWidget->isTabVisible(lastOpenedTab)) {
|
if (lastOpenedTab >= 0) {
|
||||||
tabWidget->setCurrentIndex(lastOpenedTab);
|
tabWidget->setCurrentIndex(lastOpenedTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ public:
|
|||||||
EXPORT void Load(obs_data_t *, Macro *, const char *name = "tempVar");
|
EXPORT void Load(obs_data_t *, Macro *, const char *name = "tempVar");
|
||||||
EXPORT std::optional<const TempVariable> GetTempVariable(Macro *) const;
|
EXPORT std::optional<const TempVariable> GetTempVariable(Macro *) const;
|
||||||
EXPORT bool operator==(const TempVariableRef &other) const;
|
EXPORT bool operator==(const TempVariableRef &other) const;
|
||||||
bool HasValidID() const { return !_id.empty(); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION };
|
enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION };
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
QObject *HighlightWidget(QWidget *widget, QColor startColor, QColor endColor,
|
QMetaObject::Connection PulseWidget(QWidget *widget, QColor startColor,
|
||||||
bool once)
|
QColor endColor, bool once)
|
||||||
{
|
{
|
||||||
QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect(widget);
|
QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect(widget);
|
||||||
widget->setGraphicsEffect(effect);
|
widget->setGraphicsEffect(effect);
|
||||||
@@ -24,22 +24,33 @@ QObject *HighlightWidget(QWidget *widget, QColor startColor, QColor endColor,
|
|||||||
animation->setEndValue(endColor);
|
animation->setEndValue(endColor);
|
||||||
animation->setDuration(1000);
|
animation->setDuration(1000);
|
||||||
|
|
||||||
// Clean up the effect when the animation is deleted
|
QMetaObject::Connection con;
|
||||||
QWidget::connect(animation, &QPropertyAnimation::destroyed, [widget]() {
|
|
||||||
if (widget) {
|
|
||||||
widget->setGraphicsEffect(nullptr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (once) {
|
if (once) {
|
||||||
|
auto widgetPtr = widget;
|
||||||
|
con = QWidget::connect(
|
||||||
|
animation, &QPropertyAnimation::finished,
|
||||||
|
[widgetPtr]() {
|
||||||
|
if (widgetPtr) {
|
||||||
|
widgetPtr->setGraphicsEffect(nullptr);
|
||||||
|
}
|
||||||
|
});
|
||||||
animation->start(QPropertyAnimation::DeleteWhenStopped);
|
animation->start(QPropertyAnimation::DeleteWhenStopped);
|
||||||
return animation;
|
} else {
|
||||||
|
auto widgetPtr = widget;
|
||||||
|
con = QWidget::connect(
|
||||||
|
animation, &QPropertyAnimation::finished,
|
||||||
|
[animation, widgetPtr]() {
|
||||||
|
QTimer *timer = new QTimer(widgetPtr);
|
||||||
|
QWidget::connect(timer, &QTimer::timeout,
|
||||||
|
[animation] {
|
||||||
|
animation->start();
|
||||||
|
});
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
timer->start(1000);
|
||||||
|
});
|
||||||
|
animation->start();
|
||||||
}
|
}
|
||||||
|
return con;
|
||||||
QWidget::connect(animation, &QPropertyAnimation::finished,
|
|
||||||
[animation]() { animation->start(); });
|
|
||||||
animation->start();
|
|
||||||
return animation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getHorizontalScrollBarHeight(QListWidget *list)
|
static int getHorizontalScrollBarHeight(QListWidget *list)
|
||||||
@@ -155,9 +166,4 @@ std::string GetThemeTypeName()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QeueUITask(void (*task)(void *param), void *param)
|
|
||||||
{
|
|
||||||
obs_queue_task(OBS_TASK_UI, task, param, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -12,11 +12,9 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
// Returns QObject* to QPropertyAnimation object
|
EXPORT QMetaObject::Connection PulseWidget(QWidget *widget, QColor startColor,
|
||||||
// Delete it to stop the animation
|
QColor endColor = QColor(0, 0, 0, 0),
|
||||||
EXPORT QObject *HighlightWidget(QWidget *widget, QColor startColor,
|
bool once = false);
|
||||||
QColor endColor = QColor(0, 0, 0, 0),
|
|
||||||
bool once = false);
|
|
||||||
|
|
||||||
EXPORT void SetHeightToContentHeight(QListWidget *list);
|
EXPORT void SetHeightToContentHeight(QListWidget *list);
|
||||||
EXPORT void SetButtonIcon(QPushButton *button, const char *path);
|
EXPORT void SetButtonIcon(QPushButton *button, const char *path);
|
||||||
@@ -31,6 +29,4 @@ EXPORT void DisplayTrayMessage(const QString &title, const QString &msg,
|
|||||||
|
|
||||||
EXPORT std::string GetThemeTypeName();
|
EXPORT std::string GetThemeTypeName();
|
||||||
|
|
||||||
void QeueUITask(void (*task)(void *param), void *param);
|
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -76,15 +76,15 @@ std::string ToString(double value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void listAddClicked(QListWidget *list, QWidget *newWidget,
|
void listAddClicked(QListWidget *list, QWidget *newWidget,
|
||||||
QPushButton *addButton, QObject *addHighlight)
|
QPushButton *addButton,
|
||||||
|
QMetaObject::Connection *addHighlight)
|
||||||
{
|
{
|
||||||
if (!list || !newWidget) {
|
if (!list || !newWidget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addHighlight) {
|
if (addButton && addHighlight) {
|
||||||
addHighlight->deleteLater();
|
addButton->disconnect(*addHighlight);
|
||||||
addHighlight = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QListWidgetItem *item;
|
QListWidgetItem *item;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ std::string ToString(double value);
|
|||||||
|
|
||||||
void listAddClicked(QListWidget *list, QWidget *newWidget,
|
void listAddClicked(QListWidget *list, QWidget *newWidget,
|
||||||
QPushButton *addButton = nullptr,
|
QPushButton *addButton = nullptr,
|
||||||
QObject *addHighlight = nullptr);
|
QMetaObject::Connection *addHighlight = nullptr);
|
||||||
bool listMoveUp(QListWidget *list);
|
bool listMoveUp(QListWidget *list);
|
||||||
bool listMoveDown(QListWidget *list);
|
bool listMoveDown(QListWidget *list);
|
||||||
|
|
||||||
|
|||||||
@@ -154,15 +154,6 @@ static void updateVariableStatus(QTableWidget *table)
|
|||||||
|
|
||||||
UpdateItemTableRow(table, row,
|
UpdateItemTableRow(table, row,
|
||||||
getCellLabels(variable.get(), false));
|
getCellLabels(variable.get(), false));
|
||||||
|
|
||||||
// Special tooltip handling for the "last used" cell
|
|
||||||
const auto lastUsedItem = table->item(row, 4);
|
|
||||||
if (!lastUsedItem) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const auto lastUsedTooltip =
|
|
||||||
formatLastChangedTooltip(variable.get());
|
|
||||||
lastUsedItem->setToolTip(lastUsedTooltip);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,14 +264,14 @@ static void setupTab(QTabWidget *tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget::connect(VariableSignalManager::Instance(),
|
QWidget::connect(VariableSignalManager::Instance(),
|
||||||
&VariableSignalManager::Rename, tab,
|
&VariableSignalManager::Rename,
|
||||||
[](const QString &oldName, const QString &newName) {
|
[](const QString &oldName, const QString &newName) {
|
||||||
RenameItemTableRow(tabWidget->Table(), oldName,
|
RenameItemTableRow(tabWidget->Table(), oldName,
|
||||||
newName);
|
newName);
|
||||||
});
|
});
|
||||||
QWidget::connect(
|
QWidget::connect(
|
||||||
VariableSignalManager::Instance(), &VariableSignalManager::Add,
|
VariableSignalManager::Instance(), &VariableSignalManager::Add,
|
||||||
tab, [tab](const QString &name) {
|
[tab](const QString &name) {
|
||||||
AddItemTableRow(
|
AddItemTableRow(
|
||||||
tabWidget->Table(),
|
tabWidget->Table(),
|
||||||
getCellLabels(GetVariableByQString(name)));
|
getCellLabels(GetVariableByQString(name)));
|
||||||
@@ -289,7 +280,7 @@ static void setupTab(QTabWidget *tab)
|
|||||||
setTabVisible(tab, true);
|
setTabVisible(tab, true);
|
||||||
});
|
});
|
||||||
QWidget::connect(VariableSignalManager::Instance(),
|
QWidget::connect(VariableSignalManager::Instance(),
|
||||||
&VariableSignalManager::Remove, tab,
|
&VariableSignalManager::Remove,
|
||||||
[](const QString &name) {
|
[](const QString &name) {
|
||||||
RemoveItemTableRow(tabWidget->Table(), name);
|
RemoveItemTableRow(tabWidget->Table(), name);
|
||||||
if (tabWidget->Table()->rowCount() == 0) {
|
if (tabWidget->Table()->rowCount() == 0) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "variable.hpp"
|
#include "variable.hpp"
|
||||||
#include "math-helpers.hpp"
|
#include "math-helpers.hpp"
|
||||||
#include "obs-module-helper.hpp"
|
#include "obs-module-helper.hpp"
|
||||||
#include "ui-helpers.hpp"
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@@ -268,53 +267,6 @@ void VariableSelection::SetVariable(const std::weak_ptr<Variable> &variable_)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableSelectionDialog::VariableSelectionDialog(QWidget *parent)
|
|
||||||
: QDialog(parent),
|
|
||||||
_variableSelection(new VariableSelection(this))
|
|
||||||
{
|
|
||||||
setModal(true);
|
|
||||||
setWindowModality(Qt::WindowModality::ApplicationModal);
|
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
||||||
setMinimumWidth(350);
|
|
||||||
setMinimumHeight(70);
|
|
||||||
|
|
||||||
auto buttonbox = new QDialogButtonBox(QDialogButtonBox::Ok |
|
|
||||||
QDialogButtonBox::Cancel);
|
|
||||||
|
|
||||||
buttonbox->setCenterButtons(true);
|
|
||||||
connect(buttonbox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
||||||
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
||||||
|
|
||||||
auto selectionLayout = new QHBoxLayout();
|
|
||||||
selectionLayout->addWidget(new QLabel(
|
|
||||||
obs_module_text("AdvSceneSwitcher.variable.selectionDialog")));
|
|
||||||
selectionLayout->addWidget(_variableSelection);
|
|
||||||
selectionLayout->addStretch();
|
|
||||||
auto layout = new QVBoxLayout();
|
|
||||||
layout->addLayout(selectionLayout);
|
|
||||||
layout->addWidget(buttonbox);
|
|
||||||
setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *GetSettingsWindow();
|
|
||||||
|
|
||||||
bool VariableSelectionDialog::AskForVariable(QWidget *parent,
|
|
||||||
std::string &varName)
|
|
||||||
{
|
|
||||||
VariableSelectionDialog dialog(GetSettingsWindow());
|
|
||||||
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
|
||||||
|
|
||||||
if (dialog.exec() != DialogCode::Accepted) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto item = dialog._variableSelection->GetCurrentItem();
|
|
||||||
if (!item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
varName = item->Name();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
VariableSignalManager::VariableSignalManager(QObject *parent) : QObject(parent)
|
VariableSignalManager::VariableSignalManager(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -423,23 +375,11 @@ void LoadVariables(obs_data_t *obj)
|
|||||||
obs_data_array_release(variablesArray);
|
obs_data_array_release(variablesArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void signalImportedVariables(void *varsPtr)
|
|
||||||
{
|
|
||||||
auto vars = std::unique_ptr<std::vector<std::shared_ptr<Item>>>(
|
|
||||||
static_cast<std::vector<std::shared_ptr<Item>> *>(varsPtr));
|
|
||||||
for (const auto &var : *vars) {
|
|
||||||
VariableSignalManager::Instance()->Add(
|
|
||||||
QString::fromStdString(var->Name()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImportVariables(obs_data_t *data)
|
void ImportVariables(obs_data_t *data)
|
||||||
{
|
{
|
||||||
obs_data_array_t *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);
|
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++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
obs_data_t *arrayElement = obs_data_array_item(array, i);
|
obs_data_t *arrayElement = obs_data_array_item(array, i);
|
||||||
auto var = Variable::Create();
|
auto var = Variable::Create();
|
||||||
@@ -451,12 +391,9 @@ void ImportVariables(obs_data_t *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetVariables().emplace_back(var);
|
GetVariables().emplace_back(var);
|
||||||
importedVars->emplace_back(var);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_data_array_release(array);
|
obs_data_array_release(array);
|
||||||
|
|
||||||
QeueUITask(signalImportedVariables, importedVars);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::high_resolution_clock::time_point GetLastVariableChangeTime()
|
std::chrono::high_resolution_clock::time_point GetLastVariableChangeTime()
|
||||||
|
|||||||
@@ -82,17 +82,6 @@ public:
|
|||||||
void SetVariable(const std::weak_ptr<Variable> &);
|
void SetVariable(const std::weak_ptr<Variable> &);
|
||||||
};
|
};
|
||||||
|
|
||||||
class VariableSelectionDialog : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
VariableSelectionDialog(QWidget *parent);
|
|
||||||
static bool AskForVariable(QWidget *parent, std::string &variableName);
|
|
||||||
|
|
||||||
private:
|
|
||||||
VariableSelection *_variableSelection;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ADVSS_EXPORT VariableSignalManager : public QObject {
|
class ADVSS_EXPORT VariableSignalManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ target_sources(
|
|||||||
macro-condition-file.hpp
|
macro-condition-file.hpp
|
||||||
macro-condition-filter.cpp
|
macro-condition-filter.cpp
|
||||||
macro-condition-filter.hpp
|
macro-condition-filter.hpp
|
||||||
macro-condition-folder.cpp
|
|
||||||
macro-condition-folder.hpp
|
|
||||||
macro-condition-hotkey.cpp
|
macro-condition-hotkey.cpp
|
||||||
macro-condition-hotkey.hpp
|
macro-condition-hotkey.hpp
|
||||||
macro-condition-idle.cpp
|
macro-condition-idle.cpp
|
||||||
@@ -168,6 +166,8 @@ target_sources(
|
|||||||
utils/source-settings-helpers.hpp
|
utils/source-settings-helpers.hpp
|
||||||
utils/source-setting.cpp
|
utils/source-setting.cpp
|
||||||
utils/source-setting.hpp
|
utils/source-setting.hpp
|
||||||
|
utils/string-list.cpp
|
||||||
|
utils/string-list.hpp
|
||||||
utils/striped-frame.cpp
|
utils/striped-frame.cpp
|
||||||
utils/striped-frame.hpp
|
utils/striped-frame.hpp
|
||||||
utils/text-helpers.cpp
|
utils/text-helpers.cpp
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "macro-action-run.hpp"
|
#include "macro-action-run.hpp"
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
|
#include "ui-helpers.hpp"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@@ -129,10 +130,16 @@ MacroActionRunEdit::MacroActionRunEdit(
|
|||||||
_waitLayout(new QHBoxLayout()),
|
_waitLayout(new QHBoxLayout()),
|
||||||
_wait(new QCheckBox()),
|
_wait(new QCheckBox()),
|
||||||
_timeout(new DurationSelection(this, true, 0.1)),
|
_timeout(new DurationSelection(this, true, 0.1)),
|
||||||
_waitHelp(new HelpIcon(obs_module_text(
|
_waitHelp(new QLabel())
|
||||||
"AdvSceneSwitcher.action.run.wait.help.tooltip")))
|
|
||||||
{
|
{
|
||||||
|
QString helpIconPath = GetThemeTypeName() == "Light"
|
||||||
|
? ":/res/images/help.svg"
|
||||||
|
: ":/res/images/help_light.svg";
|
||||||
|
QIcon helpIcon(helpIconPath);
|
||||||
|
_waitHelp->setPixmap(helpIcon.pixmap(QSize(16, 16)));
|
||||||
_waitHelp->hide();
|
_waitHelp->hide();
|
||||||
|
_waitHelp->setToolTip(obs_module_text(
|
||||||
|
"AdvSceneSwitcher.action.run.wait.help.tooltip"));
|
||||||
|
|
||||||
QWidget::connect(_procConfig,
|
QWidget::connect(_procConfig,
|
||||||
SIGNAL(ConfigChanged(const ProcessConfig &)), this,
|
SIGNAL(ConfigChanged(const ProcessConfig &)), this,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "help-icon.hpp"
|
|
||||||
#include "process-config.hpp"
|
#include "process-config.hpp"
|
||||||
#include "duration-control.hpp"
|
#include "duration-control.hpp"
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ private:
|
|||||||
QHBoxLayout *_waitLayout;
|
QHBoxLayout *_waitLayout;
|
||||||
QCheckBox *_wait;
|
QCheckBox *_wait;
|
||||||
DurationSelection *_timeout;
|
DurationSelection *_timeout;
|
||||||
HelpIcon *_waitHelp;
|
QLabel *_waitHelp;
|
||||||
|
|
||||||
std::shared_ptr<MacroActionRun> _entryData;
|
std::shared_ptr<MacroActionRun> _entryData;
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "macro-action-window.hpp"
|
#include "macro-action-window.hpp"
|
||||||
#include "help-icon.hpp"
|
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
#include "platform-funcs.hpp"
|
#include "platform-funcs.hpp"
|
||||||
#include "selection-helpers.hpp"
|
#include "selection-helpers.hpp"
|
||||||
@@ -164,8 +163,7 @@ MacroActionWindowEdit::MacroActionWindowEdit(
|
|||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_actions(new QComboBox()),
|
_actions(new QComboBox()),
|
||||||
_windows(new QComboBox()),
|
_windows(new QComboBox()),
|
||||||
_regex(new RegexConfigWidget(this)),
|
_regex(new RegexConfigWidget(this))
|
||||||
_infoLayout(new QHBoxLayout())
|
|
||||||
{
|
{
|
||||||
populateActionSelection(_actions);
|
populateActionSelection(_actions);
|
||||||
|
|
||||||
@@ -173,15 +171,6 @@ MacroActionWindowEdit::MacroActionWindowEdit(
|
|||||||
_windows->setMaxVisibleItems(20);
|
_windows->setMaxVisibleItems(20);
|
||||||
PopulateWindowSelection(_windows);
|
PopulateWindowSelection(_windows);
|
||||||
|
|
||||||
auto focusLimitation = new QLabel(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.window.type.setFocusWindow.limitation"));
|
|
||||||
_infoLayout->addWidget(focusLimitation);
|
|
||||||
|
|
||||||
auto focusLimitationDetails = new HelpIcon(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.action.window.type.setFocusWindow.limitation.details"));
|
|
||||||
_infoLayout->addWidget(focusLimitationDetails);
|
|
||||||
_infoLayout->addStretch();
|
|
||||||
|
|
||||||
QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this,
|
QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this,
|
||||||
SLOT(ActionChanged(int)));
|
SLOT(ActionChanged(int)));
|
||||||
QWidget::connect(_windows, SIGNAL(currentTextChanged(const QString &)),
|
QWidget::connect(_windows, SIGNAL(currentTextChanged(const QString &)),
|
||||||
@@ -190,15 +179,12 @@ MacroActionWindowEdit::MacroActionWindowEdit(
|
|||||||
SIGNAL(RegexConfigChanged(const RegexConfig &)), this,
|
SIGNAL(RegexConfigChanged(const RegexConfig &)), this,
|
||||||
SLOT(RegexChanged(const RegexConfig &)));
|
SLOT(RegexChanged(const RegexConfig &)));
|
||||||
|
|
||||||
auto entryLayout = new QHBoxLayout;
|
auto layout = new QHBoxLayout;
|
||||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.action.window.entry"),
|
PlaceWidgets(obs_module_text("AdvSceneSwitcher.action.window.entry"),
|
||||||
entryLayout,
|
layout,
|
||||||
{{"{{actions}}", _actions},
|
{{"{{actions}}", _actions},
|
||||||
{"{{windows}}", _windows},
|
{"{{windows}}", _windows},
|
||||||
{"{{regex}}", _regex}});
|
{"{{regex}}", _regex}});
|
||||||
auto layout = new QVBoxLayout();
|
|
||||||
layout->addLayout(entryLayout);
|
|
||||||
layout->addLayout(_infoLayout);
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
_entryData = entryData;
|
_entryData = entryData;
|
||||||
@@ -214,7 +200,8 @@ void MacroActionWindowEdit::UpdateEntryData()
|
|||||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
||||||
_windows->setCurrentText(QString::fromStdString(_entryData->_window));
|
_windows->setCurrentText(QString::fromStdString(_entryData->_window));
|
||||||
_regex->SetRegexConfig(_entryData->_regex);
|
_regex->SetRegexConfig(_entryData->_regex);
|
||||||
SetWidgetVisibility();
|
adjustSize();
|
||||||
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionWindowEdit::WindowChanged(const QString &text)
|
void MacroActionWindowEdit::WindowChanged(const QString &text)
|
||||||
@@ -241,15 +228,6 @@ void MacroActionWindowEdit::RegexChanged(const RegexConfig ®ex)
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionWindowEdit::SetWidgetVisibility()
|
|
||||||
{
|
|
||||||
SetLayoutVisible(_infoLayout,
|
|
||||||
_entryData->_action ==
|
|
||||||
MacroActionWindow::Action::SET_FOCUS_WINDOW);
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroActionWindowEdit::ActionChanged(int value)
|
void MacroActionWindowEdit::ActionChanged(int value)
|
||||||
{
|
{
|
||||||
if (_loading || !_entryData) {
|
if (_loading || !_entryData) {
|
||||||
@@ -258,7 +236,6 @@ void MacroActionWindowEdit::ActionChanged(int value)
|
|||||||
|
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
_entryData->_action = static_cast<MacroActionWindow::Action>(value);
|
_entryData->_action = static_cast<MacroActionWindow::Action>(value);
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -59,12 +59,9 @@ signals:
|
|||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetWidgetVisibility();
|
|
||||||
|
|
||||||
QComboBox *_actions;
|
QComboBox *_actions;
|
||||||
QComboBox *_windows;
|
QComboBox *_windows;
|
||||||
RegexConfigWidget *_regex;
|
RegexConfigWidget *_regex;
|
||||||
QHBoxLayout *_infoLayout;
|
|
||||||
|
|
||||||
std::shared_ptr<MacroActionWindow> _entryData;
|
std::shared_ptr<MacroActionWindow> _entryData;
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
|
|||||||
@@ -61,49 +61,13 @@ MacroConditionAudio::~MacroConditionAudio()
|
|||||||
obs_volmeter_destroy(_volmeter);
|
obs_volmeter_destroy(_volmeter);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MacroConditionAudio::GetVolumePeak()
|
|
||||||
{
|
|
||||||
using namespace std::chrono_literals;
|
|
||||||
using namespace std::chrono;
|
|
||||||
static constexpr std::chrono::milliseconds timeout = 250ms;
|
|
||||||
|
|
||||||
// OBS might rarely not update _peak quickly enough when very low
|
|
||||||
// intervals are configured on the General tab.
|
|
||||||
// In that case _peak might be set to negative infinity still, which
|
|
||||||
// will result in unexpected behavior, so we use the previously valid
|
|
||||||
// peak value instead.
|
|
||||||
//
|
|
||||||
// If no volume update was received within a timeout window, however, it
|
|
||||||
// is assumed, that the source no longer produces any audio output and
|
|
||||||
// thus a peak volume value of negative infinity is used.
|
|
||||||
|
|
||||||
float peak;
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(_peakMutex);
|
|
||||||
auto msPassedSinceLastUpdate = duration_cast<milliseconds>(
|
|
||||||
high_resolution_clock::now() - _lastPeakUpdate);
|
|
||||||
if (_lastPeakUpdate.time_since_epoch().count() != 0 &&
|
|
||||||
msPassedSinceLastUpdate > timeout) {
|
|
||||||
peak = -std::numeric_limits<float>::infinity();
|
|
||||||
} else {
|
|
||||||
peak = _peakUpdated ? _peak : _previousPeak;
|
|
||||||
}
|
|
||||||
|
|
||||||
_previousPeak = peak;
|
|
||||||
_peak = -std::numeric_limits<float>::infinity();
|
|
||||||
_peakUpdated = false;
|
|
||||||
|
|
||||||
return peak;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionAudio::CheckOutputCondition()
|
bool MacroConditionAudio::CheckOutputCondition()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
OBSSourceAutoRelease source =
|
OBSSourceAutoRelease source =
|
||||||
obs_weak_source_get_source(_audioSource.GetSource());
|
obs_weak_source_get_source(_audioSource.GetSource());
|
||||||
|
|
||||||
float peak = GetVolumePeak();
|
double curVolume = _useDb ? _peak : DecibelToPercent(_peak) * 100;
|
||||||
double curVolume = _useDb ? peak : DecibelToPercent(peak) * 100;
|
|
||||||
|
|
||||||
switch (_outputCondition) {
|
switch (_outputCondition) {
|
||||||
case OutputCondition::ABOVE:
|
case OutputCondition::ABOVE:
|
||||||
@@ -128,6 +92,7 @@ bool MacroConditionAudio::CheckOutputCondition()
|
|||||||
SetTempVarValue("output_volume", std::to_string(curVolume));
|
SetTempVarValue("output_volume", std::to_string(curVolume));
|
||||||
|
|
||||||
// Reset for next check
|
// Reset for next check
|
||||||
|
_peak = -std::numeric_limits<float>::infinity();
|
||||||
if (_audioSource.GetType() == SourceSelection::Type::VARIABLE) {
|
if (_audioSource.GetType() == SourceSelection::Type::VARIABLE) {
|
||||||
ResetVolmeter();
|
ResetVolmeter();
|
||||||
}
|
}
|
||||||
@@ -364,14 +329,11 @@ void MacroConditionAudio::SetVolumeLevel(void *data, const float *,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(c->_peakMutex);
|
|
||||||
for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) {
|
for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) {
|
||||||
if (peak[i] > c->_peak) {
|
if (peak[i] > c->_peak) {
|
||||||
c->_peak = peak[i];
|
c->_peak = peak[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c->_peakUpdated = true;
|
|
||||||
c->_lastPeakUpdate = std::chrono::high_resolution_clock::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionAudio::ResetVolmeter()
|
void MacroConditionAudio::ResetVolmeter()
|
||||||
|
|||||||
@@ -71,14 +71,9 @@ private:
|
|||||||
bool CheckMonitor();
|
bool CheckMonitor();
|
||||||
bool CheckBalance();
|
bool CheckBalance();
|
||||||
void SetupTempVars();
|
void SetupTempVars();
|
||||||
float GetVolumePeak();
|
|
||||||
|
|
||||||
Type _checkType = Type::OUTPUT_VOLUME;
|
Type _checkType = Type::OUTPUT_VOLUME;
|
||||||
std::mutex _peakMutex;
|
|
||||||
float _peak = -std::numeric_limits<float>::infinity();
|
float _peak = -std::numeric_limits<float>::infinity();
|
||||||
float _previousPeak = -std::numeric_limits<float>::infinity();
|
|
||||||
bool _peakUpdated = false;
|
|
||||||
std::chrono::high_resolution_clock::time_point _lastPeakUpdate = {};
|
|
||||||
static bool _registered;
|
static bool _registered;
|
||||||
static const std::string id;
|
static const std::string id;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "macro-condition-clipboard.hpp"
|
#include "macro-condition-clipboard.hpp"
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
|
#include "ui-helpers.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
@@ -196,11 +197,19 @@ MacroConditionClipboardEdit::MacroConditionClipboardEdit(
|
|||||||
_conditions(new QComboBox(this)),
|
_conditions(new QComboBox(this)),
|
||||||
_text(new VariableTextEdit(this)),
|
_text(new VariableTextEdit(this)),
|
||||||
_regex(new RegexConfigWidget(parent)),
|
_regex(new RegexConfigWidget(parent)),
|
||||||
_urlInfo(new HelpIcon(obs_module_text(
|
_urlInfo(new QLabel())
|
||||||
"AdvSceneSwitcher.condition.clipboard.urlTooltip")))
|
|
||||||
{
|
{
|
||||||
populateCompareModeselection(_conditions);
|
populateCompareModeselection(_conditions);
|
||||||
|
|
||||||
|
QString path = GetThemeTypeName() == "Light"
|
||||||
|
? ":/res/images/help.svg"
|
||||||
|
: ":/res/images/help_light.svg";
|
||||||
|
QIcon icon(path);
|
||||||
|
QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
||||||
|
_urlInfo->setPixmap(pixmap);
|
||||||
_urlInfo->hide();
|
_urlInfo->hide();
|
||||||
|
_urlInfo->setToolTip(obs_module_text(
|
||||||
|
"AdvSceneSwitcher.condition.clipboard.urlTooltip"));
|
||||||
|
|
||||||
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
|
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
|
||||||
SLOT(ConditionChanged(int)));
|
SLOT(ConditionChanged(int)));
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "macro-condition-edit.hpp"
|
#include "macro-condition-edit.hpp"
|
||||||
#include "filter-combo-box.hpp"
|
#include "filter-combo-box.hpp"
|
||||||
#include "help-icon.hpp"
|
|
||||||
#include "message-buffer.hpp"
|
#include "message-buffer.hpp"
|
||||||
#include "message-dispatcher.hpp"
|
#include "message-dispatcher.hpp"
|
||||||
#include "regex-config.hpp"
|
#include "regex-config.hpp"
|
||||||
@@ -84,7 +83,7 @@ private:
|
|||||||
QComboBox *_conditions;
|
QComboBox *_conditions;
|
||||||
VariableTextEdit *_text;
|
VariableTextEdit *_text;
|
||||||
RegexConfigWidget *_regex;
|
RegexConfigWidget *_regex;
|
||||||
HelpIcon *_urlInfo;
|
QLabel *_urlInfo;
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionClipboard> _entryData;
|
std::shared_ptr<MacroConditionClipboard> _entryData;
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
|
|||||||
@@ -47,19 +47,17 @@ bool MacroConditionFilter::CheckConditionHelper(const OBSWeakSource &filter)
|
|||||||
case Condition::DISABLED:
|
case Condition::DISABLED:
|
||||||
ret = !obs_source_enabled(filterSource);
|
ret = !obs_source_enabled(filterSource);
|
||||||
break;
|
break;
|
||||||
case Condition::SETTINGS_MATCH: {
|
case Condition::SETTINGS_MATCH:
|
||||||
ret = CompareSourceSettings(filter, _settings, _regex);
|
ret = CompareSourceSettings(filter, _settings, _regex);
|
||||||
const auto settings = GetSourceSettings(filter);
|
if (IsReferencedInVars()) {
|
||||||
SetVariableValue(settings);
|
SetVariableValue(GetSourceSettings(filter));
|
||||||
SetTempVarValue("settings", settings);
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case Condition::SETTINGS_CHANGED: {
|
case Condition::SETTINGS_CHANGED: {
|
||||||
const auto settings = GetSourceSettings(filter);
|
std::string settings = GetSourceSettings(filter);
|
||||||
ret = !_currentSettings.empty() && settings != _currentSettings;
|
ret = !_currentSettings.empty() && settings != _currentSettings;
|
||||||
_currentSettings = settings;
|
_currentSettings = settings;
|
||||||
SetVariableValue(settings);
|
SetVariableValue(settings);
|
||||||
SetTempVarValue("settings", settings);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Condition::INDIVIDUAL_SETTING_MATCH: {
|
case Condition::INDIVIDUAL_SETTING_MATCH: {
|
||||||
@@ -70,7 +68,6 @@ bool MacroConditionFilter::CheckConditionHelper(const OBSWeakSource &filter)
|
|||||||
ret = _regex.Enabled() ? _regex.Matches(*value, _settings)
|
ret = _regex.Enabled() ? _regex.Matches(*value, _settings)
|
||||||
: value == std::string(_settings);
|
: value == std::string(_settings);
|
||||||
SetVariableValue(*value);
|
SetVariableValue(*value);
|
||||||
SetTempVarValue("setting", *value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Condition::INDIVIDUAL_SETTING_CHANGED: {
|
case Condition::INDIVIDUAL_SETTING_CHANGED: {
|
||||||
@@ -81,7 +78,6 @@ bool MacroConditionFilter::CheckConditionHelper(const OBSWeakSource &filter)
|
|||||||
ret = _currentSettingsValue != value;
|
ret = _currentSettingsValue != value;
|
||||||
_currentSettingsValue = *value;
|
_currentSettingsValue = *value;
|
||||||
SetVariableValue(*value);
|
SetVariableValue(*value);
|
||||||
SetTempVarValue("setting", *value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -126,8 +122,7 @@ bool MacroConditionFilter::Load(obs_data_t *obj)
|
|||||||
MacroCondition::Load(obj);
|
MacroCondition::Load(obj);
|
||||||
_source.Load(obj);
|
_source.Load(obj);
|
||||||
_filter.Load(obj, _source, "filter");
|
_filter.Load(obj, _source, "filter");
|
||||||
SetCondition(
|
_condition = static_cast<Condition>(obs_data_get_int(obj, "condition"));
|
||||||
static_cast<Condition>(obs_data_get_int(obj, "condition")));
|
|
||||||
_settings.Load(obj, "settings");
|
_settings.Load(obj, "settings");
|
||||||
_regex.Load(obj);
|
_regex.Load(obj);
|
||||||
// TOOD: remove in future version
|
// TOOD: remove in future version
|
||||||
@@ -147,37 +142,6 @@ std::string MacroConditionFilter::GetShortDesc() const
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionFilter::SetCondition(Condition cond)
|
|
||||||
{
|
|
||||||
_condition = cond;
|
|
||||||
SetupTempVars();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFilter::SetupTempVars()
|
|
||||||
{
|
|
||||||
MacroCondition::SetupTempVars();
|
|
||||||
switch (_condition) {
|
|
||||||
case Condition::ENABLED:
|
|
||||||
break;
|
|
||||||
case Condition::DISABLED:
|
|
||||||
break;
|
|
||||||
case Condition::SETTINGS_MATCH:
|
|
||||||
case Condition::SETTINGS_CHANGED:
|
|
||||||
AddTempvar("settings",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.filter.settings"));
|
|
||||||
break;
|
|
||||||
case Condition::INDIVIDUAL_SETTING_MATCH:
|
|
||||||
case Condition::INDIVIDUAL_SETTING_CHANGED:
|
|
||||||
AddTempvar("setting",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.filter.setting"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void populateConditionSelection(QComboBox *list)
|
static inline void populateConditionSelection(QComboBox *list)
|
||||||
{
|
{
|
||||||
for (const auto &[_, name] : filterConditionTypes) {
|
for (const auto &[_, name] : filterConditionTypes) {
|
||||||
@@ -299,8 +263,8 @@ void MacroConditionFilterEdit::ConditionChanged(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
_entryData->SetCondition(
|
_entryData->_condition =
|
||||||
static_cast<MacroConditionFilter::Condition>(index));
|
static_cast<MacroConditionFilter::Condition>(index);
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +283,7 @@ void MacroConditionFilterEdit::GetSettingsClicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
if (_entryData->GetCondition() ==
|
if (_entryData->_condition ==
|
||||||
MacroConditionFilter::Condition::SETTINGS_MATCH) {
|
MacroConditionFilter::Condition::SETTINGS_MATCH) {
|
||||||
value = FormatJsonString(GetSourceSettings(filters.at(0)));
|
value = FormatJsonString(GetSourceSettings(filters.at(0)));
|
||||||
} else {
|
} else {
|
||||||
@@ -382,22 +346,21 @@ void MacroConditionFilterEdit::RefreshVariableSourceSelectionValue()
|
|||||||
void MacroConditionFilterEdit::SetWidgetVisibility()
|
void MacroConditionFilterEdit::SetWidgetVisibility()
|
||||||
{
|
{
|
||||||
const bool showSettingsControls =
|
const bool showSettingsControls =
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition ==
|
||||||
MacroConditionFilter::Condition::SETTINGS_MATCH ||
|
MacroConditionFilter::Condition::SETTINGS_MATCH ||
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition ==
|
||||||
MacroConditionFilter::Condition::INDIVIDUAL_SETTING_MATCH;
|
MacroConditionFilter::Condition::INDIVIDUAL_SETTING_MATCH;
|
||||||
_settings->setVisible(showSettingsControls);
|
_settings->setVisible(showSettingsControls);
|
||||||
_getSettings->setVisible(showSettingsControls);
|
_getSettings->setVisible(showSettingsControls);
|
||||||
_regex->setVisible(showSettingsControls);
|
_regex->setVisible(showSettingsControls);
|
||||||
_settingSelection->setVisible(
|
_settingSelection->setVisible(
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition == MacroConditionFilter::Condition::
|
||||||
MacroConditionFilter::Condition::INDIVIDUAL_SETTING_MATCH ||
|
INDIVIDUAL_SETTING_MATCH ||
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition == MacroConditionFilter::Condition::
|
||||||
MacroConditionFilter::Condition::
|
INDIVIDUAL_SETTING_CHANGED);
|
||||||
INDIVIDUAL_SETTING_CHANGED);
|
|
||||||
_refreshSettingSelection->setVisible(
|
_refreshSettingSelection->setVisible(
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition == MacroConditionFilter::Condition::
|
||||||
MacroConditionFilter::Condition::INDIVIDUAL_SETTING_MATCH &&
|
INDIVIDUAL_SETTING_MATCH &&
|
||||||
(_entryData->_source.GetType() ==
|
(_entryData->_source.GetType() ==
|
||||||
SourceSelection::Type::VARIABLE ||
|
SourceSelection::Type::VARIABLE ||
|
||||||
_entryData->_filter.GetType() ==
|
_entryData->_filter.GetType() ==
|
||||||
@@ -414,8 +377,7 @@ void MacroConditionFilterEdit::UpdateEntryData()
|
|||||||
|
|
||||||
_sources->SetSource(_entryData->_source);
|
_sources->SetSource(_entryData->_source);
|
||||||
_filters->SetFilter(_entryData->_source, _entryData->_filter);
|
_filters->SetFilter(_entryData->_source, _entryData->_filter);
|
||||||
_conditions->setCurrentIndex(
|
_conditions->setCurrentIndex(static_cast<int>(_entryData->_condition));
|
||||||
static_cast<int>(_entryData->GetCondition()));
|
|
||||||
_settings->setPlainText(_entryData->_settings);
|
_settings->setPlainText(_entryData->_settings);
|
||||||
_regex->SetRegexConfig(_entryData->_regex);
|
_regex->SetRegexConfig(_entryData->_regex);
|
||||||
const auto filters =
|
const auto filters =
|
||||||
|
|||||||
@@ -33,20 +33,17 @@ public:
|
|||||||
INDIVIDUAL_SETTING_MATCH,
|
INDIVIDUAL_SETTING_MATCH,
|
||||||
INDIVIDUAL_SETTING_CHANGED,
|
INDIVIDUAL_SETTING_CHANGED,
|
||||||
};
|
};
|
||||||
void SetCondition(Condition);
|
|
||||||
Condition GetCondition() const { return _condition; }
|
|
||||||
|
|
||||||
SourceSelection _source;
|
SourceSelection _source;
|
||||||
FilterSelection _filter;
|
FilterSelection _filter;
|
||||||
|
Condition _condition = Condition::ENABLED;
|
||||||
StringVariable _settings = "";
|
StringVariable _settings = "";
|
||||||
RegexConfig _regex;
|
RegexConfig _regex;
|
||||||
SourceSetting _setting;
|
SourceSetting _setting;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupTempVars();
|
|
||||||
bool CheckConditionHelper(const OBSWeakSource &);
|
bool CheckConditionHelper(const OBSWeakSource &);
|
||||||
|
|
||||||
Condition _condition = Condition::ENABLED;
|
|
||||||
std::string _currentSettings;
|
std::string _currentSettings;
|
||||||
std::string _currentSettingsValue;
|
std::string _currentSettingsValue;
|
||||||
|
|
||||||
|
|||||||
@@ -1,407 +0,0 @@
|
|||||||
#include "macro-condition-folder.hpp"
|
|
||||||
#include "help-icon.hpp"
|
|
||||||
#include "macro-helpers.hpp"
|
|
||||||
#include "layout-helpers.hpp"
|
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
const std::string MacroConditionFolder::id = "folder";
|
|
||||||
|
|
||||||
bool MacroConditionFolder::_registered = MacroConditionFactory::Register(
|
|
||||||
MacroConditionFolder::id,
|
|
||||||
{MacroConditionFolder::Create, MacroConditionFolderEdit::Create,
|
|
||||||
"AdvSceneSwitcher.condition.folder"});
|
|
||||||
|
|
||||||
static const std::map<MacroConditionFolder::Condition, std::string> conditions =
|
|
||||||
{
|
|
||||||
{MacroConditionFolder::Condition::ANY,
|
|
||||||
"AdvSceneSwitcher.condition.folder.condition.any"},
|
|
||||||
{MacroConditionFolder::Condition::FILE_ADD,
|
|
||||||
"AdvSceneSwitcher.condition.folder.condition.fileAdd"},
|
|
||||||
{MacroConditionFolder::Condition::FILE_CHANGE,
|
|
||||||
"AdvSceneSwitcher.condition.folder.condition.fileChange"},
|
|
||||||
{MacroConditionFolder::Condition::FILE_REMOVE,
|
|
||||||
"AdvSceneSwitcher.condition.folder.condition.fileRemove"},
|
|
||||||
{MacroConditionFolder::Condition::FOLDER_ADD,
|
|
||||||
"AdvSceneSwitcher.condition.folder.condition.folderAdd"},
|
|
||||||
{MacroConditionFolder::Condition::FOLDER_REMOVE,
|
|
||||||
"AdvSceneSwitcher.condition.folder.condition.folderRemove"},
|
|
||||||
};
|
|
||||||
|
|
||||||
MacroConditionFolder::MacroConditionFolder(Macro *m) : MacroCondition(m, true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionFolder::CheckCondition()
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
bool ret = _matched;
|
|
||||||
if (_lastWatchedValue != _folder.UnresolvedValue()) {
|
|
||||||
SetupWatcher();
|
|
||||||
}
|
|
||||||
|
|
||||||
SetTempVarValues();
|
|
||||||
|
|
||||||
_newFiles.clear();
|
|
||||||
_changedFiles.clear();
|
|
||||||
_removedFiles.clear();
|
|
||||||
_newDirs.clear();
|
|
||||||
_removedDirs.clear();
|
|
||||||
_matched = false;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionFolder::Save(obs_data_t *obj) const
|
|
||||||
{
|
|
||||||
MacroCondition::Save(obj);
|
|
||||||
_folder.Save(obj, "file");
|
|
||||||
obs_data_set_bool(obj, "enableFilter", _enableFilter);
|
|
||||||
_regex.Save(obj);
|
|
||||||
_filter.Save(obj, "filter");
|
|
||||||
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionFolder::Load(obs_data_t *obj)
|
|
||||||
{
|
|
||||||
MacroCondition::Load(obj);
|
|
||||||
_folder.Load(obj, "file");
|
|
||||||
_enableFilter = obs_data_get_bool(obj, "enableFilter");
|
|
||||||
_regex.Load(obj);
|
|
||||||
_regex.SetEnabled(true); // Already controlled via _enableFilter
|
|
||||||
_filter.Load(obj, "filter");
|
|
||||||
_condition = static_cast<Condition>(obs_data_get_int(obj, "condition"));
|
|
||||||
SetupWatcher();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MacroConditionFolder::GetShortDesc() const
|
|
||||||
{
|
|
||||||
return _folder.UnresolvedValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolder::SetFolder(const std::string &folder)
|
|
||||||
{
|
|
||||||
_folder = folder;
|
|
||||||
SetupWatcher();
|
|
||||||
}
|
|
||||||
|
|
||||||
static QSet<QString> getFilesInDir(const QString &path)
|
|
||||||
{
|
|
||||||
QSet<QString> result;
|
|
||||||
for (const auto &file : QDir(path).entryList(QDir::Files)) {
|
|
||||||
result << file;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QSet<QString> getDirsInDir(const QString &path)
|
|
||||||
{
|
|
||||||
QSet<QString> result;
|
|
||||||
for (const auto &dir : QDir(path).entryList(QDir::AllDirs)) {
|
|
||||||
result << dir;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reduceSetToPatternMatch(QSet<QString> &set,
|
|
||||||
const RegexConfig ®ex,
|
|
||||||
const std::string &pattern)
|
|
||||||
{
|
|
||||||
QSet<QString> copy = set;
|
|
||||||
for (const auto &value : copy) {
|
|
||||||
if (!regex.Matches(value.toStdString(), pattern)) {
|
|
||||||
set.remove(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolder::DirectoryChanged(const QString &path)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
if (MacroIsPaused(GetMacro())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto currentFiles = getFilesInDir(path);
|
|
||||||
auto currentDirs = getDirsInDir(path);
|
|
||||||
|
|
||||||
if (currentFiles.count() > _currentFiles.count()) {
|
|
||||||
_newFiles += currentFiles - _currentFiles;
|
|
||||||
} else {
|
|
||||||
_removedFiles += _currentFiles - currentFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentDirs.count() > _currentDirs.count()) {
|
|
||||||
_newDirs += currentDirs - _currentDirs;
|
|
||||||
} else {
|
|
||||||
_removedDirs += _currentDirs - currentDirs;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_enableFilter) {
|
|
||||||
reduceSetToPatternMatch(_newFiles, _regex, _filter);
|
|
||||||
reduceSetToPatternMatch(_removedFiles, _regex, _filter);
|
|
||||||
reduceSetToPatternMatch(_newDirs, _regex, _filter);
|
|
||||||
reduceSetToPatternMatch(_removedDirs, _regex, _filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (_condition) {
|
|
||||||
case Condition::ANY:
|
|
||||||
_matched = _matched || _newFiles.count() > 0 ||
|
|
||||||
_removedFiles.count() > 0 || _newDirs.count() > 0 ||
|
|
||||||
_removedDirs.count() > 0;
|
|
||||||
break;
|
|
||||||
case Condition::FILE_ADD:
|
|
||||||
_matched = _newFiles.count() > 0;
|
|
||||||
break;
|
|
||||||
case Condition::FILE_REMOVE:
|
|
||||||
_matched = _removedFiles.count() > 0;
|
|
||||||
break;
|
|
||||||
case Condition::FOLDER_ADD:
|
|
||||||
_matched = _newDirs.count() > 0;
|
|
||||||
break;
|
|
||||||
case Condition::FOLDER_REMOVE:
|
|
||||||
_matched = _removedDirs.count() > 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto &newFile : _newFiles) {
|
|
||||||
_watcher->addPath(path + "/" + newFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentFiles = currentFiles;
|
|
||||||
_currentDirs = currentDirs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolder::FileChanged(const QString &path)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
QFileInfo fileInfo(path);
|
|
||||||
if (!fileInfo.exists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto fileName = fileInfo.fileName();
|
|
||||||
if (_enableFilter && !_regex.Matches(fileName.toStdString(), _filter)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_changedFiles << fileName;
|
|
||||||
if (_condition == Condition::FILE_CHANGE ||
|
|
||||||
_condition == Condition::ANY) {
|
|
||||||
_matched = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static QStringList getFileWatcherList(const QSet<QString> &files,
|
|
||||||
const QString &dirName)
|
|
||||||
{
|
|
||||||
QStringList list;
|
|
||||||
for (const auto &value : files) {
|
|
||||||
list << (dirName + "/" + value);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolder::SetupWatcher()
|
|
||||||
{
|
|
||||||
_watcher = std::make_unique<QFileSystemWatcher>();
|
|
||||||
const auto path = QString::fromStdString(_folder);
|
|
||||||
_currentFiles = getFilesInDir(path);
|
|
||||||
_currentDirs = getDirsInDir(path);
|
|
||||||
_lastWatchedValue = _folder.UnresolvedValue();
|
|
||||||
connect(_watcher.get(), SIGNAL(directoryChanged(const QString &)), this,
|
|
||||||
SLOT(DirectoryChanged(const QString &)));
|
|
||||||
connect(_watcher.get(), SIGNAL(fileChanged(const QString &)), this,
|
|
||||||
SLOT(FileChanged(const QString &)));
|
|
||||||
_watcher.get()->addPaths(getFileWatcherList(_currentFiles, path));
|
|
||||||
_watcher->addPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolder::SetTempVarValues()
|
|
||||||
{
|
|
||||||
auto setVarHelper = [this](const QSet<QString> &set,
|
|
||||||
const std::string &id) {
|
|
||||||
std::string result;
|
|
||||||
for (const auto &value : set) {
|
|
||||||
result += value.toStdString() + "\n";
|
|
||||||
}
|
|
||||||
if (result.size() > 0) {
|
|
||||||
result.pop_back();
|
|
||||||
}
|
|
||||||
SetTempVarValue(id, result);
|
|
||||||
};
|
|
||||||
|
|
||||||
setVarHelper(_newFiles, "newFiles");
|
|
||||||
setVarHelper(_changedFiles, "changedFiles");
|
|
||||||
setVarHelper(_removedFiles, "removedFiles");
|
|
||||||
setVarHelper(_newDirs, "newDirs");
|
|
||||||
setVarHelper(_removedDirs, "removedDirs");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolder::SetupTempVars()
|
|
||||||
{
|
|
||||||
MacroCondition::SetupTempVars();
|
|
||||||
AddTempvar("newFiles",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.folder.newFiles"));
|
|
||||||
AddTempvar("changedFiles",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.folder.changedFiles"));
|
|
||||||
AddTempvar("removedFiles",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.folder.removedFiles"));
|
|
||||||
AddTempvar("newDirs",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.folder.newDirs"));
|
|
||||||
AddTempvar(
|
|
||||||
"removedDirs",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.folder.removedDirs"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void populateConditions(QComboBox *list)
|
|
||||||
{
|
|
||||||
for (const auto &[value, name] : conditions) {
|
|
||||||
list->addItem(obs_module_text(name.c_str()),
|
|
||||||
static_cast<int>(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MacroConditionFolderEdit::MacroConditionFolderEdit(
|
|
||||||
QWidget *parent, std::shared_ptr<MacroConditionFolder> entryData)
|
|
||||||
: QWidget(parent),
|
|
||||||
_conditions(new QComboBox()),
|
|
||||||
_folder(new FileSelection(FileSelection::Type::FOLDER)),
|
|
||||||
_enableFilter(new QCheckBox(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.condition.folder.enableFilter"))),
|
|
||||||
_filterLayout(new QHBoxLayout()),
|
|
||||||
_regex(new RegexConfigWidget(this, false)),
|
|
||||||
_filter(new VariableLineEdit(this))
|
|
||||||
{
|
|
||||||
populateConditions(_conditions);
|
|
||||||
|
|
||||||
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
|
|
||||||
SLOT(ConditionChanged(int)));
|
|
||||||
QWidget::connect(_folder, SIGNAL(PathChanged(const QString &)), this,
|
|
||||||
SLOT(PathChanged(const QString &)));
|
|
||||||
QWidget::connect(_enableFilter, SIGNAL(stateChanged(int)), this,
|
|
||||||
SLOT(EnableFilterChanged(int)));
|
|
||||||
QWidget::connect(_regex,
|
|
||||||
SIGNAL(RegexConfigChanged(const RegexConfig &)), this,
|
|
||||||
SLOT(RegexChanged(const RegexConfig &)));
|
|
||||||
QWidget::connect(_filter, SIGNAL(editingFinished()), this,
|
|
||||||
SLOT(FilterChanged()));
|
|
||||||
|
|
||||||
auto tooltipLabel = new HelpIcon(
|
|
||||||
obs_module_text("AdvSceneSwitcher.condition.folder.tooltip"));
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
|
||||||
{"{{conditions}}", _conditions}, {"{{folder}}", _folder},
|
|
||||||
{"{{tooltip}}", tooltipLabel}, {"{{regex}}", _regex},
|
|
||||||
{"{{filter}}", _filter},
|
|
||||||
};
|
|
||||||
|
|
||||||
auto entryLayout = new QHBoxLayout();
|
|
||||||
entryLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.condition.folder.entry"),
|
|
||||||
entryLayout, widgetPlaceholders, false);
|
|
||||||
_filterLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
PlaceWidgets(obs_module_text(
|
|
||||||
"AdvSceneSwitcher.condition.folder.entry.filter"),
|
|
||||||
_filterLayout, widgetPlaceholders, false);
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout();
|
|
||||||
layout->addLayout(entryLayout);
|
|
||||||
layout->addWidget(_enableFilter);
|
|
||||||
layout->addLayout(_filterLayout);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
_entryData = entryData;
|
|
||||||
UpdateEntryData();
|
|
||||||
_loading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::UpdateEntryData()
|
|
||||||
{
|
|
||||||
if (!_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_conditions->setCurrentIndex(_conditions->findData(
|
|
||||||
static_cast<int>(_entryData->_condition)));
|
|
||||||
_folder->SetPath(_entryData->GetFolder());
|
|
||||||
_enableFilter->setChecked(_entryData->_enableFilter);
|
|
||||||
_regex->SetRegexConfig(_entryData->_regex);
|
|
||||||
_filter->setText(_entryData->_filter);
|
|
||||||
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::ConditionChanged(int index)
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->_condition = static_cast<MacroConditionFolder::Condition>(
|
|
||||||
_conditions->itemData(index).toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::PathChanged(const QString &text)
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->SetFolder(text.toStdString());
|
|
||||||
emit HeaderInfoChanged(
|
|
||||||
QString::fromStdString(_entryData->GetShortDesc()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::RegexChanged(const RegexConfig ®ex)
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->_regex = regex;
|
|
||||||
_entryData->_regex.SetEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::FilterChanged()
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->_filter = _filter->text().toStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::EnableFilterChanged(int value)
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->_enableFilter = value;
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionFolderEdit::SetWidgetVisibility()
|
|
||||||
{
|
|
||||||
SetLayoutVisible(_filterLayout, _entryData->_enableFilter);
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "macro-condition-edit.hpp"
|
|
||||||
#include "file-selection.hpp"
|
|
||||||
#include "regex-config.hpp"
|
|
||||||
#include "variable-line-edit.hpp"
|
|
||||||
|
|
||||||
#include <QFileSystemWatcher>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
class MacroConditionFolder : public QObject, public MacroCondition {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MacroConditionFolder(Macro *m);
|
|
||||||
bool CheckCondition();
|
|
||||||
bool Save(obs_data_t *obj) const;
|
|
||||||
bool Load(obs_data_t *obj);
|
|
||||||
std::string GetShortDesc() const;
|
|
||||||
std::string GetId() const { return id; };
|
|
||||||
static std::shared_ptr<MacroCondition> Create(Macro *m)
|
|
||||||
{
|
|
||||||
return std::make_shared<MacroConditionFolder>(m);
|
|
||||||
}
|
|
||||||
void SetFolder(const std::string &);
|
|
||||||
StringVariable GetFolder() const { return _folder; }
|
|
||||||
|
|
||||||
enum class Condition {
|
|
||||||
ANY,
|
|
||||||
FILE_ADD,
|
|
||||||
FILE_CHANGE,
|
|
||||||
FILE_REMOVE,
|
|
||||||
FOLDER_ADD,
|
|
||||||
FOLDER_REMOVE,
|
|
||||||
};
|
|
||||||
|
|
||||||
Condition _condition = Condition::ANY;
|
|
||||||
bool _enableFilter = false;
|
|
||||||
RegexConfig _regex = RegexConfig(true);
|
|
||||||
StringVariable _filter = ".*";
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void DirectoryChanged(const QString &);
|
|
||||||
void FileChanged(const QString &);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SetupWatcher();
|
|
||||||
void SetTempVarValues();
|
|
||||||
void SetupTempVars();
|
|
||||||
|
|
||||||
StringVariable _folder = obs_module_text("AdvSceneSwitcher.enterPath");
|
|
||||||
|
|
||||||
std::unique_ptr<QFileSystemWatcher> _watcher;
|
|
||||||
std::string _lastWatchedValue = "";
|
|
||||||
|
|
||||||
std::mutex _mutex;
|
|
||||||
bool _matched = false;
|
|
||||||
QSet<QString> _newFiles;
|
|
||||||
QSet<QString> _changedFiles;
|
|
||||||
QSet<QString> _removedFiles;
|
|
||||||
QSet<QString> _newDirs;
|
|
||||||
QSet<QString> _removedDirs;
|
|
||||||
QSet<QString> _currentFiles;
|
|
||||||
QSet<QString> _currentDirs;
|
|
||||||
|
|
||||||
static bool _registered;
|
|
||||||
static const std::string id;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MacroConditionFolderEdit : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MacroConditionFolderEdit(
|
|
||||||
QWidget *parent,
|
|
||||||
std::shared_ptr<MacroConditionFolder> cond = nullptr);
|
|
||||||
void UpdateEntryData();
|
|
||||||
static QWidget *Create(QWidget *parent,
|
|
||||||
std::shared_ptr<MacroCondition> cond)
|
|
||||||
{
|
|
||||||
return new MacroConditionFolderEdit(
|
|
||||||
parent,
|
|
||||||
std::dynamic_pointer_cast<MacroConditionFolder>(cond));
|
|
||||||
}
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void ConditionChanged(int index);
|
|
||||||
void PathChanged(const QString &text);
|
|
||||||
void EnableFilterChanged(int value);
|
|
||||||
void RegexChanged(const RegexConfig &);
|
|
||||||
void FilterChanged();
|
|
||||||
signals:
|
|
||||||
void HeaderInfoChanged(const QString &);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SetWidgetVisibility();
|
|
||||||
|
|
||||||
QComboBox *_conditions;
|
|
||||||
FileSelection *_folder;
|
|
||||||
QCheckBox *_enableFilter;
|
|
||||||
QHBoxLayout *_filterLayout;
|
|
||||||
RegexConfigWidget *_regex;
|
|
||||||
VariableLineEdit *_filter;
|
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionFolder> _entryData;
|
|
||||||
bool _loading = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -45,13 +45,11 @@ static bool setupReplayBufferEventHandler()
|
|||||||
|
|
||||||
bool MacroConditionReplayBuffer::ReplayBufferWasSaved()
|
bool MacroConditionReplayBuffer::ReplayBufferWasSaved()
|
||||||
{
|
{
|
||||||
if (!_saveTimeInitialized) {
|
bool timersAreInitialized =
|
||||||
_saveTime = replayBufferSaveTime;
|
_saveTime.time_since_epoch().count() != 0 &&
|
||||||
_saveTimeInitialized = true;
|
replayBufferSaveTime.time_since_epoch().count() != 0;
|
||||||
return false;
|
bool newSaveOccurred = timersAreInitialized &&
|
||||||
}
|
_saveTime != replayBufferSaveTime;
|
||||||
|
|
||||||
bool newSaveOccurred = _saveTime != replayBufferSaveTime;
|
|
||||||
_saveTime = replayBufferSaveTime;
|
_saveTime = replayBufferSaveTime;
|
||||||
return newSaveOccurred;
|
return newSaveOccurred;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool ReplayBufferWasSaved();
|
bool ReplayBufferWasSaved();
|
||||||
|
|
||||||
bool _saveTimeInitialized = false;
|
|
||||||
std::chrono::high_resolution_clock::time_point _saveTime = {};
|
std::chrono::high_resolution_clock::time_point _saveTime = {};
|
||||||
static bool _registered;
|
static bool _registered;
|
||||||
static const std::string id;
|
static const std::string id;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ bool MacroConditionSource::_registered = MacroConditionFactory::Register(
|
|||||||
{MacroConditionSource::Create, MacroConditionSourceEdit::Create,
|
{MacroConditionSource::Create, MacroConditionSourceEdit::Create,
|
||||||
"AdvSceneSwitcher.condition.source"});
|
"AdvSceneSwitcher.condition.source"});
|
||||||
|
|
||||||
static const std::map<MacroConditionSource::Condition, std::string>
|
const static std::map<MacroConditionSource::Condition, std::string>
|
||||||
sourceConditionTypes = {
|
sourceCnditionTypes = {
|
||||||
{MacroConditionSource::Condition::ACTIVE,
|
{MacroConditionSource::Condition::ACTIVE,
|
||||||
"AdvSceneSwitcher.condition.source.type.active"},
|
"AdvSceneSwitcher.condition.source.type.active"},
|
||||||
{MacroConditionSource::Condition::SHOWING,
|
{MacroConditionSource::Condition::SHOWING,
|
||||||
@@ -28,38 +28,8 @@ static const std::map<MacroConditionSource::Condition, std::string>
|
|||||||
"AdvSceneSwitcher.condition.source.type.individualSettingMatches"},
|
"AdvSceneSwitcher.condition.source.type.individualSettingMatches"},
|
||||||
{MacroConditionSource::Condition::INDIVIDUAL_SETTING_CHANGED,
|
{MacroConditionSource::Condition::INDIVIDUAL_SETTING_CHANGED,
|
||||||
"AdvSceneSwitcher.condition.source.type.individualSettingChanged"},
|
"AdvSceneSwitcher.condition.source.type.individualSettingChanged"},
|
||||||
{MacroConditionSource::Condition::HEIGHT,
|
|
||||||
"AdvSceneSwitcher.condition.source.type.height"},
|
|
||||||
{MacroConditionSource::Condition::WIDTH,
|
|
||||||
"AdvSceneSwitcher.condition.source.type.width"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::map<MacroConditionSource::SizeComparision, std::string>
|
|
||||||
compareMethods = {
|
|
||||||
{MacroConditionSource::SizeComparision::LESS,
|
|
||||||
"AdvSceneSwitcher.condition.source.sizeCompare.less"},
|
|
||||||
{MacroConditionSource::SizeComparision::EQUAL,
|
|
||||||
"AdvSceneSwitcher.condition.source.sizeCompare.equal"},
|
|
||||||
{MacroConditionSource::SizeComparision::MORE,
|
|
||||||
"AdvSceneSwitcher.condition.source.sizeCompare.more"},
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool compareSourceSize(MacroConditionSource::SizeComparision method,
|
|
||||||
int sourceValue, int compareValue)
|
|
||||||
{
|
|
||||||
switch (method) {
|
|
||||||
case MacroConditionSource::SizeComparision::LESS:
|
|
||||||
return sourceValue < compareValue;
|
|
||||||
case MacroConditionSource::SizeComparision::EQUAL:
|
|
||||||
return sourceValue == compareValue;
|
|
||||||
case MacroConditionSource::SizeComparision::MORE:
|
|
||||||
return sourceValue > compareValue;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionSource::CheckCondition()
|
bool MacroConditionSource::CheckCondition()
|
||||||
{
|
{
|
||||||
if (!_source.GetSource()) {
|
if (!_source.GetSource()) {
|
||||||
@@ -77,24 +47,23 @@ bool MacroConditionSource::CheckCondition()
|
|||||||
case Condition::SHOWING:
|
case Condition::SHOWING:
|
||||||
ret = obs_source_showing(s);
|
ret = obs_source_showing(s);
|
||||||
break;
|
break;
|
||||||
case Condition::ALL_SETTINGS_MATCH: {
|
case Condition::ALL_SETTINGS_MATCH:
|
||||||
ret = CompareSourceSettings(_source.GetSource(), _settings,
|
ret = CompareSourceSettings(_source.GetSource(), _settings,
|
||||||
_regex);
|
_regex);
|
||||||
const auto settings = GetSourceSettings(_source.GetSource());
|
if (IsReferencedInVars()) {
|
||||||
SetVariableValue(settings);
|
SetVariableValue(
|
||||||
SetTempVarValue("settings", settings);
|
GetSourceSettings(_source.GetSource()));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case Condition::SETTINGS_CHANGED: {
|
case Condition::SETTINGS_CHANGED: {
|
||||||
const auto settings = GetSourceSettings(_source.GetSource());
|
std::string settings = GetSourceSettings(_source.GetSource());
|
||||||
ret = !_currentSettings.empty() && settings != _currentSettings;
|
ret = !_currentSettings.empty() && settings != _currentSettings;
|
||||||
_currentSettings = settings;
|
_currentSettings = settings;
|
||||||
SetVariableValue(settings);
|
SetVariableValue(settings);
|
||||||
SetTempVarValue("settings", settings);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Condition::INDIVIDUAL_SETTING_MATCH: {
|
case Condition::INDIVIDUAL_SETTING_MATCH: {
|
||||||
const auto value =
|
auto value =
|
||||||
GetSourceSettingValue(_source.GetSource(), _setting);
|
GetSourceSettingValue(_source.GetSource(), _setting);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return false;
|
return false;
|
||||||
@@ -102,11 +71,10 @@ bool MacroConditionSource::CheckCondition()
|
|||||||
ret = _regex.Enabled() ? _regex.Matches(*value, _settings)
|
ret = _regex.Enabled() ? _regex.Matches(*value, _settings)
|
||||||
: value == std::string(_settings);
|
: value == std::string(_settings);
|
||||||
SetVariableValue(*value);
|
SetVariableValue(*value);
|
||||||
SetTempVarValue("setting", *value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Condition::INDIVIDUAL_SETTING_CHANGED: {
|
case Condition::INDIVIDUAL_SETTING_CHANGED: {
|
||||||
const auto value =
|
auto value =
|
||||||
GetSourceSettingValue(_source.GetSource(), _setting);
|
GetSourceSettingValue(_source.GetSource(), _setting);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return false;
|
return false;
|
||||||
@@ -114,19 +82,6 @@ bool MacroConditionSource::CheckCondition()
|
|||||||
ret = _currentSettingsValue != *value;
|
ret = _currentSettingsValue != *value;
|
||||||
_currentSettingsValue = *value;
|
_currentSettingsValue = *value;
|
||||||
SetVariableValue(*value);
|
SetVariableValue(*value);
|
||||||
SetTempVarValue("setting", *value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Condition::HEIGHT: {
|
|
||||||
const auto height = obs_source_get_height(s);
|
|
||||||
ret = compareSourceSize(_comparision, height, _size);
|
|
||||||
SetTempVarValue("height", std::to_string(height));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Condition::WIDTH: {
|
|
||||||
const auto width = obs_source_get_width(s);
|
|
||||||
ret = compareSourceSize(_comparision, width, _size);
|
|
||||||
SetTempVarValue("width", std::to_string(width));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -148,9 +103,6 @@ bool MacroConditionSource::Save(obs_data_t *obj) const
|
|||||||
_settings.Save(obj, "settings");
|
_settings.Save(obj, "settings");
|
||||||
_regex.Save(obj);
|
_regex.Save(obj);
|
||||||
_setting.Save(obj);
|
_setting.Save(obj);
|
||||||
_size.Save(obj, "size");
|
|
||||||
obs_data_set_int(obj, "sizeComparisionMethod",
|
|
||||||
static_cast<int>(_comparision));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +110,7 @@ bool MacroConditionSource::Load(obs_data_t *obj)
|
|||||||
{
|
{
|
||||||
MacroCondition::Load(obj);
|
MacroCondition::Load(obj);
|
||||||
_source.Load(obj);
|
_source.Load(obj);
|
||||||
SetCondition(
|
_condition = static_cast<Condition>(obs_data_get_int(obj, "condition"));
|
||||||
static_cast<Condition>(obs_data_get_int(obj, "condition")));
|
|
||||||
_settings.Load(obj, "settings");
|
_settings.Load(obj, "settings");
|
||||||
_regex.Load(obj);
|
_regex.Load(obj);
|
||||||
// TOOD: remove in future version
|
// TOOD: remove in future version
|
||||||
@@ -168,9 +119,6 @@ bool MacroConditionSource::Load(obs_data_t *obj)
|
|||||||
obs_data_get_bool(obj, "regex"));
|
obs_data_get_bool(obj, "regex"));
|
||||||
}
|
}
|
||||||
_setting.Load(obj);
|
_setting.Load(obj);
|
||||||
_size.Load(obj, "size");
|
|
||||||
_comparision = static_cast<SizeComparision>(
|
|
||||||
obs_data_get_int(obj, "sizeComparisionMethod"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,52 +127,9 @@ std::string MacroConditionSource::GetShortDesc() const
|
|||||||
return _source.ToString();
|
return _source.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionSource::SetCondition(Condition cond)
|
static inline void populateConditionSelection(QComboBox *list)
|
||||||
{
|
{
|
||||||
_condition = cond;
|
for (const auto &[_, name] : sourceCnditionTypes) {
|
||||||
SetupTempVars();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionSource::SetupTempVars()
|
|
||||||
{
|
|
||||||
MacroCondition::SetupTempVars();
|
|
||||||
switch (_condition) {
|
|
||||||
case Condition::ACTIVE:
|
|
||||||
break;
|
|
||||||
case Condition::SHOWING:
|
|
||||||
break;
|
|
||||||
case Condition::ALL_SETTINGS_MATCH:
|
|
||||||
case Condition::SETTINGS_CHANGED:
|
|
||||||
AddTempvar("settings",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.source.settings"));
|
|
||||||
break;
|
|
||||||
case Condition::INDIVIDUAL_SETTING_MATCH:
|
|
||||||
case Condition::INDIVIDUAL_SETTING_CHANGED:
|
|
||||||
AddTempvar("setting",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.source.setting"));
|
|
||||||
break;
|
|
||||||
case Condition::HEIGHT:
|
|
||||||
AddTempvar("height",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.source.height"));
|
|
||||||
break;
|
|
||||||
case Condition::WIDTH:
|
|
||||||
AddTempvar("width",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.source.width"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
static inline void populateSelection(QComboBox *list,
|
|
||||||
const std::map<T, std::string> &map)
|
|
||||||
{
|
|
||||||
for (const auto &[_, name] : map) {
|
|
||||||
list->addItem(obs_module_text(name.c_str()));
|
list->addItem(obs_module_text(name.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,13 +144,10 @@ MacroConditionSourceEdit::MacroConditionSourceEdit(
|
|||||||
_settings(new VariableTextEdit(this)),
|
_settings(new VariableTextEdit(this)),
|
||||||
_regex(new RegexConfigWidget(parent)),
|
_regex(new RegexConfigWidget(parent)),
|
||||||
_settingSelection(new SourceSettingSelection()),
|
_settingSelection(new SourceSettingSelection()),
|
||||||
_refreshSettingSelection(new QPushButton(obs_module_text(
|
_refreshSettingSelection(new QPushButton(
|
||||||
"AdvSceneSwitcher.condition.source.refresh"))),
|
obs_module_text("AdvSceneSwitcher.condition.source.refresh")))
|
||||||
_size(new VariableSpinBox(this)),
|
|
||||||
_sizeCompareMethods(new QComboBox())
|
|
||||||
{
|
{
|
||||||
populateSelection(_conditions, sourceConditionTypes);
|
populateConditionSelection(_conditions);
|
||||||
populateSelection(_sizeCompareMethods, compareMethods);
|
|
||||||
auto sources = GetSourceNames();
|
auto sources = GetSourceNames();
|
||||||
sources.sort();
|
sources.sort();
|
||||||
auto scenes = GetSceneNames();
|
auto scenes = GetSceneNames();
|
||||||
@@ -253,7 +155,6 @@ MacroConditionSourceEdit::MacroConditionSourceEdit(
|
|||||||
_sources->SetSourceNameList(sources + scenes);
|
_sources->SetSourceNameList(sources + scenes);
|
||||||
_refreshSettingSelection->setToolTip(obs_module_text(
|
_refreshSettingSelection->setToolTip(obs_module_text(
|
||||||
"AdvSceneSwitcher.condition.source.refreshTooltip"));
|
"AdvSceneSwitcher.condition.source.refreshTooltip"));
|
||||||
_size->setMaximum(999999);
|
|
||||||
|
|
||||||
QWidget::connect(_sources,
|
QWidget::connect(_sources,
|
||||||
SIGNAL(SourceChanged(const SourceSelection &)), this,
|
SIGNAL(SourceChanged(const SourceSelection &)), this,
|
||||||
@@ -272,36 +173,31 @@ MacroConditionSourceEdit::MacroConditionSourceEdit(
|
|||||||
SLOT(SettingSelectionChanged(const SourceSetting &)));
|
SLOT(SettingSelectionChanged(const SourceSetting &)));
|
||||||
QWidget::connect(_refreshSettingSelection, SIGNAL(clicked()), this,
|
QWidget::connect(_refreshSettingSelection, SIGNAL(clicked()), this,
|
||||||
SLOT(RefreshVariableSourceSelectionValue()));
|
SLOT(RefreshVariableSourceSelectionValue()));
|
||||||
QWidget::connect(
|
|
||||||
_size,
|
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||||
SIGNAL(NumberVariableChanged(const NumberVariable<int> &)),
|
{"{{sources}}", _sources},
|
||||||
this, SLOT(SizeChanged(const NumberVariable<int> &)));
|
{"{{conditions}}", _conditions},
|
||||||
QWidget::connect(_sizeCompareMethods, SIGNAL(currentIndexChanged(int)),
|
{"{{settings}}", _settings},
|
||||||
this, SLOT(CompareMethodChanged(int)));
|
{"{{getSettings}}", _getSettings},
|
||||||
|
{"{{regex}}", _regex},
|
||||||
|
{"{{settingSelection}}", _settingSelection},
|
||||||
|
{"{{refresh}}", _refreshSettingSelection}};
|
||||||
|
|
||||||
auto line1Layout = new QHBoxLayout;
|
auto line1Layout = new QHBoxLayout;
|
||||||
line1Layout->setContentsMargins(0, 0, 0, 0);
|
line1Layout->setContentsMargins(0, 0, 0, 0);
|
||||||
PlaceWidgets(obs_module_text(
|
PlaceWidgets(obs_module_text(
|
||||||
"AdvSceneSwitcher.condition.source.entry.line1"),
|
"AdvSceneSwitcher.condition.source.entry.line1"),
|
||||||
line1Layout,
|
line1Layout, widgetPlaceholders);
|
||||||
{{"{{sources}}", _sources},
|
|
||||||
{"{{conditions}}", _conditions},
|
|
||||||
{"{{settingSelection}}", _settingSelection},
|
|
||||||
{"{{refresh}}", _refreshSettingSelection},
|
|
||||||
{"{{size}}", _size},
|
|
||||||
{"{{sizeCompareMethods}}", _sizeCompareMethods}});
|
|
||||||
auto line2Layout = new QHBoxLayout;
|
auto line2Layout = new QHBoxLayout;
|
||||||
line2Layout->setContentsMargins(0, 0, 0, 0);
|
line2Layout->setContentsMargins(0, 0, 0, 0);
|
||||||
PlaceWidgets(obs_module_text(
|
PlaceWidgets(obs_module_text(
|
||||||
"AdvSceneSwitcher.condition.source.entry.line2"),
|
"AdvSceneSwitcher.condition.source.entry.line2"),
|
||||||
line2Layout, {{"{{settings}}", _settings}}, false);
|
line2Layout, widgetPlaceholders, false);
|
||||||
auto line3Layout = new QHBoxLayout;
|
auto line3Layout = new QHBoxLayout;
|
||||||
line3Layout->setContentsMargins(0, 0, 0, 0);
|
line3Layout->setContentsMargins(0, 0, 0, 0);
|
||||||
PlaceWidgets(obs_module_text(
|
PlaceWidgets(obs_module_text(
|
||||||
"AdvSceneSwitcher.condition.source.entry.line3"),
|
"AdvSceneSwitcher.condition.source.entry.line3"),
|
||||||
line3Layout,
|
line3Layout, widgetPlaceholders);
|
||||||
{{"{{getSettings}}", _getSettings}, {"{{regex}}", _regex}},
|
|
||||||
true);
|
|
||||||
auto mainLayout = new QVBoxLayout;
|
auto mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(line1Layout);
|
mainLayout->addLayout(line1Layout);
|
||||||
mainLayout->addLayout(line2Layout);
|
mainLayout->addLayout(line2Layout);
|
||||||
@@ -336,8 +232,8 @@ void MacroConditionSourceEdit::ConditionChanged(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
_entryData->SetCondition(
|
_entryData->_condition =
|
||||||
static_cast<MacroConditionSource::Condition>(index));
|
static_cast<MacroConditionSource::Condition>(index);
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +244,7 @@ void MacroConditionSourceEdit::GetSettingsClicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
if (_entryData->GetCondition() ==
|
if (_entryData->_condition ==
|
||||||
MacroConditionSource::Condition::ALL_SETTINGS_MATCH) {
|
MacroConditionSource::Condition::ALL_SETTINGS_MATCH) {
|
||||||
value = FormatJsonString(
|
value = FormatJsonString(
|
||||||
GetSourceSettings(_entryData->_source.GetSource()));
|
GetSourceSettings(_entryData->_source.GetSource()));
|
||||||
@@ -407,67 +303,37 @@ void MacroConditionSourceEdit::RefreshVariableSourceSelectionValue()
|
|||||||
_settingSelection->SetSource(_entryData->_source.GetSource());
|
_settingSelection->SetSource(_entryData->_source.GetSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionSourceEdit::SizeChanged(const NumberVariable<int> &value)
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->_size = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionSourceEdit::CompareMethodChanged(int index)
|
|
||||||
{
|
|
||||||
if (_loading || !_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lock = LockContext();
|
|
||||||
_entryData->_comparision =
|
|
||||||
static_cast<MacroConditionSource::SizeComparision>(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionSourceEdit::SetWidgetVisibility()
|
void MacroConditionSourceEdit::SetWidgetVisibility()
|
||||||
{
|
{
|
||||||
const bool settingsMatch =
|
const bool settingsMatch =
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition ==
|
||||||
MacroConditionSource::Condition::ALL_SETTINGS_MATCH ||
|
MacroConditionSource::Condition::ALL_SETTINGS_MATCH ||
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition ==
|
||||||
MacroConditionSource::Condition::INDIVIDUAL_SETTING_MATCH;
|
MacroConditionSource::Condition::INDIVIDUAL_SETTING_MATCH;
|
||||||
_settings->setVisible(settingsMatch);
|
_settings->setVisible(settingsMatch);
|
||||||
_getSettings->setVisible(settingsMatch);
|
_getSettings->setVisible(settingsMatch);
|
||||||
_regex->setVisible(settingsMatch);
|
_regex->setVisible(settingsMatch);
|
||||||
_settingSelection->setVisible(
|
_settingSelection->setVisible(
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition == MacroConditionSource::Condition::
|
||||||
MacroConditionSource::Condition::INDIVIDUAL_SETTING_MATCH ||
|
INDIVIDUAL_SETTING_MATCH ||
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition == MacroConditionSource::Condition::
|
||||||
MacroConditionSource::Condition::
|
INDIVIDUAL_SETTING_CHANGED);
|
||||||
INDIVIDUAL_SETTING_CHANGED);
|
|
||||||
|
|
||||||
setToolTip(
|
setToolTip(
|
||||||
(_entryData->GetCondition() ==
|
(_entryData->_condition ==
|
||||||
MacroConditionSource::Condition::ACTIVE ||
|
MacroConditionSource::Condition::ACTIVE ||
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition ==
|
||||||
MacroConditionSource::Condition::SHOWING)
|
MacroConditionSource::Condition::SHOWING)
|
||||||
? obs_module_text(
|
? obs_module_text(
|
||||||
"AdvSceneSwitcher.condition.source.sceneVisibilityHint")
|
"AdvSceneSwitcher.condition.source.sceneVisibilityHint")
|
||||||
: "");
|
: "");
|
||||||
|
|
||||||
_refreshSettingSelection->setVisible(
|
_refreshSettingSelection->setVisible(
|
||||||
_entryData->GetCondition() ==
|
_entryData->_condition == MacroConditionSource::Condition::
|
||||||
MacroConditionSource::Condition::INDIVIDUAL_SETTING_MATCH &&
|
INDIVIDUAL_SETTING_MATCH &&
|
||||||
_entryData->_source.GetType() ==
|
_entryData->_source.GetType() ==
|
||||||
SourceSelection::Type::VARIABLE);
|
SourceSelection::Type::VARIABLE);
|
||||||
|
|
||||||
const bool isSizeCheck =
|
|
||||||
_entryData->GetCondition() ==
|
|
||||||
MacroConditionSource::Condition::WIDTH ||
|
|
||||||
_entryData->GetCondition() ==
|
|
||||||
MacroConditionSource::Condition::HEIGHT;
|
|
||||||
_size->setVisible(isSizeCheck);
|
|
||||||
_sizeCompareMethods->setVisible(isSizeCheck);
|
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
@@ -479,15 +345,11 @@ void MacroConditionSourceEdit::UpdateEntryData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_sources->SetSource(_entryData->_source);
|
_sources->SetSource(_entryData->_source);
|
||||||
_conditions->setCurrentIndex(
|
_conditions->setCurrentIndex(static_cast<int>(_entryData->_condition));
|
||||||
static_cast<int>(_entryData->GetCondition()));
|
|
||||||
_settings->setPlainText(_entryData->_settings);
|
_settings->setPlainText(_entryData->_settings);
|
||||||
_regex->SetRegexConfig(_entryData->_regex);
|
_regex->SetRegexConfig(_entryData->_regex);
|
||||||
_settingSelection->SetSource(_entryData->_source.GetSource());
|
_settingSelection->SetSource(_entryData->_source.GetSource());
|
||||||
_settingSelection->SetSetting(_entryData->_setting);
|
_settingSelection->SetSetting(_entryData->_setting);
|
||||||
_size->SetValue(_entryData->_size);
|
|
||||||
_sizeCompareMethods->setCurrentIndex(
|
|
||||||
static_cast<int>(_entryData->_comparision));
|
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,25 +31,15 @@ public:
|
|||||||
SETTINGS_CHANGED,
|
SETTINGS_CHANGED,
|
||||||
INDIVIDUAL_SETTING_MATCH,
|
INDIVIDUAL_SETTING_MATCH,
|
||||||
INDIVIDUAL_SETTING_CHANGED,
|
INDIVIDUAL_SETTING_CHANGED,
|
||||||
HEIGHT,
|
|
||||||
WIDTH,
|
|
||||||
};
|
};
|
||||||
void SetCondition(Condition);
|
|
||||||
Condition GetCondition() const { return _condition; }
|
|
||||||
|
|
||||||
enum class SizeComparision { LESS, EQUAL, MORE };
|
|
||||||
|
|
||||||
SourceSelection _source;
|
SourceSelection _source;
|
||||||
|
Condition _condition = Condition::ACTIVE;
|
||||||
StringVariable _settings = "";
|
StringVariable _settings = "";
|
||||||
SourceSetting _setting;
|
SourceSetting _setting;
|
||||||
RegexConfig _regex;
|
RegexConfig _regex;
|
||||||
IntVariable _size;
|
|
||||||
SizeComparision _comparision = SizeComparision::EQUAL;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupTempVars();
|
|
||||||
|
|
||||||
Condition _condition = Condition::ACTIVE;
|
|
||||||
std::string _currentSettings;
|
std::string _currentSettings;
|
||||||
std::string _currentSettingsValue;
|
std::string _currentSettingsValue;
|
||||||
|
|
||||||
@@ -81,8 +71,6 @@ private slots:
|
|||||||
void RegexChanged(const RegexConfig &);
|
void RegexChanged(const RegexConfig &);
|
||||||
void SettingSelectionChanged(const SourceSetting &);
|
void SettingSelectionChanged(const SourceSetting &);
|
||||||
void RefreshVariableSourceSelectionValue();
|
void RefreshVariableSourceSelectionValue();
|
||||||
void SizeChanged(const NumberVariable<int> &value);
|
|
||||||
void CompareMethodChanged(int);
|
|
||||||
signals:
|
signals:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
|
|
||||||
@@ -94,8 +82,6 @@ protected:
|
|||||||
RegexConfigWidget *_regex;
|
RegexConfigWidget *_regex;
|
||||||
SourceSettingSelection *_settingSelection;
|
SourceSettingSelection *_settingSelection;
|
||||||
QPushButton *_refreshSettingSelection;
|
QPushButton *_refreshSettingSelection;
|
||||||
VariableSpinBox *_size;
|
|
||||||
QComboBox *_sizeCompareMethods;
|
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionSource> _entryData;
|
std::shared_ptr<MacroConditionSource> _entryData;
|
||||||
|
|
||||||
|
|||||||
@@ -529,26 +529,68 @@ void OSCMessageElementEdit::TypeChanged(int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OSCMessageEdit::OSCMessageEdit(QWidget *parent)
|
OSCMessageEdit::OSCMessageEdit(QWidget *parent)
|
||||||
: ListEditor(parent),
|
: QWidget(parent),
|
||||||
_address(new VariableLineEdit(this))
|
_address(new VariableLineEdit(this)),
|
||||||
|
_elements(new QListWidget()),
|
||||||
|
_add(new QPushButton()),
|
||||||
|
_remove(new QPushButton()),
|
||||||
|
_up(new QPushButton()),
|
||||||
|
_down(new QPushButton())
|
||||||
{
|
{
|
||||||
_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
_elements->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
_list->setAutoScroll(false);
|
_elements->setAutoScroll(false);
|
||||||
|
|
||||||
|
_add->setMaximumWidth(22);
|
||||||
|
_add->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("addIconSmall")));
|
||||||
|
_add->setFlat(true);
|
||||||
|
_remove->setMaximumWidth(22);
|
||||||
|
_remove->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||||
|
_remove->setFlat(true);
|
||||||
|
_up->setMaximumWidth(22);
|
||||||
|
_up->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
||||||
|
_up->setFlat(true);
|
||||||
|
_down->setMaximumWidth(22);
|
||||||
|
_down->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
||||||
|
_down->setFlat(true);
|
||||||
|
|
||||||
QWidget::connect(_address, SIGNAL(editingFinished()), this,
|
QWidget::connect(_address, SIGNAL(editingFinished()), this,
|
||||||
SLOT(AddressChanged()));
|
SLOT(AddressChanged()));
|
||||||
|
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
|
||||||
|
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
|
||||||
|
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
|
||||||
|
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
|
||||||
|
|
||||||
_mainLayout->insertWidget(0, _address);
|
auto controlsLayout = new QHBoxLayout();
|
||||||
|
controlsLayout->addWidget(_add);
|
||||||
|
controlsLayout->addWidget(_remove);
|
||||||
|
QFrame *line = new QFrame();
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
controlsLayout->addWidget(line);
|
||||||
|
controlsLayout->addWidget(_up);
|
||||||
|
controlsLayout->addWidget(_down);
|
||||||
|
controlsLayout->addStretch();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout;
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(_address);
|
||||||
|
layout->addWidget(_elements);
|
||||||
|
layout->addLayout(controlsLayout);
|
||||||
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSCMessageEdit::InsertElement(const OSCMessageElement &element)
|
void OSCMessageEdit::InsertElement(const OSCMessageElement &element)
|
||||||
{
|
{
|
||||||
auto item = new QListWidgetItem(_list);
|
auto item = new QListWidgetItem(_elements);
|
||||||
_list->addItem(item);
|
_elements->addItem(item);
|
||||||
auto elementEdit = new OSCMessageElementEdit(this);
|
auto elementEdit = new OSCMessageElementEdit(this);
|
||||||
elementEdit->SetMessageElement(element);
|
elementEdit->SetMessageElement(element);
|
||||||
item->setSizeHint(elementEdit->minimumSizeHint());
|
item->setSizeHint(elementEdit->minimumSizeHint());
|
||||||
_list->setItemWidget(item, elementEdit);
|
_elements->setItemWidget(item, elementEdit);
|
||||||
QWidget::connect(elementEdit,
|
QWidget::connect(elementEdit,
|
||||||
SIGNAL(ElementValueChanged(const OSCMessageElement &)),
|
SIGNAL(ElementValueChanged(const OSCMessageElement &)),
|
||||||
this,
|
this,
|
||||||
@@ -565,7 +607,7 @@ void OSCMessageEdit::SetMessage(const OSCMessage &message)
|
|||||||
InsertElement(element);
|
InsertElement(element);
|
||||||
}
|
}
|
||||||
_currentSelection = message;
|
_currentSelection = message;
|
||||||
UpdateListSize();
|
SetWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSCMessageEdit::AddressChanged()
|
void OSCMessageEdit::AddressChanged()
|
||||||
@@ -579,13 +621,13 @@ void OSCMessageEdit::Add()
|
|||||||
OSCMessageElement element;
|
OSCMessageElement element;
|
||||||
InsertElement(element);
|
InsertElement(element);
|
||||||
emit MessageChanged(_currentSelection);
|
emit MessageChanged(_currentSelection);
|
||||||
UpdateListSize();
|
SetWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSCMessageEdit::Remove()
|
void OSCMessageEdit::Remove()
|
||||||
{
|
{
|
||||||
auto item = _list->currentItem();
|
auto item = _elements->currentItem();
|
||||||
int idx = _list->currentRow();
|
int idx = _elements->currentRow();
|
||||||
if (!item || idx == -1) {
|
if (!item || idx == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -593,7 +635,7 @@ void OSCMessageEdit::Remove()
|
|||||||
_currentSelection._elements.erase(_currentSelection._elements.begin() +
|
_currentSelection._elements.erase(_currentSelection._elements.begin() +
|
||||||
idx);
|
idx);
|
||||||
emit MessageChanged(_currentSelection);
|
emit MessageChanged(_currentSelection);
|
||||||
UpdateListSize();
|
SetWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool moveUp(QListWidget *list)
|
static bool moveUp(QListWidget *list)
|
||||||
@@ -616,8 +658,8 @@ static bool moveUp(QListWidget *list)
|
|||||||
|
|
||||||
void OSCMessageEdit::Up()
|
void OSCMessageEdit::Up()
|
||||||
{
|
{
|
||||||
int idx = _list->currentRow();
|
int idx = _elements->currentRow();
|
||||||
if (!moveUp(_list)) {
|
if (!moveUp(_elements)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,7 +667,7 @@ void OSCMessageEdit::Up()
|
|||||||
_currentSelection._elements.begin() + idx - 1);
|
_currentSelection._elements.begin() + idx - 1);
|
||||||
|
|
||||||
emit MessageChanged(_currentSelection);
|
emit MessageChanged(_currentSelection);
|
||||||
UpdateListSize();
|
SetWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool moveDown(QListWidget *list)
|
static bool moveDown(QListWidget *list)
|
||||||
@@ -648,8 +690,8 @@ static bool moveDown(QListWidget *list)
|
|||||||
|
|
||||||
void OSCMessageEdit::Down()
|
void OSCMessageEdit::Down()
|
||||||
{
|
{
|
||||||
int idx = _list->currentRow();
|
int idx = _elements->currentRow();
|
||||||
if (!moveDown(_list)) {
|
if (!moveDown(_elements)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,7 +699,7 @@ void OSCMessageEdit::Down()
|
|||||||
_currentSelection._elements.begin() + idx + 1);
|
_currentSelection._elements.begin() + idx + 1);
|
||||||
|
|
||||||
emit MessageChanged(_currentSelection);
|
emit MessageChanged(_currentSelection);
|
||||||
UpdateListSize();
|
SetWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QListWidgetItem *getItemFromWidget(QListWidget *list, QWidget *widget)
|
static QListWidgetItem *getItemFromWidget(QListWidget *list, QWidget *widget)
|
||||||
@@ -685,7 +727,7 @@ int OSCMessageEdit::GetIndexOfSignal()
|
|||||||
if (!widget) {
|
if (!widget) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return _list->row(getItemFromWidget(_list, widget));
|
return _elements->row(getItemFromWidget(_elements, widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSCMessageEdit::ElementFocussed()
|
void OSCMessageEdit::ElementFocussed()
|
||||||
@@ -694,7 +736,7 @@ void OSCMessageEdit::ElementFocussed()
|
|||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_list->setCurrentRow(idx);
|
_elements->setCurrentRow(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSCMessageEdit::ElementValueChanged(const OSCMessageElement &element)
|
void OSCMessageEdit::ElementValueChanged(const OSCMessageElement &element)
|
||||||
@@ -705,8 +747,15 @@ void OSCMessageEdit::ElementValueChanged(const OSCMessageElement &element)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_currentSelection._elements.at(idx) = element;
|
_currentSelection._elements.at(idx) = element;
|
||||||
_list->setCurrentRow(idx);
|
_elements->setCurrentRow(idx);
|
||||||
emit MessageChanged(_currentSelection);
|
emit MessageChanged(_currentSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OSCMessageEdit::SetWidgetSize()
|
||||||
|
{
|
||||||
|
SetHeightToContentHeight(_elements);
|
||||||
|
adjustSize();
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "list-editor.hpp"
|
|
||||||
#include "variable-string.hpp"
|
#include "variable-string.hpp"
|
||||||
#include "variable-number.hpp"
|
#include "variable-number.hpp"
|
||||||
#include "variable-line-edit.hpp"
|
#include "variable-line-edit.hpp"
|
||||||
@@ -7,6 +6,7 @@
|
|||||||
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ private:
|
|||||||
VariableLineEdit *_binaryText;
|
VariableLineEdit *_binaryText;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OSCMessageEdit final : public ListEditor {
|
class OSCMessageEdit : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
OSCMessageEdit(QWidget *);
|
OSCMessageEdit(QWidget *);
|
||||||
@@ -157,9 +157,15 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void InsertElement(const OSCMessageElement &);
|
void InsertElement(const OSCMessageElement &);
|
||||||
|
void SetWidgetSize();
|
||||||
int GetIndexOfSignal();
|
int GetIndexOfSignal();
|
||||||
|
|
||||||
VariableLineEdit *_address;
|
VariableLineEdit *_address;
|
||||||
|
QListWidget *_elements;
|
||||||
|
QPushButton *_add;
|
||||||
|
QPushButton *_remove;
|
||||||
|
QPushButton *_up;
|
||||||
|
QPushButton *_down;
|
||||||
|
|
||||||
OSCMessage _currentSelection;
|
OSCMessage _currentSelection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "source-setting.hpp"
|
#include "source-setting.hpp"
|
||||||
#include "obs-module-helper.hpp"
|
#include "obs-module-helper.hpp"
|
||||||
#include "math-helpers.hpp"
|
#include "math-helpers.hpp"
|
||||||
|
#include "ui-helpers.hpp"
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -232,8 +233,14 @@ SourceSettingSelection::SourceSettingSelection(QWidget *parent)
|
|||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_settings(new FilterComboBox(
|
_settings(new FilterComboBox(
|
||||||
this, obs_module_text("AdvSceneSwitcher.setting.select"))),
|
this, obs_module_text("AdvSceneSwitcher.setting.select"))),
|
||||||
_tooltip(new HelpIcon())
|
_tooltip(new QLabel())
|
||||||
{
|
{
|
||||||
|
QString path = GetThemeTypeName() == "Light"
|
||||||
|
? ":/res/images/help.svg"
|
||||||
|
: ":/res/images/help_light.svg";
|
||||||
|
QIcon icon(path);
|
||||||
|
QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
||||||
|
_tooltip->setPixmap(pixmap);
|
||||||
_tooltip->hide();
|
_tooltip->hide();
|
||||||
|
|
||||||
_settings->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
_settings->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "filter-combo-box.hpp"
|
#include "filter-combo-box.hpp"
|
||||||
#include "help-icon.hpp"
|
|
||||||
|
|
||||||
#include <obs.hpp>
|
#include <obs.hpp>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -53,7 +52,7 @@ private:
|
|||||||
void Populate(const OBSWeakSource &);
|
void Populate(const OBSWeakSource &);
|
||||||
|
|
||||||
FilterComboBox *_settings;
|
FilterComboBox *_settings;
|
||||||
HelpIcon *_tooltip;
|
QLabel *_tooltip;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -49,12 +49,60 @@ void StringList::ResolveVariables()
|
|||||||
StringListEdit::StringListEdit(QWidget *parent, const QString &addString,
|
StringListEdit::StringListEdit(QWidget *parent, const QString &addString,
|
||||||
const QString &addStringDescription,
|
const QString &addStringDescription,
|
||||||
int maxStringSize, bool allowEmtpy)
|
int maxStringSize, bool allowEmtpy)
|
||||||
: ListEditor(parent),
|
: QWidget(parent),
|
||||||
|
_list(new QListWidget()),
|
||||||
|
_add(new QPushButton()),
|
||||||
|
_remove(new QPushButton()),
|
||||||
|
_up(new QPushButton()),
|
||||||
|
_down(new QPushButton()),
|
||||||
_addString(addString),
|
_addString(addString),
|
||||||
_addStringDescription(addStringDescription),
|
_addStringDescription(addStringDescription),
|
||||||
_maxStringSize(maxStringSize),
|
_maxStringSize(maxStringSize),
|
||||||
_allowEmpty(allowEmtpy)
|
_allowEmpty(allowEmtpy)
|
||||||
{
|
{
|
||||||
|
_add->setMaximumWidth(22);
|
||||||
|
_add->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("addIconSmall")));
|
||||||
|
_add->setFlat(true);
|
||||||
|
_remove->setMaximumWidth(22);
|
||||||
|
_remove->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||||
|
_remove->setFlat(true);
|
||||||
|
_up->setMaximumWidth(22);
|
||||||
|
_up->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
||||||
|
_up->setFlat(true);
|
||||||
|
_down->setMaximumWidth(22);
|
||||||
|
_down->setProperty("themeID",
|
||||||
|
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
||||||
|
_down->setFlat(true);
|
||||||
|
|
||||||
|
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
|
||||||
|
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
|
||||||
|
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
|
||||||
|
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
|
||||||
|
QWidget::connect(_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
||||||
|
this, SLOT(Clicked(QListWidgetItem *)));
|
||||||
|
|
||||||
|
auto controlLayout = new QHBoxLayout;
|
||||||
|
controlLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
controlLayout->addWidget(_add);
|
||||||
|
controlLayout->addWidget(_remove);
|
||||||
|
QFrame *line = new QFrame();
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
controlLayout->addWidget(line);
|
||||||
|
controlLayout->addWidget(_up);
|
||||||
|
controlLayout->addWidget(_down);
|
||||||
|
controlLayout->addStretch();
|
||||||
|
|
||||||
|
auto mainLayout = new QVBoxLayout;
|
||||||
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
mainLayout->addWidget(_list);
|
||||||
|
mainLayout->addLayout(controlLayout);
|
||||||
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringListEdit::SetStringList(const StringList &list)
|
void StringListEdit::SetStringList(const StringList &list)
|
||||||
@@ -67,7 +115,7 @@ void StringListEdit::SetStringList(const StringList &list)
|
|||||||
_list);
|
_list);
|
||||||
item->setData(Qt::UserRole, string);
|
item->setData(Qt::UserRole, string);
|
||||||
}
|
}
|
||||||
UpdateListSize();
|
SetListSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringListEdit::SetMaxStringSize(int size)
|
void StringListEdit::SetMaxStringSize(int size)
|
||||||
@@ -75,6 +123,17 @@ void StringListEdit::SetMaxStringSize(int size)
|
|||||||
_maxStringSize = size;
|
_maxStringSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StringListEdit::showEvent(QShowEvent *e)
|
||||||
|
{
|
||||||
|
QWidget::showEvent(e);
|
||||||
|
// This is necessary as the list viewport might not be updated yet
|
||||||
|
// while the list was hidden.
|
||||||
|
// Thus, previous calls to SetListSize() might not have resized the
|
||||||
|
// widget correctly, for example due to not regarding the horizontal
|
||||||
|
// scrollbar yet.
|
||||||
|
SetListSize();
|
||||||
|
}
|
||||||
|
|
||||||
void StringListEdit::Add()
|
void StringListEdit::Add()
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
@@ -94,7 +153,7 @@ void StringListEdit::Add()
|
|||||||
_stringList << string;
|
_stringList << string;
|
||||||
|
|
||||||
// Delay resizing to make sure the list viewport was already updated
|
// Delay resizing to make sure the list viewport was already updated
|
||||||
QTimer::singleShot(0, this, [this]() { UpdateListSize(); });
|
QTimer::singleShot(0, this, [this]() { SetListSize(); });
|
||||||
|
|
||||||
StringListChanged(_stringList);
|
StringListChanged(_stringList);
|
||||||
}
|
}
|
||||||
@@ -114,7 +173,7 @@ void StringListEdit::Remove()
|
|||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
// Delay resizing to make sure the list viewport was already updated
|
// Delay resizing to make sure the list viewport was already updated
|
||||||
QTimer::singleShot(0, this, [this]() { UpdateListSize(); });
|
QTimer::singleShot(0, this, [this]() { SetListSize(); });
|
||||||
|
|
||||||
StringListChanged(_stringList);
|
StringListChanged(_stringList);
|
||||||
}
|
}
|
||||||
@@ -163,9 +222,16 @@ void StringListEdit::Clicked(QListWidgetItem *item)
|
|||||||
_stringList[idx] = string;
|
_stringList[idx] = string;
|
||||||
|
|
||||||
// Delay resizing to make sure the list viewport was already updated
|
// Delay resizing to make sure the list viewport was already updated
|
||||||
QTimer::singleShot(0, this, [this]() { UpdateListSize(); });
|
QTimer::singleShot(0, this, [this]() { SetListSize(); });
|
||||||
|
|
||||||
StringListChanged(_stringList);
|
StringListChanged(_stringList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StringListEdit::SetListSize()
|
||||||
|
{
|
||||||
|
SetHeightToContentHeight(_list);
|
||||||
|
adjustSize();
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
@@ -1,25 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "export-symbol-helper.hpp"
|
|
||||||
#include "list-editor.hpp"
|
|
||||||
#include "obs-module-helper.hpp"
|
|
||||||
#include "variable-string.hpp"
|
#include "variable-string.hpp"
|
||||||
|
#include "obs-module-helper.hpp"
|
||||||
|
|
||||||
#include <obs-data.h>
|
#include <obs-data.h>
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
class StringList : public QList<StringVariable> {
|
class StringList : public QList<StringVariable> {
|
||||||
public:
|
public:
|
||||||
EXPORT bool Save(obs_data_t *obj, const char *name,
|
bool Save(obs_data_t *obj, const char *name,
|
||||||
const char *elementName = "string") const;
|
const char *elementName = "string") const;
|
||||||
EXPORT bool Load(obs_data_t *obj, const char *name,
|
bool Load(obs_data_t *obj, const char *name,
|
||||||
const char *elementName = "string");
|
const char *elementName = "string");
|
||||||
EXPORT void ResolveVariables();
|
void ResolveVariables();
|
||||||
|
|
||||||
friend class StringListEdit;
|
friend class StringListEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ADVSS_EXPORT StringListEdit final : public ListEditor {
|
class StringListEdit : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -29,6 +31,9 @@ public:
|
|||||||
void SetStringList(const StringList &);
|
void SetStringList(const StringList &);
|
||||||
void SetMaxStringSize(int);
|
void SetMaxStringSize(int);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void Add();
|
void Add();
|
||||||
void Remove();
|
void Remove();
|
||||||
@@ -39,8 +44,16 @@ signals:
|
|||||||
void StringListChanged(const StringList &);
|
void StringListChanged(const StringList &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void SetListSize();
|
||||||
|
|
||||||
StringList _stringList;
|
StringList _stringList;
|
||||||
|
|
||||||
|
QListWidget *_list;
|
||||||
|
QPushButton *_add;
|
||||||
|
QPushButton *_remove;
|
||||||
|
QPushButton *_up;
|
||||||
|
QPushButton *_down;
|
||||||
|
|
||||||
QString _addString;
|
QString _addString;
|
||||||
QString _addStringDescription;
|
QString _addStringDescription;
|
||||||
int _maxStringSize = 170;
|
int _maxStringSize = 170;
|
||||||
@@ -207,14 +207,14 @@ static void setupTab(QTabWidget *tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget::connect(ConnectionSelectionSignalManager::Instance(),
|
QWidget::connect(ConnectionSelectionSignalManager::Instance(),
|
||||||
&ConnectionSelectionSignalManager::Rename, tab,
|
&ConnectionSelectionSignalManager::Rename,
|
||||||
[](const QString &oldName, const QString &newName) {
|
[](const QString &oldName, const QString &newName) {
|
||||||
RenameItemTableRow(tabWidget->Table(), oldName,
|
RenameItemTableRow(tabWidget->Table(), oldName,
|
||||||
newName);
|
newName);
|
||||||
});
|
});
|
||||||
QWidget::connect(
|
QWidget::connect(
|
||||||
ConnectionSelectionSignalManager::Instance(),
|
ConnectionSelectionSignalManager::Instance(),
|
||||||
&ConnectionSelectionSignalManager::Add, tab,
|
&ConnectionSelectionSignalManager::Add,
|
||||||
[tab](const QString &name) {
|
[tab](const QString &name) {
|
||||||
AddItemTableRow(
|
AddItemTableRow(
|
||||||
tabWidget->Table(),
|
tabWidget->Table(),
|
||||||
@@ -224,7 +224,7 @@ static void setupTab(QTabWidget *tab)
|
|||||||
setTabVisible(tab, true);
|
setTabVisible(tab, true);
|
||||||
});
|
});
|
||||||
QWidget::connect(ConnectionSelectionSignalManager::Instance(),
|
QWidget::connect(ConnectionSelectionSignalManager::Instance(),
|
||||||
&ConnectionSelectionSignalManager::Remove, tab,
|
&ConnectionSelectionSignalManager::Remove,
|
||||||
[](const QString &name) {
|
[](const QString &name) {
|
||||||
RemoveItemTableRow(tabWidget->Table(), name);
|
RemoveItemTableRow(tabWidget->Table(), name);
|
||||||
if (tabWidget->Table()->rowCount() == 0) {
|
if (tabWidget->Table()->rowCount() == 0) {
|
||||||
|
|||||||
@@ -175,43 +175,22 @@ void PressKeys(const std::vector<HotkeyType> keys, int duration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool windowIsValid(HWND window)
|
static HWND getHWNDfromTitle(const std::string &title)
|
||||||
{
|
{
|
||||||
if (!IsWindowVisible(window)) {
|
HWND hwnd = NULL;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only accept for top level windows and not controls within them
|
|
||||||
if (window != GetAncestor(window, GA_ROOT)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<HWND> getHWNDfromTitle(const std::string &title)
|
|
||||||
{
|
|
||||||
HWND hwnd = nullptr;
|
|
||||||
HWND hPrevWnd = nullptr;
|
|
||||||
std::vector<HWND> hwnds;
|
|
||||||
wchar_t wTitle[512];
|
wchar_t wTitle[512];
|
||||||
os_utf8_to_wcs(title.c_str(), 0, wTitle, 512);
|
os_utf8_to_wcs(title.c_str(), 0, wTitle, 512);
|
||||||
while ((hwnd = FindWindowEx(NULL, hPrevWnd, NULL, wTitle)) != nullptr) {
|
hwnd = FindWindowEx(NULL, NULL, NULL, wTitle);
|
||||||
if (windowIsValid(hwnd)) {
|
return hwnd;
|
||||||
hwnds.emplace_back(hwnd);
|
|
||||||
}
|
|
||||||
hPrevWnd = hwnd;
|
|
||||||
}
|
|
||||||
return hwnds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetWindowClassByWindowTitle(const std::string &window)
|
std::string GetWindowClassByWindowTitle(const std::string &window)
|
||||||
{
|
{
|
||||||
auto hwnds = getHWNDfromTitle(window);
|
HWND hwnd = NULL;
|
||||||
if (hwnds.empty()) {
|
hwnd = getHWNDfromTitle(window);
|
||||||
|
if (!hwnd) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
auto hwnd = hwnds.at(0);
|
|
||||||
std::wstring wClass;
|
std::wstring wClass;
|
||||||
wClass.resize(1024);
|
wClass.resize(1024);
|
||||||
if (!GetClassNameW(hwnd, &wClass[0], wClass.capacity())) {
|
if (!GetClassNameW(hwnd, &wClass[0], wClass.capacity())) {
|
||||||
@@ -227,54 +206,41 @@ std::string GetWindowClassByWindowTitle(const std::string &window)
|
|||||||
|
|
||||||
void SetFocusWindow(const std::string &title)
|
void SetFocusWindow(const std::string &title)
|
||||||
{
|
{
|
||||||
auto hwnds = getHWNDfromTitle(title);
|
auto handle = getHWNDfromTitle(title);
|
||||||
if (hwnds.empty()) {
|
if (!handle) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ShowWindow(handle, SW_RESTORE);
|
||||||
for (const auto &handle : hwnds) {
|
SetForegroundWindow(handle);
|
||||||
const bool isMinimized = IsIconic(handle);
|
SetFocus(handle);
|
||||||
ShowWindow(handle, isMinimized ? SW_RESTORE : SW_SHOW);
|
SetActiveWindow(handle);
|
||||||
SetForegroundWindow(handle);
|
|
||||||
SetFocus(handle);
|
|
||||||
SetActiveWindow(handle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseWindow(const std::string &title)
|
void CloseWindow(const std::string &title)
|
||||||
{
|
{
|
||||||
auto hwnds = getHWNDfromTitle(title);
|
auto handle = getHWNDfromTitle(title);
|
||||||
if (hwnds.empty()) {
|
if (!handle) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SendMessage(handle, WM_CLOSE, 0, 0);
|
||||||
for (const auto &handle : hwnds) {
|
|
||||||
SendMessage(handle, WM_CLOSE, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaximizeWindow(const std::string &title)
|
void MaximizeWindow(const std::string &title)
|
||||||
{
|
{
|
||||||
auto hwnds = getHWNDfromTitle(title);
|
auto handle = getHWNDfromTitle(title);
|
||||||
if (hwnds.empty()) {
|
if (!handle) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ShowWindow(handle, SW_MAXIMIZE);
|
||||||
for (const auto &handle : hwnds) {
|
|
||||||
ShowWindow(handle, SW_MAXIMIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinimizeWindow(const std::string &title)
|
void MinimizeWindow(const std::string &title)
|
||||||
{
|
{
|
||||||
auto hwnds = getHWNDfromTitle(title);
|
auto handle = getHWNDfromTitle(title);
|
||||||
if (hwnds.empty()) {
|
if (!handle) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ShowWindow(handle, SW_MINIMIZE);
|
||||||
for (const auto &handle : hwnds) {
|
|
||||||
ShowWindow(handle, SW_MINIMIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class RawMouseInputFilter;
|
class RawMouseInputFilter;
|
||||||
|
|||||||
@@ -12,7 +12,73 @@ bool MacroConditionMidi::_registered = MacroConditionFactory::Register(
|
|||||||
{MacroConditionMidi::Create, MacroConditionMidiEdit::Create,
|
{MacroConditionMidi::Create, MacroConditionMidiEdit::Create,
|
||||||
"AdvSceneSwitcher.condition.midi"});
|
"AdvSceneSwitcher.condition.midi"});
|
||||||
|
|
||||||
|
static const std::map<MacroConditionMidi::Condition, std::string>
|
||||||
|
conditionTypes = {
|
||||||
|
{MacroConditionMidi::Condition::MIDI_MESSAGE,
|
||||||
|
"AdvSceneSwitcher.condition.midi.condition.message"},
|
||||||
|
{MacroConditionMidi::Condition::MIDI_CONNECTED_DEVICE_NAMES,
|
||||||
|
"AdvSceneSwitcher.condition.midi.condition.deviceName"},
|
||||||
|
};
|
||||||
|
|
||||||
bool MacroConditionMidi::CheckCondition()
|
bool MacroConditionMidi::CheckCondition()
|
||||||
|
{
|
||||||
|
switch (_condition) {
|
||||||
|
case Condition::MIDI_MESSAGE:
|
||||||
|
return CheckMessage();
|
||||||
|
case Condition::MIDI_CONNECTED_DEVICE_NAMES:
|
||||||
|
return CheckConnectedDevcieNames();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MacroConditionMidi::Save(obs_data_t *obj) const
|
||||||
|
{
|
||||||
|
MacroCondition::Save(obj);
|
||||||
|
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
||||||
|
_message.Save(obj);
|
||||||
|
_device.Save(obj);
|
||||||
|
_deviceName.Save(obj, "deviceName");
|
||||||
|
_regex.Save(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MacroConditionMidi::Load(obs_data_t *obj)
|
||||||
|
{
|
||||||
|
MacroCondition::Load(obj);
|
||||||
|
_message.Load(obj);
|
||||||
|
_device.Load(obj);
|
||||||
|
_deviceName.Load(obj, "deviceName");
|
||||||
|
_regex.Load(obj);
|
||||||
|
SetCondition(
|
||||||
|
static_cast<Condition>(obs_data_get_int(obj, "condition")));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string MacroConditionMidi::GetShortDesc() const
|
||||||
|
{
|
||||||
|
return _condition == MacroConditionMidi::Condition::MIDI_MESSAGE
|
||||||
|
? _device.Name()
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionMidi::SetDevice(const MidiDevice &dev)
|
||||||
|
{
|
||||||
|
_device = dev;
|
||||||
|
_messageBuffer = dev.RegisterForMidiMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionMidi::SetCondition(Condition condition)
|
||||||
|
{
|
||||||
|
_condition = condition;
|
||||||
|
if (_condition == Condition::MIDI_MESSAGE) {
|
||||||
|
_messageBuffer = _device.RegisterForMidiMessages();
|
||||||
|
}
|
||||||
|
SetupTempVars();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MacroConditionMidi::CheckMessage()
|
||||||
{
|
{
|
||||||
if (!_messageBuffer) {
|
if (!_messageBuffer) {
|
||||||
return false;
|
return false;
|
||||||
@@ -40,37 +106,27 @@ bool MacroConditionMidi::CheckCondition()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroConditionMidi::Save(obs_data_t *obj) const
|
bool MacroConditionMidi::CheckConnectedDevcieNames()
|
||||||
{
|
{
|
||||||
MacroCondition::Save(obj);
|
auto deviceNames = GetDeviceNames();
|
||||||
_message.Save(obj);
|
if (!_regex.Enabled()) {
|
||||||
_device.Save(obj);
|
return std::find(deviceNames.begin(), deviceNames.end(),
|
||||||
return true;
|
std::string(_deviceName)) != deviceNames.end();
|
||||||
}
|
}
|
||||||
|
for (const auto &deviceName : deviceNames) {
|
||||||
bool MacroConditionMidi::Load(obs_data_t *obj)
|
if (_regex.Matches(deviceName, _deviceName)) {
|
||||||
{
|
return true;
|
||||||
MacroCondition::Load(obj);
|
}
|
||||||
_message.Load(obj);
|
}
|
||||||
_device.Load(obj);
|
return false;
|
||||||
_messageBuffer = _device.RegisterForMidiMessages();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MacroConditionMidi::GetShortDesc() const
|
|
||||||
{
|
|
||||||
return _device.Name();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionMidi::SetDevice(const MidiDevice &dev)
|
|
||||||
{
|
|
||||||
_device = dev;
|
|
||||||
_messageBuffer = dev.RegisterForMidiMessages();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionMidi::SetupTempVars()
|
void MacroConditionMidi::SetupTempVars()
|
||||||
{
|
{
|
||||||
MacroCondition::SetupTempVars();
|
MacroCondition::SetupTempVars();
|
||||||
|
if (_condition == Condition::MIDI_CONNECTED_DEVICE_NAMES) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
AddTempvar("type",
|
AddTempvar("type",
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.midi.type"));
|
obs_module_text("AdvSceneSwitcher.tempVar.midi.type"));
|
||||||
AddTempvar("channel",
|
AddTempvar("channel",
|
||||||
@@ -98,16 +154,45 @@ void MacroConditionMidi::SetVariableValues(const MidiMessage &m)
|
|||||||
SetTempVarValue("value2", std::to_string(m.Value()));
|
SetTempVarValue("value2", std::to_string(m.Value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void populateConditionSelection(QComboBox *list)
|
||||||
|
{
|
||||||
|
for (const auto &[_, name] : conditionTypes) {
|
||||||
|
list->addItem(obs_module_text(name.c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MacroConditionMidiEdit::MacroConditionMidiEdit(
|
MacroConditionMidiEdit::MacroConditionMidiEdit(
|
||||||
QWidget *parent, std::shared_ptr<MacroConditionMidi> entryData)
|
QWidget *parent, std::shared_ptr<MacroConditionMidi> entryData)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
_conditions(new QComboBox()),
|
||||||
_devices(new MidiDeviceSelection(this, MidiDeviceType::INPUT)),
|
_devices(new MidiDeviceSelection(this, MidiDeviceType::INPUT)),
|
||||||
_message(new MidiMessageSelection(this)),
|
_message(new MidiMessageSelection(this)),
|
||||||
_resetMidiDevices(new QPushButton(
|
_resetMidiDevices(new QPushButton(
|
||||||
obs_module_text("AdvSceneSwitcher.midi.resetDevices"))),
|
obs_module_text("AdvSceneSwitcher.midi.resetDevices"))),
|
||||||
_listen(new QPushButton(
|
_listen(new QPushButton(
|
||||||
obs_module_text("AdvSceneSwitcher.midi.startListen")))
|
obs_module_text("AdvSceneSwitcher.midi.startListen"))),
|
||||||
|
_deviceNames(new QComboBox()),
|
||||||
|
_regex(new RegexConfigWidget()),
|
||||||
|
_deviceListInfo(new QLabel()),
|
||||||
|
_listenLayout(new QHBoxLayout()),
|
||||||
|
_entryLayout(new QHBoxLayout())
|
||||||
{
|
{
|
||||||
|
_deviceNames->addItems(GetDeviceNamesAsQStringList());
|
||||||
|
_deviceNames->setEditable(true);
|
||||||
|
|
||||||
|
QString path = GetThemeTypeName() == "Light"
|
||||||
|
? ":/res/images/help.svg"
|
||||||
|
: ":/res/images/help_light.svg";
|
||||||
|
QIcon icon(path);
|
||||||
|
QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
||||||
|
_deviceListInfo->setPixmap(pixmap);
|
||||||
|
_deviceListInfo->setToolTip(obs_module_text(
|
||||||
|
"AdvSceneSwitcher.condition.midi.condition.deviceName.info"));
|
||||||
|
|
||||||
|
populateConditionSelection(_conditions);
|
||||||
|
|
||||||
|
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
|
||||||
|
SLOT(ConditionChanged(int)));
|
||||||
QWidget::connect(_devices,
|
QWidget::connect(_devices,
|
||||||
SIGNAL(DeviceSelectionChanged(const MidiDevice &)),
|
SIGNAL(DeviceSelectionChanged(const MidiDevice &)),
|
||||||
this,
|
this,
|
||||||
@@ -121,19 +206,21 @@ MacroConditionMidiEdit::MacroConditionMidiEdit(
|
|||||||
SLOT(ToggleListen()));
|
SLOT(ToggleListen()));
|
||||||
QWidget::connect(&_listenTimer, SIGNAL(timeout()), this,
|
QWidget::connect(&_listenTimer, SIGNAL(timeout()), this,
|
||||||
SLOT(SetMessageSelectionToLastReceived()));
|
SLOT(SetMessageSelectionToLastReceived()));
|
||||||
|
QWidget::connect(_deviceNames,
|
||||||
|
SIGNAL(currentTextChanged(const QString &)), this,
|
||||||
|
SLOT(DeviceNameChanged(const QString &)));
|
||||||
|
QWidget::connect(_regex,
|
||||||
|
SIGNAL(RegexConfigChanged(const RegexConfig &)), this,
|
||||||
|
SLOT(RegexChanged(const RegexConfig &)));
|
||||||
|
|
||||||
auto entryLayout = new QHBoxLayout;
|
|
||||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.condition.midi.entry"),
|
|
||||||
entryLayout, {{"{{device}}", _devices}});
|
|
||||||
auto listenLayout = new QHBoxLayout;
|
|
||||||
PlaceWidgets(
|
PlaceWidgets(
|
||||||
obs_module_text("AdvSceneSwitcher.condition.midi.entry.listen"),
|
obs_module_text("AdvSceneSwitcher.condition.midi.entry.listen"),
|
||||||
listenLayout, {{"{{listenButton}}", _listen}});
|
_listenLayout, {{"{{listenButton}}", _listen}});
|
||||||
|
|
||||||
auto mainLayout = new QVBoxLayout;
|
auto mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(entryLayout);
|
mainLayout->addLayout(_entryLayout);
|
||||||
mainLayout->addWidget(_message);
|
mainLayout->addWidget(_message);
|
||||||
mainLayout->addLayout(listenLayout);
|
mainLayout->addLayout(_listenLayout);
|
||||||
mainLayout->addWidget(_resetMidiDevices);
|
mainLayout->addWidget(_resetMidiDevices);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
@@ -155,11 +242,14 @@ void MacroConditionMidiEdit::UpdateEntryData()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_conditions->setCurrentIndex(
|
||||||
|
static_cast<int>(_entryData->GetCondition()));
|
||||||
_message->SetMessage(_entryData->_message);
|
_message->SetMessage(_entryData->_message);
|
||||||
_devices->SetDevice(_entryData->GetDevice());
|
_devices->SetDevice(_entryData->GetDevice());
|
||||||
|
_deviceNames->setCurrentText(QString::fromStdString(
|
||||||
adjustSize();
|
_entryData->_deviceName.UnresolvedValue()));
|
||||||
updateGeometry();
|
_regex->SetRegexConfig(_entryData->_regex);
|
||||||
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionMidiEdit::DeviceSelectionChanged(const MidiDevice &device)
|
void MacroConditionMidiEdit::DeviceSelectionChanged(const MidiDevice &device)
|
||||||
@@ -211,6 +301,46 @@ void MacroConditionMidiEdit::EnableListening(bool enable)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroConditionMidiEdit::SetWidgetVisibility()
|
||||||
|
{
|
||||||
|
_entryLayout->removeWidget(_conditions);
|
||||||
|
_entryLayout->removeWidget(_devices);
|
||||||
|
_entryLayout->removeWidget(_deviceNames);
|
||||||
|
_entryLayout->removeWidget(_regex);
|
||||||
|
|
||||||
|
ClearLayout(_entryLayout);
|
||||||
|
|
||||||
|
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||||
|
{"{{conditions}}", _conditions},
|
||||||
|
{"{{device}}", _devices},
|
||||||
|
{"{{deviceNames}}", _deviceNames},
|
||||||
|
{"{{regex}}", _regex},
|
||||||
|
{"{{deviceListInfo}}", _deviceListInfo},
|
||||||
|
};
|
||||||
|
|
||||||
|
const bool isMessageCheck = _entryData->GetCondition() ==
|
||||||
|
MacroConditionMidi::Condition::MIDI_MESSAGE;
|
||||||
|
|
||||||
|
auto layoutString =
|
||||||
|
isMessageCheck
|
||||||
|
? "AdvSceneSwitcher.condition.midi.entry.message"
|
||||||
|
: "AdvSceneSwitcher.condition.midi.entry.deviceName";
|
||||||
|
|
||||||
|
PlaceWidgets(obs_module_text(layoutString), _entryLayout,
|
||||||
|
widgetPlaceholders);
|
||||||
|
|
||||||
|
SetLayoutVisible(_listenLayout, isMessageCheck);
|
||||||
|
_devices->setVisible(isMessageCheck);
|
||||||
|
_message->setVisible(isMessageCheck);
|
||||||
|
_resetMidiDevices->setVisible(isMessageCheck);
|
||||||
|
_deviceNames->setVisible(!isMessageCheck);
|
||||||
|
_regex->setVisible(!isMessageCheck);
|
||||||
|
_deviceListInfo->setVisible(!isMessageCheck);
|
||||||
|
|
||||||
|
adjustSize();
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
void MacroConditionMidiEdit::ToggleListen()
|
void MacroConditionMidiEdit::ToggleListen()
|
||||||
{
|
{
|
||||||
if (!_entryData) {
|
if (!_entryData) {
|
||||||
@@ -249,4 +379,41 @@ void MacroConditionMidiEdit::SetMessageSelectionToLastReceived()
|
|||||||
_entryData->_message = *message;
|
_entryData->_message = *message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroConditionMidiEdit::ConditionChanged(int value)
|
||||||
|
{
|
||||||
|
if (_loading || !_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lock = LockContext();
|
||||||
|
_entryData->SetCondition(
|
||||||
|
static_cast<MacroConditionMidi::Condition>(value));
|
||||||
|
SetWidgetVisibility();
|
||||||
|
emit HeaderInfoChanged(
|
||||||
|
QString::fromStdString(_entryData->GetShortDesc()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionMidiEdit::DeviceNameChanged(const QString &deviceName)
|
||||||
|
{
|
||||||
|
if (_loading || !_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lock = LockContext();
|
||||||
|
_entryData->_deviceName = deviceName.toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionMidiEdit::RegexChanged(const RegexConfig &conf)
|
||||||
|
{
|
||||||
|
if (_loading || !_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lock = LockContext();
|
||||||
|
_entryData->_regex = conf;
|
||||||
|
|
||||||
|
adjustSize();
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "macro-condition-edit.hpp"
|
#include "macro-condition-edit.hpp"
|
||||||
#include "midi-helpers.hpp"
|
#include "midi-helpers.hpp"
|
||||||
|
#include "regex-config.hpp"
|
||||||
|
#include "variable-line-edit.hpp"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -23,11 +25,23 @@ public:
|
|||||||
void SetDevice(const MidiDevice &dev);
|
void SetDevice(const MidiDevice &dev);
|
||||||
const MidiDevice &GetDevice() const { return _device; }
|
const MidiDevice &GetDevice() const { return _device; }
|
||||||
MidiMessage _message;
|
MidiMessage _message;
|
||||||
|
StringVariable _deviceName;
|
||||||
|
RegexConfig _regex;
|
||||||
|
|
||||||
|
enum class Condition {
|
||||||
|
MIDI_MESSAGE,
|
||||||
|
MIDI_CONNECTED_DEVICE_NAMES,
|
||||||
|
};
|
||||||
|
void SetCondition(Condition);
|
||||||
|
Condition GetCondition() const { return _condition; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool CheckMessage();
|
||||||
|
bool CheckConnectedDevcieNames();
|
||||||
void SetupTempVars();
|
void SetupTempVars();
|
||||||
void SetVariableValues(const MidiMessage &);
|
void SetVariableValues(const MidiMessage &);
|
||||||
|
|
||||||
|
Condition _condition = Condition::MIDI_MESSAGE;
|
||||||
MidiDevice _device;
|
MidiDevice _device;
|
||||||
MidiMessageBuffer _messageBuffer;
|
MidiMessageBuffer _messageBuffer;
|
||||||
std::chrono::high_resolution_clock::time_point _lastCheck{};
|
std::chrono::high_resolution_clock::time_point _lastCheck{};
|
||||||
@@ -58,18 +72,29 @@ private slots:
|
|||||||
void ResetMidiDevices();
|
void ResetMidiDevices();
|
||||||
void ToggleListen();
|
void ToggleListen();
|
||||||
void SetMessageSelectionToLastReceived();
|
void SetMessageSelectionToLastReceived();
|
||||||
|
void ConditionChanged(int);
|
||||||
|
void DeviceNameChanged(const QString &);
|
||||||
|
void RegexChanged(const RegexConfig &);
|
||||||
signals:
|
signals:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EnableListening(bool);
|
void EnableListening(bool);
|
||||||
|
void SetWidgetVisibility();
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionMidi> _entryData;
|
std::shared_ptr<MacroConditionMidi> _entryData;
|
||||||
|
|
||||||
|
QComboBox *_conditions;
|
||||||
MidiDeviceSelection *_devices;
|
MidiDeviceSelection *_devices;
|
||||||
MidiMessageSelection *_message;
|
MidiMessageSelection *_message;
|
||||||
QPushButton *_resetMidiDevices;
|
QPushButton *_resetMidiDevices;
|
||||||
QPushButton *_listen;
|
QPushButton *_listen;
|
||||||
|
QComboBox *_deviceNames;
|
||||||
|
RegexConfigWidget *_regex;
|
||||||
|
QLabel *_deviceListInfo;
|
||||||
|
QHBoxLayout *_listenLayout;
|
||||||
|
QHBoxLayout *_entryLayout;
|
||||||
|
|
||||||
QTimer _listenTimer;
|
QTimer _listenTimer;
|
||||||
MidiMessageBuffer _messageBuffer;
|
MidiMessageBuffer _messageBuffer;
|
||||||
bool _currentlyListening = false;
|
bool _currentlyListening = false;
|
||||||
|
|||||||
@@ -20,56 +20,47 @@ std::map<std::pair<MidiDeviceType, std::string>, MidiDeviceInstance *>
|
|||||||
static bool setupDeviceObservers()
|
static bool setupDeviceObservers()
|
||||||
{
|
{
|
||||||
static std::vector<libremidi::observer> observers;
|
static std::vector<libremidi::observer> observers;
|
||||||
try {
|
for (auto api : libremidi::available_apis()) {
|
||||||
for (auto api : libremidi::available_apis()) {
|
libremidi::observer_configuration cbs;
|
||||||
libremidi::observer_configuration cbs;
|
cbs.track_virtual = true;
|
||||||
cbs.input_added = [=](const libremidi::input_port &p) {
|
cbs.input_added = [](const libremidi::input_port &p) {
|
||||||
auto dev = MidiDeviceInstance::GetDevice(p);
|
auto dev = MidiDeviceInstance::GetDevice(p);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blog(LOG_INFO, "MIDI input connected: %s",
|
blog(LOG_INFO, "MIDI input connected: %s",
|
||||||
p.port_name.c_str());
|
p.port_name.c_str());
|
||||||
dev->ClosePort();
|
dev->ClosePort();
|
||||||
dev->OpenPort();
|
dev->OpenPort();
|
||||||
};
|
};
|
||||||
cbs.input_removed = [=](const libremidi::input_port &p) {
|
cbs.input_removed = [](const libremidi::input_port &p) {
|
||||||
auto dev = MidiDeviceInstance::GetDevice(p);
|
auto dev = MidiDeviceInstance::GetDevice(p);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blog(LOG_INFO, "MIDI input removed: %s",
|
blog(LOG_INFO, "MIDI input removed: %s",
|
||||||
p.port_name.c_str());
|
p.port_name.c_str());
|
||||||
};
|
};
|
||||||
cbs.output_added = [=](const libremidi::output_port &p) {
|
cbs.output_added = [](const libremidi::output_port &p) {
|
||||||
auto dev = MidiDeviceInstance::GetDevice(p);
|
auto dev = MidiDeviceInstance::GetDevice(p);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blog(LOG_INFO, "MIDI output connected: %s",
|
blog(LOG_INFO, "MIDI output connected: %s",
|
||||||
p.port_name.c_str());
|
p.port_name.c_str());
|
||||||
dev->ClosePort();
|
dev->ClosePort();
|
||||||
dev->OpenPort();
|
dev->OpenPort();
|
||||||
};
|
};
|
||||||
cbs.output_removed =
|
cbs.output_removed = [](const libremidi::output_port &p) {
|
||||||
[=](const libremidi::output_port &p) {
|
auto dev = MidiDeviceInstance::GetDevice(p);
|
||||||
auto dev =
|
if (!dev) {
|
||||||
MidiDeviceInstance::GetDevice(
|
return;
|
||||||
p);
|
}
|
||||||
if (!dev) {
|
blog(LOG_INFO, "MIDI output removed: %s",
|
||||||
return;
|
p.port_name.c_str());
|
||||||
}
|
};
|
||||||
blog(LOG_INFO,
|
observers.emplace_back(
|
||||||
"MIDI output removed: %s",
|
cbs, libremidi::observer_configuration_for(api));
|
||||||
p.port_name.c_str());
|
|
||||||
};
|
|
||||||
observers.emplace_back(
|
|
||||||
cbs,
|
|
||||||
libremidi::observer_configuration_for(api));
|
|
||||||
}
|
|
||||||
} catch (const libremidi::driver_error &error) {
|
|
||||||
blog(LOG_WARNING, "Failed to setup midi device observers: %s",
|
|
||||||
error.what());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -338,35 +329,95 @@ advss::MidiDeviceInstance::GetDevice(const libremidi::output_port &p)
|
|||||||
|
|
||||||
static inline QStringList getInputDeviceNames()
|
static inline QStringList getInputDeviceNames()
|
||||||
{
|
{
|
||||||
QStringList devices;
|
static QStringList devices;
|
||||||
|
static std::mutex m;
|
||||||
|
static std::vector<libremidi::observer> observers;
|
||||||
|
static bool setupDone = false;
|
||||||
|
|
||||||
|
if (setupDone) {
|
||||||
|
std::lock_guard<std::mutex> lock(m);
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up observers
|
||||||
try {
|
try {
|
||||||
libremidi::observer obs;
|
for (auto api : libremidi::available_apis()) {
|
||||||
for (const libremidi::input_port &port :
|
libremidi::observer_configuration cbs;
|
||||||
obs.get_input_ports()) {
|
cbs.track_virtual = true;
|
||||||
devices << QString::fromStdString(
|
cbs.input_added = [](const libremidi::input_port &p) {
|
||||||
getNameFromPortInformation(port));
|
std::lock_guard<std::mutex> lock(m);
|
||||||
|
auto device = QString::fromStdString(
|
||||||
|
getNameFromPortInformation(p));
|
||||||
|
if (devices.indexOf(device) == -1) {
|
||||||
|
devices << device;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cbs.input_removed = [](const libremidi::input_port &p) {
|
||||||
|
std::lock_guard<std::mutex> lock(m);
|
||||||
|
auto device = QString::fromStdString(
|
||||||
|
getNameFromPortInformation(p));
|
||||||
|
if (int i = devices.indexOf(device) != -1) {
|
||||||
|
devices.removeAt(i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
observers.emplace_back(
|
||||||
|
cbs,
|
||||||
|
libremidi::observer_configuration_for(api));
|
||||||
}
|
}
|
||||||
} catch (const libremidi::driver_error &error) {
|
} catch (const libremidi::driver_error &error) {
|
||||||
blog(LOG_WARNING, "Failed to get midi input devices: %s",
|
blog(LOG_WARNING, "Failed to get midi input devices: %s",
|
||||||
error.what());
|
error.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupDone = true;
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QStringList getOutputDeviceNames()
|
static inline QStringList getOutputDeviceNames()
|
||||||
{
|
{
|
||||||
QStringList devices;
|
static QStringList devices;
|
||||||
|
static std::mutex m;
|
||||||
|
static std::vector<libremidi::observer> observers;
|
||||||
|
static bool setupDone = false;
|
||||||
|
|
||||||
|
if (setupDone) {
|
||||||
|
std::lock_guard<std::mutex> lock(m);
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up observers
|
||||||
try {
|
try {
|
||||||
libremidi::observer obs;
|
for (auto api : libremidi::available_apis()) {
|
||||||
for (const libremidi::output_port &port :
|
libremidi::observer_configuration cbs;
|
||||||
obs.get_output_ports()) {
|
cbs.track_virtual = true;
|
||||||
devices << QString::fromStdString(
|
cbs.output_added = [](const libremidi::output_port &p) {
|
||||||
getNameFromPortInformation(port));
|
std::lock_guard<std::mutex> lock(m);
|
||||||
|
auto device = QString::fromStdString(
|
||||||
|
getNameFromPortInformation(p));
|
||||||
|
if (devices.indexOf(device) == -1) {
|
||||||
|
devices << device;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cbs.output_removed =
|
||||||
|
[](const libremidi::output_port &p) {
|
||||||
|
std::lock_guard<std::mutex> lock(m);
|
||||||
|
auto device = QString::fromStdString(
|
||||||
|
getNameFromPortInformation(p));
|
||||||
|
if (int i = devices.indexOf(device) !=
|
||||||
|
-1) {
|
||||||
|
devices.removeAt(i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
observers.emplace_back(
|
||||||
|
cbs,
|
||||||
|
libremidi::observer_configuration_for(api));
|
||||||
}
|
}
|
||||||
} catch (const libremidi::driver_error &error) {
|
} catch (const libremidi::driver_error &error) {
|
||||||
blog(LOG_WARNING, "Failed to get midi output devices: %s",
|
blog(LOG_WARNING, "Failed to get midi output devices: %s",
|
||||||
error.what());
|
error.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupDone = true;
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,16 +485,11 @@ bool MidiDevice::SendMessge(const MidiMessage &m) const
|
|||||||
static std::optional<libremidi::output_port>
|
static std::optional<libremidi::output_port>
|
||||||
getOutPortFromName(const std::string &name)
|
getOutPortFromName(const std::string &name)
|
||||||
{
|
{
|
||||||
try {
|
libremidi::observer obs;
|
||||||
libremidi::observer obs;
|
for (const libremidi::output_port &port : obs.get_output_ports()) {
|
||||||
for (const libremidi::output_port &port :
|
if (getNameFromPortInformation(port) == name) {
|
||||||
obs.get_output_ports()) {
|
return port;
|
||||||
if (getNameFromPortInformation(port) == name) {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (const libremidi::driver_error &error) {
|
|
||||||
blog(LOG_WARNING, "%s: %s", __func__, error.what());
|
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -451,16 +497,11 @@ getOutPortFromName(const std::string &name)
|
|||||||
static std::optional<libremidi::input_port>
|
static std::optional<libremidi::input_port>
|
||||||
getInPortFromName(const std::string &name)
|
getInPortFromName(const std::string &name)
|
||||||
{
|
{
|
||||||
try {
|
libremidi::observer obs;
|
||||||
libremidi::observer obs;
|
for (const libremidi::input_port &port : obs.get_input_ports()) {
|
||||||
for (const libremidi::input_port &port :
|
if (getNameFromPortInformation(port) == name) {
|
||||||
obs.get_input_ports()) {
|
return port;
|
||||||
if (getNameFromPortInformation(port) == name) {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (const libremidi::driver_error &error) {
|
|
||||||
blog(LOG_WARNING, "%s: %s", __func__, error.what());
|
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -1017,6 +1058,28 @@ void MidiMessageSelection::ValueChanged(const NumberVariable<int> &v)
|
|||||||
emit MidiMessageChanged((_currentSelection));
|
emit MidiMessageChanged((_currentSelection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GetDeviceNames()
|
||||||
|
{
|
||||||
|
std::vector<std::string> result;
|
||||||
|
const auto names = GetDeviceNamesAsQStringList();
|
||||||
|
for (const auto &name : names) {
|
||||||
|
result.emplace_back(name.toStdString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList GetDeviceNamesAsQStringList()
|
||||||
|
{
|
||||||
|
QStringList result;
|
||||||
|
for (const auto &input : getInputDeviceNames()) {
|
||||||
|
result << input;
|
||||||
|
}
|
||||||
|
for (const auto &output : getOutputDeviceNames()) {
|
||||||
|
result << output;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList GetAllNotes()
|
QStringList GetAllNotes()
|
||||||
{
|
{
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
|
|||||||
@@ -171,6 +171,8 @@ private:
|
|||||||
const MidiDeviceType _type;
|
const MidiDeviceType _type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> GetDeviceNames();
|
||||||
|
QStringList GetDeviceNamesAsQStringList();
|
||||||
QStringList GetAllNotes();
|
QStringList GetAllNotes();
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -529,8 +529,7 @@ TwitchTokenSettingsDialog::TwitchTokenSettingsDialog(
|
|||||||
HideToken();
|
HideToken();
|
||||||
|
|
||||||
if (_name->text().isEmpty()) {
|
if (_name->text().isEmpty()) {
|
||||||
HighlightWidget(_requestToken, Qt::green, QColor(0, 0, 0, 0),
|
PulseWidget(_requestToken, Qt::green, QColor(0, 0, 0, 0), true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentToken = settings;
|
_currentToken = settings;
|
||||||
@@ -574,8 +573,7 @@ void TwitchTokenSettingsDialog::HideToken()
|
|||||||
void TwitchTokenSettingsDialog::TokenOptionChanged(int)
|
void TwitchTokenSettingsDialog::TokenOptionChanged(int)
|
||||||
{
|
{
|
||||||
if (!_name->text().isEmpty()) {
|
if (!_name->text().isEmpty()) {
|
||||||
HighlightWidget(_requestToken, Qt::green, QColor(0, 0, 0, 0),
|
PulseWidget(_requestToken, Qt::green, QColor(0, 0, 0, 0), true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
_name->setText("");
|
_name->setText("");
|
||||||
SetTokenInfoVisible(false);
|
SetTokenInfoVisible(false);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user