tazweb view src/tazweb-qt.cpp @ rev 202

Small clean to tazweb.c and more update to NG
author Christophe Lincoln <pankso@slitaz.org>
date Sat Mar 18 14:45:40 2017 +0100 (2017-03-18)
parents 1603951a52b8
children
line source
1 /*
2 * TazWeb-Qt is a radically simple web browser providing a single window.
3 * Commented line code starts with // and comments are between * *
4 *
5 * Copyright (C) 2011-2017 SliTaz GNU/Linux - BSD License
6 * See AUTHORS and LICENSE for detailed information
7 *
8 */
9 #include <QtGui>
10 #include <QtWebKit>
12 int main(int argc, char** argv)
13 {
14 QApplication app(argc, argv);
15 QApplication::setWindowIcon(QIcon::fromTheme("tazweb"));
16 QFile file(QDir::homePath() + "/.config/slitaz/subox.conf");
17 QString msg, line;
18 QString msg2("\n ENTER/ok -> tazpanel, ESC/cancel -> bookmarks/webhome");
19 QUrl url;
20 if (argc > 1) { url = QUrl::fromUserInput(argv[1]); }
21 else {
22 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
23 msg = "Using subox pass... Load successfully" + msg2;
24 QTextStream in(&file);
25 while (!in.atEnd()) { line = in.readLine(); }
26 file.close(); }
27 else { msg = file.fileName() + " not found.\nroot password requested:" + msg2;
28 line = "root"; }
29 bool ok;
30 QString text = QInputDialog::getText(0, "TazWeb-Qt: TazPanel authentication",
31 msg, QLineEdit::Password, line, &ok);
32 if (ok && !text.isEmpty()) {
33 QApplication::setWindowIcon(QIcon::fromTheme("tazpanel"));
34 url = QUrl("http://root:" + text + "@tazpanel:82"); }
35 else {
36 if (QFile::exists(QDir::homePath() + "/.config/tazweb/bookmarks.txt"))
37 url = QUrl("http://localhost/cgi-bin/bookmarks.cgi?home=" + QDir::homePath());
38 else
39 url = QUrl("file:///usr/share/webhome/index.html"); }
40 }
41 QWebView view;
42 /*
43 view.show();
44 //view.setUrl(QUrl("file:///usr/share/webhome/index.html"));
45 view.load(QUrl("file:///usr/share/webhome/index.html"));
46 */
47 //view.settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
48 //view.settings()->setAttribute(QWebSettings::ZoomTextOnly, true);
49 //view.setTextSizeMultiplier(1);
50 view.showMaximized();
51 view.load(url);
52 return app.exec();
53 }