Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Obs Studio
提交
c7fd733b
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,发现更多精彩内容 >>
未验证
提交
c7fd733b
编写于
4月 12, 2019
作者:
J
Jim
提交者:
GitHub
4月 12, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1825 from torresam/master
UI: Fix remux dialog ignoring filename changes
上级
8d3ee570
7ddab80d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
217 addition
and
189 deletion
+217
-189
UI/window-remux.cpp
UI/window-remux.cpp
+185
-189
UI/window-remux.hpp
UI/window-remux.hpp
+32
-0
未找到文件。
UI/window-remux.cpp
浏览文件 @
c7fd733b
...
...
@@ -57,216 +57,212 @@ enum RemuxEntryRole {
Delegate - Presents cells in the grid.
**********************************************************/
class
RemuxEntryPathItemDelegate
:
public
QStyledItemDelegate
{
public:
RemuxEntryPathItemDelegate
(
bool
isOutput
,
const
QString
&
defaultPath
)
:
QStyledItemDelegate
(),
isOutput
(
isOutput
),
defaultPath
(
defaultPath
)
{
}
virtual
QWidget
*
createEditor
(
QWidget
*
parent
,
const
QStyleOptionViewItem
&
/* option */
,
const
QModelIndex
&
index
)
const
override
{
RemuxEntryState
state
=
index
.
model
()
->
index
(
index
.
row
(),
RemuxEntryColumn
::
State
)
.
data
(
RemuxEntryRole
::
EntryStateRole
)
.
value
<
RemuxEntryState
>
();
if
(
state
==
RemuxEntryState
::
Pending
||
state
==
RemuxEntryState
::
InProgress
)
{
// Never allow modification of rows that are
// in progress.
return
Q_NULLPTR
;
}
else
if
(
isOutput
&&
state
!=
RemuxEntryState
::
Ready
)
{
// Do not allow modification of output rows
// that aren't associated with a valid input.
return
Q_NULLPTR
;
}
else
if
(
!
isOutput
&&
state
==
RemuxEntryState
::
Complete
)
{
// Don't allow modification of rows that are
// already complete.
return
Q_NULLPTR
;
}
else
{
QSizePolicy
buttonSizePolicy
(
QSizePolicy
::
Policy
::
Minimum
,
QSizePolicy
::
Policy
::
Expanding
,
QSizePolicy
::
ControlType
::
PushButton
);
QWidget
*
container
=
new
QWidget
(
parent
);
auto
browseCallback
=
[
this
,
container
]()
{
const_cast
<
RemuxEntryPathItemDelegate
*>
(
this
)
->
handleBrowse
(
container
);
};
auto
clearCallback
=
[
this
,
container
]()
{
const_cast
<
RemuxEntryPathItemDelegate
*>
(
this
)
->
handleClear
(
container
);
};
QHBoxLayout
*
layout
=
new
QHBoxLayout
();
layout
->
setMargin
(
0
);
layout
->
setSpacing
(
0
);
QLineEdit
*
text
=
new
QLineEdit
();
text
->
setObjectName
(
QStringLiteral
(
"text"
));
text
->
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Policy
::
Expanding
,
QSizePolicy
::
Policy
::
Expanding
,
QSizePolicy
::
ControlType
::
LineEdit
));
layout
->
addWidget
(
text
);
QToolButton
*
browseButton
=
new
QToolButton
();
browseButton
->
setText
(
"..."
);
browseButton
->
setSizePolicy
(
buttonSizePolicy
);
layout
->
addWidget
(
browseButton
);
container
->
connect
(
browseButton
,
&
QToolButton
::
clicked
,
browseCallback
);
// The "clear" button is not shown in output cells
// or the insertion point's input cell.
if
(
!
isOutput
&&
state
!=
RemuxEntryState
::
Empty
)
{
QToolButton
*
clearButton
=
new
QToolButton
();
clearButton
->
setText
(
"X"
);
clearButton
->
setSizePolicy
(
buttonSizePolicy
);
layout
->
addWidget
(
clearButton
);
container
->
connect
(
clearButton
,
&
QToolButton
::
clicked
,
clearCallback
);
}
container
->
setLayout
(
layout
);
container
->
setFocusProxy
(
text
);
return
container
;
RemuxEntryPathItemDelegate
::
RemuxEntryPathItemDelegate
(
bool
isOutput
,
const
QString
&
defaultPath
)
:
QStyledItemDelegate
(),
isOutput
(
isOutput
),
defaultPath
(
defaultPath
)
{
}
QWidget
*
RemuxEntryPathItemDelegate
::
createEditor
(
QWidget
*
parent
,
const
QStyleOptionViewItem
&
/* option */
,
const
QModelIndex
&
index
)
const
{
RemuxEntryState
state
=
index
.
model
()
->
index
(
index
.
row
(),
RemuxEntryColumn
::
State
)
.
data
(
RemuxEntryRole
::
EntryStateRole
)
.
value
<
RemuxEntryState
>
();
if
(
state
==
RemuxEntryState
::
Pending
||
state
==
RemuxEntryState
::
InProgress
)
{
// Never allow modification of rows that are
// in progress.
return
Q_NULLPTR
;
}
else
if
(
isOutput
&&
state
!=
RemuxEntryState
::
Ready
)
{
// Do not allow modification of output rows
// that aren't associated with a valid input.
return
Q_NULLPTR
;
}
else
if
(
!
isOutput
&&
state
==
RemuxEntryState
::
Complete
)
{
// Don't allow modification of rows that are
// already complete.
return
Q_NULLPTR
;
}
else
{
QSizePolicy
buttonSizePolicy
(
QSizePolicy
::
Policy
::
Minimum
,
QSizePolicy
::
Policy
::
Expanding
,
QSizePolicy
::
ControlType
::
PushButton
);
QWidget
*
container
=
new
QWidget
(
parent
);
auto
browseCallback
=
[
this
,
container
]()
{
const_cast
<
RemuxEntryPathItemDelegate
*>
(
this
)
->
handleBrowse
(
container
);
};
auto
clearCallback
=
[
this
,
container
]()
{
const_cast
<
RemuxEntryPathItemDelegate
*>
(
this
)
->
handleClear
(
container
);
};
QHBoxLayout
*
layout
=
new
QHBoxLayout
();
layout
->
setMargin
(
0
);
layout
->
setSpacing
(
0
);
QLineEdit
*
text
=
new
QLineEdit
();
text
->
setObjectName
(
QStringLiteral
(
"text"
));
text
->
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Policy
::
Expanding
,
QSizePolicy
::
Policy
::
Expanding
,
QSizePolicy
::
ControlType
::
LineEdit
));
layout
->
addWidget
(
text
);
QToolButton
*
browseButton
=
new
QToolButton
();
browseButton
->
setText
(
"..."
);
browseButton
->
setSizePolicy
(
buttonSizePolicy
);
layout
->
addWidget
(
browseButton
);
container
->
connect
(
browseButton
,
&
QToolButton
::
clicked
,
browseCallback
);
// The "clear" button is not shown in output cells
// or the insertion point's input cell.
if
(
!
isOutput
&&
state
!=
RemuxEntryState
::
Empty
)
{
QToolButton
*
clearButton
=
new
QToolButton
();
clearButton
->
setText
(
"X"
);
clearButton
->
setSizePolicy
(
buttonSizePolicy
);
layout
->
addWidget
(
clearButton
);
container
->
connect
(
clearButton
,
&
QToolButton
::
clicked
,
clearCallback
);
}
}
virtual
void
setEditorData
(
QWidget
*
editor
,
const
QModelIndex
&
index
)
const
override
{
QLineEdit
*
text
=
editor
->
findChild
<
QLineEdit
*>
();
text
->
setText
(
index
.
data
().
toString
());
editor
->
setProperty
(
PATH_LIST_PROP
,
QVariant
());
container
->
setLayout
(
layout
);
container
->
setFocusProxy
(
text
);
return
container
;
}
}
virtual
void
setModelData
(
QWidget
*
editor
,
QAbstractItemModel
*
model
,
const
QModelIndex
&
index
)
const
override
{
// We use the PATH_LIST_PROP property to pass a list of
// path strings from the editor widget into the model's
// NewPathsToProcessRole. This is only used when paths
// are selected through the "browse" or "delete" buttons
// in the editor. If the user enters new text in the
// text box, we simply pass that text on to the model
// as normal text data in the default role.
QVariant
pathListProp
=
editor
->
property
(
PATH_LIST_PROP
);
if
(
pathListProp
.
isValid
())
{
QStringList
list
=
editor
->
property
(
PATH_LIST_PROP
)
.
toStringList
();
if
(
isOutput
)
{
if
(
list
.
size
()
>
0
)
model
->
setData
(
index
,
list
);
}
else
model
->
setData
(
index
,
list
,
RemuxEntryRole
::
NewPathsToProcessRole
);
}
else
{
QLineEdit
*
lineEdit
=
editor
->
findChild
<
QLineEdit
*>
();
model
->
setData
(
index
,
lineEdit
->
text
());
}
void
RemuxEntryPathItemDelegate
::
setEditorData
(
QWidget
*
editor
,
const
QModelIndex
&
index
)
const
{
QLineEdit
*
text
=
editor
->
findChild
<
QLineEdit
*>
();
text
->
setText
(
index
.
data
().
toString
());
QObject
::
connect
(
text
,
SIGNAL
(
textEdited
(
QString
)),
this
,
SLOT
(
updateText
()));
editor
->
setProperty
(
PATH_LIST_PROP
,
QVariant
());
}
void
RemuxEntryPathItemDelegate
::
setModelData
(
QWidget
*
editor
,
QAbstractItemModel
*
model
,
const
QModelIndex
&
index
)
const
{
// We use the PATH_LIST_PROP property to pass a list of
// path strings from the editor widget into the model's
// NewPathsToProcessRole. This is only used when paths
// are selected through the "browse" or "delete" buttons
// in the editor. If the user enters new text in the
// text box, we simply pass that text on to the model
// as normal text data in the default role.
QVariant
pathListProp
=
editor
->
property
(
PATH_LIST_PROP
);
if
(
pathListProp
.
isValid
())
{
QStringList
list
=
editor
->
property
(
PATH_LIST_PROP
)
.
toStringList
();
if
(
isOutput
)
{
if
(
list
.
size
()
>
0
)
model
->
setData
(
index
,
list
);
}
else
model
->
setData
(
index
,
list
,
RemuxEntryRole
::
NewPathsToProcessRole
);
}
else
{
QLineEdit
*
lineEdit
=
editor
->
findChild
<
QLineEdit
*>
();
model
->
setData
(
index
,
lineEdit
->
text
());
}
}
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
override
{
RemuxEntryState
state
=
index
.
model
()
->
index
(
index
.
row
(),
RemuxEntryColumn
::
State
)
.
data
(
RemuxEntryRole
::
EntryStateRole
)
.
value
<
RemuxEntryState
>
();
void
RemuxEntryPathItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
RemuxEntryState
state
=
index
.
model
()
->
index
(
index
.
row
(),
RemuxEntryColumn
::
State
)
.
data
(
RemuxEntryRole
::
EntryStateRole
)
.
value
<
RemuxEntryState
>
();
QStyleOptionViewItem
localOption
=
option
;
initStyleOption
(
&
localOption
,
index
);
QStyleOptionViewItem
localOption
=
option
;
initStyleOption
(
&
localOption
,
index
);
if
(
isOutput
)
{
if
(
state
!=
Ready
)
{
QColor
background
=
localOption
.
palette
.
color
(
QPalette
::
ColorGroup
::
Disabled
,
QPalette
::
ColorRole
::
Background
);
if
(
isOutput
)
{
if
(
state
!=
Ready
)
{
QColor
background
=
localOption
.
palette
.
color
(
QPalette
::
ColorGroup
::
Disabled
,
QPalette
::
ColorRole
::
Background
);
localOption
.
backgroundBrush
=
QBrush
(
background
);
}
localOption
.
backgroundBrush
=
QBrush
(
background
);
}
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_ItemViewItem
,
&
localOption
,
painter
);
}
private:
bool
isOutput
;
QString
defaultPath
;
QApplication
::
style
()
->
drawControl
(
QStyle
::
CE_ItemViewItem
,
&
localOption
,
painter
)
;
}
const
char
*
PATH_LIST_PROP
=
"pathList"
;
void
RemuxEntryPathItemDelegate
::
handleBrowse
(
QWidget
*
container
)
{
QString
OutputPattern
=
"(*.mp4 *.flv *.mov *.mkv *.ts *.m3u8)"
;
QString
InputPattern
=
"(*.flv *.mov *.mkv *.ts *.m3u8)"
;
void
handleBrowse
(
QWidget
*
container
)
{
QString
OutputPattern
=
"(*.mp4 *.flv *.mov *.mkv *.ts *.m3u8)"
;
QString
InputPattern
=
"(*.flv *.mov *.mkv *.ts *.m3u8)"
;
QLineEdit
*
text
=
container
->
findChild
<
QLineEdit
*>
();
QLineEdit
*
text
=
container
->
findChild
<
QLineEdit
*>
();
QString
currentPath
=
text
->
text
();
if
(
currentPath
.
isEmpty
())
currentPath
=
defaultPath
;
QString
currentPath
=
text
->
text
();
if
(
currentPath
.
isEmpty
())
currentPath
=
defaultPath
;
bool
isSet
=
false
;
if
(
isOutput
)
{
QString
newPath
=
QFileDialog
::
getSaveFileName
(
container
,
QTStr
(
"Remux.SelectTarget"
),
currentPath
,
OutputPattern
);
bool
isSet
=
false
;
if
(
isOutput
)
{
QString
newPath
=
QFileDialog
::
getSaveFileName
(
container
,
QTStr
(
"Remux.SelectTarget"
),
currentPath
,
OutputPattern
);
if
(
!
newPath
.
isEmpty
())
{
container
->
setProperty
(
PATH_LIST_PROP
,
QStringList
()
<<
newPath
);
isSet
=
true
;
}
}
else
{
QStringList
paths
=
QFileDialog
::
getOpenFileNames
(
container
,
QTStr
(
"Remux.SelectRecording"
),
currentPath
,
QTStr
(
"Remux.OBSRecording"
)
+
QString
(
" "
)
+
InputPattern
);
if
(
!
paths
.
empty
())
{
container
->
setProperty
(
PATH_LIST_PROP
,
paths
);
isSet
=
true
;
}
if
(
!
newPath
.
isEmpty
())
{
container
->
setProperty
(
PATH_LIST_PROP
,
QStringList
()
<<
newPath
);
isSet
=
true
;
}
}
else
{
QStringList
paths
=
QFileDialog
::
getOpenFileNames
(
container
,
QTStr
(
"Remux.SelectRecording"
),
currentPath
,
QTStr
(
"Remux.OBSRecording"
)
+
QString
(
" "
)
+
InputPattern
);
if
(
!
paths
.
empty
())
{
container
->
setProperty
(
PATH_LIST_PROP
,
paths
);
isSet
=
true
;
}
if
(
isSet
)
emit
commitData
(
container
);
}
void
handleClear
(
QWidget
*
container
)
{
// An empty string list will indicate that the entry is being
// blanked and should be deleted.
container
->
setProperty
(
PATH_LIST_PROP
,
QStringList
());
if
(
isSet
)
emit
commitData
(
container
);
}
};
}
void
RemuxEntryPathItemDelegate
::
handleClear
(
QWidget
*
container
)
{
// An empty string list will indicate that the entry is being
// blanked and should be deleted.
container
->
setProperty
(
PATH_LIST_PROP
,
QStringList
());
emit
commitData
(
container
);
}
void
RemuxEntryPathItemDelegate
::
updateText
()
{
QLineEdit
*
lineEdit
=
dynamic_cast
<
QLineEdit
*>
(
sender
());
QWidget
*
editor
=
lineEdit
->
parentWidget
();
emit
commitData
(
editor
);
}
/**********************************************************
Model - Manages the queue's data
...
...
UI/window-remux.hpp
浏览文件 @
c7fd733b
...
...
@@ -21,6 +21,7 @@
#include <QMutex>
#include <QPointer>
#include <QThread>
#include <QStyledItemDelegate>
#include <memory>
#include "ui_OBSRemux.h"
...
...
@@ -160,3 +161,34 @@ signals:
friend
class
OBSRemux
;
};
class
RemuxEntryPathItemDelegate
:
public
QStyledItemDelegate
{
Q_OBJECT
public:
RemuxEntryPathItemDelegate
(
bool
isOutput
,
const
QString
&
defaultPath
);
virtual
QWidget
*
createEditor
(
QWidget
*
parent
,
const
QStyleOptionViewItem
&
/* option */
,
const
QModelIndex
&
index
)
const
override
;
virtual
void
setEditorData
(
QWidget
*
editor
,
const
QModelIndex
&
index
)
const
override
;
virtual
void
setModelData
(
QWidget
*
editor
,
QAbstractItemModel
*
model
,
const
QModelIndex
&
index
)
const
override
;
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
override
;
private:
bool
isOutput
;
QString
defaultPath
;
const
char
*
PATH_LIST_PROP
=
"pathList"
;
void
handleBrowse
(
QWidget
*
container
);
void
handleClear
(
QWidget
*
container
);
private
slots
:
void
updateText
();
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录