Skip to content

Commit 4dc3094

Browse files
committed
Added busy icon and set shortcuts.
1 parent 29815e7 commit 4dc3094

File tree

5 files changed

+82
-18
lines changed

5 files changed

+82
-18
lines changed

YoutubeDL.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
<file>images/Actions-edit-paste-icon.png</file>
77
<file>images/Actions-help-contents-icon.png</file>
88
<file>images/Status-dialog-information-icon.png</file>
9+
<file>images/loader.gif</file>
910
</qresource>
1011
</RCC>

images/loader.gif

7.54 KB
Loading

youtubedl.cpp

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QProcess>
2424
#include <QByteArray>
2525
#include <QMessageBox>
26+
#include <QMovie>
2627

2728
YoutubeDL::YoutubeDL(QWidget *parent) :
2829
QMainWindow(parent),
@@ -72,22 +73,9 @@ void YoutubeDL::on_browseButton_clicked() {
7273
void YoutubeDL::on_url_textChanged(const QString &arg1) {
7374
// Check if URL is correct and valid
7475
if (arg1.isEmpty() || !QUrl(arg1).isValid()) {
75-
info->kill();
76-
ui->pasteButton->setEnabled(true);
77-
ui->downloadButton->setDisabled(true);
78-
ui->cancelButton->setDisabled(true);
79-
ui->pauseButton->setDisabled(true);
80-
ui->downloadOptions->setDisabled(true);
81-
ui->downloadProgressBar->setValue(0);
82-
ui->downloadProgressBar->setFormat("0%");
83-
ui->titleDescLabel->setText("");
84-
ui->imageLabel->setPixmap(QPixmap());
85-
ui->downloadOptionsFrame->setHidden(true);
86-
ui->audioCheckBox->setChecked(false);
87-
ui->audioFormatCombo->setDisabled(true);
88-
ui->audioQualityCombo->setDisabled(true);
89-
ui->keepVideoCheckBox->setDisabled(true);
90-
ui->keepVideoCheckBox->setChecked(false);
76+
if (NULL != info && info->state() != 0)
77+
info->kill();
78+
this->resetInterface();
9179
} else {
9280
ui->pasteButton->setDisabled(true);
9381
// Get video info
@@ -96,12 +84,36 @@ void YoutubeDL::on_url_textChanged(const QString &arg1) {
9684
arguments <<"--get-thumbnail"<<"--get-title"<<"--get-description" << arg1;
9785
info = new QProcess(this);
9886
info->start(program, arguments);
99-
QObject::connect(info, SIGNAL(finished(int)), this, SLOT(getInfo()));
87+
10088
QObject::connect(info, SIGNAL(readyReadStandardError()), this, SLOT(printError()));
101-
ui->titleDescLabel->setText("Fetching video/audio info...");
89+
QObject::connect(info, SIGNAL(finished(int)), this, SLOT(getInfo()));
90+
91+
QMovie *movie = new QMovie(":images/loader.gif");
92+
ui->titleDescLabel->setAlignment(Qt::AlignCenter);
93+
ui->titleDescLabel->setMovie(movie);
94+
movie->start();
95+
10296
}
10397
}
10498

99+
void YoutubeDL::resetInterface() {
100+
ui->pasteButton->setEnabled(true);
101+
ui->downloadButton->setDisabled(true);
102+
ui->cancelButton->setDisabled(true);
103+
ui->pauseButton->setDisabled(true);
104+
ui->downloadOptions->setDisabled(true);
105+
ui->downloadProgressBar->setValue(0);
106+
ui->downloadProgressBar->setFormat("0%");
107+
ui->titleDescLabel->setText(" ");
108+
ui->imageLabel->setPixmap(QPixmap());
109+
ui->downloadOptionsFrame->setHidden(true);
110+
ui->audioCheckBox->setChecked(false);
111+
ui->audioFormatCombo->setDisabled(true);
112+
ui->audioQualityCombo->setDisabled(true);
113+
ui->keepVideoCheckBox->setDisabled(true);
114+
ui->keepVideoCheckBox->setChecked(false);
115+
}
116+
105117
void YoutubeDL::printError() {
106118
QString errorInfo(info->readAllStandardError());
107119
if (errorInfo.length() > 0) {
@@ -134,6 +146,7 @@ void YoutubeDL::getInfo()
134146
connect(m_netwManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_netwManagerFinished(QNetworkReply*)));
135147
QNetworkRequest request(thumbnail);
136148
m_netwManager->get(request);
149+
ui->titleDescLabel->setAlignment(Qt::AlignLeft);
137150
ui->titleDescLabel->setText("<b>"+title+"</b>"+"<br><br>"+description);
138151
ui->downloadButton->setEnabled(true);
139152
ui->pasteButton->setEnabled(true);

youtubedl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ private slots:
7171

7272
void setMenuIcons();
7373

74+
void resetInterface();
75+
7476
private:
7577
Ui::YoutubeDL *ui;
7678
QProcess *download;

youtubedl.ui

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,5 +500,53 @@
500500
</hint>
501501
</hints>
502502
</connection>
503+
<connection>
504+
<sender>actionPaste</sender>
505+
<signal>triggered()</signal>
506+
<receiver>url</receiver>
507+
<slot>paste()</slot>
508+
<hints>
509+
<hint type="sourcelabel">
510+
<x>-1</x>
511+
<y>-1</y>
512+
</hint>
513+
<hint type="destinationlabel">
514+
<x>196</x>
515+
<y>38</y>
516+
</hint>
517+
</hints>
518+
</connection>
519+
<connection>
520+
<sender>actionClear</sender>
521+
<signal>triggered()</signal>
522+
<receiver>url</receiver>
523+
<slot>clear()</slot>
524+
<hints>
525+
<hint type="sourcelabel">
526+
<x>-1</x>
527+
<y>-1</y>
528+
</hint>
529+
<hint type="destinationlabel">
530+
<x>196</x>
531+
<y>38</y>
532+
</hint>
533+
</hints>
534+
</connection>
535+
<connection>
536+
<sender>actionExit</sender>
537+
<signal>triggered()</signal>
538+
<receiver>YoutubeDL</receiver>
539+
<slot>close()</slot>
540+
<hints>
541+
<hint type="sourcelabel">
542+
<x>-1</x>
543+
<y>-1</y>
544+
</hint>
545+
<hint type="destinationlabel">
546+
<x>282</x>
547+
<y>191</y>
548+
</hint>
549+
</hints>
550+
</connection>
503551
</connections>
504552
</ui>

0 commit comments

Comments
 (0)