aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/loadingbar.cpp48
-rw-r--r--src/widgets/loadingbar.h41
-rw-r--r--src/widgets/urllineedit.cpp6
-rw-r--r--src/widgets/webviewtabbar.cpp8
-rw-r--r--src/widgets/webviewtabbar.h10
5 files changed, 104 insertions, 9 deletions
diff --git a/src/widgets/loadingbar.cpp b/src/widgets/loadingbar.cpp
new file mode 100644
index 0000000..31208b8
--- /dev/null
+++ b/src/widgets/loadingbar.cpp
@@ -0,0 +1,48 @@
+/** LICENSE ********************************************************************
+ **
+ ** smolbote: yet another qute browser
+ ** Copyright (C) 2017 Xian Nox
+ **
+ ** This program is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** This program is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **
+ ******************************************************************************/
+
+#include "loadingbar.h"
+#include <QWebEngineView>
+
+LoadingBar::LoadingBar(QWidget *parent) :
+ QProgressBar(parent)
+{
+ setMaximum(100);
+}
+
+void LoadingBar::connectWebView(QWebEngineView *view)
+{
+ disconnect(this);
+
+ connect(view, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
+ connect(view, SIGNAL(loadProgress(int)), this, SLOT(setValue(int)));
+ connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
+}
+
+void LoadingBar::loadStarted()
+{
+ show();
+ setValue(0);
+}
+
+void LoadingBar::loadFinished()
+{
+ hide();
+}
diff --git a/src/widgets/loadingbar.h b/src/widgets/loadingbar.h
new file mode 100644
index 0000000..938549f
--- /dev/null
+++ b/src/widgets/loadingbar.h
@@ -0,0 +1,41 @@
+/** LICENSE ********************************************************************
+ **
+ ** smolbote: yet another qute browser
+ ** Copyright (C) 2017 Xian Nox
+ **
+ ** This program is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** This program is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **
+ ******************************************************************************/
+
+#ifndef LOADINGBAR_H
+#define LOADINGBAR_H
+
+#include <QProgressBar>
+
+class QWebEngineView;
+class LoadingBar : public QProgressBar
+{
+ Q_OBJECT
+public:
+ explicit LoadingBar(QWidget *parent = 0);
+ void connectWebView(QWebEngineView *view);
+
+signals:
+
+public slots:
+ void loadStarted();
+ void loadFinished();
+};
+
+#endif // LOADINGBAR_H
diff --git a/src/widgets/urllineedit.cpp b/src/widgets/urllineedit.cpp
index 5c1f5c4..6f07a4a 100644
--- a/src/widgets/urllineedit.cpp
+++ b/src/widgets/urllineedit.cpp
@@ -20,6 +20,7 @@
#include "urllineedit.h"
#include <QUrl>
+#include <QTimer>
UrlLineEdit::UrlLineEdit(QWidget *parent) :
QLineEdit(parent)
@@ -54,6 +55,11 @@ void UrlLineEdit::focusInEvent(QFocusEvent *event)
{
clearTextFormat();
QLineEdit::focusInEvent(event);
+
+ // select the contents when receiving focus
+ // http://stackoverflow.com/a/35725950/1054406
+ // mousePressEvent triggers right after focusInEvent so text selected in focusInEvent unselects by mousePressEvent
+ QTimer::singleShot(0, this, SLOT(selectAll()));
}
void UrlLineEdit::focusOutEvent(QFocusEvent *event)
diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp
index aef2bd8..c091e56 100644
--- a/src/widgets/webviewtabbar.cpp
+++ b/src/widgets/webviewtabbar.cpp
@@ -37,7 +37,7 @@ WebViewTabBar::~WebViewTabBar()
int WebViewTabBar::addTab(QWebEngineProfile *profile, const QUrl &url)
{
- QWebEngineView *view = new QWebEngineView(0);
+ WebView *view = new WebView(0);
QWebEnginePage *page = new QWebEnginePage(profile);
view->setPage(page);
page->load(url);
@@ -65,7 +65,7 @@ void WebViewTabBar::setProfile(QWebEngineProfile *profile)
}
}
-QWebEngineView *WebViewTabBar::currentView()
+WebView *WebViewTabBar::currentView()
{
return m_views.at(currentIndex());
}
@@ -78,7 +78,7 @@ QSize WebViewTabBar::tabSizeHint(int index) const
void WebViewTabBar::handleCurrentChanged(int index)
{
- emit(currentTabChanged(m_views.at(index)));
+ emit currentTabChanged(m_views.at(index));
}
void WebViewTabBar::handleTabClose(int index)
@@ -88,7 +88,7 @@ void WebViewTabBar::handleTabClose(int index)
m_views.remove(index);
}
-void WebViewTabBar::updateTabText(QWebEngineView *view, const QString &text)
+void WebViewTabBar::updateTabText(WebView *view, const QString &text)
{
int index = m_views.indexOf(view);
setTabText(index, text);
diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h
index bf7edb2..260100b 100644
--- a/src/widgets/webviewtabbar.h
+++ b/src/widgets/webviewtabbar.h
@@ -22,7 +22,7 @@
#define WEBVIEWTABBAR_H
#include <QTabBar>
-#include <QWebEngineView>
+#include "webengine/webview.h"
class WebViewTabBar : public QTabBar
{
@@ -35,10 +35,10 @@ public:
int addTab(QWebEngineProfile *profile, const QUrl &url);
void setProfile(QWebEngineProfile *profile);
- QWebEngineView *currentView();
+ WebView *currentView();
signals:
- void currentTabChanged(QWebEngineView *view);
+ void currentTabChanged(WebView *view);
protected:
QSize tabSizeHint(int index) const;
@@ -47,10 +47,10 @@ private slots:
void handleCurrentChanged(int index);
void handleTabClose(int index);
- void updateTabText(QWebEngineView *view, const QString &text);
+ void updateTabText(WebView *view, const QString &text);
private:
- QVector<QWebEngineView*> m_views;
+ QVector<WebView*> m_views;
};
#endif // WEBVIEWTABBAR_H