Build the manual lance test

It had been excluded from the manual tests with a strange comment in the
CMakeLists.txt -- e0fb295aad0063410aca3b2a109a7cda15628bda already
ported the code away from QGL and to QOpenGL* classes.

Fix a couple of discarded QFile::open usages.

Change-Id: I248dabd706f34305b7120d3aaf36120040afc08c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2024-12-20 13:56:42 +01:00
parent 5feca3da72
commit 08e8446461
2 changed files with 21 additions and 5 deletions

View File

@ -21,7 +21,9 @@ add_subdirectory(highdpi)
add_subdirectory(inputmethodhints)
add_subdirectory(keypadnavigation)
add_subdirectory(keyevents)
#add_subdirectory(lance) # qgl.h missing
if(QT_FEATURE_opengl)
add_subdirectory(lance)
endif()
add_subdirectory(qcursor)
add_subdirectory(qdesktopservices)
add_subdirectory(qdnslookup)

View File

@ -119,10 +119,17 @@ void InteractiveWidget::load()
void InteractiveWidget::load(const QString &fname)
{
if (!fname.isEmpty()) {
QFile file(fname);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox::critical(
window(),
tr("Unable to open file"),
tr("Cannot open file %1 for loading: %2").arg(fname, file.errorString())
);
return;
}
m_filename = fname;
ui_textEdit->clear();
QFile file(fname);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream textFile(&file);
QString script = textFile.readAll();
ui_textEdit->setPlainText(script);
@ -141,9 +148,16 @@ void InteractiveWidget::save()
QFileInfo(m_filename).absoluteFilePath(),
QString("QPaintEngine Script (*.qps);;All files (*.*)"));
if (!fname.isEmpty()) {
m_filename = fname;
QFile file(fname);
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QMessageBox::critical(
window(),
tr("Unable to open file"),
tr("Cannot open file %1 for saving: %2").arg(fname, file.errorString())
);
return;
}
m_filename = fname;
QTextStream textFile(&file);
textFile << script;
m_onScreenWidget->m_filename = fname;