Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kdiroperator.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 84 | public: | |||
---|---|---|---|---|---|
142 | void _k_assureVisibleSelection(); | 142 | void _k_assureVisibleSelection(); | ||
143 | void _k_synchronizeSortingState(int, Qt::SortOrder); | 143 | void _k_synchronizeSortingState(int, Qt::SortOrder); | ||
144 | void _k_slotChangeDecorationPosition(); | 144 | void _k_slotChangeDecorationPosition(); | ||
145 | void _k_slotExpandToUrl(const QModelIndex &); | 145 | void _k_slotExpandToUrl(const QModelIndex &); | ||
146 | void _k_slotItemsChanged(); | 146 | void _k_slotItemsChanged(); | ||
147 | void _k_slotDirectoryCreated(const QUrl &); | 147 | void _k_slotDirectoryCreated(const QUrl &); | ||
148 | 148 | | |||
149 | int iconSizeForViewType(QAbstractItemView *itemView) const; | 149 | int iconSizeForViewType(QAbstractItemView *itemView) const; | ||
150 | void writeIconZoomSettingsIfNeeded(); | ||||
150 | 151 | | |||
151 | // private members | 152 | // private members | ||
152 | KDirOperator * const parent; | 153 | KDirOperator * const parent; | ||
153 | QStack<QUrl *> backStack; ///< Contains all URLs you can reach with the back button. | 154 | 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. | 155 | QStack<QUrl *> forwardStack; ///< Contains all URLs you can reach with the forward button. | ||
155 | 156 | | |||
156 | QModelIndex lastHoveredIndex; | 157 | QModelIndex lastHoveredIndex; | ||
157 | 158 | | |||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Line(s) | |||||
505 | 506 | | |||
506 | KFile::FileView KDirOperator::Private::allViews() | 507 | KFile::FileView KDirOperator::Private::allViews() | ||
507 | { | 508 | { | ||
508 | return static_cast<KFile::FileView>(KFile::Simple | KFile::Detail | KFile::Tree | KFile::DetailTree); | 509 | return static_cast<KFile::FileView>(KFile::Simple | KFile::Detail | KFile::Tree | KFile::DetailTree); | ||
509 | } | 510 | } | ||
510 | 511 | | |||
511 | void KDirOperator::Private::_k_slotDetailedView() | 512 | void KDirOperator::Private::_k_slotDetailedView() | ||
512 | { | 513 | { | ||
514 | // save old zoom settings | ||||
515 | writeIconZoomSettingsIfNeeded(); | ||||
516 | | ||||
513 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | 517 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | ||
514 | parent->setView(view); | 518 | parent->setView(view); | ||
515 | } | 519 | } | ||
516 | 520 | | |||
517 | void KDirOperator::Private::_k_slotSimpleView() | 521 | void KDirOperator::Private::_k_slotSimpleView() | ||
518 | { | 522 | { | ||
523 | // save old zoom settings | ||||
524 | writeIconZoomSettingsIfNeeded(); | ||||
525 | | ||||
519 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 526 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
520 | parent->setView(view); | 527 | parent->setView(view); | ||
521 | } | 528 | } | ||
522 | 529 | | |||
523 | void KDirOperator::Private::_k_slotTreeView() | 530 | void KDirOperator::Private::_k_slotTreeView() | ||
524 | { | 531 | { | ||
532 | // save old zoom settings | ||||
533 | writeIconZoomSettingsIfNeeded(); | ||||
534 | | ||||
525 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Tree); | 535 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Tree); | ||
526 | parent->setView(view); | 536 | parent->setView(view); | ||
527 | } | 537 | } | ||
528 | 538 | | |||
529 | void KDirOperator::Private::_k_slotDetailedTreeView() | 539 | void KDirOperator::Private::_k_slotDetailedTreeView() | ||
530 | { | 540 | { | ||
541 | // save old zoom settings | ||||
542 | writeIconZoomSettingsIfNeeded(); | ||||
543 | | ||||
531 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | 544 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | ||
532 | parent->setView(view); | 545 | parent->setView(view); | ||
533 | } | 546 | } | ||
534 | 547 | | |||
535 | void KDirOperator::Private::_k_slotToggleAllowExpansion(bool allow) { | 548 | void KDirOperator::Private::_k_slotToggleAllowExpansion(bool allow) { | ||
536 | KFile::FileView view = KFile::Detail; | 549 | KFile::FileView view = KFile::Detail; | ||
537 | if (allow) { | 550 | if (allow) { | ||
538 | view = KFile::DetailTree; | 551 | view = KFile::DetailTree; | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
629 | void KDirOperator::Private::_k_slotToggleDirsFirst() | 642 | void KDirOperator::Private::_k_slotToggleDirsFirst() | ||
630 | { | 643 | { | ||
631 | QDir::SortFlags s = (sorting ^ QDir::DirsFirst); | 644 | QDir::SortFlags s = (sorting ^ QDir::DirsFirst); | ||
632 | updateSorting(s); | 645 | updateSorting(s); | ||
633 | } | 646 | } | ||
634 | 647 | | |||
635 | void KDirOperator::Private::_k_slotToggleIconsView() | 648 | void KDirOperator::Private::_k_slotToggleIconsView() | ||
636 | { | 649 | { | ||
650 | // save old zoom settings | ||||
651 | writeIconZoomSettingsIfNeeded(); | ||||
652 | | ||||
637 | // Put the icons on top | 653 | // Put the icons on top | ||
638 | actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true); | 654 | actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true); | ||
639 | decorationPosition = QStyleOptionViewItem::Top; | 655 | decorationPosition = QStyleOptionViewItem::Top; | ||
640 | 656 | | |||
641 | // Switch to simple view | 657 | // Switch to simple view | ||
642 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 658 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
643 | parent->setView(fileView); | 659 | parent->setView(fileView); | ||
644 | } | 660 | } | ||
645 | 661 | | |||
646 | void KDirOperator::Private::_k_slotToggleCompactView() | 662 | void KDirOperator::Private::_k_slotToggleCompactView() | ||
647 | { | 663 | { | ||
664 | // save old zoom settings | ||||
665 | writeIconZoomSettingsIfNeeded(); | ||||
666 | | ||||
648 | // Put the icons on the side | 667 | // Put the icons on the side | ||
649 | actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true); | 668 | actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true); | ||
650 | decorationPosition = QStyleOptionViewItem::Left; | 669 | decorationPosition = QStyleOptionViewItem::Left; | ||
651 | 670 | | |||
652 | // Switch to simple view | 671 | // Switch to simple view | ||
653 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 672 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
654 | parent->setView(fileView); | 673 | parent->setView(fileView); | ||
655 | } | 674 | } | ||
656 | 675 | | |||
657 | void KDirOperator::Private::_k_slotToggleDetailsView() | 676 | void KDirOperator::Private::_k_slotToggleDetailsView() | ||
658 | { | 677 | { | ||
678 | // save old zoom settings | ||||
679 | writeIconZoomSettingsIfNeeded(); | ||||
680 | | ||||
659 | KFile::FileView view; | 681 | KFile::FileView view; | ||
660 | if (actionCollection->action(QStringLiteral("allow expansion"))->isChecked()) { | 682 | if (actionCollection->action(QStringLiteral("allow expansion"))->isChecked()) { | ||
661 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | 683 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | ||
662 | } else { | 684 | } else { | ||
663 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | 685 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | ||
664 | } | 686 | } | ||
665 | parent->setView(view); | 687 | parent->setView(view); | ||
666 | } | 688 | } | ||
▲ Show 20 Lines • Show All 1619 Lines • ▼ Show 20 Line(s) | 2307 | } else if (KFile::isTreeView(fv)) { | |||
2286 | style = QStringLiteral("Tree"); | 2308 | style = QStringLiteral("Tree"); | ||
2287 | } else if (KFile::isDetailTreeView(fv)) { | 2309 | } else if (KFile::isDetailTreeView(fv)) { | ||
2288 | style = QStringLiteral("DetailTree"); | 2310 | style = QStringLiteral("DetailTree"); | ||
2289 | } | 2311 | } | ||
2290 | configGroup.writeEntry(QStringLiteral("View Style"), style); | 2312 | configGroup.writeEntry(QStringLiteral("View Style"), style); | ||
2291 | 2313 | | |||
2292 | if (d->inlinePreviewState == Private::NotForced) { | 2314 | if (d->inlinePreviewState == Private::NotForced) { | ||
2293 | configGroup.writeEntry(QStringLiteral("Show Inline Previews"), d->showPreviews); | 2315 | configGroup.writeEntry(QStringLiteral("Show Inline Previews"), d->showPreviews); | ||
2294 | if (qobject_cast<QListView *>(d->itemView)) { | 2316 | d->writeIconZoomSettingsIfNeeded(); | ||
2295 | configGroup.writeEntry(QStringLiteral("listViewIconSize"), d->iconsZoom); | | |||
2296 | } else { | | |||
2297 | configGroup.writeEntry(QStringLiteral("detailedViewIconSize"), d->iconsZoom); | | |||
2298 | } | | |||
2299 | } | 2317 | } | ||
2300 | 2318 | | |||
2301 | configGroup.writeEntry(QStringLiteral("Decoration position"), (int) d->decorationPosition); | 2319 | configGroup.writeEntry(QStringLiteral("Decoration position"), (int) d->decorationPosition); | ||
2302 | } | 2320 | } | ||
2303 | 2321 | | |||
2322 | void KDirOperator::Private::writeIconZoomSettingsIfNeeded() { | ||||
2323 | // must match behavior of iconSizeForViewType | ||||
2324 | if (configGroup && itemView) { | ||||
2325 | KFile::FileView fv = static_cast<KFile::FileView>(viewKind); | ||||
2326 | | ||||
2327 | if (KFile::isSimpleView(fv)) { | ||||
2328 | if (decorationPosition == QStyleOptionViewItem::Top){ | ||||
2329 | // Simple view decoration above, aka Icons View | ||||
2330 | configGroup->writeEntry(QStringLiteral("iconViewIconSize"), iconsZoom); | ||||
2331 | } else { | ||||
2332 | // Simple view decoration left, aka compact view | ||||
2333 | configGroup->writeEntry(QStringLiteral("listViewIconSize"), iconsZoom); | ||||
2334 | } | ||||
2335 | } else { | ||||
2336 | if (KFile::isTreeView(fv)) { | ||||
2337 | configGroup->writeEntry(QStringLiteral("treeViewIconSize"), iconsZoom); | ||||
2338 | } else if (KFile::isDetailTreeView(fv) || KFile::isDetailView(fv)) { | ||||
2339 | configGroup->writeEntry(QStringLiteral("detailViewIconSize"), iconsZoom); | ||||
2340 | } | ||||
2341 | } | ||||
2342 | } | ||||
2343 | } | ||||
2304 | 2344 | | |||
2305 | void KDirOperator::resizeEvent(QResizeEvent *) | 2345 | void KDirOperator::resizeEvent(QResizeEvent *) | ||
2306 | { | 2346 | { | ||
2307 | // resize the splitter and assure that the width of | 2347 | // resize the splitter and assure that the width of | ||
2308 | // the preview widget is restored | 2348 | // the preview widget is restored | ||
2309 | QList<int> sizes = d->splitter->sizes(); | 2349 | QList<int> sizes = d->splitter->sizes(); | ||
2310 | const bool hasPreview = (sizes.count() == 2); | 2350 | const bool hasPreview = (sizes.count() == 2); | ||
2311 | 2351 | | |||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Line(s) | |||||
2632 | 2672 | | |||
2633 | void KDirOperator::Private::_k_slotItemsChanged() | 2673 | void KDirOperator::Private::_k_slotItemsChanged() | ||
2634 | { | 2674 | { | ||
2635 | completeListDirty = true; | 2675 | completeListDirty = true; | ||
2636 | } | 2676 | } | ||
2637 | 2677 | | |||
2638 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | 2678 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | ||
2639 | { | 2679 | { | ||
2680 | // must match behavior of writeIconZoomSettingsIfNeeded | ||||
2640 | if (!itemView || !configGroup) { | 2681 | if (!itemView || !configGroup) { | ||
2641 | return 0; | 2682 | return 0; | ||
2642 | } | 2683 | } | ||
2643 | 2684 | | |||
2644 | if (qobject_cast<QListView *>(itemView)) { | 2685 | KFile::FileView fv = static_cast<KFile::FileView>(viewKind); | ||
2645 | return configGroup->readEntry("listViewIconSize", 0); | 2686 | | ||
2646 | } else { | 2687 | if (KFile::isSimpleView(fv)) { | ||
2647 | return configGroup->readEntry("detailedViewIconSize", 0); | 2688 | if (decorationPosition == QStyleOptionViewItem::Top){ | ||
2689 | // Simple view decoration above, aka Icons View | ||||
2690 | // default to 43% aka 64px | ||||
2691 | return configGroup->readEntry(QStringLiteral("iconViewIconSize"), 43); | ||||
2692 | } else { | ||||
2693 | // Simple view decoration left, aka compact view | ||||
2694 | return configGroup->readEntry(QStringLiteral("listViewIconSize"), 0); | ||||
2695 | } | ||||
2696 | } else { | ||||
2697 | if (KFile::isTreeView(fv)) { | ||||
2698 | return configGroup->readEntry(QStringLiteral("treeViewIconSize"), 0); | ||||
2699 | } else if (KFile::isDetailView(fv) || KFile::isDetailTreeView(fv)) { | ||||
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. | |||||
2700 | return configGroup->readEntry(QStringLiteral("detailViewIconSize"), 0); | ||||
2701 | } | ||||
2648 | } | 2702 | } | ||
2703 | | ||||
2704 | return 0; | ||||
2649 | } | 2705 | } | ||
2650 | 2706 | | |||
2651 | void KDirOperator::setViewConfig(KConfigGroup &configGroup) | 2707 | void KDirOperator::setViewConfig(KConfigGroup &configGroup) | ||
2652 | { | 2708 | { | ||
2653 | delete d->configGroup; | 2709 | delete d->configGroup; | ||
2654 | d->configGroup = new KConfigGroup(configGroup); | 2710 | d->configGroup = new KConfigGroup(configGroup); | ||
2655 | } | 2711 | } | ||
2656 | 2712 | | |||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
Perhaps we could use a more sensible default value for ColumnView.
What would you say about 32px ?