File indexing completed on 2025-02-23 04:34:16
0001 /** 0002 * \file downloaddialog.cpp 0003 * Dialog displayed during a download. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 31 Dec 2008 0008 * 0009 * Copyright (C) 2008-2018 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #include "downloaddialog.h" 0028 #include <QString> 0029 0030 /** 0031 * Constructor. 0032 * 0033 * @param parent parent widget 0034 * @param caption dialog title 0035 */ 0036 DownloadDialog::DownloadDialog(QWidget* parent, const QString& caption) 0037 : QProgressDialog(parent) 0038 { 0039 setObjectName(QLatin1String("DownloadDialog")); 0040 setWindowTitle(caption); 0041 } 0042 0043 /** 0044 * Show dialog to report start of download. 0045 * @param url URL of download 0046 */ 0047 void DownloadDialog::showStartOfDownload(const QString& url) 0048 { 0049 if (isHidden()) { 0050 show(); 0051 } 0052 m_url = url; 0053 setLabelText(url); 0054 } 0055 0056 /** 0057 * Display message in status bar. 0058 * 0059 * @param msg status message 0060 * @param receivedBytes bytes received 0061 * @param totalBytes total bytes 0062 */ 0063 void DownloadDialog::updateProgressStatus(const QString& msg, 0064 int receivedBytes, int totalBytes) 0065 { 0066 setLabelText(m_url + QLatin1Char('\n') + msg); 0067 if (receivedBytes >= 0 && totalBytes >= 0) { 0068 setRange(0, totalBytes); 0069 setValue(receivedBytes); 0070 } 0071 }