Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/PanelView/krview.cpp
Show All 23 Lines | |||||
24 | #include "krselectionmode.h" | 24 | #include "krselectionmode.h" | ||
25 | #include "krviewfactory.h" | 25 | #include "krviewfactory.h" | ||
26 | #include "krviewitem.h" | 26 | #include "krviewitem.h" | ||
27 | #include "../FileSystem/dirlisterinterface.h" | 27 | #include "../FileSystem/dirlisterinterface.h" | ||
28 | #include "../FileSystem/fileitem.h" | 28 | #include "../FileSystem/fileitem.h" | ||
29 | #include "../FileSystem/krpermhandler.h" | 29 | #include "../FileSystem/krpermhandler.h" | ||
30 | #include "../Filter/filterdialog.h" | 30 | #include "../Filter/filterdialog.h" | ||
31 | #include "../defaults.h" | 31 | #include "../defaults.h" | ||
32 | #include "../kicons.h" | 32 | #include "../filelisticon.h" | ||
33 | #include "../krcolorcache.h" | 33 | #include "../krcolorcache.h" | ||
34 | #include "../krglobal.h" | 34 | #include "../krglobal.h" | ||
35 | #include "../krpreviews.h" | 35 | #include "../krpreviews.h" | ||
36 | #include "../viewactions.h" | 36 | #include "../viewactions.h" | ||
37 | 37 | | |||
38 | // QtCore | 38 | // QtCore | ||
39 | #include <QDebug> | 39 | #include <QDebug> | ||
40 | #include <QDir> | 40 | #include <QDir> | ||
41 | // QtGui | 41 | // QtGui | ||
42 | #include <QPixmapCache> | 42 | #include <QPixmapCache> | ||
43 | #include <QBitmap> | 43 | #include <QBitmap> | ||
44 | #include <QPainter> | 44 | #include <QPainter> | ||
45 | #include <QPixmap> | 45 | #include <QPixmap> | ||
46 | // QtWidgets | 46 | // QtWidgets | ||
47 | #include <QAction> | 47 | #include <QAction> | ||
48 | #include <QInputDialog> | 48 | #include <QInputDialog> | ||
49 | #include <QMimeDatabase> | 49 | #include <QMimeDatabase> | ||
50 | #include <QMimeType> | 50 | #include <QMimeType> | ||
51 | #include <qnamespace.h> | 51 | #include <qnamespace.h> | ||
52 | 52 | | |||
53 | #include <KConfigCore/KSharedConfig> | 53 | #include <KConfigCore/KSharedConfig> | ||
54 | #include <KI18n/KLocalizedString> | 54 | #include <KI18n/KLocalizedString> | ||
55 | #include <KIconThemes/KIconLoader> | 55 | | ||
56 | 56 | | |||
57 | #define FILEITEM getFileItem() | 57 | #define FILEITEM getFileItem() | ||
58 | 58 | | |||
59 | KrView *KrViewOperator::_changedView = 0; | 59 | KrView *KrViewOperator::_changedView = 0; | ||
60 | KrViewProperties::PropertyType KrViewOperator::_changedProperties = KrViewProperties::NoProperty; | 60 | KrViewProperties::PropertyType KrViewOperator::_changedProperties = KrViewProperties::NoProperty; | ||
61 | 61 | | |||
62 | 62 | | |||
63 | // ----------------------------- operator | 63 | // ----------------------------- operator | ||
Show All 33 Lines | |||||
97 | void KrViewOperator::startDrag() | 97 | void KrViewOperator::startDrag() | ||
98 | { | 98 | { | ||
99 | QStringList items; | 99 | QStringList items; | ||
100 | _view->getSelectedItems(&items); | 100 | _view->getSelectedItems(&items); | ||
101 | if (items.empty()) | 101 | if (items.empty()) | ||
102 | return ; // don't drag an empty thing | 102 | return ; // don't drag an empty thing | ||
103 | QPixmap px; | 103 | QPixmap px; | ||
104 | if (items.count() > 1 || _view->getCurrentKrViewItem() == 0) | 104 | if (items.count() > 1 || _view->getCurrentKrViewItem() == 0) | ||
105 | px = FL_LOADICON("queue"); // how much are we dragging | 105 | px = FileListIcon("document-multiple").pixmap(); // we are dragging multiple items | ||
106 | else | 106 | else | ||
107 | px = _view->getCurrentKrViewItem() ->icon(); | 107 | px = _view->getCurrentKrViewItem()->icon(); | ||
108 | emit letsDrag(items, px); | 108 | emit letsDrag(items, px); | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | bool KrViewOperator::searchItem(const QString &text, bool caseSensitive, int direction) | 111 | bool KrViewOperator::searchItem(const QString &text, bool caseSensitive, int direction) | ||
112 | { | 112 | { | ||
113 | KrViewItem * item = _view->getCurrentKrViewItem(); | 113 | KrViewItem * item = _view->getCurrentKrViewItem(); | ||
114 | if (!item) { | 114 | if (!item) { | ||
115 | return false; | 115 | return false; | ||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Line(s) | |||||
292 | } | 292 | } | ||
293 | 293 | | |||
294 | QPixmap KrView::processIcon(const QPixmap &icon, bool dim, const QColor & dimColor, int dimFactor, bool symlink) | 294 | QPixmap KrView::processIcon(const QPixmap &icon, bool dim, const QColor & dimColor, int dimFactor, bool symlink) | ||
295 | { | 295 | { | ||
296 | QPixmap pixmap = icon; | 296 | QPixmap pixmap = icon; | ||
297 | 297 | | |||
298 | if (symlink) { | 298 | if (symlink) { | ||
299 | const QStringList overlays = QStringList() << QString() << "emblem-symbolic-link"; | 299 | const QStringList overlays = QStringList() << QString() << "emblem-symbolic-link"; | ||
300 | KIconLoader::global()->drawOverlays(overlays, pixmap, KIconLoader::Desktop); | 300 | Icon::applyOverlays(&pixmap, overlays); | ||
301 | } | 301 | } | ||
302 | 302 | | |||
303 | if(!dim) | 303 | if(!dim) | ||
304 | return pixmap; | 304 | return pixmap; | ||
305 | 305 | | |||
306 | QImage dimmed = pixmap.toImage(); | 306 | QImage dimmed = pixmap.toImage(); | ||
307 | 307 | | |||
308 | QPainter p(&dimmed); | 308 | QPainter p(&dimmed); | ||
309 | p.setCompositionMode(QPainter::CompositionMode_SourceIn); | 309 | p.setCompositionMode(QPainter::CompositionMode_SourceIn); | ||
310 | p.fillRect(0, 0, icon.width(), icon.height(), dimColor); | 310 | p.fillRect(0, 0, icon.width(), icon.height(), dimColor); | ||
311 | p.setCompositionMode(QPainter::CompositionMode_SourceOver); | 311 | p.setCompositionMode(QPainter::CompositionMode_SourceOver); | ||
312 | p.setOpacity((qreal)dimFactor / (qreal)100); | 312 | p.setOpacity((qreal)dimFactor / (qreal)100); | ||
313 | p.drawPixmap(0, 0, icon.width(), icon.height(), pixmap); | 313 | p.drawPixmap(0, 0, icon.width(), icon.height(), pixmap); | ||
314 | 314 | | |||
315 | return QPixmap::fromImage(dimmed, Qt::ColorOnly | Qt::ThresholdDither | | 315 | return QPixmap::fromImage(dimmed, Qt::ColorOnly | Qt::ThresholdDither | | ||
316 | Qt::ThresholdAlphaDither | Qt::NoOpaqueDetection ); | 316 | Qt::ThresholdAlphaDither | Qt::NoOpaqueDetection ); | ||
317 | } | 317 | } | ||
318 | 318 | | |||
319 | QPixmap KrView::getIcon(FileItem *fileitem, bool active, int size/*, KRListItem::cmpColor color*/) | 319 | QPixmap KrView::getIcon(FileItem *fileitem, bool active, int size/*, KRListItem::cmpColor color*/) | ||
320 | { | 320 | { | ||
321 | // KConfigGroup ag( krConfig, "Advanced"); | 321 | // KConfigGroup ag( krConfig, "Advanced"); | ||
322 | ////////////////////////////// | 322 | ////////////////////////////// | ||
323 | QPixmap icon; | 323 | QPixmap icon; | ||
324 | QString icon_name = fileitem->getIcon(); | 324 | QString iconName = fileitem->getIcon(); | ||
325 | QString cacheName; | 325 | QString cacheName; | ||
326 | 326 | | |||
327 | if(!size) | 327 | if(!size) | ||
328 | size = _FilelistIconSize.toInt(); | 328 | size = _FilelistIconSize.toInt(); | ||
329 | 329 | | |||
330 | QColor dimColor; | 330 | QColor dimColor; | ||
331 | int dimFactor; | 331 | int dimFactor; | ||
332 | bool dim = !active && KrColorCache::getColorCache().getDimSettings(dimColor, dimFactor); | 332 | bool dim = !active && KrColorCache::getColorCache().getDimSettings(dimColor, dimFactor); | ||
333 | 333 | | |||
334 | if (icon_name.isNull()) | 334 | if (iconName.isNull()) | ||
335 | icon_name = ""; | 335 | iconName = ""; | ||
336 | 336 | | |||
337 | cacheName.append(QString::number(size)); | 337 | cacheName.append(QString::number(size)); | ||
338 | if(fileitem->isSymLink()) | 338 | if(fileitem->isSymLink()) | ||
339 | cacheName.append("LINK_"); | 339 | cacheName.append("LINK_"); | ||
340 | if(dim) | 340 | if(dim) | ||
341 | cacheName.append("DIM_"); | 341 | cacheName.append("DIM_"); | ||
342 | cacheName.append(icon_name); | 342 | cacheName.append(iconName); | ||
343 | 343 | | |||
344 | //QPixmapCache::setCacheLimit( ag.readEntry("Icon Cache Size",_IconCacheSize) ); | 344 | //QPixmapCache::setCacheLimit( ag.readEntry("Icon Cache Size",_IconCacheSize) ); | ||
345 | 345 | | |||
346 | // first try the cache | 346 | // first try the cache | ||
347 | if (!QPixmapCache::find(cacheName, icon)) { | 347 | if (!QPixmapCache::find(cacheName, icon)) { | ||
348 | icon = processIcon(krLoader->loadIcon(icon_name, KIconLoader::Desktop, size), | 348 | icon = processIcon(Icon(iconName).pixmap(size), | ||
349 | dim, dimColor, dimFactor, fileitem->isSymLink()); | 349 | dim, dimColor, dimFactor, fileitem->isSymLink()); | ||
350 | // insert it into the cache | 350 | // insert it into the cache | ||
351 | QPixmapCache::insert(cacheName, icon); | 351 | QPixmapCache::insert(cacheName, icon); | ||
352 | } | 352 | } | ||
353 | 353 | | |||
354 | return icon; | 354 | return icon; | ||
355 | } | 355 | } | ||
356 | 356 | | |||
▲ Show 20 Lines • Show All 867 Lines • Show Last 20 Lines |