Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | |||||
142 | void InformationPanelContent::showItem(const KFileItem& item) | 142 | void InformationPanelContent::showItem(const KFileItem& item) | ||
143 | { | 143 | { | ||
144 | // If there is a preview job, kill it to prevent that we have jobs for | 144 | // If there is a preview job, kill it to prevent that we have jobs for | ||
145 | // multiple items running, and thus a race condition (bug 250787). | 145 | // multiple items running, and thus a race condition (bug 250787). | ||
146 | if (m_previewJob) { | 146 | if (m_previewJob) { | ||
147 | m_previewJob->kill(); | 147 | m_previewJob->kill(); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | if (InformationPanelSettings::previewsShown()) { | ||||
151 | m_preview->show(); | ||||
152 | | ||||
150 | const QUrl itemUrl = item.url(); | 153 | const QUrl itemUrl = item.url(); | ||
151 | const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && item.localPath().isEmpty(); | 154 | const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && item.localPath().isEmpty(); | ||
152 | setNameLabelText(item.text()); | 155 | setNameLabelText(item.text()); | ||
153 | if (isSearchUrl) { | 156 | if (isSearchUrl) { | ||
154 | // in the case of a search-URL the URL is not readable for humans | 157 | // in the case of a search-URL the URL is not readable for humans | ||
155 | // (at least not useful to show in the Information Panel) | 158 | // (at least not useful to show in the Information Panel) | ||
156 | m_preview->setPixmap( | 159 | m_preview->setPixmap( | ||
157 | QIcon::fromTheme(QStringLiteral("nepomuk")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) | 160 | QIcon::fromTheme(QStringLiteral("nepomuk")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) | ||
158 | ); | 161 | ); | ||
159 | } else { | 162 | } else { | ||
160 | // try to get a preview pixmap from the item... | 163 | // try to get a preview pixmap from the item... | ||
161 | 164 | | |||
162 | // Mark the currently shown preview as outdated. This is done | 165 | // Mark the currently shown preview as outdated. This is done | ||
163 | // with a small delay to prevent a flickering when the next preview | 166 | // with a small delay to prevent a flickering when the next preview | ||
164 | // can be shown within a short timeframe. This timer is not started | 167 | // can be shown within a short timeframe. This timer is not started | ||
165 | // for directories, as directory previews might fail and return the | 168 | // for directories, as directory previews might fail and return the | ||
166 | // same icon. | 169 | // same icon. | ||
167 | if (!item.isDir()) { | 170 | if (!item.isDir()) { | ||
168 | m_outdatedPreviewTimer->start(); | 171 | m_outdatedPreviewTimer->start(); | ||
169 | } | 172 | } | ||
170 | 173 | | |||
171 | QStringList plugins = KIO::PreviewJob::availablePlugins(); | 174 | QStringList plugins = KIO::PreviewJob::availablePlugins(); | ||
172 | m_previewJob = new KIO::PreviewJob(KFileItemList() << item, | 175 | m_previewJob = new KIO::PreviewJob(KFileItemList() << item, | ||
173 | QSize(m_preview->width(), m_preview->height()), | 176 | QSize(m_preview->width(), m_preview->height()), | ||
174 | &plugins); | 177 | &plugins); | ||
175 | m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); | 178 | m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); | ||
elvisangelaccio: Unrelated whitespace changes. | |||||
meven: It is related : this code is now in a if statement starting line 157. | |||||
elvisangelaccio: Ah you're right, the phabricator UI confused me :/ | |||||
176 | m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); | 179 | m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); | ||
177 | if (m_previewJob->uiDelegate()) { | 180 | if (m_previewJob->uiDelegate()) { | ||
178 | KJobWidgets::setWindow(m_previewJob, this); | 181 | KJobWidgets::setWindow(m_previewJob, this); | ||
179 | } | 182 | } | ||
180 | 183 | | |||
181 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | 184 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | ||
182 | this, &InformationPanelContent::showPreview); | 185 | this, &InformationPanelContent::showPreview); | ||
183 | connect(m_previewJob.data(), &KIO::PreviewJob::failed, | 186 | connect(m_previewJob.data(), &KIO::PreviewJob::failed, | ||
184 | this, &InformationPanelContent::showIcon); | 187 | this, &InformationPanelContent::showIcon); | ||
185 | } | | |||
186 | | ||||
187 | if (m_metaDataWidget) { | | |||
188 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | | |||
189 | m_metaDataWidget->show(); | | |||
190 | m_metaDataWidget->setItems(KFileItemList() << item); | | |||
191 | } | | |||
192 | 188 | | |||
193 | if (InformationPanelSettings::previewsShown()) { | | |||
194 | const QString mimeType = item.mimetype(); | 189 | const QString mimeType = item.mimetype(); | ||
195 | const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); | 190 | const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); | ||
196 | if (usePhonon) { | 191 | if (usePhonon) { | ||
197 | m_phononWidget->show(); | 192 | m_phononWidget->show(); | ||
198 | m_phononWidget->setUrl(item.targetUrl()); | 193 | m_phononWidget->setUrl(item.targetUrl()); | ||
elvisangelaccio: Unrelated whitespace changes. | |||||
meven: This is the correct spacing. Have a look at the side-by-side view. | |||||
199 | if (m_preview->isVisible()) { | | |||
200 | m_phononWidget->setVideoSize(m_preview->size()); | 194 | m_phononWidget->setVideoSize(m_preview->size()); | ||
201 | } | | |||
202 | } else { | 195 | } else { | ||
203 | m_phononWidget->hide(); | 196 | m_phononWidget->hide(); | ||
204 | m_preview->setVisible(true); | 197 | } | ||
205 | } | 198 | } | ||
206 | } else { | 199 | } else { | ||
200 | m_preview->hide(); | ||||
207 | m_phononWidget->hide(); | 201 | m_phononWidget->hide(); | ||
208 | } | 202 | } | ||
209 | 203 | | |||
204 | if (m_metaDataWidget) { | ||||
205 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||||
206 | m_metaDataWidget->show(); | ||||
207 | m_metaDataWidget->setItems(KFileItemList() << item); | ||||
208 | } | ||||
209 | | ||||
210 | m_item = item; | 210 | m_item = item; | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | void InformationPanelContent::showItems(const KFileItemList& items) | 213 | void InformationPanelContent::showItems(const KFileItemList& items) | ||
214 | { | 214 | { | ||
215 | // If there is a preview job, kill it to prevent that we have jobs for | 215 | // If there is a preview job, kill it to prevent that we have jobs for | ||
216 | // multiple items running, and thus a race condition (bug 250787). | 216 | // multiple items running, and thus a race condition (bug 250787). | ||
217 | if (m_previewJob) { | 217 | if (m_previewJob) { | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
285 | { | 285 | { | ||
286 | KIconEffect *iconEffect = KIconLoader::global()->iconEffect(); | 286 | KIconEffect *iconEffect = KIconLoader::global()->iconEffect(); | ||
287 | QPixmap disabledPixmap = iconEffect->apply(m_preview->pixmap(), | 287 | QPixmap disabledPixmap = iconEffect->apply(m_preview->pixmap(), | ||
288 | KIconLoader::Desktop, | 288 | KIconLoader::Desktop, | ||
289 | KIconLoader::DisabledState); | 289 | KIconLoader::DisabledState); | ||
290 | m_preview->setPixmap(disabledPixmap); | 290 | m_preview->setPixmap(disabledPixmap); | ||
291 | } | 291 | } | ||
292 | 292 | | |||
293 | void InformationPanelContent::setPreviewVisible(bool visible) { | | |||
294 | m_preview->setVisible(visible); | | |||
295 | } | | |||
296 | | ||||
297 | KFileItemList InformationPanelContent::items() { | 293 | KFileItemList InformationPanelContent::items() { | ||
298 | return m_metaDataWidget->items(); | 294 | return m_metaDataWidget->items(); | ||
299 | } | 295 | } | ||
300 | 296 | | |||
301 | void InformationPanelContent::slotHasVideoChanged(bool hasVideo) | 297 | void InformationPanelContent::slotHasVideoChanged(bool hasVideo) | ||
302 | { | 298 | { | ||
303 | m_preview->setVisible(InformationPanelSettings::previewsShown() && !hasVideo); | 299 | m_preview->setVisible(InformationPanelSettings::previewsShown() && !hasVideo); | ||
304 | } | 300 | } | ||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
Unrelated whitespace changes.