Skip to content

Commit

Permalink
Hiding empty audio and subtitle elements
Browse files Browse the repository at this point in the history
  • Loading branch information
CineEncoder committed Oct 3, 2021
1 parent 5ae48db commit 305272e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 28 deletions.
88 changes: 76 additions & 12 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
raiseThumb->setText(tr("No media"));
raiseThumb->setStyleSheet("color: #09161E; font: 64pt; font-style: oblique;");

audioThumb = new QLabel(ui->frameTab_2);
ui->gridLayoutAudio->addWidget(audioThumb);
audioThumb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
audioThumb->setAlignment(Qt::AlignCenter);
audioThumb->setText(tr("No audio"));
audioThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");

subtitleThumb = new QLabel(ui->frameTab_3);
ui->gridLayoutSubtitle->addWidget(subtitleThumb);
subtitleThumb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
subtitleThumb->setAlignment(Qt::AlignCenter);
subtitleThumb->setText(tr("No subtitle"));
subtitleThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");

// **************************** Create docks ***********************************//

QGridLayout *layout = new QGridLayout(ui->frame_middle);
Expand Down Expand Up @@ -474,6 +488,11 @@ void Widget::createConnections()
}

// ************************ Audio Elements Actions ****************************//
QList<QLabel*> labelsAudio = ui->frameTab_2->findChildren<QLabel*>();
foreach (QLabel *label, labelsAudio) {
label->setVisible(false);
}
audioThumb->setVisible(true);

for (int stream = 0; stream < AMOUNT_AUDIO_STREAMS; stream++) {
// Check Boxes
Expand All @@ -491,6 +510,8 @@ void Widget::createConnections()
_audioStreamCheckState[stream] = state_qstr.toInt();
}
});
checkBoxAudio->setEnabled(true);
checkBoxAudio->setVisible(false);
// Line Edit Lang
QLineEdit *lineEditLangAudio = ui->frameTab_2->findChild<QLineEdit *>("lineEditLangAudio_"
+ QString::number(stream + 1), Qt::FindDirectChildrenOnly);
Expand All @@ -515,6 +536,8 @@ void Widget::createConnections()
ui->frame_middle->setFocus();
});
}
lineEditLangAudio->setEnabled(true);
lineEditLangAudio->setVisible(false);
// Line Edit Title
QLineEdit *lineEditTitleAudio = ui->frameTab_2->findChild<QLineEdit *>("lineEditTitleAudio_"
+ QString::number(stream + 1), Qt::FindDirectChildrenOnly);
Expand All @@ -539,9 +562,16 @@ void Widget::createConnections()
ui->frame_middle->setFocus();
});
}
lineEditTitleAudio->setEnabled(true);
lineEditTitleAudio->setVisible(false);
}

// ************************ Subtitle Elements Actions ****************************//
QList<QLabel*> labelsSubtitle = ui->frameTab_3->findChildren<QLabel*>();
foreach (QLabel *label, labelsSubtitle) {
label->setVisible(false);
}
subtitleThumb->setVisible(true);

for (int stream = 0; stream < AMOUNT_SUBTITLES; stream++) {
// Check Boxes
Expand All @@ -559,6 +589,8 @@ void Widget::createConnections()
_subtitleCheckState[stream] = state_qstr.toInt();
}
});
checkBoxSubtitle->setEnabled(true);
checkBoxSubtitle->setVisible(false);
// Line Edit Lang
QLineEdit *lineEditLangSubtitle = ui->frameTab_3->findChild<QLineEdit *>("lineEditLangSubtitle_"
+ QString::number(stream + 1), Qt::FindDirectChildrenOnly);
Expand All @@ -583,6 +615,8 @@ void Widget::createConnections()
ui->frame_middle->setFocus();
});
}
lineEditLangSubtitle->setEnabled(true);
lineEditLangSubtitle->setVisible(false);
// Line Edit Title
QLineEdit *lineEditTitleSubtitle = ui->frameTab_3->findChild<QLineEdit *>("lineEditTitleSubtitle_"
+ QString::number(stream + 1), Qt::FindDirectChildrenOnly);
Expand All @@ -607,6 +641,8 @@ void Widget::createConnections()
ui->frame_middle->setFocus();
});
}
lineEditTitleSubtitle->setEnabled(true);
lineEditTitleSubtitle->setVisible(false);
}
}

Expand Down Expand Up @@ -1372,7 +1408,9 @@ void Widget::get_current_data() /*** Get current data ***/
}

//******************************** Set audio widgets *****************************//

if (countAudioStreams > 0) {
audioThumb->setVisible(false);
}
for (int q = 0; q < AMOUNT_AUDIO_STREAMS; q++) {
QCheckBox *checkBoxAudio = ui->frameTab_2->findChild<QCheckBox *>("checkBoxAudio_"
+ QString::number(q+1), Qt::FindDirectChildrenOnly);
Expand All @@ -1385,15 +1423,20 @@ void Widget::get_current_data() /*** Get current data ***/
+ QString::number(q+1), Qt::FindDirectChildrenOnly);
lineEditTitleAudio->setText(_audioTitle[q]);
lineEditTitleAudio->setCursorPosition(0);
QLabel *labelAudio = ui->frameTab_2->findChild<QLabel *>("labelTitleAudio_"
+ QString::number(q+1), Qt::FindDirectChildrenOnly);
if (q < countAudioStreams) {
checkBoxAudio->setEnabled(true);
lineEditLangAudio->setEnabled(true);
lineEditTitleAudio->setEnabled(true);
checkBoxAudio->setVisible(true);
lineEditLangAudio->setVisible(true);
lineEditTitleAudio->setVisible(true);
labelAudio->setVisible(true);
}
}

//******************************** Set subtitle widgets *****************************//

if (countSubtitles > 0) {
subtitleThumb->setVisible(false);
}
for (int q = 0; q < AMOUNT_SUBTITLES; q++) {
QCheckBox *checkBoxSubtitle = ui->frameTab_3->findChild<QCheckBox *>("checkBoxSubtitle_"
+ QString::number(q+1), Qt::FindDirectChildrenOnly);
Expand All @@ -1406,10 +1449,13 @@ void Widget::get_current_data() /*** Get current data ***/
+ QString::number(q+1), Qt::FindDirectChildrenOnly);
lineEditTitleSubtitle->setText(_subtitleTitle[q]);
lineEditTitleSubtitle->setCursorPosition(0);
QLabel *labelSubtitle = ui->frameTab_3->findChild<QLabel *>("labelTitleSub_"
+ QString::number(q+1), Qt::FindDirectChildrenOnly);
if (q < countSubtitles) {
checkBoxSubtitle->setEnabled(true);
lineEditLangSubtitle->setEnabled(true);
lineEditTitleSubtitle->setEnabled(true);
checkBoxSubtitle->setVisible(true);
lineEditLangSubtitle->setVisible(true);
lineEditTitleSubtitle->setVisible(true);
labelSubtitle->setVisible(true);
}
}
}
Expand All @@ -1423,18 +1469,26 @@ void Widget::setTheme(int &ind_theme) /*** Set theme ***/
case 0:
file.setFileName(":/resources/css/style_0.css");
raiseThumb->setStyleSheet("color: #09161E; font: 64pt; font-style: oblique;");
audioThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");
subtitleThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");
break;
case 1:
file.setFileName(":/resources/css/style_1.css");
raiseThumb->setStyleSheet("color: #09161E; font: 64pt; font-style: oblique;");
audioThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");
subtitleThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");
break;
case 2:
file.setFileName(":/resources/css/style_2.css");
raiseThumb->setStyleSheet("color: #09161E; font: 64pt; font-style: oblique;");
audioThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");
subtitleThumb->setStyleSheet("color: #09161E; font: 24pt; font-style: oblique;");
break;
case 3:
file.setFileName(":/resources/css/style_3.css");
raiseThumb->setStyleSheet("color: #E3E3E3; font: 64pt; font-style: oblique;");
audioThumb->setStyleSheet("color: #E3E3E3; font: 24pt; font-style: oblique;");
subtitleThumb->setStyleSheet("color: #E3E3E3; font: 24pt; font-style: oblique;");
break;
}
if (file.open(QFile::ReadOnly)) {
Expand Down Expand Up @@ -3502,22 +3556,32 @@ void Widget::on_tableWidget_itemSelectionChanged() /*** Item selection changed
// **************************** Disable audio widgets ***********************************//
QList <QCheckBox *> checkBoxAudio = ui->frameTab_2->findChildren<QCheckBox *>();
QList <QLineEdit *> lineEditAudio = ui->frameTab_2->findChildren<QLineEdit *>();
QList <QLabel*> labelsAudio = ui->frameTab_2->findChildren<QLabel*>();
foreach (QCheckBox *checkBox, checkBoxAudio) {
checkBox->setEnabled(false);
checkBox->setVisible(false);
}
foreach (QLineEdit *lineEdit, lineEditAudio) {
lineEdit->setEnabled(false);
lineEdit->setVisible(false);
}
foreach (QLabel *label, labelsAudio) {
label->setVisible(false);
}
audioThumb->setVisible(true);

// **************************** Disable subtitle widgets ***********************************//
QList <QCheckBox *> checkBoxSubtitle = ui->frameTab_3->findChildren<QCheckBox *>();
QList <QLineEdit *> lineEditSubtitle = ui->frameTab_3->findChildren<QLineEdit *>();
QList <QLabel*> labelsSubtitle = ui->frameTab_3->findChildren<QLabel*>();
foreach (QCheckBox *checkBox, checkBoxSubtitle) {
checkBox->setEnabled(false);
checkBox->setVisible(false);
}
foreach (QLineEdit *lineEdit, lineEditSubtitle) {
lineEdit->setEnabled(false);
lineEdit->setVisible(false);
}
foreach (QLabel *label, labelsSubtitle) {
label->setVisible(false);
}
subtitleThumb->setVisible(true);

_row = ui->tableWidget->currentRow();
if (_row != -1) {
Expand Down
4 changes: 4 additions & 0 deletions app/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ private slots:

QLabel *raiseThumb;

QLabel *audioThumb;

QLabel *subtitleThumb;

// **************** Progress animation ***********************//

QMovie *animation;
Expand Down
35 changes: 19 additions & 16 deletions app/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>268</width>
<width>273</width>
<height>371</height>
</rect>
</property>
Expand Down Expand Up @@ -2170,6 +2170,9 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
Expand Down Expand Up @@ -2216,8 +2219,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>268</width>
<y>-179</y>
<width>273</width>
<height>371</height>
</rect>
</property>
Expand Down Expand Up @@ -2268,7 +2271,7 @@
<number>9</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_17">
<layout class="QGridLayout" name="gridLayoutSubtitle">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
Expand Down Expand Up @@ -2317,7 +2320,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="labelTitleAudio_15">
<widget class="QLabel" name="labelTitleSub_1">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2383,7 +2386,7 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labelTitleAudio_10">
<widget class="QLabel" name="labelTitleSub_3">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2564,7 +2567,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="labelTitleAudio_12">
<widget class="QLabel" name="labelTitleSub_2">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2598,7 +2601,7 @@
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="labelTitleAudio_16">
<widget class="QLabel" name="labelTitleSub_9">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2706,7 +2709,7 @@
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="labelTitleAudio_13">
<widget class="QLabel" name="labelTitleSub_5">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2785,7 +2788,7 @@
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="labelTitleAudio_11">
<widget class="QLabel" name="labelTitleSub_6">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2819,7 +2822,7 @@
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="labelTitleAudio_14">
<widget class="QLabel" name="labelTitleSub_7">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2936,7 +2939,7 @@
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="labelTitleAudio_17">
<widget class="QLabel" name="labelTitleSub_4">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -2986,7 +2989,7 @@
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="labelTitleAudio_18">
<widget class="QLabel" name="labelTitleSub_8">
<property name="enabled">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -5315,7 +5318,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<width>407</width>
<height>371</height>
</rect>
</property>
Expand Down Expand Up @@ -6119,8 +6122,8 @@
<widget class="QWidget" name="scrollAreaWidgetContents_4">
<property name="geometry">
<rect>
<x>-11</x>
<y>-37</y>
<x>0</x>
<y>0</y>
<width>415</width>
<height>371</height>
</rect>
Expand Down

0 comments on commit 305272e

Please sign in to comment.