diff options
author | Simon Rettberg | 2022-12-06 12:05:20 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-12-06 12:05:20 +0100 |
commit | d2af1b2537ad885d4c177d8312a5e31643247dee (patch) | |
tree | d6073ca00d326f3c8f3c99842409a6571287aa0a /src | |
parent | Enable local storage (diff) | |
download | slxbrowser-d2af1b2537ad885d4c177d8312a5e31643247dee.tar.gz slxbrowser-d2af1b2537ad885d4c177d8312a5e31643247dee.tar.xz slxbrowser-d2af1b2537ad885d4c177d8312a5e31643247dee.zip |
Add --zoom option
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 7 | ||||
-rw-r--r-- | src/slxbrowser.cpp | 6 | ||||
-rw-r--r-- | src/slxbrowser.h | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2213913..4d3b6e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,12 +42,14 @@ int main(int argc, char** argv) QCommandLineOption reloadInterval("reload-interval", "Reload displayed page every X seconds.", "seconds"); QCommandLineOption whitelist("whitelist", "Path to a file of allowed URLs.", "file"); QCommandLineOption blacklist("blacklist", "Path to a file of disallowed URLs.", "file"); + QCommandLineOption zoom("zoom", "Default zoom level.", "percent"); parser.addOption(ignoreSsl); parser.addOption(fullscreen); parser.addOption(maximized); parser.addOption(reloadInterval); parser.addOption(whitelist); parser.addOption(blacklist); + parser.addOption(zoom); parser.process(app); QStringList list(parser.positionalArguments()); if (list.empty()) { @@ -66,6 +68,11 @@ int main(int argc, char** argv) if (parser.isSet(blacklist)) { settings.blackList = loadUrlList(parser.value(blacklist)); } + if (parser.isSet(zoom)) { + settings.zoom = parser.value(zoom).toInt(); + } else { + settings.zoom = 100; + } SlxBrowser main(settings); main.show(); app.installEventFilter(new KeyHandler(&main)); diff --git a/src/slxbrowser.cpp b/src/slxbrowser.cpp index f6d9850..2bfb617 100644 --- a/src/slxbrowser.cpp +++ b/src/slxbrowser.cpp @@ -21,6 +21,11 @@ SlxBrowser::SlxBrowser(BrowserSettings settings) _pageValid(false) { _settings.reloadInterval *= 1000; + if (_settings.zoom <= 0) { + _settings.zoom = 100; + } else if (_settings.zoom > 400) { + _settings.zoom = 400; + } if (_settings.fullscreen) { this->showFullScreen(); this->setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); @@ -32,6 +37,7 @@ SlxBrowser::SlxBrowser(BrowserSettings settings) QWidget *w = new QWidget; QLayout *l = new QVBoxLayout; _browser = new WebView; + _browser->setZoomFactor(float(_settings.zoom) * .01f); _progress = new QProgressBar; _progress->hide(); l->addWidget(_browser); diff --git a/src/slxbrowser.h b/src/slxbrowser.h index fd0cf06..ba95f6b 100644 --- a/src/slxbrowser.h +++ b/src/slxbrowser.h @@ -19,6 +19,7 @@ struct BrowserSettings bool ignoreSslErrors; int reloadInterval; QStringList blackList, whiteList; + int zoom; }; class SlxBrowser : public QMainWindow |