Skip to content

Commit

Permalink
Merge pull request #2 from OpenMandrivaSoftware/master
Browse files Browse the repository at this point in the history
Fix various syntax errors -- </html> should go into HTML, not bash
  • Loading branch information
cris-b authored Jun 17, 2016
2 parents 396c3fd + d281ee0 commit 1c022ee
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 11 deletions.
11 changes: 11 additions & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.5)
project(om-welcome)

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_definitions(-std=gnu++14)

find_package(Qt5 COMPONENTS Core Gui Widgets WebEngineWidgets REQUIRED)
add_executable(om-welcome main.cpp Page.cpp)
qt5_use_modules(om-welcome Core Gui Widgets WebEngineWidgets)
28 changes: 28 additions & 0 deletions launcher/Page.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Page.h"
#include <QProcess>
using namespace std;

bool Page::acceptNavigationRequest(QUrl const &url, NavigationType type, bool isMainFrame) {
if(url.isLocalFile()) {
open(url.path());
return false;
}
return true;
}

void Page::open(QString file) {
cerr << "Page::Open " << qPrintable(file) << endl;
if(!file.contains("://") && !file.startsWith("/"))
file="/usr/share/oma-welcome/" + file;

if(file.startsWith('/') && (file.endsWith(".sh.htm") || file.endsWith(".sh.html"))) {
QProcess p(this);
p.setWorkingDirectory(file.section('/', 0, -2));
p.start("/bin/bash", QStringList() << "-c" << file, QProcess::ReadOnly);
p.waitForFinished(60000);
setContent(p.readAllStandardOutput().replace("target=\"hidden\" ", ""), "text/html", QUrl("file://" + file));
} else if(file.endsWith(".run")) {
QProcess::startDetached("/bin/bash", QStringList() << "-c" << file);
} else
QWebEnginePage::load(file);
}
13 changes: 13 additions & 0 deletions launcher/Page.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef _PAGE_H_
#define _PAGE_H_ 1
#include <QWebEnginePage>

class Page:public QWebEnginePage {
Q_OBJECT
public:
Page(QObject *parent=0):QWebEnginePage(parent) {}
void open(QString file);
protected:
bool acceptNavigationRequest(QUrl const &url, NavigationType type, bool isMainFrame) override;
};
#endif
14 changes: 14 additions & 0 deletions launcher/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <QApplication>
#include <QWebEngineView>
#include "Page.h"

int main(int argc, char **argv) {
QApplication app(argc, argv);
QWebEngineView *l=new QWebEngineView(0);
Page *p=new Page(l);
l->setPage(p);
p->open("index.sh.htm");
l->show();
app.exec();
delete l;
}
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-development.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-gaming.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-graphics.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
1 change: 0 additions & 1 deletion usr/share/oma-welcome/apps-internet.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,3 @@
</body>
</html>
EOF

2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-multimedia.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-office.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-utilitarios.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ <h1 class="titlePage">$cabecalho03 $(head -1 /README |cut -d " " -f1-3) $cabecal
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps-utility.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/apps.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@
<a href="community.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/community.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@
<a href="execute close$" class="button">$endapp</a>
</div>
</body>
</html>
EOF
2 changes: 1 addition & 1 deletion usr/share/oma-welcome/conf.sh.htm
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@
<a href="apps-office.sh.htm" class="button">$next</a>
</div>
</body>
EOF
</html>
EOF

0 comments on commit 1c022ee

Please sign in to comment.