tazweb diff src/tazweb-qt.cpp @ rev 187
Tiny edits
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Tue Mar 14 17:21:58 2017 +0000 (2017-03-14) |
parents | 24f6230d2119 |
children | bb7b18c98c63 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/tazweb-qt.cpp Tue Mar 14 17:21:58 2017 +0000 1.3 @@ -0,0 +1,53 @@ 1.4 +/* 1.5 + * TazWeb-Qt is a radically simple web browser providing a single window. 1.6 + * Commented line code starts with // and comments are between * * 1.7 + * 1.8 + * Copyright (C) 2011-2014 SliTaz GNU/Linux - BSD License 1.9 + * See AUTHORS and LICENSE for detailed information 1.10 + * 1.11 + */ 1.12 +#include <QtGui> 1.13 +#include <QtWebKit> 1.14 + 1.15 +int main(int argc, char** argv) 1.16 +{ 1.17 + QApplication app(argc, argv); 1.18 + QApplication::setWindowIcon(QIcon::fromTheme("tazweb")); 1.19 + QFile file(QDir::homePath() + "/.config/slitaz/subox.conf"); 1.20 + QString msg, line; 1.21 + QString msg2("\n ENTER/ok -> tazpanel, ESC/cancel -> bookmarks/webhome"); 1.22 + QUrl url; 1.23 + if (argc > 1) { url = QUrl::fromUserInput(argv[1]); } 1.24 + else { 1.25 + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { 1.26 + msg = "Using subox pass... Load successfully" + msg2; 1.27 + QTextStream in(&file); 1.28 + while (!in.atEnd()) { line = in.readLine(); } 1.29 + file.close(); } 1.30 + else { msg = file.fileName() + " not found.\nroot password requested:" + msg2; 1.31 + line = "root"; } 1.32 + bool ok; 1.33 + QString text = QInputDialog::getText(0, "TazWeb-Qt: TazPanel authentication", 1.34 + msg, QLineEdit::Password, line, &ok); 1.35 + if (ok && !text.isEmpty()) { 1.36 + QApplication::setWindowIcon(QIcon::fromTheme("tazpanel")); 1.37 + url = QUrl("http://root:" + text + "@tazpanel:82"); } 1.38 + else { 1.39 + if (QFile::exists(QDir::homePath() + "/.config/tazweb/bookmarks.txt")) 1.40 + url = QUrl("http://localhost/cgi-bin/bookmarks.cgi?home=" + QDir::homePath()); 1.41 + else 1.42 + url = QUrl("file:///usr/share/webhome/index.html"); } 1.43 + } 1.44 + QWebView view; 1.45 +/* 1.46 + view.show(); 1.47 + //view.setUrl(QUrl("file:///usr/share/webhome/index.html")); 1.48 + view.load(QUrl("file:///usr/share/webhome/index.html")); 1.49 +*/ 1.50 + //view.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); 1.51 + //view.settings()->setAttribute(QWebSettings::ZoomTextOnly, true); 1.52 + //view.setTextSizeMultiplier(1); 1.53 + view.showMaximized(); 1.54 + view.load(url); 1.55 + return app.exec(); 1.56 +}