65 lines
2.7 KiB
Diff
65 lines
2.7 KiB
Diff
qtbase_genode_textedit_example.patch
|
|
|
|
diff --git a/qtbase/examples/widgets/richtext/textedit/textedit.cpp b/qtbase/examples/widgets/richtext/textedit/textedit.cpp
|
|
index 00ea032..83de198 100644
|
|
--- a/qtbase/examples/widgets/richtext/textedit/textedit.cpp
|
|
+++ b/qtbase/examples/widgets/richtext/textedit/textedit.cpp
|
|
@@ -451,7 +451,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();
|
|
@@ -468,7 +469,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);
|
|
@@ -485,9 +491,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 b7a2155..704f738 100644
|
|
--- a/qtbase/examples/widgets/richtext/textedit/textedit.pro
|
|
+++ b/qtbase/examples/widgets/richtext/textedit/textedit.pro
|
|
@@ -1,5 +1,4 @@
|
|
QT += widgets
|
|
-requires(qtConfig(filedialog))
|
|
qtHaveModule(printsupport): QT += printsupport
|
|
|
|
TEMPLATE = app
|
|
@@ -10,10 +9,6 @@ SOURCES = textedit.cpp \
|
|
main.cpp
|
|
|
|
RESOURCES += textedit.qrc
|
|
-build_all:!build_pass {
|
|
- CONFIG -= build_all
|
|
- CONFIG += release
|
|
-}
|
|
|
|
EXAMPLE_FILES = textedit.qdoc
|
|
|