Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kfilewidget.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 83 | public: | |||
---|---|---|---|---|---|
110 | } | 110 | } | ||
111 | 111 | | |||
112 | ~KFileWidgetPrivate() | 112 | ~KFileWidgetPrivate() | ||
113 | { | 113 | { | ||
114 | delete bookmarkHandler; // Should be deleted before ops! | 114 | delete bookmarkHandler; // Should be deleted before ops! | ||
115 | delete ops; | 115 | delete ops; | ||
116 | } | 116 | } | ||
117 | 117 | | |||
118 | void updateLocationWhatsThis(); | 118 | void updateWhatsThis(); | ||
119 | void updateFilterLabel(); | ||||
119 | void updateAutoSelectExtension(); | 120 | void updateAutoSelectExtension(); | ||
120 | void initSpeedbar(); | 121 | void initSpeedbar(); | ||
121 | void initGUI(); | 122 | void initGUI(); | ||
122 | void readViewConfig(); | 123 | void readViewConfig(); | ||
123 | void writeViewConfig(); | 124 | void writeViewConfig(); | ||
124 | void setNonExtSelection(); | 125 | void setNonExtSelection(); | ||
125 | void setLocationText(const QUrl &); | 126 | void setLocationText(const QUrl &); | ||
126 | void setLocationText(const QList<QUrl> &); | 127 | void setLocationText(const QList<QUrl> &); | ||
▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Line(s) | 408 | #endif | |||
565 | d->locationEdit->installEventFilter(this); | 566 | d->locationEdit->installEventFilter(this); | ||
566 | // Properly let the dialog be resized (to smaller). Otherwise we could have | 567 | // Properly let the dialog be resized (to smaller). Otherwise we could have | ||
567 | // huge dialogs that can't be resized to smaller (it would be as big as the longest | 568 | // huge dialogs that can't be resized to smaller (it would be as big as the longest | ||
568 | // item in this combo box). (ereslibre) | 569 | // item in this combo box). (ereslibre) | ||
569 | d->locationEdit->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | 570 | d->locationEdit->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | ||
570 | connect(d->locationEdit, SIGNAL(editTextChanged(QString)), | 571 | connect(d->locationEdit, SIGNAL(editTextChanged(QString)), | ||
571 | SLOT(_k_slotLocationChanged(QString))); | 572 | SLOT(_k_slotLocationChanged(QString))); | ||
572 | 573 | | |||
573 | d->updateLocationWhatsThis(); | | |||
574 | d->locationLabel->setBuddy(d->locationEdit); | 574 | d->locationLabel->setBuddy(d->locationEdit); | ||
575 | 575 | | |||
576 | KUrlCompletion *fileCompletionObj = new KUrlCompletion(KUrlCompletion::FileCompletion); | 576 | KUrlCompletion *fileCompletionObj = new KUrlCompletion(KUrlCompletion::FileCompletion); | ||
577 | d->locationEdit->setCompletionObject(fileCompletionObj); | 577 | d->locationEdit->setCompletionObject(fileCompletionObj); | ||
578 | d->locationEdit->setAutoDeleteCompletionObject(true); | 578 | d->locationEdit->setAutoDeleteCompletionObject(true); | ||
579 | connect(fileCompletionObj, SIGNAL(match(QString)), | 579 | connect(fileCompletionObj, SIGNAL(match(QString)), | ||
580 | SLOT(_k_fileCompletion(QString))); | 580 | SLOT(_k_fileCompletion(QString))); | ||
581 | 581 | | |||
582 | connect(d->locationEdit, SIGNAL(returnPressed(QString)), | 582 | connect(d->locationEdit, SIGNAL(returnPressed(QString)), | ||
583 | this, SLOT(_k_locationAccepted(QString))); | 583 | this, SLOT(_k_locationAccepted(QString))); | ||
584 | 584 | | |||
585 | // the Filter label/edit | 585 | // the Filter label/edit | ||
586 | whatsThisText = i18n("<qt>This is the filter to apply to the file list. " | | |||
587 | "File names that do not match the filter will not be shown.<p>" | | |||
588 | "You may select from one of the preset filters in the " | | |||
589 | "drop down menu, or you may enter a custom filter " | | |||
590 | "directly into the text area.</p><p>" | | |||
591 | "Wildcards such as * and ? are allowed.</p></qt>"); | | |||
592 | d->filterLabel = new QLabel(i18n("&Filter:"), this); | 586 | d->filterLabel = new QLabel(i18n("&Filter:"), this); | ||
rkflx: I'm talking about this. E.g. an intermediate-level user could filter for… | |||||
593 | d->filterLabel->setWhatsThis(whatsThisText); | | |||
594 | d->filterWidget = new KFileFilterCombo(this); | 587 | d->filterWidget = new KFileFilterCombo(this); | ||
595 | // Properly let the dialog be resized (to smaller). Otherwise we could have | 588 | // Properly let the dialog be resized (to smaller). Otherwise we could have | ||
596 | // huge dialogs that can't be resized to smaller (it would be as big as the longest | 589 | // huge dialogs that can't be resized to smaller (it would be as big as the longest | ||
597 | // item in this combo box). (ereslibre) | 590 | // item in this combo box). (ereslibre) | ||
598 | d->filterWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | 591 | d->filterWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | ||
599 | d->filterWidget->setWhatsThis(whatsThisText); | | |||
600 | d->filterLabel->setBuddy(d->filterWidget); | 592 | d->filterLabel->setBuddy(d->filterWidget); | ||
601 | connect(d->filterWidget, SIGNAL(filterChanged()), SLOT(_k_slotFilterChanged())); | 593 | connect(d->filterWidget, SIGNAL(filterChanged()), SLOT(_k_slotFilterChanged())); | ||
602 | 594 | | |||
603 | d->filterDelayTimer.setSingleShot(true); | 595 | d->filterDelayTimer.setSingleShot(true); | ||
604 | d->filterDelayTimer.setInterval(300); | 596 | d->filterDelayTimer.setInterval(300); | ||
605 | connect(d->filterWidget, SIGNAL(editTextChanged(QString)), &d->filterDelayTimer, SLOT(start())); | 597 | connect(d->filterWidget, SIGNAL(editTextChanged(QString)), &d->filterDelayTimer, SLOT(start())); | ||
606 | connect(&d->filterDelayTimer, SIGNAL(timeout()), SLOT(_k_slotFilterChanged())); | 598 | connect(&d->filterDelayTimer, SIGNAL(timeout()), SLOT(_k_slotFilterChanged())); | ||
607 | 599 | | |||
600 | d->updateWhatsThis(); | ||||
601 | d->updateFilterLabel(); | ||||
602 | | ||||
608 | // the Automatically Select Extension checkbox | 603 | // the Automatically Select Extension checkbox | ||
609 | // (the text, visibility etc. is set in updateAutoSelectExtension(), which is called by readConfig()) | 604 | // (the text, visibility etc. is set in updateAutoSelectExtension(), which is called by readConfig()) | ||
610 | d->autoSelectExtCheckBox = new QCheckBox(this); | 605 | d->autoSelectExtCheckBox = new QCheckBox(this); | ||
611 | const int spacingHint = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); | 606 | const int spacingHint = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); | ||
612 | d->autoSelectExtCheckBox->setStyleSheet(QStringLiteral("QCheckBox { padding-top: %1px; }").arg(spacingHint)); | 607 | d->autoSelectExtCheckBox->setStyleSheet(QStringLiteral("QCheckBox { padding-top: %1px; }").arg(spacingHint)); | ||
613 | connect(d->autoSelectExtCheckBox, SIGNAL(clicked()), SLOT(_k_slotAutoSelectExtClicked())); | 608 | connect(d->autoSelectExtCheckBox, SIGNAL(clicked()), SLOT(_k_slotAutoSelectExtClicked())); | ||
614 | 609 | | |||
615 | d->initGUI(); // activate GM | 610 | d->initGUI(); // activate GM | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 670 | { | |||
679 | delete d; | 674 | delete d; | ||
680 | } | 675 | } | ||
681 | 676 | | |||
682 | void KFileWidget::setLocationLabel(const QString &text) | 677 | void KFileWidget::setLocationLabel(const QString &text) | ||
683 | { | 678 | { | ||
684 | d->locationLabel->setText(text); | 679 | d->locationLabel->setText(text); | ||
685 | } | 680 | } | ||
686 | 681 | | |||
682 | void KFileWidget::setFilterLabel(const QString &text) | ||||
683 | { | ||||
684 | d->filterLabel->setText(text); | ||||
685 | } | ||||
686 | | ||||
687 | void KFileWidget::setFilter(const QString &filter) | 687 | void KFileWidget::setFilter(const QString &filter) | ||
688 | { | 688 | { | ||
689 | int pos = filter.indexOf('/'); | 689 | int pos = filter.indexOf('/'); | ||
690 | 690 | | |||
691 | // Check for an un-escaped '/', if found | 691 | // Check for an un-escaped '/', if found | ||
692 | // interpret as a MIME filter. | 692 | // interpret as a MIME filter. | ||
693 | 693 | | |||
694 | if (pos > 0 && filter[pos - 1] != '\\') { | 694 | if (pos > 0 && filter[pos - 1] != '\\') { | ||
▲ Show 20 Lines • Show All 629 Lines • ▼ Show 20 Line(s) | 1308 | { | |||
1324 | } | 1324 | } | ||
1325 | 1325 | | |||
1326 | // don't change selection when user has clicked on an item | 1326 | // don't change selection when user has clicked on an item | ||
1327 | if (operationMode == KFileWidget::Saving && !locationEdit->isVisible()) { | 1327 | if (operationMode == KFileWidget::Saving && !locationEdit->isVisible()) { | ||
1328 | setNonExtSelection(); | 1328 | setNonExtSelection(); | ||
1329 | } | 1329 | } | ||
1330 | } | 1330 | } | ||
1331 | 1331 | | |||
1332 | void KFileWidgetPrivate::updateLocationWhatsThis() | 1332 | void KFileWidgetPrivate::updateWhatsThis() | ||
1333 | { | 1333 | { | ||
1334 | QString whatsThisText; | 1334 | QString locationWhatsThisText; | ||
1335 | QString filterWhatsThisText; | ||||
1336 | | ||||
1335 | if (operationMode == KFileWidget::Saving) { | 1337 | if (operationMode == KFileWidget::Saving) { | ||
I think with an empty line after the QString variable declarations, the 'if' can breathe a bit :) cfeck: I think with an empty line after the QString variable declarations, the 'if' can breathe a bit… | |||||
1336 | whatsThisText = "<qt>" + i18n("This is the name to save the file as.") + | 1338 | locationWhatsThisText = "<qt>" + i18n("This is the name to save the file as.") + | ||
1337 | i18n(autocompletionWhatsThisText); | 1339 | i18n(autocompletionWhatsThisText); | ||
1340 | filterWhatsThisText = i18n("<qt>This is the file type selector. " | ||||
1341 | "Use it to choose the type for the file that will be saved.</qt>"); | ||||
cfeck: Do you say "Save a file as a format" or "Save a file in a format"? | |||||
I've always said "save as." "Save that picture as a JPEG real fast, would ya?" ngraham: I've always said "save as."
"Save that picture as a JPEG real fast, would ya?" | |||||
bruns: "Use it to choose which format to use for saving"? | |||||
Personally I hate it when a help text just repeats what's already written in the UI. I'd say here you can utilize …the format the file will be saved in., which helps out everyone not understanding "type" in the first place, looking for help, and then finding something they recognize. After all, Wikipedia also calls the concept "File format" (keep "type" for the label, though). rkflx: Personally I hate it when a help text just repeats what's already written in the UI. I'd say… | |||||
1338 | } else if (ops->mode() & KFile::Files) { | 1342 | } else if (ops->mode() & KFile::Files) { | ||
It feels odd that the label is changed in this method. I suggest to move it into the function that calls it. cfeck: It feels odd that the label is changed in this method. I suggest to move it into the function… | |||||
1339 | whatsThisText = "<qt>" + i18n("This is the list of files to open. More than " | 1343 | locationWhatsThisText = "<qt>" + i18n("This is the list of files to open. More than " | ||
1340 | "one file can be specified by listing several " | 1344 | "one file can be specified by listing several " | ||
1341 | "files, separated by spaces.") + | 1345 | "files, separated by spaces.") + | ||
rkflx: Indentation? | |||||
1342 | i18n(autocompletionWhatsThisText); | 1346 | i18n(autocompletionWhatsThisText); | ||
1343 | } else { | 1347 | } else { | ||
1344 | whatsThisText = "<qt>" + i18n("This is the name of the file to open.") + | 1348 | locationWhatsThisText = "<qt>" + i18n("This is the name of the file to open.") + | ||
1345 | i18n(autocompletionWhatsThisText); | 1349 | i18n(autocompletionWhatsThisText); | ||
1350 | filterWhatsThisText = i18n("<qt>This is the filter to apply to the file list. " | ||||
1351 | "File names that do not match the filter will not be shown.<p>" | ||||
1352 | "You may select from one of the preset filters in the " | ||||
1353 | "drop down menu, or you may enter a custom filter " | ||||
1354 | "directly into the text area.</p><p>" | ||||
1355 | "Wildcards such as * and ? are allowed.</p></qt>"); | ||||
1346 | } | 1356 | } | ||
1347 | 1357 | | |||
1348 | locationLabel->setWhatsThis(whatsThisText); | 1358 | locationLabel->setWhatsThis(locationWhatsThisText); | ||
1349 | locationEdit->setWhatsThis(whatsThisText); | 1359 | locationEdit->setWhatsThis(locationWhatsThisText); | ||
1360 | filterLabel->setWhatsThis(filterWhatsThisText); | ||||
1361 | filterWidget->setWhatsThis(filterWhatsThisText); | ||||
1362 | } | ||||
1363 | | ||||
1364 | void KFileWidgetPrivate::updateFilterLabel() | ||||
1365 | { | ||||
1366 | if (operationMode == KFileWidget::Saving) { | ||||
1367 | q->setFilterLabel(i18n("&File type:")); | ||||
1368 | } | ||||
1350 | } | 1369 | } | ||
1351 | 1370 | | |||
1352 | void KFileWidgetPrivate::initSpeedbar() | 1371 | void KFileWidgetPrivate::initSpeedbar() | ||
1353 | { | 1372 | { | ||
1354 | if (placesDock) { | 1373 | if (placesDock) { | ||
1355 | return; | 1374 | return; | ||
1356 | } | 1375 | } | ||
1357 | 1376 | | |||
▲ Show 20 Lines • Show All 699 Lines • ▼ Show 20 Line(s) | 2072 | if (mode == Opening) { | |||
2057 | // hide the new folder actions...usability team says they shouldn't be in open file dialog | 2076 | // hide the new folder actions...usability team says they shouldn't be in open file dialog | ||
2058 | actionCollection()->removeAction(actionCollection()->action(QStringLiteral("mkdir"))); | 2077 | actionCollection()->removeAction(actionCollection()->action(QStringLiteral("mkdir"))); | ||
2059 | } else if (mode == Saving) { | 2078 | } else if (mode == Saving) { | ||
2060 | KGuiItem::assign(d->okButton, KStandardGuiItem::save()); | 2079 | KGuiItem::assign(d->okButton, KStandardGuiItem::save()); | ||
2061 | d->setNonExtSelection(); | 2080 | d->setNonExtSelection(); | ||
2062 | } else { | 2081 | } else { | ||
2063 | KGuiItem::assign(d->okButton, KStandardGuiItem::ok()); | 2082 | KGuiItem::assign(d->okButton, KStandardGuiItem::ok()); | ||
2064 | } | 2083 | } | ||
2065 | d->updateLocationWhatsThis(); | 2084 | d->updateWhatsThis(); | ||
2085 | d->updateFilterLabel(); | ||||
2066 | d->updateAutoSelectExtension(); | 2086 | d->updateAutoSelectExtension(); | ||
2067 | 2087 | | |||
2068 | if (d->ops) { | 2088 | if (d->ops) { | ||
2069 | d->ops->setIsSaving(mode == Saving); | 2089 | d->ops->setIsSaving(mode == Saving); | ||
2070 | } | 2090 | } | ||
2071 | } | 2091 | } | ||
2072 | 2092 | | |||
2073 | KFileWidget::OperationMode KFileWidget::operationMode() const | 2093 | KFileWidget::OperationMode KFileWidget::operationMode() const | ||
▲ Show 20 Lines • Show All 792 Lines • Show Last 20 Lines |
I'm talking about this. E.g. an intermediate-level user could filter for *ProjectX*CustomerMeetingApril*, which is not at all about filetypes.
Of course the very simple folder listing in your screenshot does not have the need for filtering like that, but you know very well that in the real world folder listings can get very long, otherwise you would not work on the Places panel ;)