New upstream version 25.0.3+dfsg1
This commit is contained in:
parent
04fe0efc67
commit
8b2e5f2130
569 changed files with 62491 additions and 5875 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <QDropEvent>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeData>
|
||||
#include <QUrlQuery>
|
||||
#include <string>
|
||||
|
||||
#include "window-basic-main.hpp"
|
||||
|
|
@ -55,14 +56,47 @@ static string GenerateSourceName(const char *base)
|
|||
}
|
||||
}
|
||||
|
||||
void OBSBasic::AddDropURL(const char *url, QString &name, obs_data_t *settings,
|
||||
const obs_video_info &ovi)
|
||||
{
|
||||
QUrl path = QString::fromUtf8(url);
|
||||
QUrlQuery query = QUrlQuery(path.query(QUrl::FullyEncoded));
|
||||
|
||||
int cx = (int)ovi.base_width;
|
||||
int cy = (int)ovi.base_height;
|
||||
|
||||
if (query.hasQueryItem("layer-width"))
|
||||
cx = query.queryItemValue("layer-width").toInt();
|
||||
if (query.hasQueryItem("layer-height"))
|
||||
cy = query.queryItemValue("layer-height").toInt();
|
||||
|
||||
obs_data_set_int(settings, "width", cx);
|
||||
obs_data_set_int(settings, "height", cy);
|
||||
|
||||
name = query.hasQueryItem("layer-name")
|
||||
? query.queryItemValue("layer-name", QUrl::FullyDecoded)
|
||||
: path.host();
|
||||
|
||||
query.removeQueryItem("layer-width");
|
||||
query.removeQueryItem("layer-height");
|
||||
query.removeQueryItem("layer-name");
|
||||
path.setQuery(query);
|
||||
|
||||
obs_data_set_string(settings, "url", QT_TO_UTF8(path.url()));
|
||||
}
|
||||
|
||||
void OBSBasic::AddDropSource(const char *data, DropType image)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
obs_data_t *settings = obs_data_create();
|
||||
obs_source_t *source = nullptr;
|
||||
const char *type = nullptr;
|
||||
std::vector<const char *> types;
|
||||
QString name;
|
||||
|
||||
obs_video_info ovi;
|
||||
obs_get_video_info(&ovi);
|
||||
|
||||
switch (image) {
|
||||
case DropType_RawText:
|
||||
obs_data_set_string(settings, "text", data);
|
||||
|
|
@ -97,12 +131,24 @@ void OBSBasic::AddDropSource(const char *data, DropType image)
|
|||
case DropType_Html:
|
||||
obs_data_set_bool(settings, "is_local_file", true);
|
||||
obs_data_set_string(settings, "local_file", data);
|
||||
obs_data_set_int(settings, "width", ovi.base_width);
|
||||
obs_data_set_int(settings, "height", ovi.base_height);
|
||||
name = QUrl::fromLocalFile(QString(data)).fileName();
|
||||
type = "browser_source";
|
||||
types = {"browser_source", "linuxbrowser-source"};
|
||||
break;
|
||||
case DropType_Url:
|
||||
AddDropURL(data, name, settings, ovi);
|
||||
types = {"browser_source", "linuxbrowser-source"};
|
||||
break;
|
||||
}
|
||||
|
||||
if (!obs_source_get_display_name(type)) {
|
||||
for (char const *t : types) {
|
||||
if (obs_source_get_display_name(t)) {
|
||||
type = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type == nullptr || !obs_source_get_display_name(type)) {
|
||||
obs_data_release(settings);
|
||||
return;
|
||||
}
|
||||
|
|
@ -136,6 +182,35 @@ void OBSBasic::dragMoveEvent(QDragMoveEvent *event)
|
|||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void OBSBasic::ConfirmDropUrl(const QString &url)
|
||||
{
|
||||
if (url.left(7).compare("http://", Qt::CaseInsensitive) == 0 ||
|
||||
url.left(8).compare("https://", Qt::CaseInsensitive) == 0) {
|
||||
|
||||
activateWindow();
|
||||
|
||||
QString msg = QTStr("AddUrl.Text");
|
||||
msg += "\n\n";
|
||||
msg += QTStr("AddUrl.Text.Url").arg(url);
|
||||
|
||||
QMessageBox messageBox(this);
|
||||
messageBox.setWindowTitle(QTStr("AddUrl.Title"));
|
||||
messageBox.setText(msg);
|
||||
|
||||
QPushButton *yesButton = messageBox.addButton(
|
||||
QTStr("Yes"), QMessageBox::YesRole);
|
||||
QPushButton *noButton =
|
||||
messageBox.addButton(QTStr("No"), QMessageBox::NoRole);
|
||||
messageBox.setDefaultButton(yesButton);
|
||||
messageBox.setEscapeButton(noButton);
|
||||
messageBox.setIcon(QMessageBox::Question);
|
||||
messageBox.exec();
|
||||
|
||||
if (messageBox.clickedButton() == yesButton)
|
||||
AddDropSource(QT_TO_UTF8(url), DropType_Url);
|
||||
}
|
||||
}
|
||||
|
||||
void OBSBasic::dropEvent(QDropEvent *event)
|
||||
{
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
|
|
@ -144,11 +219,14 @@ void OBSBasic::dropEvent(QDropEvent *event)
|
|||
QList<QUrl> urls = mimeData->urls();
|
||||
|
||||
for (int i = 0; i < urls.size(); i++) {
|
||||
QString file = urls.at(i).toLocalFile();
|
||||
QUrl url = urls[i];
|
||||
QString file = url.toLocalFile();
|
||||
QFileInfo fileInfo(file);
|
||||
|
||||
if (!fileInfo.exists())
|
||||
if (!fileInfo.exists()) {
|
||||
ConfirmDropUrl(url.url());
|
||||
continue;
|
||||
}
|
||||
|
||||
QString suffixQStr = fileInfo.suffix();
|
||||
QByteArray suffixArray = suffixQStr.toUtf8();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue