Add file selection widget

Rework the following macro conditions and actions to use this widget:
 - file action
 - run action
 - file condition
This commit is contained in:
WarmUpTill
2021-09-18 23:15:17 +02:00
committed by WarmUpTill
parent aea9d1b319
commit b3f1aff03c
11 changed files with 119 additions and 104 deletions

View File

@@ -0,0 +1,30 @@
#pragma once
#include <QLineEdit>
#include <QPushButton>
#include <QWidget>
class FileSelection : public QWidget {
Q_OBJECT
public:
enum class Type {
READ,
WRITE,
};
FileSelection(FileSelection::Type type = FileSelection::Type::READ,
QWidget *parent = 0);
void SetPath(const QString &);
QPushButton *Button() { return _browseButton; }
private slots:
void BrowseButtonClicked();
void PathChange();
signals:
void PathChanged(const QString &);
private:
Type _type;
QLineEdit *_filePath;
QPushButton *_browseButton;
};

View File

@@ -2,6 +2,7 @@
#include <QSpinBox>
#include <QPlainTextEdit>
#include "macro-action-edit.hpp"
#include "file-selection.hpp"
enum class FileAction {
WRITE,
@@ -47,16 +48,14 @@ public:
}
private slots:
void FilePathChanged();
void BrowseButtonClicked();
void PathChanged(const QString &text);
void TextChanged();
void ActionChanged(int value);
signals:
void HeaderInfoChanged(const QString &);
protected:
QLineEdit *_filePath;
QPushButton *_browseButton;
FileSelection *_filePath;
QPlainTextEdit *_text;
QComboBox *_actions;
std::shared_ptr<MacroActionFile> _entryData;

View File

@@ -1,5 +1,6 @@
#pragma once
#include "macro-action-edit.hpp"
#include "file-selection.hpp"
#include <QLineEdit>
#include <QPushButton>
@@ -43,8 +44,7 @@ public:
}
private slots:
void FilePathChanged();
void BrowseButtonClicked();
void PathChanged(const QString &text);
void AddArg();
void RemoveArg();
void ArgUp();
@@ -56,8 +56,7 @@ protected:
std::shared_ptr<MacroActionRun> _entryData;
private:
QLineEdit *_filePath;
QPushButton *_browseButton;
FileSelection *_filePath;
QListWidget *_argList;
QPushButton *_addArg;
QPushButton *_removeArg;

View File

@@ -1,5 +1,7 @@
#pragma once
#include "macro.hpp"
#include "file-selection.hpp"
#include <QWidget>
#include <QComboBox>
#include <QDateTime>
@@ -61,8 +63,7 @@ public:
private slots:
void FileTypeChanged(int index);
void FilePathChanged();
void BrowseButtonClicked();
void PathChanged(const QString &text);
void MatchTextChanged();
void UseRegexChanged(int state);
void CheckModificationDateChanged(int state);
@@ -72,8 +73,7 @@ signals:
protected:
QComboBox *_fileType;
QLineEdit *_filePath;
QPushButton *_browseButton;
FileSelection *_filePath;
QPlainTextEdit *_matchText;
QCheckBox *_useRegex;
QCheckBox *_checkModificationDate;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "macro.hpp"
#include "screenshot-helper.hpp"
#include "file-selection.hpp"
#include <QWidget>
#include <QComboBox>
@@ -41,6 +42,10 @@ private:
std::unique_ptr<AdvSSScreenshotObj> _screenshotData = nullptr;
QImage _matchImage;
std::string _modelDataPath =
obs_get_module_data_path(obs_current_module()) +
std::string(
"/res/cascadeClassifiers/haarcascade_frontalface_alt.xml");
static bool _registered;
static const std::string id;
};