• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Fixed TED / QT redirects to iframe src instead of displaying iframe

Holzchopf

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jul 31, 2017
Messages
500
I guess I stumbled across a QT bug :(

The First Cerberus Steps help page contains an iframe, containing a running html5 example. Works fine in the online version. It does not work locally as the built example is not included in the docs data:oops: So if you look at the "First Cerberus Steps" page in the IDE, you get an iframe displaying a 404 - page not found.

In TED/QT however, the whole page gets replaced by the iframe contents. Instead of loading the iframe src into the iframe, the browser window is redirected to the iframe src. Not only does this mean you can't ever see the rest of the "First Cerberus Steps" page, but even more you can't "go back" from the src page to where you've been before (because "one back" means "go to the page that just redirects me here").

I'm 90% sure this bug wasn't present before the 20181230 update, because I would have noticed it when fiddling with the docs. That's why I think this is a QT bug (wasn't the only change in TED the QT version upgrade?). A very annoying QT bug, because having running html5 examples embedded into help pages would be quite helpful. Speaking of embedding - it shows the exact same behaviour with the embed element.
 
The fix:
Located in mainwindow.cpp
C++:
// DAWLANE - QtWebEnginge/Page uses a different way to call hypertext links.
#if QT_VERSION>0x050501
bool WebEnginePage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame )
{
    // Capture links that have been clicked only in the main frame. Embedded elements will be child frames within a QWebEnginePage.
    if ( (type == QWebEnginePage::NavigationTypeLinkClicked)  && (isMainFrame)  )
    {
        //  Convert the url all to lower case to deal with caputing local files.
        QString str=url.toString();
        if( (str.startsWith( "file:///", Qt::CaseInsensitive ))){

            // If our link leads to one of the recognised source or text files, then strip off the file tag
            // and call the open file method in the main window class to load it into the editor
            QString ext=";"+extractExt(str)+";";
            if( textFileTypes.contains( ext.toLower() ) || codeFileTypes.contains( ext.toLower() ) ){

#ifdef Q_OS_WIN
                CerberusApplication::mainWindow->openFile( str.mid(8),false );
#else
                CerberusApplication::mainWindow->openFile( str.mid(7),false );
#endif
                return false;
            }

            // Our file isn't one of the main types, so try to open it any way.
            CerberusApplication::mainWindow->openFile( str,false );
            return false;
        }

        // Our file isn't local, so try to open this is a web browser rather than in the QWebEngineView.
        QDesktopServices::openUrl( str );
        return false;
    }
    return true;
}
#else
 

Attachments

  • Ted.7z
    149.8 KB · Views: 193
Back
Top Bottom