Skip to content

Commit

Permalink
Correction des bugs des fenêtres, et ajout d'un système de 'nouvel on…
Browse files Browse the repository at this point in the history
…glet'
  • Loading branch information
SuperAtraction committed Sep 30, 2023
1 parent cf741e5 commit 0a8f93d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
Binary file modified Olop
Binary file not shown.
3 changes: 1 addition & 2 deletions Olop.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 11.0.2, 2023-09-16T09:50:57. -->
<!-- Written by QtCreator 11.0.2, 2023-09-30T15:58:18. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -251,7 +251,6 @@
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/superatraction/Documents/Qt C++/Olop/Olop.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/superatraction/Documents/Qt C++/Olop/Olop.pro</value>
<value type="QString" key="RunConfiguration.Arguments">--server 2555</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
Expand Down
3 changes: 2 additions & 1 deletion assets/Olop.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ function createWindowElement(icon, title, content, isnotif, id, useIframe) {
windowElement.ready(function() {
windowElement.draggable({
handle: ".window-title-bar",
containment: "window"
containment: "window",
iframeFix: true
});

updateMinSize(windowElement, useIframe);
Expand Down
3 changes: 2 additions & 1 deletion assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ <h1>Olop</h1>
<ul>
<li onclick="loadPage('home')">Accueil</li>
<li onclick="loadPage('Library')">Bibliothèque</li>
<li><a href="https://minecraft.fr">LIEN</A></li>
</ul>
<div id="info1" style="display: none;">
<div id="button-update"></div>
Expand All @@ -441,4 +442,4 @@ <h1>Olop</h1>
<button type="button" onclick="toggleMenu()" class="menu-button">&#9776;</button>
</div>
</body>
</html>
</html>
5 changes: 5 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "olop.hpp"
#include <QDesktopServices>

MainWindow::MainWindow(QWidget *parent, QString url) :
QMainWindow(parent),
Expand Down Expand Up @@ -33,6 +34,10 @@ MainWindow::MainWindow(QWidget *parent, QString url) :
connect(ui->Web, &QWebEngineView::loadFinished, this, [=](bool ok) {
onLoadingHtmlFinished(ok, "http://localhost:"+url+"/");
});
connect(static_cast<CustomWebEnginePage*>(ui->Web->page()), &CustomWebEnginePage::urlRequested, this,
[=](const QUrl& url) {
QDesktopServices::openUrl(url);
});
// Initialisation de UiInstance
uiInstance = new Ui::UiInstance(ui->Web->page(), url);

Expand Down
16 changes: 16 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <QtCore>
#include <QFile>
#include <QLocalServer>
#include <QWebEngineProfile>
#include <QDesktopServices>

namespace Ui {
class UiInstance : public QObject {
Expand Down Expand Up @@ -65,13 +67,27 @@ class CustomWebEnginePage : public QWebEnginePage
CustomWebEnginePage(QObject* parent = nullptr) : QWebEnginePage(parent) {}

signals:
void requestCreateWindow(QWebEnginePage::WebWindowType type); // Ajoutez ce signal
void customJavaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
void urlRequested(const QUrl& url);

protected:
virtual void javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override
{
emit customJavaScriptConsoleMessage(level, message, lineNumber, sourceID);
}

virtual QWebEnginePage* createWindow(WebWindowType type) override {
if (type == QWebEnginePage::WebBrowserTab || type == QWebEnginePage::WebBrowserWindow) {
CustomWebEnginePage* newPage = new CustomWebEnginePage(this);
connect(newPage, &QWebEnginePage::urlChanged, this, [this, newPage](const QUrl& url) {
emit urlRequested(url);
newPage->deleteLater();
});
return newPage;
}
return nullptr;
}
};

#endif // MAINWINDOW_H

0 comments on commit 0a8f93d

Please sign in to comment.