aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-23 14:24:39 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-23 14:24:39 +0100
commit9b943eafc83653db3bedbd7d7f3fbfa77e0ec448 (patch)
treed7eeca80e2a398338830a0cbeed57d1a43440207 /src
parentSingle instance (diff)
downloadsmolbote-9b943eafc83653db3bedbd7d7f3fbfa77e0ec448.tar.xz
Minor features
First run check focusAddress and *toolbarMovable options
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp18
-rw-r--r--src/browser.h1
-rw-r--r--src/main.cpp3
-rw-r--r--src/mainwindow.cpp15
-rw-r--r--src/mainwindow.h1
5 files changed, 38 insertions, 0 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 46af166..a1c097a 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -22,11 +22,15 @@
#include "mainwindow.h"
#include "settings.h"
#include <QtWebEngine>
+#include <QMessageBox>
Browser::Browser(int &argc, char *argv[]) :
QApplication(argc, argv)
{
setApplicationName("smolbote");
+
+ // This lets the web view automatically scale on high-dpi displays.
+ setAttribute(Qt::AA_EnableHighDpiScaling);
}
Browser::~Browser()
@@ -39,6 +43,20 @@ Browser::~Browser()
}
/*!
+ * Check if the settings are empty
+ */
+void Browser::firstRun()
+{
+ Settings settings;
+ if(settings.allKeys().isEmpty()) {
+ // There are no keys in the settings
+ QMessageBox::information(0,
+ tr("Configuration is empty"),
+ tr("The configuration file <i>%1</i> is empty. Using default values").arg(settings.staticFilePath()));
+ }
+}
+
+/*!
* Anything that needs to run after the QCommandLineParser but before showing a main window
*/
bool Browser::preLaunch(QStringList urls)
diff --git a/src/browser.h b/src/browser.h
index 2d3c2b0..3d3b297 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -36,6 +36,7 @@ public:
Browser(int &argc, char *argv[]);
~Browser();
+ void firstRun();
bool preLaunch(QStringList urls);
static Browser *instance();
diff --git a/src/main.cpp b/src/main.cpp
index 656472c..b787caf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,7 +43,10 @@ int main(int argc, char *argv[])
parser.process(app);
+ // set config path
app.setConfigPath(parser.value(configOption));
+ app.firstRun();
+
if(!app.preLaunch(parser.positionalArguments())) {
return 0;
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index fa7f01d..5d7c3b7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -79,8 +79,10 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
//profileMenu->addAction(tr("Settings"));
//profileMenu->addAction(tr("Cookies"));
+ navigationToolBar->setMovable(settings.value("ui/navtoolbarMovable", true).toBool());
this->addToolBar(Qt::TopToolBarArea, navigationToolBar);
this->addToolBarBreak(Qt::TopToolBarArea);
+ tabToolBar->setMovable(settings.value("ui/tabtoolbarMovable", true).toBool());
this->addToolBar(Qt::TopToolBarArea, tabToolBar);
navigationToolBar->addWidget(urlLineEdit);
@@ -89,8 +91,15 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
tabToolBar->addWidget(tabBar);
connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*)));
+ // loading bar
ui->statusBar->addPermanentWidget(progressBar);
+ // shortcuts
+ QAction *focusAddressAction = new QAction(this);
+ focusAddressAction->setShortcut(QKeySequence::fromString(settings.value("shortcuts/focusAddress").toString()));
+ connect(focusAddressAction, SIGNAL(triggered(bool)), this, SLOT(focusAddress()));
+ addAction(focusAddressAction);
+
if(!defaultUrl.isEmpty()) {
addNewTab(defaultUrl);
} else {
@@ -121,6 +130,12 @@ void MainWindow::addNewTab(const QUrl &url)
}
}
+void MainWindow::focusAddress()
+{
+ urlLineEdit->setFocus();
+ urlLineEdit->selectAll();
+}
+
void MainWindow::closeEvent(QCloseEvent *event)
{
if(tabBar->count() > 1) {
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 0c1f659..e7fb6c6 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -49,6 +49,7 @@ public:
public slots:
void addNewTab(const QUrl &url = QUrl(""));
+ void focusAddress();
protected:
void closeEvent(QCloseEvent *event) override;