Changeset View
Changeset View
Standalone View
Standalone View
src/document/katedocument.cpp
Show First 20 Lines • Show All 4287 Lines • ▼ Show 20 Line(s) | 4264 | { | |||
---|---|---|---|---|---|
4288 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::autoReloadTriggered, this, &DocumentPrivate::onModOnHdAutoReload); | 4288 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::autoReloadTriggered, this, &DocumentPrivate::onModOnHdAutoReload); | ||
4289 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::ignoreTriggered, this, &DocumentPrivate::onModOnHdIgnore); | 4289 | connect(m_modOnHdHandler.data(), &KateModOnHdPrompt::ignoreTriggered, this, &DocumentPrivate::onModOnHdIgnore); | ||
4290 | } | 4290 | } | ||
4291 | 4291 | | |||
4292 | void KTextEditor::DocumentPrivate::onModOnHdSaveAs() | 4292 | void KTextEditor::DocumentPrivate::onModOnHdSaveAs() | ||
4293 | { | 4293 | { | ||
4294 | m_modOnHd = false; | 4294 | m_modOnHd = false; | ||
4295 | QWidget *parentWidget(dialogParent()); | 4295 | QWidget *parentWidget(dialogParent()); | ||
4296 | const QUrl res = QFileDialog::getSaveFileUrl(parentWidget, i18n("Save File"), url(), {}, nullptr, | 4296 | const QUrl res = QFileDialog::getSaveFileUrl(parentWidget, i18n("Save File"), url()); | ||
4297 | QFileDialog::DontConfirmOverwrite); | 4297 | if (!res.isEmpty()) { | ||
4298 | if (!res.isEmpty() && checkOverwrite(res, parentWidget)) { | | |||
4299 | if (! saveAs(res)) { | 4298 | if (! saveAs(res)) { | ||
4300 | KMessageBox::error(parentWidget, i18n("Save failed")); | 4299 | KMessageBox::error(parentWidget, i18n("Save failed")); | ||
4301 | m_modOnHd = true; | 4300 | m_modOnHd = true; | ||
4302 | } else { | 4301 | } else { | ||
4303 | delete m_modOnHdHandler; | 4302 | delete m_modOnHdHandler; | ||
4304 | m_prevModOnHdReason = OnDiskUnmodified; | 4303 | m_prevModOnHdReason = OnDiskUnmodified; | ||
4305 | emit modifiedOnDisk(this, false, OnDiskUnmodified); | 4304 | emit modifiedOnDisk(this, false, OnDiskUnmodified); | ||
4306 | } | 4305 | } | ||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 4471 | if (!url().isValid() || !isReadWrite()) { | |||
4473 | return documentSaveAs(); | 4472 | return documentSaveAs(); | ||
4474 | } | 4473 | } | ||
4475 | 4474 | | |||
4476 | return save(); | 4475 | return save(); | ||
4477 | } | 4476 | } | ||
4478 | 4477 | | |||
4479 | bool KTextEditor::DocumentPrivate::documentSaveAs() | 4478 | bool KTextEditor::DocumentPrivate::documentSaveAs() | ||
4480 | { | 4479 | { | ||
4481 | const QUrl saveUrl = QFileDialog::getSaveFileUrl(dialogParent(), i18n("Save File"), url(), {}, nullptr, | 4480 | const QUrl saveUrl = QFileDialog::getSaveFileUrl(dialogParent(), i18n("Save File"), url()); | ||
4482 | QFileDialog::DontConfirmOverwrite); | 4481 | if (saveUrl.isEmpty()) { | ||
4483 | if (saveUrl.isEmpty() || !checkOverwrite(saveUrl, dialogParent())) { | | |||
4484 | return false; | 4482 | return false; | ||
4485 | } | 4483 | } | ||
4486 | 4484 | | |||
4487 | return saveAs(saveUrl); | 4485 | return saveAs(saveUrl); | ||
4488 | } | 4486 | } | ||
4489 | 4487 | | |||
4490 | bool KTextEditor::DocumentPrivate::documentSaveAsWithEncoding(const QString &encoding) | 4488 | bool KTextEditor::DocumentPrivate::documentSaveAsWithEncoding(const QString &encoding) | ||
4491 | { | 4489 | { | ||
4492 | const QUrl saveUrl = QFileDialog::getSaveFileUrl(dialogParent(), i18n("Save File"), url(), {}, nullptr, | 4490 | const QUrl saveUrl = QFileDialog::getSaveFileUrl(dialogParent(), i18n("Save File"), url()); | ||
4493 | QFileDialog::DontConfirmOverwrite); | 4491 | if (saveUrl.isEmpty()) { | ||
4494 | if (saveUrl.isEmpty() || !checkOverwrite(saveUrl, dialogParent())) { | | |||
4495 | return false; | 4492 | return false; | ||
4496 | } | 4493 | } | ||
4497 | 4494 | | |||
4498 | setEncoding(encoding); | 4495 | setEncoding(encoding); | ||
4499 | return saveAs(saveUrl); | 4496 | return saveAs(saveUrl); | ||
4500 | } | 4497 | } | ||
4501 | 4498 | | |||
4502 | bool KTextEditor::DocumentPrivate::documentSaveCopyAs() | 4499 | bool KTextEditor::DocumentPrivate::documentSaveCopyAs() | ||
4503 | { | 4500 | { | ||
4504 | const QUrl saveUrl = QFileDialog::getSaveFileUrl(dialogParent(), i18n("Save Copy of File"), url(), {}, nullptr, | 4501 | const QUrl saveUrl = QFileDialog::getSaveFileUrl(dialogParent(), i18n("Save Copy of File"), url()); | ||
4505 | QFileDialog::DontConfirmOverwrite); | 4502 | if (saveUrl.isEmpty()) { | ||
4506 | if (saveUrl.isEmpty() || !checkOverwrite(saveUrl, dialogParent())) { | | |||
4507 | return false; | 4503 | return false; | ||
4508 | } | 4504 | } | ||
4509 | 4505 | | |||
4510 | QTemporaryFile file; | 4506 | QTemporaryFile file; | ||
4511 | if (!file.open()) { | 4507 | if (!file.open()) { | ||
4512 | return false; | 4508 | return false; | ||
4513 | } | 4509 | } | ||
4514 | 4510 | | |||
▲ Show 20 Lines • Show All 679 Lines • ▼ Show 20 Line(s) | |||||
5194 | } | 5190 | } | ||
5195 | 5191 | | |||
5196 | void KTextEditor::DocumentPrivate::slotQueryClose_save(bool *handled, bool *abortClosing) | 5192 | void KTextEditor::DocumentPrivate::slotQueryClose_save(bool *handled, bool *abortClosing) | ||
5197 | { | 5193 | { | ||
5198 | *handled = true; | 5194 | *handled = true; | ||
5199 | *abortClosing = true; | 5195 | *abortClosing = true; | ||
5200 | if (this->url().isEmpty()) { | 5196 | if (this->url().isEmpty()) { | ||
5201 | QWidget *parentWidget(dialogParent()); | 5197 | QWidget *parentWidget(dialogParent()); | ||
5202 | const QUrl res = QFileDialog::getSaveFileUrl(parentWidget, i18n("Save File"), QUrl(), {}, nullptr, | 5198 | const QUrl res = QFileDialog::getSaveFileUrl(parentWidget, i18n("Save File")); | ||
5203 | QFileDialog::DontConfirmOverwrite); | 5199 | if (res.isEmpty()) { | ||
5204 | if (res.isEmpty() || !checkOverwrite(res, parentWidget)) { | | |||
5205 | *abortClosing = true; | 5200 | *abortClosing = true; | ||
5206 | return; | 5201 | return; | ||
5207 | } | 5202 | } | ||
5208 | saveAs(res); | 5203 | saveAs(res); | ||
5209 | *abortClosing = false; | 5204 | *abortClosing = false; | ||
5210 | } else { | 5205 | } else { | ||
5211 | save(); | 5206 | save(); | ||
5212 | *abortClosing = false; | 5207 | *abortClosing = false; | ||
5213 | } | 5208 | } | ||
5214 | 5209 | | |||
5215 | } | 5210 | } | ||
5216 | 5211 | | |||
5217 | bool KTextEditor::DocumentPrivate::checkOverwrite(QUrl u, QWidget *parent) | | |||
5218 | { | | |||
5219 | if (!u.isLocalFile()) { | | |||
5220 | return true; | | |||
5221 | } | | |||
5222 | | ||||
5223 | QFileInfo info(u.path()); | | |||
5224 | if (!info.exists()) { | | |||
5225 | return true; | | |||
5226 | } | | |||
5227 | | ||||
5228 | return KMessageBox::Cancel != KMessageBox::warningContinueCancel(parent, | | |||
5229 | i18n("A file named \"%1\" already exists. " | | |||
5230 | "Are you sure you want to overwrite it?", info.fileName()), | | |||
5231 | i18n("Overwrite File?"), KStandardGuiItem::overwrite(), | | |||
5232 | KStandardGuiItem::cancel(), QString(), KMessageBox::Options(KMessageBox::Notify | KMessageBox::Dangerous)); | | |||
5233 | } | | |||
5234 | | ||||
5235 | //BEGIN KTextEditor::ConfigInterface | 5212 | //BEGIN KTextEditor::ConfigInterface | ||
5236 | 5213 | | |||
5237 | // BEGIN ConfigInterface stff | 5214 | // BEGIN ConfigInterface stff | ||
5238 | QStringList KTextEditor::DocumentPrivate::configKeys() const | 5215 | QStringList KTextEditor::DocumentPrivate::configKeys() const | ||
5239 | { | 5216 | { | ||
5240 | /** | 5217 | /** | ||
5241 | * expose all internally registered keys of the KateDocumentConfig | 5218 | * expose all internally registered keys of the KateDocumentConfig | ||
5242 | */ | 5219 | */ | ||
▲ Show 20 Lines • Show All 860 Lines • Show Last 20 Lines |