mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-02 00:22:10 -05:00
Reduce text edit areas size of file, filter, source, transform segments
This commit is contained in:
parent
6fb8297275
commit
1cfd981245
|
|
@ -262,6 +262,7 @@ set(advanced-scene-switcher_HEADERS
|
|||
src/headers/section.hpp
|
||||
src/headers/status-control.hpp
|
||||
src/headers/platform-funcs.hpp
|
||||
src/headers/resizing-text-edit.hpp
|
||||
src/headers/utility.hpp
|
||||
src/headers/volume-control.hpp
|
||||
src/headers/version.h)
|
||||
|
|
@ -359,6 +360,7 @@ set(advanced-scene-switcher_SOURCES
|
|||
src/screenshot-helper.cpp
|
||||
src/transition-selection.cpp
|
||||
src/name-dialog.cpp
|
||||
src/resizing-text-edit.cpp
|
||||
src/duration-control.cpp
|
||||
src/status-control.cpp
|
||||
src/section.cpp
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#pragma once
|
||||
#include <QSpinBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "file-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
enum class FileAction {
|
||||
WRITE,
|
||||
|
|
@ -57,7 +58,7 @@ signals:
|
|||
|
||||
protected:
|
||||
FileSelection *_filePath;
|
||||
QPlainTextEdit *_text;
|
||||
ResizingPlainTextEdit *_text;
|
||||
QComboBox *_actions;
|
||||
std::shared_ptr<MacroActionFile> _entryData;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
#include <QSpinBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
enum class FilterAction {
|
||||
ENABLE,
|
||||
|
|
@ -63,7 +64,7 @@ protected:
|
|||
QComboBox *_filters;
|
||||
QComboBox *_actions;
|
||||
QPushButton *_getSettings;
|
||||
QPlainTextEdit *_settings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
std::shared_ptr<MacroActionFilter> _entryData;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#include "macro-action-edit.hpp"
|
||||
#include "scene-selection.hpp"
|
||||
#include "scene-item-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
class MacroActionSceneTransform : public MacroAction {
|
||||
public:
|
||||
|
|
@ -61,7 +61,7 @@ protected:
|
|||
SceneSelectionWidget *_scenes;
|
||||
SceneItemSelectionWidget *_sources;
|
||||
QPushButton *_getSettings;
|
||||
QPlainTextEdit *_settings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
std::shared_ptr<MacroActionSceneTransform> _entryData;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
enum class SourceAction {
|
||||
ENABLE,
|
||||
|
|
@ -63,7 +63,7 @@ protected:
|
|||
QComboBox *_sources;
|
||||
QComboBox *_actions;
|
||||
QPushButton *_getSettings;
|
||||
QPlainTextEdit *_settings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
QLabel *_warning;
|
||||
std::shared_ptr<MacroActionSource> _entryData;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "file-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QDateTime>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
enum class FileType {
|
||||
|
|
@ -75,7 +75,7 @@ signals:
|
|||
protected:
|
||||
QComboBox *_fileType;
|
||||
FileSelection *_filePath;
|
||||
QPlainTextEdit *_matchText;
|
||||
ResizingPlainTextEdit *_matchText;
|
||||
QCheckBox *_useRegex;
|
||||
QCheckBox *_checkModificationDate;
|
||||
QCheckBox *_checkFileContent;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
enum class FilterCondition {
|
||||
|
|
@ -67,7 +67,7 @@ protected:
|
|||
QComboBox *_filters;
|
||||
QComboBox *_conditions;
|
||||
QPushButton *_getSettings;
|
||||
QPlainTextEdit *_settings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
QCheckBox *_regex;
|
||||
|
||||
std::shared_ptr<MacroConditionFilter> _entryData;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#include "macro.hpp"
|
||||
#include "scene-selection.hpp"
|
||||
#include "scene-item-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
class MacroConditionSceneTransform : public MacroCondition {
|
||||
|
|
@ -61,7 +61,7 @@ protected:
|
|||
SceneSelectionWidget *_scenes;
|
||||
SceneItemSelectionWidget *_sources;
|
||||
QPushButton *_getSettings;
|
||||
QPlainTextEdit *_settings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
QCheckBox *_regex;
|
||||
|
||||
std::shared_ptr<MacroConditionSceneTransform> _entryData;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
enum class SourceCondition {
|
||||
|
|
@ -64,7 +64,7 @@ protected:
|
|||
QComboBox *_sources;
|
||||
QComboBox *_conditions;
|
||||
QPushButton *_getSettings;
|
||||
QPlainTextEdit *_settings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
QCheckBox *_regex;
|
||||
|
||||
std::shared_ptr<MacroConditionSource> _entryData;
|
||||
|
|
|
|||
17
src/headers/resizing-text-edit.hpp
Normal file
17
src/headers/resizing-text-edit.hpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
class ResizingPlainTextEdit : public QPlainTextEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResizingPlainTextEdit(QWidget *parent, const int scrollAt = 10,
|
||||
const int minLines = 3,
|
||||
const int paddingLines = 2);
|
||||
private slots:
|
||||
void ResizeTexteditArea();
|
||||
|
||||
private:
|
||||
const int _scrollAt;
|
||||
const int _minLines;
|
||||
const int _paddingLines;
|
||||
};
|
||||
|
|
@ -87,7 +87,7 @@ MacroActionFileEdit::MacroActionFileEdit(
|
|||
: QWidget(parent)
|
||||
{
|
||||
_filePath = new FileSelection(FileSelection::Type::WRITE);
|
||||
_text = new QPlainTextEdit();
|
||||
_text = new ResizingPlainTextEdit(this);
|
||||
_actions = new QComboBox();
|
||||
|
||||
populateActionSelection(_actions);
|
||||
|
|
@ -150,6 +150,9 @@ void MacroActionFileEdit::TextChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_text = _text->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroActionFileEdit::ActionChanged(int value)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ MacroActionFilterEdit::MacroActionFilterEdit(
|
|||
_actions = new QComboBox();
|
||||
_getSettings = new QPushButton(
|
||||
obs_module_text("AdvSceneSwitcher.action.filter.getSettings"));
|
||||
_settings = new QPlainTextEdit();
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
|
||||
populateActionSelection(_actions);
|
||||
populateSourcesWithFilterSelection(_sources);
|
||||
|
|
@ -211,6 +211,9 @@ void MacroActionFilterEdit::SettingsChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_settings = _settings->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroActionFilterEdit::SetWidgetVisibility(bool showSettings)
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ MacroActionSceneTransformEdit::MacroActionSceneTransformEdit(
|
|||
_sources = new SceneItemSelectionWidget(parent);
|
||||
_getSettings = new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.action.sceneTransform.getTransform"));
|
||||
_settings = new QPlainTextEdit();
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
|
||||
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
|
||||
this, SLOT(SceneChanged(const SceneSelection &)));
|
||||
|
|
@ -212,4 +212,7 @@ void MacroActionSceneTransformEdit::SettingsChanged()
|
|||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto json = _settings->toPlainText().toStdString();
|
||||
_entryData->SetSettings(json);
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ MacroActionSourceEdit::MacroActionSourceEdit(
|
|||
_actions = new QComboBox();
|
||||
_getSettings = new QPushButton(
|
||||
obs_module_text("AdvSceneSwitcher.action.source.getSettings"));
|
||||
_settings = new QPlainTextEdit();
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_warning = new QLabel(
|
||||
obs_module_text("AdvSceneSwitcher.action.source.warning"));
|
||||
|
||||
|
|
@ -184,6 +184,9 @@ void MacroActionSourceEdit::SettingsChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_settings = _settings->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroActionSourceEdit::SetWidgetVisibility(bool showSettings)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ MacroConditionFileEdit::MacroConditionFileEdit(
|
|||
{
|
||||
_fileType = new QComboBox();
|
||||
_filePath = new FileSelection();
|
||||
_matchText = new QPlainTextEdit();
|
||||
_matchText = new ResizingPlainTextEdit(this);
|
||||
_useRegex = new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.fileTab.useRegExp"));
|
||||
_checkModificationDate = new QCheckBox(obs_module_text(
|
||||
|
|
@ -250,6 +250,9 @@ void MacroConditionFileEdit::MatchTextChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_text = _matchText->toPlainText().toUtf8().constData();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroConditionFileEdit::UseRegexChanged(int state)
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ MacroConditionFilterEdit::MacroConditionFilterEdit(
|
|||
_conditions = new QComboBox();
|
||||
_getSettings = new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.filter.getSettings"));
|
||||
_settings = new QPlainTextEdit();
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_regex = new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.condition.filter.regex"));
|
||||
|
||||
|
|
@ -208,6 +208,9 @@ void MacroConditionFilterEdit::SettingsChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_settings = _settings->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroConditionFilterEdit::RegexChanged(int state)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ MacroConditionSceneTransformEdit::MacroConditionSceneTransformEdit(
|
|||
parent, true, SceneItemSelectionWidget::AllSelectionType::ANY);
|
||||
_getSettings = new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.sceneTransform.getTransform"));
|
||||
_settings = new QPlainTextEdit();
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_regex = new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.sceneTransform.regex"));
|
||||
|
||||
|
|
@ -190,6 +190,9 @@ void MacroConditionSceneTransformEdit::SettingsChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_settings = _settings->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroConditionSceneTransformEdit::RegexChanged(int state)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ MacroConditionSourceEdit::MacroConditionSourceEdit(
|
|||
_conditions = new QComboBox();
|
||||
_getSettings = new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.source.getSettings"));
|
||||
_settings = new QPlainTextEdit();
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_regex = new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.condition.source.regex"));
|
||||
|
||||
|
|
@ -185,6 +185,9 @@ void MacroConditionSourceEdit::SettingsChanged()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_settings = _settings->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroConditionSourceEdit::RegexChanged(int state)
|
||||
|
|
|
|||
31
src/resizing-text-edit.cpp
Normal file
31
src/resizing-text-edit.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "headers/resizing-text-edit.hpp"
|
||||
|
||||
ResizingPlainTextEdit::ResizingPlainTextEdit(QWidget *parent,
|
||||
const int scrollAt,
|
||||
const int minLines,
|
||||
const int paddingLines)
|
||||
: QPlainTextEdit(parent),
|
||||
_scrollAt(scrollAt),
|
||||
_minLines(minLines),
|
||||
_paddingLines(paddingLines)
|
||||
{
|
||||
QWidget::connect(this, SIGNAL(textChanged()), this,
|
||||
SLOT(ResizeTexteditArea()));
|
||||
}
|
||||
|
||||
void ResizingPlainTextEdit::ResizeTexteditArea()
|
||||
{
|
||||
QFontMetrics f(font());
|
||||
int rowHeight = f.lineSpacing();
|
||||
int numLines = document()->blockCount();
|
||||
if (numLines + _paddingLines < _minLines) {
|
||||
setFixedHeight(_minLines * rowHeight);
|
||||
} else if (numLines + _paddingLines < _scrollAt) {
|
||||
setFixedHeight((numLines + _paddingLines) * rowHeight);
|
||||
} else {
|
||||
setFixedHeight(_scrollAt * rowHeight);
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user