Commit a15751bb authored by François Cartegnie's avatar François Cartegnie 🤞

Qt: profiles_selector: change/simplify widgets reset/selection behavior

parent 43084cb6
......@@ -75,7 +75,6 @@ VLCProfileSelector::VLCProfileSelector( QWidget *_parent ): QWidget( _parent )
CONNECT( profileBox, activated( int ),
this, updateOptions( int ) );
updateOptions( 0 );
}
......@@ -385,15 +384,6 @@ VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value
}
loadCapabilities();
registerCodecs();
CONNECT( ui.valueholder_video_enable, toggled( bool ),
this, setVTranscodeOptions( bool ) );
CONNECT( ui.valueholder_audio_enable, toggled( bool ),
this, setATranscodeOptions( bool ) );
CONNECT( ui.valueholder_subtitles_enable, toggled( bool ),
this, setSTranscodeOptions( bool ) );
setVTranscodeOptions( false );
setATranscodeOptions( false );
setSTranscodeOptions( false );
QPushButton *saveButton = new QPushButton(
( qs_name.isEmpty() ) ? qtr( "Create" ) : qtr( "Save" ) );
......@@ -403,6 +393,12 @@ VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value
ui.buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
BUTTONACT( cancelButton, reject() );
CONNECT( ui.valueholder_video_copy, stateChanged( int ),
this, activatePanels() );
CONNECT( ui.valueholder_audio_copy, stateChanged( int ),
this, activatePanels() );
reset();
fillProfile( value );
muxSelected();
}
......@@ -570,6 +566,11 @@ void VLCProfileEditor::fillProfile( const QString& qs )
QCheckBox *box = qobject_cast<QCheckBox *>( object );
box->setChecked( ! value.isEmpty() );
}
else if( object->inherits( "QGroupBox" ) )
{
QGroupBox *box = qobject_cast<QGroupBox *>( object );
box->setChecked( ! value.isEmpty() );
}
else if( object->inherits( "QSpinBox" ) )
{
QSpinBox *box = qobject_cast<QSpinBox *>( object );
......@@ -636,42 +637,6 @@ void VLCProfileEditor::fillProfileOldFormat( const QString& qs )
ui.valueholder_subtitles_overlay->setChecked( options[15].toInt() );
}
void VLCProfileEditor::setVTranscodeOptions( bool b_trans )
{
ui.vCodecLabel->setEnabled( b_trans );
ui.valueholder_video_codec->setEnabled( b_trans );
ui.vBitrateLabel->setEnabled( b_trans );
ui.valueholder_vcodec_bitrate->setEnabled( b_trans );
ui.vScaleLabel->setEnabled( b_trans );
ui.valueholder_vcodec_scale->setEnabled( b_trans );
ui.valueholder_vcodec_height->setEnabled( b_trans );
ui.heightLabel->setEnabled( b_trans );
ui.valueholder_vcodec_width->setEnabled( b_trans );
ui.widthLabel->setEnabled( b_trans );
ui.valueholder_vcodec_framerate->setEnabled( b_trans );
ui.vFrameLabel->setEnabled( b_trans );
ui.valueholder_video_copy->setEnabled( b_trans );
}
void VLCProfileEditor::setATranscodeOptions( bool b_trans )
{
ui.aCodecLabel->setEnabled( b_trans );
ui.valueholder_audio_codec->setEnabled( b_trans );
ui.aBitrateLabel->setEnabled( b_trans );
ui.valueholder_acodec_bitrate->setEnabled( b_trans );
ui.aChannelsLabel->setEnabled( b_trans );
ui.valueholder_acodec_channels->setEnabled( b_trans );
ui.aSampleLabel->setEnabled( b_trans );
ui.valueholder_acodec_samplerate->setEnabled( b_trans );
ui.valueholder_audio_copy->setEnabled( b_trans );
}
void VLCProfileEditor::setSTranscodeOptions( bool b_trans )
{
ui.valueholder_subtitles_codec->setEnabled( b_trans );
ui.valueholder_subtitles_overlay->setEnabled( b_trans );
}
void VLCProfileEditor::close()
{
if( ui.profileLine->text().isEmpty() )
......@@ -717,6 +682,11 @@ QString VLCProfileEditor::transcodeValue()
const QCheckBox *box = qobject_cast<const QCheckBox *>( object );
value = box->isChecked() ? "yes" : "";
}
else if( object->inherits( "QGroupBox" ) )
{
const QGroupBox *box = qobject_cast<const QGroupBox *>( object );
value = box->isChecked() ? "yes" : "";
}
else if( object->inherits( "QSpinBox" ) )
{
const QSpinBox *box = qobject_cast<const QSpinBox *>( object );
......@@ -741,6 +711,24 @@ QString VLCProfileEditor::transcodeValue()
return configuration.join( ";" );
}
void VLCProfileEditor::reset()
{
/* reset to default state as we can only check/enable existing values */
ui.valueholder_video_copy->setChecked( false );
ui.valueholder_audio_copy->setChecked( false );
activatePanels();
/* end with top level ones for cascaded setEnabled() */
ui.valueholder_video_enable->setChecked( false );
ui.valueholder_audio_enable->setChecked( false );
ui.valueholder_subtitles_enable->setChecked( false );
}
void VLCProfileEditor::activatePanels()
{
ui.transcodevideo->setEnabled( ! ui.valueholder_video_copy->isChecked() );
ui.transcodeaudio->setEnabled( ! ui.valueholder_audio_copy->isChecked() );
}
#undef CATPROP2NAME
#undef CATANDPROP
#undef OLDFORMAT
......@@ -78,13 +78,12 @@ private:
typedef QSet<QString> resultset;
QHash<QString, resultset> caps;
void loadCapabilities();
void reset();
protected slots:
virtual void close();
private slots:
void setVTranscodeOptions( bool );
void setATranscodeOptions( bool );
void setSTranscodeOptions( bool );
void muxSelected();
void activatePanels();
};
#endif
......@@ -13,27 +13,8 @@
<property name="windowTitle">
<string>Profile edition</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Profile Name</string>
</property>
<property name="margin">
<number>10</number>
</property>
<property name="buddy">
<cstring>profileLine</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="profileLine"/>
</item>
<item row="2" column="1">
<widget class="QDialogButtonBox" name="buttonBox"/>
</item>
<item row="1" column="0" colspan="2">
<layout class="QFormLayout" name="formLayout_4">
<item row="3" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
......@@ -294,315 +275,356 @@
<attribute name="title">
<string>Video codec</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="valueholder_video_enable">
<property name="text">
<item>
<widget class="QGroupBox" name="valueholder_video_enable">
<property name="title">
<string>Video</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="vCodecLabel">
<property name="enabled">
<property name="flat">
<bool>true</bool>
</property>
<property name="text">
<string>Codec</string>
</property>
<property name="buddy">
<cstring>valueholder_video_codec</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="valueholder_video_codec">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="vBitrateLabel">
<property name="text">
<string>Bitrate</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_bitrate</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="valueholder_vcodec_bitrate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="accelerated">
<property name="checkable">
<bool>true</bool>
</property>
<property name="suffix">
<string> kb/s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>32768</number>
</property>
<property name="value">
<number>800</number>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="vFrameLabel">
<property name="text">
<string>Frame Rate</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_framerate</cstring>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Same as source</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> fps</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Resolution</string>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You just need to fill one of the three following parameters, VLC will autodetect the other using the original aspect ratio</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="vScaleLabel">
<property name="text">
<string>Scale</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_scale</cstring>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="valueholder_vcodec_scale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="widthLabel">
<property name="text">
<string>Width</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_width</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3">
<widget class="QLabel" name="heightLabel">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="valueholder_video_copy">
<property name="text">
<string>Height</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_height</cstring>
<string>Keep original video track</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="valueholder_vcodec_width">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QSpinBox" name="valueholder_vcodec_height">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
<item>
<widget class="QWidget" name="transcodevideo" native="true">
<layout class="QFormLayout" name="formLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="vCodecLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Codec</string>
</property>
<property name="buddy">
<cstring>valueholder_video_codec</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="valueholder_video_codec">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="vBitrateLabel">
<property name="text">
<string>Bitrate</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_bitrate</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="vFrameLabel">
<property name="text">
<string>Frame Rate</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_framerate</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="valueholder_vcodec_bitrate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="suffix">
<string> kb/s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>32768</number>
</property>
<property name="value">
<number>800</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Same as source</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> fps</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Resolution</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You just need to fill one of the three following parameters, VLC will autodetect the other using the original aspect ratio</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="vScaleLabel">
<property name="text">
<string>Scale</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_scale</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="valueholder_vcodec_scale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="widthLabel">
<property name="text">
<string>Width</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_width</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="valueholder_vcodec_width">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="heightLabel">
<property name="text">
<string>Height</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_height</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="valueholder_vcodec_height">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="Framesize">
<property name="text">
<string>Frame size</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="valueholder_video_copy">
<property name="text">
<string>Keep original video track</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="audioCodec">
<attribute name="title">
<string>Audio codec</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="valueholder_audio_enable">
<property name="text">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="valueholder_audio_enable">
<property name="title">
<string>Audio</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="valueholder_audio_copy">
<property name="text">
<string>Keep original audio track</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="aCodecLabel">
<property name="text">
<string>Codec</string>
</property>
<property name="buddy">
<cstring>valueholder_audio_codec</cstring>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="valueholder_audio_codec"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="aBitrateLabel">
<property name="text">
<string>Bitrate</string>
</property>
<property name="buddy">
<cstring>valueholder_acodec_bitrate</cstring>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QSpinBox" name="valueholder_acodec_bitrate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> kb/s</string>
</property>
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>512</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="aChannelsLabel">
<property name="text">
<string>Channels</string>
</property>
<property name="buddy">
<cstring>valueholder_acodec_channels</cstring>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="valueholder_acodec_channels">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="aSampleLabel">
<property name="text">
<string>Sample Rate</string>
<property name="flat">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>valueholder_acodec_samplerate</cstring>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="valueholder_audio_copy">
<property name="text">
<string>Keep original audio track</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="transcodeaudio" native="true">
<layout class="QFormLayout" name="_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0"