commit 278f5fdd276106ae4c4bcd5fabdf6abd0008ff5a
parent 015a50dc0c4ec96acd1f87c69693521dc28c08c5
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 12 Feb 2016 23:57:54 -0800
partially revert 015a50dc0c4ec96acd1f87c69693521dc28c08c5
most website aren't reporting Content-Length?!
Diffstat:
5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/download.cpp b/src/download.cpp
@@ -183,15 +183,12 @@ int Download::UpdateProgress(void *ptr, const double dltotal, const double dlnow
if(dl->isAborted())
return 1;
- short progress;
const double total = ultotal + dltotal;
- if(total > 0)
- progress = (short)(ulnow + dlnow / total) * 100;
- else
- progress = 10;
-
- dl->setProgress(min(progress, (short)100));
+ if(total > 0) {
+ const short progress = (short)((ulnow + dlnow / total) * 100);
+ dl->setProgress(min(progress, (short)100));
+ }
return 0;
}
diff --git a/src/import.cpp b/src/import.cpp
@@ -53,6 +53,10 @@ void Import::onInit()
m_ok = getControl(IDOK);
hide(m_progress);
+
+#ifdef PBM_SETMARQUEE
+ SendMessage(m_progress, PBM_SETMARQUEE, 1, 0);
+#endif
}
void Import::onCommand(const int id)
@@ -75,8 +79,10 @@ void Import::onCommand(const int id)
void Import::onTimer(int)
{
- if(m_download)
- SendMessage(m_progress, PBM_SETPOS, m_download->progress(), 0);
+#ifndef PBM_SETMARQUEE
+ m_fakePos = (m_fakePos + 1) % 100;
+ SendMessage(m_progress, PBM_SETPOS, m_fakePos, 0);
+#endif
}
void Import::browseFile()
@@ -186,10 +192,13 @@ void Import::setWaiting(const bool wait)
setVisible(wait, m_progress);
setEnabled(!wait, m_url);
+#ifndef PBM_SETMARQUEE
if(wait)
startTimer(42, 1);
else
stopTimer(1);
+ m_fakePos = 0;
SendMessage(m_progress, PBM_SETPOS, 0, 0);
+#endif
}
diff --git a/src/import.hpp b/src/import.hpp
@@ -48,6 +48,7 @@ private:
ReaPack *m_reapack;
Download *m_download;
+ short m_fakePos;
HWND m_url;
HWND m_file;
diff --git a/src/resource.hpp b/src/resource.hpp
@@ -25,6 +25,7 @@
#define PROGRESS_CLASS "msctls_progress32"
#define WC_LISTVIEW "SysListView32"
#define WC_TABCONTROL "SysTabControl32"
+#define PBS_MARQUEE 0
#endif
#define DIALOG_STYLE \
diff --git a/src/resource.rc b/src/resource.rc
@@ -73,7 +73,7 @@ BEGIN
RTEXT "From a file:", IDC_LABEL3, 5, 48, 50, 10
EDITTEXT IDC_FILE, 60, 44, 177, 14, ES_AUTOHSCROLL
PUSHBUTTON "&Browse...", IDC_BROWSE, 240, 44, 40, 14
- CONTROL "", IDC_PROGRESS, PROGRESS_CLASS, 0x0, 10, 74, 150, 5
+ CONTROL "", IDC_PROGRESS, PROGRESS_CLASS, PBS_MARQUEE, 10, 74, 150, 5
DEFPUSHBUTTON "&OK", IDOK, 200, 70, 40, 14
PUSHBUTTON "&Cancel", IDCANCEL, 244, 70, 40, 14
END