Changeset View
Changeset View
Standalone View
Standalone View
korganizer/plugins/picoftheday/picoftheday.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 78 | { | |||
---|---|---|---|---|---|
85 | step1StartDownload(); | 85 | step1StartDownload(); | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | /** First step of three in the download process */ | 88 | /** First step of three in the download process */ | ||
89 | void POTDElement::step1StartDownload() | 89 | void POTDElement::step1StartDownload() | ||
90 | { | 90 | { | ||
91 | // Start downloading the picture | 91 | // Start downloading the picture | ||
92 | if (!mFirstStepCompleted && !mFirstStepJob) { | 92 | if (!mFirstStepCompleted && !mFirstStepJob) { | ||
93 | QUrl url = QUrl(QStringLiteral("http://en.wikipedia.org/w/index.php?title=Template:POTD/") | 93 | QUrl url = QUrl(QStringLiteral("https://en.wikipedia.org/w/index.php?title=Template:POTD/") | ||
94 | +mDate.toString(Qt::ISODate) + QStringLiteral("&action=raw")); | 94 | +mDate.toString(Qt::ISODate) + QStringLiteral("&action=raw")); | ||
95 | // The file at that URL contains the file name for the POTD | 95 | // The file at that URL contains the file name for the POTD | ||
96 | 96 | | |||
97 | mFirstStepJob = KIO::storedGet(url, KIO::NoReload, KIO::HideProgressInfo); | 97 | mFirstStepJob = KIO::storedGet(url, KIO::NoReload, KIO::HideProgressInfo); | ||
98 | KIO::Scheduler::setJobPriority(mFirstStepJob, 1); | 98 | KIO::Scheduler::setJobPriority(mFirstStepJob, 1); | ||
99 | 99 | | |||
100 | connect(mFirstStepJob, &KIO::SimpleJob::result, this, &POTDElement::step1Result); | 100 | connect(mFirstStepJob, &KIO::SimpleJob::result, this, &POTDElement::step1Result); | ||
101 | connect(this, &POTDElement::step1Success, this, &POTDElement::step2GetImagePage); | 101 | connect(this, &POTDElement::step1Success, this, &POTDElement::step2GetImagePage); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 110 | { | |||
152 | mFirstStepJob = nullptr; | 152 | mFirstStepJob = nullptr; | ||
153 | Q_EMIT step1Success(); | 153 | Q_EMIT step1Success(); | ||
154 | } | 154 | } | ||
155 | 155 | | |||
156 | /** Second step of three in the download process */ | 156 | /** Second step of three in the download process */ | ||
157 | void POTDElement::step2GetImagePage() | 157 | void POTDElement::step2GetImagePage() | ||
158 | { | 158 | { | ||
159 | if (!mSecondStepCompleted && !mSecondStepJob) { | 159 | if (!mSecondStepCompleted && !mSecondStepJob) { | ||
160 | mUrl = QUrl(QStringLiteral("http://en.wikipedia.org/wiki/File:") + mFileName); | 160 | mUrl = QUrl(QStringLiteral("https://en.wikipedia.org/wiki/File:") + mFileName); | ||
161 | // We'll find the info to get the thumbnail we want on the POTD's image page | 161 | // We'll find the info to get the thumbnail we want on the POTD's image page | ||
162 | 162 | | |||
163 | Q_EMIT gotNewUrl(mUrl); | 163 | Q_EMIT gotNewUrl(mUrl); | ||
164 | mShortText = i18n("Picture Page"); | 164 | mShortText = i18n("Picture Page"); | ||
165 | Q_EMIT gotNewShortText(mShortText); | 165 | Q_EMIT gotNewShortText(mShortText); | ||
166 | 166 | | |||
167 | mSecondStepJob = KIO::storedGet(mUrl, KIO::NoReload, KIO::HideProgressInfo); | 167 | mSecondStepJob = KIO::storedGet(mUrl, KIO::NoReload, KIO::HideProgressInfo); | ||
168 | KIO::Scheduler::setJobPriority(mSecondStepJob, 1); | 168 | KIO::Scheduler::setJobPriority(mSecondStepJob, 1); | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 243 | if (width != 0) { | |||
244 | thumbUrl.replace(QRegExp(QLatin1String("//upload.wikimedia.org/wikipedia/commons/(.*)/([^/]*)")), | 244 | thumbUrl.replace(QRegExp(QLatin1String("//upload.wikimedia.org/wikipedia/commons/(.*)/([^/]*)")), | ||
245 | QStringLiteral("//upload.wikimedia.org/wikipedia/commons/thumb/\\1/\\2/") | 245 | QStringLiteral("//upload.wikimedia.org/wikipedia/commons/thumb/\\1/\\2/") | ||
246 | +QString::number(width) + QStringLiteral("px-\\2")); | 246 | +QString::number(width) + QStringLiteral("px-\\2")); | ||
247 | } else { // This will not return a valid thumbnail URL, but will at least | 247 | } else { // This will not return a valid thumbnail URL, but will at least | ||
248 | // give some info (the beginning of the URL) | 248 | // give some info (the beginning of the URL) | ||
249 | thumbUrl.replace(QRegExp(QLatin1String("//upload.wikimedia.org/wikipedia/commons/(.*)/([^/]*)")), | 249 | thumbUrl.replace(QRegExp(QLatin1String("//upload.wikimedia.org/wikipedia/commons/(.*)/([^/]*)")), | ||
250 | QStringLiteral("//upload.wikimedia.org/wikipedia/commons/thumb/\\1/\\2")); | 250 | QStringLiteral("//upload.wikimedia.org/wikipedia/commons/thumb/\\1/\\2")); | ||
251 | } | 251 | } | ||
252 | thumbUrl.replace(QRegExp(QLatin1String("^file:////")), QStringLiteral("http://")); | 252 | thumbUrl.replace(QRegExp(QLatin1String("^file:////")), QStringLiteral("https://")); | ||
253 | return QUrl(thumbUrl); | 253 | return QUrl(thumbUrl); | ||
254 | } | 254 | } | ||
255 | 255 | | |||
256 | /** Third step of three in the downloading process */ | 256 | /** Third step of three in the downloading process */ | ||
257 | void POTDElement::step3GetThumbnail() | 257 | void POTDElement::step3GetThumbnail() | ||
258 | { | 258 | { | ||
259 | if (mThirdStepJob) { | 259 | if (mThirdStepJob) { | ||
260 | mThirdStepJob->kill(); | 260 | mThirdStepJob->kill(); | ||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |