diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-06-30 19:14:57 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-06-30 19:14:57 +0200 |
commit | 501e2035c4207ba906aee84461f3ee427a9bce97 (patch) | |
tree | fa32316f806f9e0fe4b7f5e315dcbbb065bcd9b4 /src | |
parent | Some MainWindow and WebViewTabBar cleanup (diff) | |
download | smolbote-501e2035c4207ba906aee84461f3ee427a9bce97.tar.xz |
Status bar height capped; loading bar now hides after 2s
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 6 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/mainwindow.ui | 15 | ||||
-rw-r--r-- | src/plugins/plugins.qbs | 2 | ||||
-rw-r--r-- | src/widgets/loadingbar.cpp | 9 | ||||
-rw-r--r-- | src/widgets/loadingbar.h | 2 |
6 files changed, 26 insertions, 10 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6944ac7..eae09e6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -37,7 +37,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : tabToolBar(new QToolBar(tr("Tab bar"), this)), tabBar(new WebViewTabBar(nullptr, this)), urlLineEdit(new UrlLineEdit(navigationToolBar)), - progressBar(new LoadingBar(this)) + m_progressBar(new LoadingBar(this)) { // set up UI ui->setupUi(this); @@ -93,7 +93,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : tabBar->setProfile(qApp->profile(sSettings->value("browser.profile.default").toString())); // loading bar - ui->statusBar->addPermanentWidget(progressBar); + ui->statusBar->addPermanentWidget(m_progressBar); // shortcuts QAction *focusAddressAction = new QAction(this); @@ -219,7 +219,7 @@ void MainWindow::handleTabChanged(WebView *view) connect(view, SIGNAL(titleChanged(QString)), this, SLOT(handleTitleUpdated(QString))); connect(view, SIGNAL(linkHovered(QString)), ui->statusBar, SLOT(showMessage(QString))); - progressBar->connectWebView(view); + m_progressBar->connectWebView(view); // update UI urlLineEdit->setUrl(view->url()); diff --git a/src/mainwindow.h b/src/mainwindow.h index ac2a335..2f5a662 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -74,7 +74,7 @@ private: QToolBar *navigationToolBar, *tabToolBar; WebViewTabBar *tabBar; UrlLineEdit *urlLineEdit; - LoadingBar *progressBar; + LoadingBar *m_progressBar; }; #endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 46f241a..13c5f8f 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -14,7 +14,20 @@ <string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
- <widget class="QStatusBar" name="statusBar"/>
+ <widget class="QStatusBar" name="statusBar">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>24</height>
+ </size>
+ </property>
+ </widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
diff --git a/src/plugins/plugins.qbs b/src/plugins/plugins.qbs index 72b4ba2..85f9c88 100644 --- a/src/plugins/plugins.qbs +++ b/src/plugins/plugins.qbs @@ -1,5 +1,5 @@ Project { references: [ - "tomleditor/tomleditor.qbs", + //"tomleditor/tomleditor.qbs", ] } diff --git a/src/widgets/loadingbar.cpp b/src/widgets/loadingbar.cpp index a9194bd..9ab5467 100644 --- a/src/widgets/loadingbar.cpp +++ b/src/widgets/loadingbar.cpp @@ -20,6 +20,7 @@ #include "loadingbar.h" #include <QWebEngineView> +#include <QTimer> LoadingBar::LoadingBar(QWidget *parent) : QProgressBar(parent) @@ -33,16 +34,18 @@ void LoadingBar::connectWebView(QWebEngineView *view) connect(view, SIGNAL(loadStarted()), this, SLOT(loadStarted())); connect(view, SIGNAL(loadProgress(int)), this, SLOT(setValue(int))); - connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); + connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); } void LoadingBar::loadStarted() { + resetFormat(); show(); setValue(0); } -void LoadingBar::loadFinished() +void LoadingBar::loadFinished(bool ok) { - hide(); + setFormat(QString("%p% %1").arg(ok ? tr("Finished") : tr("Failed"))); + QTimer::singleShot(2000, this, SLOT(hide())); } diff --git a/src/widgets/loadingbar.h b/src/widgets/loadingbar.h index 4523f88..a797e55 100644 --- a/src/widgets/loadingbar.h +++ b/src/widgets/loadingbar.h @@ -35,7 +35,7 @@ signals: public slots: void loadStarted(); - void loadFinished(); + void loadFinished(bool ok); }; #endif // LOADINGBAR_H |