File: ImageSourceToolbar.cpp

package info (click to toggle)
obs-studio 32.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 49,868 kB
  • sloc: ansic: 191,636; cpp: 110,959; makefile: 877; python: 675; sh: 287; javascript: 19
file content (53 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "ImageSourceToolbar.hpp"
#include "ui_image-source-toolbar.h"

#include <qt-wrappers.hpp>

#include "moc_ImageSourceToolbar.cpp"

ImageSourceToolbar::ImageSourceToolbar(QWidget *parent, OBSSource source)
	: SourceToolbar(parent, source),
	  ui(new Ui_ImageSourceToolbar)
{
	ui->setupUi(this);

	obs_module_t *mod = obs_get_module("image-source");
	ui->pathLabel->setText(obs_module_get_locale_text(mod, "File"));

	OBSDataAutoRelease settings = obs_source_get_settings(source);
	std::string file = obs_data_get_string(settings, "file");

	ui->path->setText(file.c_str());
}

ImageSourceToolbar::~ImageSourceToolbar() {}

void ImageSourceToolbar::on_browse_clicked()
{
	OBSSource source = GetSource();
	if (!source) {
		return;
	}

	obs_property_t *p = obs_properties_get(props.get(), "file");
	const char *desc = obs_property_description(p);
	const char *filter = obs_property_path_filter(p);
	const char *default_path = obs_property_path_default_path(p);

	QString startDir = ui->path->text();
	if (startDir.isEmpty())
		startDir = default_path;

	QString path = OpenFile(this, desc, startDir, filter);
	if (path.isEmpty()) {
		return;
	}

	ui->path->setText(path);

	SaveOldProperties(source);
	OBSDataAutoRelease settings = obs_data_create();
	obs_data_set_string(settings, "file", QT_TO_UTF8(path));
	obs_source_update(source, settings);
	SetUndoProperties(source);
}