Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Obs Studio
提交
5f830522
O
Obs Studio
项目概览
小白菜888
/
Obs Studio
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Obs Studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f830522
编写于
3月 04, 2019
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UI: Add drag and drop for URLs
Co-authored-by:
N
Matt Gajownik
<
matt@wizardcm.com
>
上级
505d3218
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
2 deletion
+77
-2
UI/data/locale/en-US.ini
UI/data/locale/en-US.ini
+5
-0
UI/window-basic-main-dropfiles.cpp
UI/window-basic-main-dropfiles.cpp
+68
-2
UI/window-basic-main.hpp
UI/window-basic-main.hpp
+4
-0
未找到文件。
UI/data/locale/en-US.ini
浏览文件 @
5f830522
...
...
@@ -984,6 +984,11 @@ About.Authors="Authors"
About.License
=
"License"
About.Contribute
=
"Support the OBS Project"
# Drag-drop URL
AddUrl.Title
=
"Add Source via URL"
AddUrl.Text
=
"You have dragged a URL into OBS. This will automatically add the link as a source. Continue?"
AddUrl.Text.Url
=
"URL: %1"
# Dynamic output size
ResizeOutputSizeOfSource
=
"Resize output (source size)"
ResizeOutputSizeOfSource.Text
=
"The base and output resolutions will be resized to the size of the current source."
...
...
UI/window-basic-main-dropfiles.cpp
浏览文件 @
5f830522
...
...
@@ -4,6 +4,7 @@
#include <QDropEvent>
#include <QFileInfo>
#include <QMimeData>
#include <QUrlQuery>
#include <string>
#include "window-basic-main.hpp"
...
...
@@ -55,6 +56,35 @@ 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
());
...
...
@@ -105,6 +135,10 @@ void OBSBasic::AddDropSource(const char *data, DropType image)
name
=
QUrl
::
fromLocalFile
(
QString
(
data
)).
fileName
();
type
=
"browser_source"
;
break
;
case
DropType_Url
:
AddDropURL
(
data
,
name
,
settings
,
ovi
);
type
=
"browser_source"
;
break
;
}
if
(
!
obs_source_get_display_name
(
type
))
{
...
...
@@ -141,6 +175,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
();
...
...
@@ -149,11 +212,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
();
...
...
UI/window-basic-main.hpp
浏览文件 @
5f830522
...
...
@@ -170,6 +170,7 @@ class OBSBasic : public OBSMainWindow {
DropType_Image
,
DropType_Media
,
DropType_Html
,
DropType_Url
,
};
private:
...
...
@@ -435,6 +436,9 @@ private:
inline
void
OnDeactivate
();
void
AddDropSource
(
const
char
*
file
,
DropType
image
);
void
AddDropURL
(
const
char
*
url
,
QString
&
name
,
obs_data_t
*
settings
,
const
obs_video_info
&
ovi
);
void
ConfirmDropUrl
(
const
QString
&
url
);
void
dragEnterEvent
(
QDragEnterEvent
*
event
)
override
;
void
dragLeaveEvent
(
QDragLeaveEvent
*
event
)
override
;
void
dragMoveEvent
(
QDragMoveEvent
*
event
)
override
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录