Skip to content

Commit e61d5ae

Browse files
committed
Merge branch 'improve-ui' into develop
2 parents 904de48 + ba143e0 commit e61d5ae

File tree

84 files changed

+5589
-7409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5589
-7409
lines changed

installer/windows/NSIS/i18n/sources/nl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"DESC_LauncherSession": "Launcher (required)",
99
"DESC_StartMenuGroupSession": "Start Menu Shortcut",
1010
"DESC_DesktopShortcutSession": "Desktop Shortcut",
11-
"DESC_VisitWebSite": "Visit our website:"
11+
"DESC_VisitWebSite": "Bezoek onze website:"
1212
}

src/constants.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ const std::chrono::milliseconds TIMEOUT_STATUSBAR_LONG(5000);
3434
const int DIALOG_WIDTH = 600;
3535

3636
const int DEFAULT_TIMEOUT_SECS = 30; // ref.: QNetworkConfigurationPrivate::DefaultTimeout
37-
const int DEFAULT_CONCURRENT_FRAGMENTS = 20;
38-
39-
const int MAX_CONNECTION_SEGMENTS = 10;
4037

4138
const std::chrono::milliseconds TIMEOUT_COUNT_DOWN(1000);
4239
const std::chrono::milliseconds TIMEOUT_INFO(150);
@@ -192,7 +189,6 @@ const QLatin1StringView REGISTRY_STREAM_SHORTCUT ("StreamShortcutEnabled");
192189

193190
// Tab Network
194191
const QLatin1StringView REGISTRY_MAX_SIMULTANEOUS ("MaxSimultaneous");
195-
const QLatin1StringView REGISTRY_CONCURRENT_FRAG ("ConcurrentFragments");
196192
const QLatin1StringView REGISTRY_CUSTOM_BATCH ("CustomBatchEnabled");
197193
const QLatin1StringView REGISTRY_CUSTOM_BATCH_BL ("CustomBatchButtonLabel");
198194
const QLatin1StringView REGISTRY_CUSTOM_BATCH_RGE ("CustomBatchRange");

src/core/abstractdownloaditem.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,6 @@ void AbstractDownloadItem::setErrorMessage(const QString &message)
159159
m_errorMessage = message;
160160
}
161161

162-
/******************************************************************************
163-
******************************************************************************/
164-
int AbstractDownloadItem::maxConnectionSegments() const
165-
{
166-
return m_maxConnectionSegments;
167-
}
168-
169-
void AbstractDownloadItem::setMaxConnectionSegments(int connectionSegments)
170-
{
171-
if (connectionSegments > 0 && connectionSegments <= MAX_CONNECTION_SEGMENTS) {
172-
m_maxConnectionSegments = connectionSegments;
173-
}
174-
}
175-
176162
/******************************************************************************
177163
******************************************************************************/
178164
int AbstractDownloadItem::maxConnections() const
@@ -357,6 +343,11 @@ void AbstractDownloadItem::rename(const QString &newName)
357343
Q_UNUSED(newName)
358344
}
359345

346+
void AbstractDownloadItem::moveToTrash()
347+
{
348+
// do nothing
349+
}
350+
360351
/******************************************************************************
361352
******************************************************************************/
362353
void AbstractDownloadItem::updateInfo(qsizetype bytesReceived, qsizetype bytesTotal)

src/core/abstractdownloaditem.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ class AbstractDownloadItem : public QObject, public IDownloadItem
5252
QString errorMessage() const;
5353
void setErrorMessage(const QString &message);
5454

55-
int maxConnectionSegments() const override;
56-
void setMaxConnectionSegments(int connectionSegments);
57-
5855
int maxConnections() const override;
5956
void setMaxConnections(int connections);
6057

@@ -82,6 +79,7 @@ class AbstractDownloadItem : public QObject, public IDownloadItem
8279
void finish();
8380

8481
virtual void rename(const QString &newName);
82+
virtual void moveToTrash();
8583

8684
signals:
8785
void changed();

src/core/downloadengine.cpp

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ void DownloadEngine::updateItems(const QList<IDownloadItem *> &items)
158158
}
159159
}
160160

161+
void DownloadEngine::movetoTrash(const QList<IDownloadItem*> &items)
162+
{
163+
if (items.isEmpty()) {
164+
return;
165+
}
166+
/* Then, move to trash */
167+
for (auto item : items) {
168+
cancel(item); // stop the reply first
169+
m_items.removeAll(item);
170+
auto downloadItem = dynamic_cast<AbstractDownloadItem*>(item);
171+
if (downloadItem) {
172+
downloadItem->moveToTrash();
173+
}
174+
}
175+
removeItems(items);
176+
}
177+
161178
/******************************************************************************
162179
******************************************************************************/
163180
const IDownloadItem* DownloadEngine::clientForRow(qsizetype row) const
@@ -199,22 +216,12 @@ static inline QList<IDownloadItem*> filter(const QList<IDownloadItem*> &items,
199216
return list;
200217
}
201218

202-
QList<IDownloadItem*> DownloadEngine::waitingJobs() const
203-
{
204-
return filter(m_items, {IDownloadItem::Idle});
205-
}
206-
207219
QList<IDownloadItem*> DownloadEngine::completedJobs() const
208220
{
209221
return filter(m_items, {IDownloadItem::Completed,
210222
IDownloadItem::Seeding});
211223
}
212224

213-
QList<IDownloadItem*> DownloadEngine::pausedJobs() const
214-
{
215-
return filter(m_items, {IDownloadItem::Paused});
216-
}
217-
218225
QList<IDownloadItem*> DownloadEngine::failedJobs() const
219226
{
220227
return filter(m_items, {IDownloadItem::Stopped,
@@ -452,28 +459,6 @@ void DownloadEngine::moveCurrentBottom()
452459
moveDownTo(targetIndex);
453460
}
454461

455-
/******************************************************************************
456-
******************************************************************************/
457-
void DownloadEngine::oneMoreSegment()
458-
{
459-
for (auto item : selection()) {
460-
auto downloadItem = dynamic_cast<AbstractDownloadItem*>(item);
461-
auto segments = downloadItem->maxConnectionSegments();
462-
segments++;
463-
downloadItem->setMaxConnectionSegments(segments);
464-
}
465-
}
466-
467-
void DownloadEngine::oneFewerSegment()
468-
{
469-
for (auto item : selection()) {
470-
auto downloadItem = dynamic_cast<AbstractDownloadItem*>(item);
471-
auto segments = downloadItem->maxConnectionSegments();
472-
segments--;
473-
downloadItem->setMaxConnectionSegments(segments);
474-
}
475-
}
476-
477462
/******************************************************************************
478463
******************************************************************************/
479464
/*!

src/core/downloadengine.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class DownloadEngine : public QObject
5252

5353
/* Statistics */
5454
QList<IDownloadItem *> downloadItems() const;
55-
QList<IDownloadItem *> waitingJobs() const;
5655
QList<IDownloadItem *> completedJobs() const;
57-
QList<IDownloadItem *> pausedJobs() const;
5856
QList<IDownloadItem *> failedJobs() const;
5957
QList<IDownloadItem *> runningJobs() const;
6058

@@ -84,9 +82,8 @@ class DownloadEngine : public QObject
8482
void moveCurrentDown();
8583
void moveCurrentBottom();
8684

87-
/* Segments */
88-
void oneMoreSegment();
89-
void oneFewerSegment();
85+
/* Misc */
86+
void movetoTrash(const QList<IDownloadItem *> &items);
9087

9188
/* Utility */
9289
virtual IDownloadItem* createItem(const QUrl &url);

src/core/downloaditem.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,19 @@ void DownloadItem::rename(const QString &newName)
150150
emit renamed(oldFileName, newFileName, success);
151151
}
152152

153+
void DownloadItem::moveToTrash()
154+
{
155+
stop();
156+
auto fileName = localFullFileName();
157+
if (!QFile::exists(fileName)) {
158+
return;
159+
}
160+
if (!QFile::moveToTrash(fileName)) {
161+
/// \todo if not moved, do something else, like rename 'myfile' to '~myfile'?
162+
}
163+
emit changed();
164+
}
165+
153166
/******************************************************************************
154167
******************************************************************************/
155168
void DownloadItem::onMetaDataChanged()

src/core/downloaditem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class DownloadItem : public AbstractDownloadItem
5454
void stop() override;
5555

5656
void rename(const QString &newName) override;
57+
void moveToTrash() override;
5758

5859
private slots:
5960
void onMetaDataChanged();

src/core/idownloaditem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class IDownloadItem
5050
virtual qreal speed() const = 0; /*!< Returns the speed in byte per second */
5151
virtual int progress() const = 0; /*!< Return a value between 0 and 100, or -1 if undefined */
5252

53-
virtual int maxConnectionSegments() const = 0;
5453
virtual int maxConnections() const = 0;
5554
virtual QString log() const = 0;
5655

src/core/mask.cpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ QString Mask::interpret(const QUrl &url, const QString &customFileName, const QS
183183
if (!url.isValid()) {
184184
return {};
185185
}
186-
auto decodedMask = QString("%0.%1").arg(NAME, EXT);
187-
if (mask.isEmpty()) {
186+
auto decodedMask = mask; //.trimmed();
187+
if (decodedMask.isEmpty()) {
188188
decodedMask = QString("%0/%1/%2.%3").arg(URL, SUBDIRS, NAME, EXT);
189-
} else {
190-
decodedMask = mask;
191189
}
192190

193191
auto host = url.host();
@@ -199,10 +197,6 @@ QString Mask::interpret(const QUrl &url, const QString &customFileName, const QS
199197
auto basename = fi.completeBaseName();
200198
auto suffix = fi.suffix();
201199

202-
if (!customFileName.isEmpty()) {
203-
basename = customFileName;
204-
}
205-
206200
auto subdirs = path;
207201
subdirs.chop(filename.count());
208202
if (subdirs.startsWith(QChar('/'))) {
@@ -223,6 +217,25 @@ QString Mask::interpret(const QUrl &url, const QString &customFileName, const QS
223217
// Renaming Tags
224218
decodedMask.replace(QChar('\\'), QChar('/'));
225219

220+
// BUGFIX
221+
if (!customFileName.isEmpty()) {
222+
QString temp = "";
223+
auto parts = decodedMask.split(QChar('/'));
224+
for (QString part : parts) {
225+
if (part.contains(NAME)) {
226+
if (part.contains(EXT)) {
227+
part = customFileName;
228+
part.append(".").append(suffix);
229+
} else {
230+
part = customFileName;
231+
}
232+
}
233+
temp.append(part).append(QChar('/'));
234+
}
235+
temp.removeLast();
236+
decodedMask = temp;
237+
}
238+
226239
decodedMask.replace( NAME , basename );
227240
decodedMask.replace( EXT , suffix );
228241
decodedMask.replace( URL , host );
@@ -233,9 +246,12 @@ QString Mask::interpret(const QUrl &url, const QString &customFileName, const QS
233246
decodedMask.replace( QSTRING , query );
234247

235248
/* Remove the trailing '.' and duplicated '/' */
236-
decodedMask.replace(QRegularExpression("/+"), "/");
237-
decodedMask.replace(QRegularExpression("^/"), "");
238-
decodedMask.replace(QRegularExpression("[/\\.]*$"), "");
249+
static QRegularExpression reDuplicateSlash("/+");
250+
static QRegularExpression reLeadingSlash("^/");
251+
static QRegularExpression reTrailingSlashAndDot("[/\\.]*$");
252+
decodedMask.replace(reDuplicateSlash, "/");
253+
decodedMask.replace(reLeadingSlash, "");
254+
decodedMask.replace(reTrailingSlashAndDot, "");
239255

240256
/* Replace reserved characters */
241257
cleanNameForWindows(decodedMask);

src/core/session.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ static inline DownloadItem* readJob(const QJsonObject &json, DownloadManager *do
191191
item->setState(intToState(json["state"].toInt()));
192192
item->setBytesReceived(static_cast<qsizetype>(json["bytesReceived"].toInteger()));
193193
item->setBytesTotal(static_cast<qsizetype>(json["bytesTotal"].toInteger()));
194-
item->setMaxConnectionSegments(json["maxConnectionSegments"].toInt());
195194
item->setMaxConnections(json["maxConnections"].toInt());
196195
item->setLog(json["log"].toString());
197196

@@ -221,7 +220,6 @@ static inline void writeJob(const DownloadItem *item, QJsonObject &json)
221220
json["state"] = stateToInt(item->state());
222221
json["bytesReceived"] = static_cast<qsizetype>(item->bytesReceived());
223222
json["bytesTotal"] = static_cast<qsizetype>(item->bytesTotal());
224-
json["maxConnectionSegments"] = item->maxConnectionSegments();
225223
json["maxConnections"] = item->maxConnections();
226224
json["log"] = item->log();
227225
}

src/core/settings.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Settings::Settings(QObject *parent) : AbstractSettings(parent)
5757

5858
// Tab Network
5959
addDefaultSettingInt(REGISTRY_MAX_SIMULTANEOUS, 4);
60-
addDefaultSettingInt(REGISTRY_CONCURRENT_FRAG, DEFAULT_CONCURRENT_FRAGMENTS);
6160
addDefaultSettingBool(REGISTRY_CUSTOM_BATCH, true);
6261
addDefaultSettingString(REGISTRY_CUSTOM_BATCH_BL, QLatin1String("1 -> 25"));
6362
addDefaultSettingString(REGISTRY_CUSTOM_BATCH_RGE, QLatin1String("[1:25]"));
@@ -300,16 +299,6 @@ void Settings::setMaxSimultaneousDownloads(int number)
300299
setSettingInt(REGISTRY_MAX_SIMULTANEOUS, number);
301300
}
302301

303-
int Settings::concurrentFragments() const
304-
{
305-
return getSettingInt(REGISTRY_CONCURRENT_FRAG);
306-
}
307-
308-
void Settings::setConcurrentFragments(int fragments)
309-
{
310-
setSettingInt(REGISTRY_CONCURRENT_FRAG, fragments);
311-
}
312-
313302
bool Settings::isCustomBatchEnabled() const
314303
{
315304
return getSettingBool(REGISTRY_CUSTOM_BATCH);

src/core/settings.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ class Settings : public AbstractSettings
105105
int maxSimultaneousDownloads() const;
106106
void setMaxSimultaneousDownloads(int number);
107107

108-
int concurrentFragments() const;
109-
void setConcurrentFragments(int fragments);
110-
111108
bool isCustomBatchEnabled() const;
112109
void setCustomBatchEnabled(bool enabled);
113110

src/core/stream.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ using namespace Qt::Literals::StringLiterals;
4242

4343

4444
static QString s_youtubedl_version = {};
45-
static int s_youtubedl_concurrent_fragments = 0;
4645
static bool s_youtubedl_last_modified_time_enabled = true;
4746
static QString s_youtubedl_user_agent = {};
4847
static int s_youtubedl_socket_type = 0;
@@ -111,11 +110,6 @@ QString Stream::website()
111110
return C_WEBSITE_URL;
112111
}
113112

114-
void Stream::setConcurrentFragments(int fragments)
115-
{
116-
s_youtubedl_concurrent_fragments = fragments > 0 ? fragments : 0;
117-
}
118-
119113
void Stream::setLastModifiedTimeEnabled(bool enabled)
120114
{
121115
s_youtubedl_last_modified_time_enabled = enabled;
@@ -381,10 +375,6 @@ QStringList Stream::arguments() const
381375
arguments << QLatin1String("--format") << m_selectedFormatId.toString();
382376

383377
/* Global settings */
384-
if (s_youtubedl_concurrent_fragments > 1) {
385-
arguments << QLatin1String("--concurrent-fragments")
386-
<< QString::number(s_youtubedl_concurrent_fragments);
387-
}
388378
if (!s_youtubedl_last_modified_time_enabled) {
389379
arguments << QLatin1String("--no-mtime");
390380
}

src/core/stream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ class Stream : public QObject
351351

352352
static QString version();
353353
static QString website();
354-
static void setConcurrentFragments(int fragments);
355354
static void setLastModifiedTimeEnabled(bool enabled);
356355
static void setUserAgent(const QString &userAgent);
357356
static void setConnectionProtocol(int index);

src/core/streammanager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void StreamManager::setSettings(Settings *settings)
4747
void StreamManager::onSettingsChanged()
4848
{
4949
if (m_settings) {
50-
Stream::setConcurrentFragments(m_settings->concurrentFragments());
5150
Stream::setLastModifiedTimeEnabled(m_settings->isRemoteLastModifiedTimeEnabled());
5251
Stream::setUserAgent(m_settings->httpUserAgent());
5352
Stream::setConnectionProtocol(m_settings->connectionProtocol());

src/core/theme.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ QStringList Theme::availablePlatformStyles()
7979
auto keys = QStyleFactory::keys();
8080
auto availables = QStringList();
8181
auto style_fusion = QLatin1String("Fusion");
82-
foreach (auto key, keys) {
82+
for (auto key : keys) {
8383
if (key.contains(style_fusion, Qt::CaseInsensitive)) {
8484
availables << key;
8585
return availables;

src/dialogs/compilerdialog.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ CompilerDialog::CompilerDialog(QWidget *parent)
5757
ui->link->setTextInteractionFlags(Qt::TextBrowserInteraction);
5858
ui->link->setOpenExternalLinks(true);
5959

60+
ui->link_github->setText(QString("<a href=\"%0\">%0</a>").arg(STR_GITHUB_REPO_ADDRESS));
61+
ui->link_github->setTextFormat(Qt::RichText);
62+
ui->link_github->setTextInteractionFlags(Qt::TextBrowserInteraction);
63+
ui->link_github->setOpenExternalLinks(true);
64+
6065
ui->compilerName->setText(STR_COMPILER_NAME);
6166
ui->compilerVersion->setText(STR_COMPILER_BUILD_ABI);
6267
ui->compilerCpuArchitecture->setText(STR_COMPILER_BUILD_CPU);

0 commit comments

Comments
 (0)