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