Skip to content

Commit

Permalink
Tweaks: UpdateDialog fix and removal of baka-mplayer group in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
u8sand committed Jun 4, 2015
1 parent dcd3c3e commit f8e2d1b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/settings.cpp
Expand Up @@ -72,6 +72,9 @@ void Settings::LoadIni()
if(group != QString())
root[group] = group_obj;

// remove excess baka-mplayer group
root.remove("baka-mplayer");

// fix input
if(root.find("input") != root.end())
{
Expand Down
32 changes: 16 additions & 16 deletions src/ui/updatedialog.cpp
Expand Up @@ -44,6 +44,21 @@ UpdateDialog::UpdateDialog(BakaEngine *baka, QWidget *parent) :
init = false;
}
}
else if(percent == 0)
{
avgSpeed = 0;
lastSpeed = 0;
lastProgress = 0;
lastTime = 0;
ui->progressBar->setValue(0);
ui->progressBar->setVisible(true);
ui->timeRemainingLabel->setText(QString());
ui->timeRemainingLabel->setVisible(true);
if(timer != nullptr)
delete timer;
timer = new QTime();
timer->start();
}
else if(timer) // don't execute this if timer is not defined--this shouldn't happen though.. but it does
{
avgSpeed = 0.005*lastSpeed + 0.995*avgSpeed;
Expand Down Expand Up @@ -72,7 +87,7 @@ UpdateDialog::UpdateDialog(BakaEngine *baka, QWidget *parent) :
connect(ui->updateButton, &QPushButton::clicked,
[=]
{
Prepare();
ui->plainTextEdit->setPlainText(QString());
baka->update->DownloadUpdate(Util::DownloadFileUrl());
});
#endif
Expand All @@ -81,10 +96,7 @@ UpdateDialog::UpdateDialog(BakaEngine *baka, QWidget *parent) :
this, SLOT(reject()));

if(baka->update->getInfo().empty())
{
Prepare();
baka->update->CheckForUpdates();
}
else
{
init = false;
Expand All @@ -105,18 +117,6 @@ void UpdateDialog::CheckForUpdates(BakaEngine *baka, QWidget *parent)
dialog->exec();
}

void UpdateDialog::Prepare()
{
avgSpeed = 0;
lastSpeed = 0;
lastProgress = 0;
lastTime = 0;
if(timer != nullptr)
delete timer;
timer = new QTime();
timer->start();
}

void UpdateDialog::ShowInfo()
{
auto &info = baka->update->getInfo();
Expand Down
3 changes: 1 addition & 2 deletions src/ui/updatedialog.h
Expand Up @@ -22,7 +22,6 @@ class UpdateDialog : public QDialog
static void CheckForUpdates(BakaEngine *baka, QWidget *parent = 0);

protected slots:
void Prepare();
void ShowInfo();

private:
Expand All @@ -31,7 +30,7 @@ protected slots:

QTime *timer;
double avgSpeed = 1,
lastSpeed=0;
lastSpeed = 0;
int lastProgress,
lastTime,
state;
Expand Down
4 changes: 2 additions & 2 deletions src/updatemanager.cpp
Expand Up @@ -38,7 +38,7 @@ bool UpdateManager::CheckForUpdates()
return false;
busy = true;
emit messageSignal(tr("Checking for updates..."));

emit progressSignal(0);
QNetworkRequest request(Util::VersionFileUrl());
QNetworkReply *reply = manager->get(request);

Expand Down Expand Up @@ -84,7 +84,7 @@ bool UpdateManager::DownloadUpdate(const QString &url)
return false;
busy = true;
emit messageSignal(tr("Downloading update..."));

emit progressSignal(0);
QNetworkRequest request(url);
QString filename = QDir::toNativeSeparators(QString("%0/Baka-MPlayer.zip").arg(QCoreApplication::applicationDirPath()));
QFile *file = new QFile(filename);
Expand Down

0 comments on commit f8e2d1b

Please sign in to comment.