Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kdiroperator.cpp
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 84 | public: | |||
---|---|---|---|---|---|
101 | 101 | | |||
102 | static bool isReadable(const QUrl &url); | 102 | static bool isReadable(const QUrl &url); | ||
103 | bool isSchemeSupported(const QString &scheme) const; | 103 | bool isSchemeSupported(const QString &scheme) const; | ||
104 | 104 | | |||
105 | KFile::FileView allViews(); | 105 | KFile::FileView allViews(); | ||
106 | 106 | | |||
107 | QMetaObject::Connection m_connection; | 107 | QMetaObject::Connection m_connection; | ||
108 | 108 | | |||
109 | // A pair to store zoom settings for view kinds | ||||
110 | struct ZoomSettingsForView { | ||||
111 | QString name; | ||||
112 | int defaultValue; | ||||
113 | }; | ||||
114 | | ||||
109 | // private slots | 115 | // private slots | ||
110 | void _k_slotDetailedView(); | 116 | void _k_slotDetailedView(); | ||
111 | void _k_slotSimpleView(); | 117 | void _k_slotSimpleView(); | ||
112 | void _k_slotTreeView(); | 118 | void _k_slotTreeView(); | ||
113 | void _k_slotDetailedTreeView(); | 119 | void _k_slotDetailedTreeView(); | ||
114 | void _k_slotIconsView(); | 120 | void _k_slotIconsView(); | ||
115 | void _k_slotCompactView(); | 121 | void _k_slotCompactView(); | ||
116 | void _k_slotDetailsView(); | 122 | void _k_slotDetailsView(); | ||
Show All 25 Lines | |||||
142 | void _k_assureVisibleSelection(); | 148 | void _k_assureVisibleSelection(); | ||
143 | void _k_synchronizeSortingState(int, Qt::SortOrder); | 149 | void _k_synchronizeSortingState(int, Qt::SortOrder); | ||
144 | void _k_slotChangeDecorationPosition(); | 150 | void _k_slotChangeDecorationPosition(); | ||
145 | void _k_slotExpandToUrl(const QModelIndex &); | 151 | void _k_slotExpandToUrl(const QModelIndex &); | ||
146 | void _k_slotItemsChanged(); | 152 | void _k_slotItemsChanged(); | ||
147 | void _k_slotDirectoryCreated(const QUrl &); | 153 | void _k_slotDirectoryCreated(const QUrl &); | ||
148 | 154 | | |||
149 | int iconSizeForViewType(QAbstractItemView *itemView) const; | 155 | int iconSizeForViewType(QAbstractItemView *itemView) const; | ||
156 | void writeIconZoomSettingsIfNeeded(); | ||||
157 | ZoomSettingsForView zoomSettingsForViewForView() const; | ||||
150 | 158 | | |||
151 | // private members | 159 | // private members | ||
152 | KDirOperator * const parent; | 160 | KDirOperator * const parent; | ||
153 | QStack<QUrl *> backStack; ///< Contains all URLs you can reach with the back button. | 161 | QStack<QUrl *> backStack; ///< Contains all URLs you can reach with the back button. | ||
154 | QStack<QUrl *> forwardStack; ///< Contains all URLs you can reach with the forward button. | 162 | QStack<QUrl *> forwardStack; ///< Contains all URLs you can reach with the forward button. | ||
155 | 163 | | |||
156 | QModelIndex lastHoveredIndex; | 164 | QModelIndex lastHoveredIndex; | ||
157 | 165 | | |||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Line(s) | |||||
505 | 513 | | |||
506 | KFile::FileView KDirOperator::Private::allViews() | 514 | KFile::FileView KDirOperator::Private::allViews() | ||
507 | { | 515 | { | ||
508 | return static_cast<KFile::FileView>(KFile::Simple | KFile::Detail | KFile::Tree | KFile::DetailTree); | 516 | return static_cast<KFile::FileView>(KFile::Simple | KFile::Detail | KFile::Tree | KFile::DetailTree); | ||
509 | } | 517 | } | ||
510 | 518 | | |||
511 | void KDirOperator::Private::_k_slotDetailedView() | 519 | void KDirOperator::Private::_k_slotDetailedView() | ||
512 | { | 520 | { | ||
521 | // save old zoom settings | ||||
522 | writeIconZoomSettingsIfNeeded(); | ||||
523 | | ||||
513 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | 524 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | ||
514 | parent->setView(view); | 525 | parent->setView(view); | ||
515 | } | 526 | } | ||
516 | 527 | | |||
517 | void KDirOperator::Private::_k_slotSimpleView() | 528 | void KDirOperator::Private::_k_slotSimpleView() | ||
518 | { | 529 | { | ||
530 | // save old zoom settings | ||||
531 | writeIconZoomSettingsIfNeeded(); | ||||
532 | | ||||
519 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 533 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
520 | parent->setView(view); | 534 | parent->setView(view); | ||
521 | } | 535 | } | ||
522 | 536 | | |||
523 | void KDirOperator::Private::_k_slotTreeView() | 537 | void KDirOperator::Private::_k_slotTreeView() | ||
524 | { | 538 | { | ||
539 | // save old zoom settings | ||||
540 | writeIconZoomSettingsIfNeeded(); | ||||
541 | | ||||
525 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Tree); | 542 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Tree); | ||
526 | parent->setView(view); | 543 | parent->setView(view); | ||
527 | } | 544 | } | ||
528 | 545 | | |||
529 | void KDirOperator::Private::_k_slotDetailedTreeView() | 546 | void KDirOperator::Private::_k_slotDetailedTreeView() | ||
530 | { | 547 | { | ||
548 | // save old zoom settings | ||||
549 | writeIconZoomSettingsIfNeeded(); | ||||
550 | | ||||
531 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | 551 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | ||
532 | parent->setView(view); | 552 | parent->setView(view); | ||
533 | } | 553 | } | ||
534 | 554 | | |||
535 | void KDirOperator::Private::_k_slotToggleAllowExpansion(bool allow) { | 555 | void KDirOperator::Private::_k_slotToggleAllowExpansion(bool allow) { | ||
536 | KFile::FileView view = KFile::Detail; | 556 | KFile::FileView view = KFile::Detail; | ||
537 | if (allow) { | 557 | if (allow) { | ||
538 | view = KFile::DetailTree; | 558 | view = KFile::DetailTree; | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
629 | void KDirOperator::Private::_k_slotToggleDirsFirst() | 649 | void KDirOperator::Private::_k_slotToggleDirsFirst() | ||
630 | { | 650 | { | ||
631 | QDir::SortFlags s = (sorting ^ QDir::DirsFirst); | 651 | QDir::SortFlags s = (sorting ^ QDir::DirsFirst); | ||
632 | updateSorting(s); | 652 | updateSorting(s); | ||
633 | } | 653 | } | ||
634 | 654 | | |||
635 | void KDirOperator::Private::_k_slotIconsView() | 655 | void KDirOperator::Private::_k_slotIconsView() | ||
636 | { | 656 | { | ||
657 | // save old zoom settings | ||||
658 | writeIconZoomSettingsIfNeeded(); | ||||
659 | | ||||
637 | // Put the icons on top | 660 | // Put the icons on top | ||
638 | actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true); | 661 | actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true); | ||
639 | decorationPosition = QStyleOptionViewItem::Top; | 662 | decorationPosition = QStyleOptionViewItem::Top; | ||
640 | 663 | | |||
641 | // Switch to simple view | 664 | // Switch to simple view | ||
642 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 665 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
643 | parent->setView(fileView); | 666 | parent->setView(fileView); | ||
644 | } | 667 | } | ||
645 | 668 | | |||
646 | void KDirOperator::Private::_k_slotCompactView() | 669 | void KDirOperator::Private::_k_slotCompactView() | ||
647 | { | 670 | { | ||
671 | // save old zoom settings | ||||
672 | writeIconZoomSettingsIfNeeded(); | ||||
673 | | ||||
648 | // Put the icons on the side | 674 | // Put the icons on the side | ||
649 | actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true); | 675 | actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true); | ||
650 | decorationPosition = QStyleOptionViewItem::Left; | 676 | decorationPosition = QStyleOptionViewItem::Left; | ||
651 | 677 | | |||
652 | // Switch to simple view | 678 | // Switch to simple view | ||
653 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 679 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
654 | parent->setView(fileView); | 680 | parent->setView(fileView); | ||
655 | } | 681 | } | ||
656 | 682 | | |||
657 | void KDirOperator::Private::_k_slotDetailsView() | 683 | void KDirOperator::Private::_k_slotDetailsView() | ||
658 | { | 684 | { | ||
685 | // save old zoom settings | ||||
686 | writeIconZoomSettingsIfNeeded(); | ||||
687 | | ||||
659 | KFile::FileView view; | 688 | KFile::FileView view; | ||
660 | if (actionCollection->action(QStringLiteral("allow expansion"))->isChecked()) { | 689 | if (actionCollection->action(QStringLiteral("allow expansion"))->isChecked()) { | ||
661 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | 690 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | ||
662 | } else { | 691 | } else { | ||
663 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | 692 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | ||
664 | } | 693 | } | ||
665 | parent->setView(view); | 694 | parent->setView(view); | ||
666 | } | 695 | } | ||
▲ Show 20 Lines • Show All 1619 Lines • ▼ Show 20 Line(s) | 2314 | } else if (KFile::isTreeView(fv)) { | |||
2286 | style = QStringLiteral("Tree"); | 2315 | style = QStringLiteral("Tree"); | ||
2287 | } else if (KFile::isDetailTreeView(fv)) { | 2316 | } else if (KFile::isDetailTreeView(fv)) { | ||
2288 | style = QStringLiteral("DetailTree"); | 2317 | style = QStringLiteral("DetailTree"); | ||
2289 | } | 2318 | } | ||
2290 | configGroup.writeEntry(QStringLiteral("View Style"), style); | 2319 | configGroup.writeEntry(QStringLiteral("View Style"), style); | ||
2291 | 2320 | | |||
2292 | if (d->inlinePreviewState == Private::NotForced) { | 2321 | if (d->inlinePreviewState == Private::NotForced) { | ||
2293 | configGroup.writeEntry(QStringLiteral("Show Inline Previews"), d->showPreviews); | 2322 | configGroup.writeEntry(QStringLiteral("Show Inline Previews"), d->showPreviews); | ||
2294 | if (qobject_cast<QListView *>(d->itemView)) { | 2323 | d->writeIconZoomSettingsIfNeeded(); | ||
2295 | configGroup.writeEntry(QStringLiteral("listViewIconSize"), d->iconsZoom); | | |||
2296 | } else { | | |||
2297 | configGroup.writeEntry(QStringLiteral("detailedViewIconSize"), d->iconsZoom); | | |||
2298 | } | | |||
2299 | } | 2324 | } | ||
2300 | 2325 | | |||
2301 | configGroup.writeEntry(QStringLiteral("Decoration position"), (int) d->decorationPosition); | 2326 | configGroup.writeEntry(QStringLiteral("Decoration position"), (int) d->decorationPosition); | ||
2302 | } | 2327 | } | ||
2303 | 2328 | | |||
2329 | void KDirOperator::Private::writeIconZoomSettingsIfNeeded() { | ||||
2330 | // must match behavior of iconSizeForViewType | ||||
2331 | if (configGroup && itemView) { | ||||
2332 | ZoomSettingsForView zoomSettings = zoomSettingsForViewForView(); | ||||
2333 | configGroup->writeEntry(zoomSettings.name, iconsZoom); | ||||
2334 | } | ||||
2335 | } | ||||
2336 | | ||||
2304 | void KDirOperator::resizeEvent(QResizeEvent *) | 2337 | void KDirOperator::resizeEvent(QResizeEvent *) | ||
2305 | { | 2338 | { | ||
2306 | // resize the splitter and assure that the width of | 2339 | // resize the splitter and assure that the width of | ||
2307 | // the preview widget is restored | 2340 | // the preview widget is restored | ||
2308 | QList<int> sizes = d->splitter->sizes(); | 2341 | QList<int> sizes = d->splitter->sizes(); | ||
2309 | const bool hasPreview = (sizes.count() == 2); | 2342 | const bool hasPreview = (sizes.count() == 2); | ||
2310 | 2343 | | |||
2311 | d->splitter->resize(size()); | 2344 | d->splitter->resize(size()); | ||
▲ Show 20 Lines • Show All 319 Lines • ▼ Show 20 Line(s) | |||||
2631 | 2664 | | |||
2632 | void KDirOperator::Private::_k_slotItemsChanged() | 2665 | void KDirOperator::Private::_k_slotItemsChanged() | ||
2633 | { | 2666 | { | ||
2634 | completeListDirty = true; | 2667 | completeListDirty = true; | ||
2635 | } | 2668 | } | ||
2636 | 2669 | | |||
2637 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | 2670 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | ||
2638 | { | 2671 | { | ||
2672 | // must match behavior of writeIconZoomSettingsIfNeeded | ||||
2639 | if (!itemView || !configGroup) { | 2673 | if (!itemView || !configGroup) { | ||
2640 | return 0; | 2674 | return 0; | ||
2641 | } | 2675 | } | ||
2642 | 2676 | | |||
2643 | if (qobject_cast<QListView *>(itemView)) { | 2677 | ZoomSettingsForView ZoomSettingsForView = zoomSettingsForViewForView(); | ||
2644 | return configGroup->readEntry("listViewIconSize", 0); | 2678 | configGroup->writeEntry(ZoomSettingsForView.name, ZoomSettingsForView.defaultValue); | ||
2679 | return configGroup->readEntry(ZoomSettingsForView.name, ZoomSettingsForView.defaultValue); | ||||
2680 | } | ||||
2681 | | ||||
2682 | KDirOperator::Private::ZoomSettingsForView KDirOperator::Private::zoomSettingsForViewForView() const { | ||||
2683 | KFile::FileView fv = static_cast<KFile::FileView>(viewKind); | ||||
2684 | if (KFile::isSimpleView(fv)) { | ||||
2685 | if (decorationPosition == QStyleOptionViewItem::Top){ | ||||
2686 | // Simple view decoration above, aka Icons View | ||||
2687 | // default to 43% aka 64px | ||||
2688 | return {QStringLiteral("iconViewIconSize"), 43}; | ||||
2689 | } else { | ||||
2690 | // Simple view decoration left, aka compact view | ||||
2691 | return {QStringLiteral("listViewIconSize"), 15}; | ||||
meven: Perhaps we could use a more sensible default value for ColumnView.
What would you say about… | |||||
ngraham: That sounds like a good default size. | |||||
2692 | } | ||||
2645 | } else { | 2693 | } else { | ||
2646 | return configGroup->readEntry("detailedViewIconSize", 0); | 2694 | if (KFile::isTreeView(fv)) { | ||
2695 | return {QStringLiteral("treeViewIconSize"), 0}; | ||||
2696 | } else { | ||||
2697 | // DetailView and DetailTreeView | ||||
2698 | return {QStringLiteral("detailViewIconSize"), 0}; | ||||
2699 | } | ||||
2647 | } | 2700 | } | ||
2648 | } | 2701 | } | ||
2649 | 2702 | | |||
2650 | void KDirOperator::setViewConfig(KConfigGroup &configGroup) | 2703 | void KDirOperator::setViewConfig(KConfigGroup &configGroup) | ||
2651 | { | 2704 | { | ||
2652 | delete d->configGroup; | 2705 | delete d->configGroup; | ||
2653 | d->configGroup = new KConfigGroup(configGroup); | 2706 | d->configGroup = new KConfigGroup(configGroup); | ||
2654 | } | 2707 | } | ||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |
Perhaps we could use a more sensible default value for ColumnView.
What would you say about 32px ?