aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/forms/profiledialog.cpp25
-rw-r--r--src/forms/profiledialog.h27
-rw-r--r--src/forms/profiledialog.ui78
-rw-r--r--src/mainwindow.cpp27
-rw-r--r--src/mainwindow.h7
-rw-r--r--src/qt-simplebrowser.pro9
6 files changed, 163 insertions, 10 deletions
diff --git a/src/forms/profiledialog.cpp b/src/forms/profiledialog.cpp
new file mode 100644
index 0000000..14279c4
--- /dev/null
+++ b/src/forms/profiledialog.cpp
@@ -0,0 +1,25 @@
+#include "profiledialog.h"
+#include "ui_profiledialog.h"
+
+ProfileDialog::ProfileDialog(QWebEngineProfile *profile, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::ProfileDialog)
+{
+ _profile = profile;
+
+ ui->setupUi(this);
+ ui->userAgent_lineEdit->setText(_profile->httpUserAgent());
+
+ connect(this, SIGNAL(accepted()), this, SLOT(saveProfile()));
+}
+
+ProfileDialog::~ProfileDialog()
+{
+ delete ui;
+}
+
+void ProfileDialog::saveProfile()
+{
+ qDebug("Saving profile...");
+ _profile->setHttpUserAgent(ui->userAgent_lineEdit->text());
+}
diff --git a/src/forms/profiledialog.h b/src/forms/profiledialog.h
new file mode 100644
index 0000000..98426d0
--- /dev/null
+++ b/src/forms/profiledialog.h
@@ -0,0 +1,27 @@
+#ifndef PROFILEDIALOG_H
+#define PROFILEDIALOG_H
+
+#include <QDialog>
+#include <QWebEngineProfile>
+
+namespace Ui {
+class ProfileDialog;
+}
+
+class ProfileDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ProfileDialog(QWebEngineProfile *profile, QWidget *parent = 0);
+ ~ProfileDialog();
+
+private slots:
+ void saveProfile();
+
+private:
+ QWebEngineProfile *_profile;
+ Ui::ProfileDialog *ui;
+};
+
+#endif // PROFILEDIALOG_H
diff --git a/src/forms/profiledialog.ui b/src/forms/profiledialog.ui
new file mode 100644
index 0000000..160743b
--- /dev/null
+++ b/src/forms/profiledialog.ui
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProfileDialog</class>
+ <widget class="QDialog" name="ProfileDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>480</width>
+ <height>640</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>User Agent</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="userAgent_lineEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ProfileDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ProfileDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index dea9f79..ccf75f3 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -5,6 +5,8 @@
#include <QCloseEvent>
#include <QMessageBox>
#include "browser.h"
+#include "forms/profiledialog.h"
+#include <QApplication>
MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
@@ -17,20 +19,25 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
browserInstance = instance;
Settings settings;
+ profile = QWebEngineProfile::defaultProfile();
+
ui->setupUi(this);
resize(settings.value("window/width", 800).toInt(), settings.value("window/height", 600).toInt());
- // Populate the menu bar
- // Browser menu - with new window, new tab, open and quit
- QMenu *browserMenu = new QMenu(qApp->applicationName(), ui->menuBar);
+ // Browser menu
+ browserMenu = new QMenu(qApp->applicationName(), ui->menuBar);
+ ui->menuBar->addMenu(browserMenu);
browserMenu->addAction(tr("New Window"), this, SLOT(handleNewWindow()), QKeySequence(tr("Ctrl+N")));
browserMenu->addAction(tr("New Tab"), this, SLOT(createNewTab()), QKeySequence(tr("Ctrl+T")));
browserMenu->addSeparator();
+ browserMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
browserMenu->addAction(tr("Quit"), qApp, SLOT(quit()), QKeySequence(tr("Ctrl+Q")));
- ui->menuBar->addMenu(browserMenu);
- // View menu - fullscreen
- // Page menu - what page actions?
- // Help menu - help contents, about, about qt
+
+ // Profile menu
+ profileMenu = new QMenu(profile->storageName());
+ ui->menuBar->addMenu(profileMenu);
+ profileMenu->addAction(tr("Edit profile"), this, SLOT(createProfileDialog()));
+ profileMenu->addAction(tr("Load profile"));
this->addToolBar(Qt::TopToolBarArea, navigationToolBar);
this->addToolBarBreak(Qt::TopToolBarArea);
@@ -103,3 +110,9 @@ void MainWindow::handleTitleUpdated(const QString &title)
Settings settings;
setWindowTitle(title + settings.value("window/title", "qtwebenginebrowser").toString());
}
+
+void MainWindow::createProfileDialog()
+{
+ ProfileDialog *dialog = new ProfileDialog(profile, this);
+ dialog->exec();
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 7371759..a5709e9 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -5,6 +5,7 @@
#include <QToolBar>
#include <QLineEdit>
#include <QWebEngineView>
+#include <QWebEngineProfile>
#include <QUrl>
#include "widgets/webviewtabbar.h"
@@ -34,9 +35,15 @@ private slots:
void handleUrlUpdated(const QUrl &url);
void handleTitleUpdated(const QString &title);
+ void createProfileDialog();
+
private:
Browser *browserInstance;
+ QWebEngineProfile *profile;
+
+ // ui
Ui::MainWindow *ui;
+ QMenu *browserMenu, *profileMenu;
QToolBar *navigationToolBar, *tabToolBar;
WebViewTabBar *tabBar;
QLineEdit *urlLineEdit;
diff --git a/src/qt-simplebrowser.pro b/src/qt-simplebrowser.pro
index 33b960f..57886d3 100644
--- a/src/qt-simplebrowser.pro
+++ b/src/qt-simplebrowser.pro
@@ -15,11 +15,14 @@ SOURCES += main.cpp \
mainwindow.cpp \
browser.cpp \
widgets/webviewtabbar.cpp \
- settings.cpp
+ settings.cpp \
+ forms/profiledialog.cpp
HEADERS += mainwindow.h \
browser.h \
widgets/webviewtabbar.h \
- settings.h
+ settings.h \
+ forms/profiledialog.h
-FORMS += mainwindow.ui
+FORMS += mainwindow.ui \
+ forms/profiledialog.ui