Commit Graph

9 Commits

Author SHA1 Message Date
MohammadHossein Qanbari 6b75bc12b7 QML Previewer Example: add QQuickWidget
Add QQuickWidget to display the list of errors. Previously, a QListView
was used for this purpose. Introduce ErrorListView.qml file, which
includes a ListView using the ErrorListModel.

Pick-to: 6.8
Change-Id: I221b347e14305338219f5d8e8d2994497a0f20f5
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2024-10-31 11:49:55 +01:00
MohammadHossein Qanbari bd3ad6c71b QML Previewer Example: Prevent unnecessary state changes
Previously, when setting a new file address and pressing the close
button, the focus would move to the quick widget due to
QLineEdit::editingFinished() being called. This triggered an attempt
to close the old file and open the new one, causing unintended state
transitions.

To resolve this, we now reload the file content and update the quick
widget's source without transitioning to CloseState and OpenState. This
is achieved by updating the file path and emitting stateChanged() from
OpenState to OpenState in the StateController, notifying other widgets
to reload their content.

Pick-to: 6.8
Change-Id: Ic623d320fe1736e11fd538a6735632b19c507394
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
2024-10-09 16:23:15 +02:00
MohammadHossein Qanbari 729c95fc8d QMLPreviewer Example: Fix compile error on Android
Fixes: QTBUG-129214
Pick-to: 6.8 6.8.0
Change-Id: I6f867244f8c21c911177e4b0adc5c7074951b470
Reviewed-by: Doris Verria <doris.verria@qt.io>
2024-09-24 02:13:24 +02:00
Doris Verria 790f16dd54 QMLPreviewer Example: More improvements
- Don't set implicitHeight to controls as the style should choose
valid default heights
- Use a QPushButton instead of a QToolButton in order to show
consistent styling between widgets and quick
- Make the QLineEdit editable so that a focus frame is displayed
around it (we don't show focus frames for read-only line edits in the
macOS style)
- Validate the URL when editing in the line edit is finished
- Add a tooltip to the button that opens the file dialog to make
its purpose more clear
- Fix typo and improve some messages shown in the message boxes

Pick-to: 6.8 6.8.0
Change-Id: I53095808a76e2615117039363be01cfa4d9f243f
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
2024-09-19 18:35:25 +02:00
MohammadHossein Qanbari fa878707fb QML Previewer Example: Fix saving the default file's changes
When changes to the default loaded file were saved, the address bar
displayed an incorrect path and the view failed to update.

The issue stemmed from an improper transition from the Dirty state to
the Open state. The correct transition is changesSaved(). The
setDirty(false) method is reserved for when changes are discarded (e.g.,
after an undo operation).

Pick-to: 6.8 6.8.0
Change-Id: Iafee4bf7c0eeae6f2fc7fdb0d32a555a99824249
Reviewed-by: Doris Verria <doris.verria@qt.io>
2024-09-19 18:35:24 +02:00
Doris Verria 27357727c1 QMLPreviewer Example: Use window container instead of qquickwidget
Tab-focusing between widgets and the quick view works better when
using qwindowcontainer instead of qquickwidget. Changes are still
ongoing to make this work for qquickwidget as well, so change the
example to use qwindowcontainer for now.

Pick-to: 6.8 6.8.0
Change-Id: Ia01d34a4ebb0b8d9c607d1664b6cfc6df164e097
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2024-09-19 16:35:24 +00:00
MohammadHossein Qanbari 130fac9911 QML Previewer Example: Fix bug when saving new file
When saving content as a new file, the application saved the changes but
nothing changed in the quick widget. The problem was that the state was
not changed correctly, and the current state wouldn't transition to the
open state.

To fix this issue, when saving the content, the transition from the new
state to the open state is `changesSaved()`, while `setDirty(false)` was
incorrectly changing the new state back to the init state.

Pick-to: 6.8
Change-Id: I20707046bc17044a18c95ce77e6e56c4a8c21627
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2024-09-03 23:23:06 +02:00
MohammadHossein Qanbari 8330154be6 QML Previewer Example: Add Error List and Line Numbers
Implement LineNumberArea to display line numbers, based on the Code
Editor Example documentation. Introduce QListView with ErrorListModel
to show errors and warnings. Double-clicking an error in the list moves
the code editor's cursor to the corresponding position.

Update shortcut functionality to work only on platforms where the
feature is available. Related code has been modified accordingly.

Fixes: QTBUG-128227
Pick-to: 6.8
Change-Id: Icb66280a5360b015280afc756f8a827247a2ebaf
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2024-09-02 22:46:58 +02:00
MohammadHossein Qanbari c156fc4527 Add the QMLPreviewer example
The example provides two sections including an editor and a view for QML
codes. The QML codes can be written by the user from scratch and save to
a file, or, it can be loaded from a file. Also, it is possible to save
the changes and see the result in the view side. The application can
detect any changes to the source file outside of itself and reloads the
editor and the view sections.

The editor is QPlainTextEdit and the view is QQuickWidget. The
QQuickWidget is used to embed QML in the application which is a widget
application.

The implemented actions in the example are:
- Open file: to open and load a (.qml) file
- Save file: to save the changes into the opened file or into a new file
- Close file: to close the opened file
- Reload: to discard the changes and to reload the opened file

Pick-to: 6.8
Change-Id: I3106dd78998c4b0e86e21803ccf1bb84205a13a4
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2024-08-30 00:28:36 +02:00