Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
adf6beb0
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
adf6beb0
编写于
7月 19, 2014
作者:
P
Palana
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add color property implementation
上级
3a2677c5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
6 deletion
+89
-6
obs/data/locale/en-US.ini
obs/data/locale/en-US.ini
+1
-0
obs/properties-view.cpp
obs/properties-view.cpp
+86
-5
obs/properties-view.hpp
obs/properties-view.hpp
+2
-1
未找到文件。
obs/data/locale/en-US.ini
浏览文件 @
adf6beb0
...
@@ -87,6 +87,7 @@ Basic.SourceSelect.AddExisting="Add Existing"
...
@@ -87,6 +87,7 @@ Basic.SourceSelect.AddExisting="Add Existing"
# properties window
# properties window
Basic.PropertiesWindow
=
"Properties for '%1'"
Basic.PropertiesWindow
=
"Properties for '%1'"
Basic.PropertiesWindow.AutoSelectFormat
=
"%1 (unsupported; autoselect: %2)"
Basic.PropertiesWindow.AutoSelectFormat
=
"%1 (unsupported; autoselect: %2)"
Basic.PropertiesWindow.SelectColor
=
"Select color"
# status bar
# status bar
Basic.StatusBar.Reconnecting
=
"Disconnected, reconnecting (attempt %1)"
Basic.StatusBar.Reconnecting
=
"Disconnected, reconnecting (attempt %1)"
...
...
obs/properties-view.cpp
浏览文件 @
adf6beb0
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <QPushButton>
#include <QPushButton>
#include <QStandardItem>
#include <QStandardItem>
#include <QFileDialog>
#include <QFileDialog>
#include <QColorDialog>
#include "qt-wrappers.hpp"
#include "qt-wrappers.hpp"
#include "properties-view.hpp"
#include "properties-view.hpp"
#include "obs-app.hpp"
#include "obs-app.hpp"
...
@@ -15,6 +16,27 @@
...
@@ -15,6 +16,27 @@
using
namespace
std
;
using
namespace
std
;
static
inline
QColor
color_from_int
(
long
long
val
)
{
return
QColor
(
val
&
0xff
,
(
val
>>
8
)
&
0xff
,
(
val
>>
16
)
&
0xff
,
(
val
>>
24
)
&
0xff
);
}
static
inline
long
long
color_to_int
(
QColor
color
)
{
auto
shift
=
[
&
](
unsigned
val
,
int
shift
)
{
return
((
val
&
0xff
)
<<
shift
);
};
return
shift
(
color
.
red
(),
0
)
|
shift
(
color
.
green
(),
8
)
|
shift
(
color
.
blue
(),
16
)
|
shift
(
color
.
alpha
(),
24
);
}
void
OBSPropertiesView
::
RefreshProperties
()
void
OBSPropertiesView
::
RefreshProperties
()
{
{
children
.
clear
();
children
.
clear
();
...
@@ -293,6 +315,37 @@ QWidget *OBSPropertiesView::AddButton(obs_property_t prop)
...
@@ -293,6 +315,37 @@ QWidget *OBSPropertiesView::AddButton(obs_property_t prop)
return
NewWidget
(
prop
,
button
,
SIGNAL
(
clicked
()));
return
NewWidget
(
prop
,
button
,
SIGNAL
(
clicked
()));
}
}
void
OBSPropertiesView
::
AddColor
(
obs_property_t
prop
,
QFormLayout
*
layout
,
QLabel
*&
label
)
{
QPushButton
*
button
=
new
QPushButton
;
QLabel
*
colorLabel
=
new
QLabel
;
const
char
*
name
=
obs_property_name
(
prop
);
long
long
val
=
obs_data_getint
(
settings
,
name
);
QColor
color
=
color_from_int
(
val
);
button
->
setText
(
QTStr
(
"Basic.PropertiesWindow.SelectColor"
));
colorLabel
->
setFrameStyle
(
QFrame
::
Sunken
|
QFrame
::
Panel
);
colorLabel
->
setText
(
color
.
name
(
QColor
::
HexArgb
));
colorLabel
->
setPalette
(
QPalette
(
color
));
colorLabel
->
setAutoFillBackground
(
true
);
colorLabel
->
setAlignment
(
Qt
::
AlignCenter
);
QHBoxLayout
*
subLayout
=
new
QHBoxLayout
;
subLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
subLayout
->
addWidget
(
colorLabel
);
subLayout
->
addWidget
(
button
);
WidgetInfo
*
info
=
new
WidgetInfo
(
this
,
prop
,
colorLabel
);
connect
(
button
,
SIGNAL
(
clicked
()),
info
,
SLOT
(
ControlChanged
()));
children
.
emplace_back
(
info
);
label
=
new
QLabel
(
QT_UTF8
(
obs_property_description
(
prop
)));
layout
->
addRow
(
label
,
subLayout
);
}
void
OBSPropertiesView
::
AddProperty
(
obs_property_t
property
,
void
OBSPropertiesView
::
AddProperty
(
obs_property_t
property
,
QFormLayout
*
layout
)
QFormLayout
*
layout
)
{
{
...
@@ -328,7 +381,7 @@ void OBSPropertiesView::AddProperty(obs_property_t property,
...
@@ -328,7 +381,7 @@ void OBSPropertiesView::AddProperty(obs_property_t property,
widget
=
AddList
(
property
,
warning
);
widget
=
AddList
(
property
,
warning
);
break
;
break
;
case
OBS_PROPERTY_COLOR
:
case
OBS_PROPERTY_COLOR
:
/* TODO */
AddColor
(
property
,
layout
,
label
);
break
;
break
;
case
OBS_PROPERTY_BUTTON
:
case
OBS_PROPERTY_BUTTON
:
widget
=
AddButton
(
property
);
widget
=
AddButton
(
property
);
...
@@ -448,10 +501,35 @@ void WidgetInfo::ListChanged(const char *setting)
...
@@ -448,10 +501,35 @@ void WidgetInfo::ListChanged(const char *setting)
}
}
}
}
void
WidgetInfo
::
ColorChanged
(
const
char
*
setting
)
bool
WidgetInfo
::
ColorChanged
(
const
char
*
setting
)
{
{
/* TODO */
const
char
*
desc
=
obs_property_description
(
property
);
UNUSED_PARAMETER
(
setting
);
long
long
val
=
obs_data_getint
(
view
->
settings
,
setting
);
QColor
color
=
color_from_int
(
val
);
QColorDialog
::
ColorDialogOptions
options
=
QColorDialog
::
ShowAlphaChannel
;
/* The native dialog on OSX has all kinds of problems, like closing
* other open QDialogs on exit, and
* https://bugreports.qt-project.org/browse/QTBUG-34532
*/
#ifdef __APPLE__
options
|=
QColorDialog
::
DontUseNativeDialog
;
#endif
color
=
QColorDialog
::
getColor
(
color
,
view
,
QT_UTF8
(
desc
),
options
);
if
(
!
color
.
isValid
())
return
false
;
QLabel
*
label
=
static_cast
<
QLabel
*>
(
widget
);
label
->
setText
(
color
.
name
(
QColor
::
HexArgb
));
label
->
setPalette
(
QPalette
(
color
));
obs_data_setint
(
view
->
settings
,
setting
,
color_to_int
(
color
));
return
true
;
}
}
void
WidgetInfo
::
ButtonClicked
()
void
WidgetInfo
::
ButtonClicked
()
...
@@ -471,8 +549,11 @@ void WidgetInfo::ControlChanged()
...
@@ -471,8 +549,11 @@ void WidgetInfo::ControlChanged()
case
OBS_PROPERTY_FLOAT
:
FloatChanged
(
setting
);
break
;
case
OBS_PROPERTY_FLOAT
:
FloatChanged
(
setting
);
break
;
case
OBS_PROPERTY_TEXT
:
TextChanged
(
setting
);
break
;
case
OBS_PROPERTY_TEXT
:
TextChanged
(
setting
);
break
;
case
OBS_PROPERTY_LIST
:
ListChanged
(
setting
);
break
;
case
OBS_PROPERTY_LIST
:
ListChanged
(
setting
);
break
;
case
OBS_PROPERTY_COLOR
:
ColorChanged
(
setting
);
break
;
case
OBS_PROPERTY_BUTTON
:
ButtonClicked
();
return
;
case
OBS_PROPERTY_BUTTON
:
ButtonClicked
();
return
;
case
OBS_PROPERTY_COLOR
:
if
(
!
ColorChanged
(
setting
))
return
;
break
;
case
OBS_PROPERTY_PATH
:
case
OBS_PROPERTY_PATH
:
if
(
!
PathChanged
(
setting
))
if
(
!
PathChanged
(
setting
))
return
;
return
;
...
...
obs/properties-view.hpp
浏览文件 @
adf6beb0
...
@@ -27,7 +27,7 @@ private:
...
@@ -27,7 +27,7 @@ private:
void
TextChanged
(
const
char
*
setting
);
void
TextChanged
(
const
char
*
setting
);
bool
PathChanged
(
const
char
*
setting
);
bool
PathChanged
(
const
char
*
setting
);
void
ListChanged
(
const
char
*
setting
);
void
ListChanged
(
const
char
*
setting
);
void
ColorChanged
(
const
char
*
setting
);
bool
ColorChanged
(
const
char
*
setting
);
void
ButtonClicked
();
void
ButtonClicked
();
public:
public:
...
@@ -68,6 +68,7 @@ private:
...
@@ -68,6 +68,7 @@ private:
QWidget
*
AddFloat
(
obs_property_t
prop
);
QWidget
*
AddFloat
(
obs_property_t
prop
);
QWidget
*
AddList
(
obs_property_t
prop
,
bool
&
warning
);
QWidget
*
AddList
(
obs_property_t
prop
,
bool
&
warning
);
QWidget
*
AddButton
(
obs_property_t
prop
);
QWidget
*
AddButton
(
obs_property_t
prop
);
void
AddColor
(
obs_property_t
prop
,
QFormLayout
*
layout
,
QLabel
*&
label
);
void
AddProperty
(
obs_property_t
property
,
QFormLayout
*
layout
);
void
AddProperty
(
obs_property_t
property
,
QFormLayout
*
layout
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录