summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-01-15 12:07:41 +0100
committerSimon Rettberg2018-01-15 12:07:41 +0100
commit9bca81b853bf66e58a8357a094c93808b2e38445 (patch)
treef911272a666ecc19f54d0a8b44b4f05685ab1681
parentChange --full-screen to --fullscreen (diff)
downloadslxbrowser-9bca81b853bf66e58a8357a094c93808b2e38445.tar.gz
slxbrowser-9bca81b853bf66e58a8357a094c93808b2e38445.tar.xz
slxbrowser-9bca81b853bf66e58a8357a094c93808b2e38445.zip
Add --reload-interval option to periodically reload the passed URL
-rw-r--r--src/main.cpp4
-rw-r--r--src/slxbrowser.cpp10
-rw-r--r--src/slxbrowser.h3
3 files changed, 13 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 9ac7748..b828d60 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,8 +29,10 @@ int main(int argc, char** argv)
parser.addPositionalArgument("url", "URL to load");
QCommandLineOption ignoreSsl("insecure", "Ignore SSL errors");
QCommandLineOption fullscreen("fullscreen", "Run browser in full screen");
+ QCommandLineOption reloadInterval("reload-interval", "Reload displayed page every X seconds", "seconds");
parser.addOption(ignoreSsl);
parser.addOption(fullscreen);
+ parser.addOption(reloadInterval);
parser.process(app);
QStringList list(parser.positionalArguments());
if (list.empty()) {
@@ -38,7 +40,7 @@ int main(int argc, char** argv)
return 1;
}
QString url(list[0]);
- SLXbrowser main(url, parser.isSet(fullscreen), parser.isSet(ignoreSsl));
+ SLXbrowser main(url, parser.isSet(fullscreen), parser.isSet(ignoreSsl), parser.value(reloadInterval).toInt());
main.show();
app.installEventFilter(new KeyHandler());
app.exec();
diff --git a/src/slxbrowser.cpp b/src/slxbrowser.cpp
index 45c235a..a8fc1d8 100644
--- a/src/slxbrowser.cpp
+++ b/src/slxbrowser.cpp
@@ -6,10 +6,11 @@
#include <QSslConfiguration>
#include <QProgressBar>
-SLXbrowser::SLXbrowser(QString url, bool fullscreen, bool ignoreSslErrors)
+SLXbrowser::SLXbrowser(QString url, bool fullscreen, bool ignoreSslErrors, int reloadIntervalSeconds)
: QMainWindow(NULL),
_url(url),
- _ignoreSslErrors(ignoreSslErrors)
+ _ignoreSslErrors(ignoreSslErrors),
+ _reloadIntervalMs(reloadIntervalSeconds * 1000)
{
if (fullscreen) {
this->showFullScreen();
@@ -55,6 +56,9 @@ SLXbrowser::~SLXbrowser()
void SLXbrowser::loadStarted()
{
_reset.stop();
+ if (_reloadIntervalMs > 0) {
+ _reset.start(_reloadIntervalMs + 10000);
+ }
_normalError.clear();
_sslErrors.clear();
_progress->setValue(0);
@@ -85,6 +89,8 @@ void SLXbrowser::loadFinished(bool ok)
_sslErrors.clear();
_normalError.clear();
_reset.start(30000);
+ } else if (_reloadIntervalMs > 0) {
+ _reset.start(_reloadIntervalMs);
}
}
diff --git a/src/slxbrowser.h b/src/slxbrowser.h
index dc357dd..acbb7d8 100644
--- a/src/slxbrowser.h
+++ b/src/slxbrowser.h
@@ -15,7 +15,7 @@ class SLXbrowser : public QMainWindow
{
Q_OBJECT
public:
- SLXbrowser(QString url, bool fullscreen, bool ignoreSslErrors);
+ SLXbrowser(QString url, bool fullscreen, bool ignoreSslErrors, int reloadInterval);
virtual ~SLXbrowser();
private slots:
@@ -34,6 +34,7 @@ private:
QTimer _reset;
QList<QSslError> _sslErrors;
QString _normalError;
+ int _reloadIntervalMs;
};
#endif /* SLXBROWSER_H_ */