@@ -61,8 +61,7 @@ void AttachmentDialog::on_fileEdit_textChanged(const QString &arg1) {
61
61
return ;
62
62
}
63
63
64
- ui->downloadButton ->setVisible (
65
- url.scheme ().startsWith (QLatin1String (" http" )));
64
+ ui->downloadButton ->setVisible (url.scheme ().startsWith (QLatin1String (" http" )));
66
65
67
66
if (url.scheme () == QLatin1String (" file" )) {
68
67
ui->fileEdit ->setText (url.toLocalFile ());
@@ -73,9 +72,8 @@ void AttachmentDialog::on_fileEdit_textChanged(const QString &arg1) {
73
72
QMimeDatabase db;
74
73
QMimeType type = db.mimeTypeForFile (arg1);
75
74
76
- ui->infoLabel ->setText (
77
- Utils::Misc::toHumanReadableByteSize (fileInfo.size ()) + " - " +
78
- type.comment ());
75
+ ui->infoLabel ->setText (Utils::Misc::toHumanReadableByteSize (fileInfo.size ()) + " - " +
76
+ type.comment ());
79
77
}
80
78
}
81
79
@@ -89,8 +87,7 @@ void AttachmentDialog::on_downloadButton_clicked() {
89
87
QNetworkRequest networkRequest (url);
90
88
91
89
#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0)
92
- networkRequest.setAttribute (QNetworkRequest::FollowRedirectsAttribute,
93
- true );
90
+ networkRequest.setAttribute (QNetworkRequest::FollowRedirectsAttribute, true );
94
91
#else
95
92
networkRequest.setAttribute (QNetworkRequest::RedirectPolicyAttribute, true );
96
93
#endif
@@ -110,13 +107,11 @@ void AttachmentDialog::on_downloadButton_clicked() {
110
107
/* *
111
108
* Shows the download progress
112
109
*/
113
- void AttachmentDialog::downloadProgress (qint64 bytesReceived,
114
- qint64 bytesTotal) {
110
+ void AttachmentDialog::downloadProgress (qint64 bytesReceived, qint64 bytesTotal) {
115
111
ui->downloadProgressBar ->setMaximum (static_cast <int >(bytesTotal));
116
112
ui->downloadProgressBar ->setValue (static_cast <int >(bytesReceived));
117
- ui->downloadSizeLabel ->setText (
118
- Utils::Misc::toHumanReadableByteSize (bytesReceived) + " / " +
119
- Utils::Misc::toHumanReadableByteSize (bytesTotal));
113
+ ui->downloadSizeLabel ->setText (Utils::Misc::toHumanReadableByteSize (bytesReceived) + " / " +
114
+ Utils::Misc::toHumanReadableByteSize (bytesTotal));
120
115
}
121
116
122
117
/* *
@@ -140,12 +135,10 @@ void AttachmentDialog::slotReplyFinished(QNetworkReply *reply) {
140
135
if (reply->error () != QNetworkReply::NoError &&
141
136
reply->error () != QNetworkReply::OperationCanceledError) {
142
137
_accept = false ;
143
- QMessageBox::critical (
144
- nullptr , tr (" Download error" ),
145
- tr (" Error while downloading:\n %1" ).arg (reply->errorString ()));
138
+ QMessageBox::critical (nullptr , tr (" Download error" ),
139
+ tr (" Error while downloading:\n %1" ).arg (reply->errorString ()));
146
140
147
- qWarning ()
148
- << QStringLiteral (" Network error: %1" ).arg (reply->errorString ());
141
+ qWarning () << QStringLiteral (" Network error: %1" ).arg (reply->errorString ());
149
142
150
143
return ;
151
144
}
@@ -162,17 +155,16 @@ void AttachmentDialog::slotReplyFinished(QNetworkReply *reply) {
162
155
}
163
156
}
164
157
165
- auto *tempFile =
166
- new QTemporaryFile (QDir::tempPath () + " /QOwnNotes-XXXXXX." + suffix);
158
+ auto *tempFile = new QTemporaryFile (QDir::tempPath () + " /QOwnNotes-XXXXXX." + suffix);
167
159
168
160
// we want to keep the file to be used in the update process
169
161
tempFile->setAutoRemove (false );
170
162
171
163
// get a temporary file
172
164
if (!tempFile->open ()) {
173
- QMessageBox::critical (nullptr , tr ( " File error " ),
174
- tr (" Could not open temporary file: \n %1 " )
175
- .arg (tempFile->errorString ()));
165
+ QMessageBox::critical (
166
+ nullptr , tr (" File error " ),
167
+ tr ( " Could not open temporary file: \n %1 " ) .arg (tempFile->errorString ()));
176
168
return ;
177
169
}
178
170
@@ -193,9 +185,8 @@ void AttachmentDialog::slotReplyFinished(QNetworkReply *reply) {
193
185
QFile file (filePath);
194
186
195
187
if (!file.open (QIODevice::WriteOnly)) {
196
- QMessageBox::critical (
197
- nullptr , tr (" File error" ),
198
- tr (" Could not store downloaded file:\n %1" ).arg (file.errorString ()));
188
+ QMessageBox::critical (nullptr , tr (" File error" ),
189
+ tr (" Could not store downloaded file:\n %1" ).arg (file.errorString ()));
199
190
return ;
200
191
}
201
192
0 commit comments