Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/kpropertiesdialog.cpp
Show First 20 Lines • Show All 434 Lines • ▼ Show 20 Line(s) | |||||
435 | 435 | | |||
436 | void KPropertiesDialog::setFileSharingPage(QWidget *page) | 436 | void KPropertiesDialog::setFileSharingPage(QWidget *page) | ||
437 | { | 437 | { | ||
438 | d->fileSharePage = page; | 438 | d->fileSharePage = page; | ||
439 | } | 439 | } | ||
440 | 440 | | |||
441 | void KPropertiesDialog::setFileNameReadOnly(bool ro) | 441 | void KPropertiesDialog::setFileNameReadOnly(bool ro) | ||
442 | { | 442 | { | ||
443 | foreach (KPropertiesDialogPlugin *it, d->m_pageList) { | 443 | for (KPropertiesDialogPlugin *it : qAsConst(d->m_pageList)) { | ||
444 | if (auto *filePropsPlugin = qobject_cast<KFilePropsPlugin *>(it)) { | 444 | if (auto *filePropsPlugin = qobject_cast<KFilePropsPlugin *>(it)) { | ||
445 | filePropsPlugin->setFileNameReadOnly(ro); | 445 | filePropsPlugin->setFileNameReadOnly(ro); | ||
446 | } else if (auto *urlPropsPlugin = qobject_cast<KUrlPropsPlugin *>(it)) { | 446 | } else if (auto *urlPropsPlugin = qobject_cast<KUrlPropsPlugin *>(it)) { | ||
447 | urlPropsPlugin->setFileNameReadOnly(ro); | 447 | urlPropsPlugin->setFileNameReadOnly(ro); | ||
448 | } | 448 | } | ||
449 | } | 449 | } | ||
450 | } | 450 | } | ||
451 | 451 | | |||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Line(s) | 639 | { | |||
643 | emit saveAs(d->m_singleUrl, newUrl); | 643 | emit saveAs(d->m_singleUrl, newUrl); | ||
644 | // qDebug() << "KPropertiesDialog::updateUrl (post)" << newUrl; | 644 | // qDebug() << "KPropertiesDialog::updateUrl (post)" << newUrl; | ||
645 | 645 | | |||
646 | d->m_singleUrl = newUrl; | 646 | d->m_singleUrl = newUrl; | ||
647 | d->m_items.first().setUrl(newUrl); | 647 | d->m_items.first().setUrl(newUrl); | ||
648 | Q_ASSERT(!d->m_singleUrl.isEmpty()); | 648 | Q_ASSERT(!d->m_singleUrl.isEmpty()); | ||
649 | // If we have an Desktop page, set it dirty, so that a full file is saved locally | 649 | // If we have an Desktop page, set it dirty, so that a full file is saved locally | ||
650 | // Same for a URL page (because of the Name= hack) | 650 | // Same for a URL page (because of the Name= hack) | ||
651 | foreach (KPropertiesDialogPlugin *it, d->m_pageList) { | 651 | for (KPropertiesDialogPlugin *it : qAsConst(d->m_pageList)) { | ||
652 | if (qobject_cast<KUrlPropsPlugin *>(it) || | 652 | if (qobject_cast<KUrlPropsPlugin *>(it) || | ||
653 | qobject_cast<KDesktopPropsPlugin *>(it)) { | 653 | qobject_cast<KDesktopPropsPlugin *>(it)) { | ||
654 | //qDebug() << "Setting page dirty"; | 654 | //qDebug() << "Setting page dirty"; | ||
655 | it->setDirty(); | 655 | it->setDirty(); | ||
656 | break; | 656 | break; | ||
657 | } | 657 | } | ||
658 | } | 658 | } | ||
659 | } | 659 | } | ||
▲ Show 20 Lines • Show All 594 Lines • ▼ Show 20 Line(s) | |||||
1254 | { | 1254 | { | ||
1255 | properties->buttonBox()->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); | 1255 | properties->buttonBox()->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); | ||
1256 | emit changed(); | 1256 | emit changed(); | ||
1257 | } | 1257 | } | ||
1258 | 1258 | | |||
1259 | static QString relativeAppsLocation(const QString &file) | 1259 | static QString relativeAppsLocation(const QString &file) | ||
1260 | { | 1260 | { | ||
1261 | const QString canonical = QFileInfo(file).canonicalFilePath(); | 1261 | const QString canonical = QFileInfo(file).canonicalFilePath(); | ||
1262 | Q_FOREACH (const QString &base, QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation)) { | 1262 | const QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation); | ||
1263 | for (const QString &base : dirs) { | ||||
1263 | QDir base_dir = QDir(base); | 1264 | QDir base_dir = QDir(base); | ||
1264 | if (base_dir.exists() && canonical.startsWith(base_dir.canonicalPath())) { | 1265 | if (base_dir.exists() && canonical.startsWith(base_dir.canonicalPath())) { | ||
1265 | return canonical.mid(base.length() + 1); | 1266 | return canonical.mid(base.length() + 1); | ||
1266 | } | 1267 | } | ||
1267 | } | 1268 | } | ||
1268 | return QString(); // return empty if the file is not in apps | 1269 | return QString(); // return empty if the file is not in apps | ||
1269 | } | 1270 | } | ||
1270 | 1271 | | |||
▲ Show 20 Lines • Show All 2357 Lines • ▼ Show 20 Line(s) | 3628 | KMimeTypeChooserDialog dlg(i18n("Add File Type for %1", properties->url().fileName()), | |||
3628 | i18n("Select one or more file types to add:"), | 3629 | i18n("Select one or more file types to add:"), | ||
3629 | QStringList(), // no preselected mimetypes | 3630 | QStringList(), // no preselected mimetypes | ||
3630 | QString(), | 3631 | QString(), | ||
3631 | QStringList(), | 3632 | QStringList(), | ||
3632 | KMimeTypeChooser::Comments | KMimeTypeChooser::Patterns, | 3633 | KMimeTypeChooser::Comments | KMimeTypeChooser::Patterns, | ||
3633 | d->m_frame); | 3634 | d->m_frame); | ||
3634 | 3635 | | |||
3635 | if (dlg.exec() == QDialog::Accepted) { | 3636 | if (dlg.exec() == QDialog::Accepted) { | ||
3636 | foreach (const QString &mimetype, dlg.chooser()->mimeTypes()) { | 3637 | const QStringList list = dlg.chooser()->mimeTypes(); | ||
3638 | for (const QString &mimetype : list) { | ||||
3637 | QMimeType p = db.mimeTypeForName(mimetype); | 3639 | QMimeType p = db.mimeTypeForName(mimetype); | ||
3638 | if (!p.isValid()) { | 3640 | if (!p.isValid()) { | ||
3639 | continue; | 3641 | continue; | ||
3640 | } | 3642 | } | ||
3641 | 3643 | | |||
3642 | bool found = false; | 3644 | bool found = false; | ||
3643 | int count = d->w->filetypeList->topLevelItemCount(); | 3645 | int count = d->w->filetypeList->topLevelItemCount(); | ||
3644 | for (int i = 0; !found && i < count; ++i) { | 3646 | for (int i = 0; !found && i < count; ++i) { | ||
▲ Show 20 Lines • Show All 282 Lines • Show Last 20 Lines |