Added about dialog, address bar works

This commit is contained in:
Andrew Lee 2020-02-10 21:24:06 -05:00
parent f9ab17d41c
commit 1a92e988d6
Signed by: andrew
GPG key ID: 4DCE67C47836D125
8 changed files with 224 additions and 12 deletions

View file

@ -16,13 +16,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
about.cpp \
main.cpp \
mainbrowser.cpp
HEADERS += \
about.h \
mainbrowser.h
FORMS += \
about.ui \
mainbrowser.ui
# Default rules for deployment.

15
about.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "about.h"
#include "ui_about.h"
#include <QtWebKitWidgets/QWebView>
About::About(QWidget *parent) :
QDialog(parent),
ui(new Ui::About)
{
ui->setupUi(this);
}
About::~About()
{
delete ui;
}

22
about.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef ABOUT_H
#define ABOUT_H
#include <QDialog>
namespace Ui {
class About;
}
class About : public QDialog
{
Q_OBJECT
public:
explicit About(QWidget *parent = nullptr);
~About();
private:
Ui::About *ui;
};
#endif // ABOUT_H

141
about.ui Normal file
View file

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QDialog" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>391</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>516</width>
<height>391</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>516</width>
<height>391</height>
</size>
</property>
<property name="windowTitle">
<string>About - Alee Music Player</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>AleeBrowser 2.0 by Alee Productions</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>Licensed with GPL-3.0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://alee-productions.xyz&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Website&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTextEdit" name="licenseText">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; AleeBrowser: A web browser written in Qt&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; Copyright (C) 2020 Alee Productions&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; This program is free software: you can redistribute it and/or modify&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; it under the terms of the GNU General Public License as published by&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; the Free Software Foundation, either version 3 of the License, or&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; (at your option) any later version.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; This program is distributed in the hope that it will be useful,&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; GNU General Public License for more details.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; You should have received a copy of the GNU General Public License&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; along with this program. If not, see &amp;lt;https://www.gnu.org/licenses/&amp;gt;.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>licenseText</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View file

@ -5,7 +5,7 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mainbrowser w;
w.show();
mainbrowser browser;
browser.show();
return a.exec();
}

View file

@ -1,17 +1,22 @@
#include "mainbrowser.h"
#include "ui_mainbrowser.h"
#include "about.h"
#include <QtWebKitWidgets/QWebView>
#include <QUrl>
#include <QDebug>
void mainbrowser::bUrl() {
url = ui->lineEdit->text();
ui->webView->load(QUrl(url));
}
mainbrowser::mainbrowser(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::mainbrowser)
{
//QString url = ui->lineEdit->text();
ui->setupUi(this);
ui->webView->load(QUrl("https://google.com"));
ui->webView->load(QUrl("https://about:blank"));
}
mainbrowser::~mainbrowser()
@ -27,5 +32,22 @@ void mainbrowser::on_actionQuit_triggered()
void mainbrowser::on_searchButton_clicked()
{
qDebug() << "Search pressed!";
bUrl();
}
void mainbrowser::on_lineEdit_returnPressed()
{
bUrl();
}
void mainbrowser::on_actionAbout_triggered()
{
About about;
about.exec();
}
void mainbrowser::on_webView_urlChanged(const QUrl &arg1)
{
qDebug() << "Loading" << url;
}

View file

@ -20,7 +20,16 @@ private slots:
void on_searchButton_clicked();
void on_lineEdit_returnPressed();
void on_actionAbout_triggered();
void bUrl();
void on_webView_urlChanged(const QUrl &arg1);
private:
Ui::mainbrowser *ui;
QString url;
};
#endif // MAINBROWSER_H

View file

@ -31,13 +31,6 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLineEdit" name="lineEdit">
<property name="text">
<string>https://www.google.com</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
@ -51,6 +44,13 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLineEdit" name="lineEdit">
<property name="text">
<string>about:blank</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">