mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
qt5_textedit improvements for use with sculpt
- support saving of files with no file name extension - make the the "All Files (*)" file selection filter the default to see configuration files immediately Fixes #2844
This commit is contained in:
parent
2755772478
commit
1093adca7e
@ -1 +1 @@
|
||||
1544f4490148dea1ca3c4d98c9504a4597be3e51
|
||||
a311bac14d399a7a37ed5c9b12190397ab40c419
|
||||
|
@ -4,9 +4,51 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
|
||||
|
||||
|
||||
---
|
||||
.../widgets/richtext/textedit/textedit.cpp | 15 +++++++++++----
|
||||
.../widgets/richtext/textedit/textedit.pro | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
2 files changed, 11 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/qtbase/examples/widgets/richtext/textedit/textedit.cpp b/qtbase/examples/widgets/richtext/textedit/textedit.cpp
|
||||
index dec0b0b..a91002c 100644
|
||||
--- a/qtbase/examples/widgets/richtext/textedit/textedit.cpp
|
||||
+++ b/qtbase/examples/widgets/richtext/textedit/textedit.cpp
|
||||
@@ -430,7 +430,8 @@ void TextEdit::fileOpen()
|
||||
QFileDialog fileDialog(this, tr("Open File..."));
|
||||
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
||||
- fileDialog.setMimeTypeFilters(QStringList() << "text/html" << "text/plain");
|
||||
+ fileDialog.setMimeTypeFilters(QStringList() << "text/html" << "text/plain" << "application/octet-stream");
|
||||
+ fileDialog.selectMimeTypeFilter("application/octet-stream");
|
||||
if (fileDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
const QString fn = fileDialog.selectedFiles().first();
|
||||
@@ -447,7 +448,12 @@ bool TextEdit::fileSave()
|
||||
if (fileName.startsWith(QStringLiteral(":/")))
|
||||
return fileSaveAs();
|
||||
|
||||
- QTextDocumentWriter writer(fileName);
|
||||
+ /* if the file name has no extension, assume plain text */
|
||||
+ QByteArray format = QByteArray();
|
||||
+ if (fileName.indexOf(".", 1) == -1)
|
||||
+ format = "plaintext";
|
||||
+
|
||||
+ QTextDocumentWriter writer(fileName, format);
|
||||
bool success = writer.write(textEdit->document());
|
||||
if (success) {
|
||||
textEdit->document()->setModified(false);
|
||||
@@ -464,9 +470,10 @@ bool TextEdit::fileSaveAs()
|
||||
QFileDialog fileDialog(this, tr("Save as..."));
|
||||
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
QStringList mimeTypes;
|
||||
- mimeTypes << "application/vnd.oasis.opendocument.text" << "text/html" << "text/plain";
|
||||
+ mimeTypes << "application/vnd.oasis.opendocument.text" << "text/html" << "text/plain" << "application/octet-stream";
|
||||
fileDialog.setMimeTypeFilters(mimeTypes);
|
||||
- fileDialog.setDefaultSuffix("odt");
|
||||
+ fileDialog.selectMimeTypeFilter("application/octet-stream");
|
||||
+ //fileDialog.setDefaultSuffix("odt");
|
||||
if (fileDialog.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
const QString fn = fileDialog.selectedFiles().first();
|
||||
diff --git a/qtbase/examples/widgets/richtext/textedit/textedit.pro b/qtbase/examples/widgets/richtext/textedit/textedit.pro
|
||||
index c32bf68..704f738 100644
|
||||
--- a/qtbase/examples/widgets/richtext/textedit/textedit.pro
|
||||
|
Loading…
Reference in New Issue
Block a user