aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2021-03-15 11:54:48 +0100
committerFelix Queißner <felix@ib-queissner.de>2021-03-17 09:49:58 +0100
commit0d1fd257093c58bfb606aaac530aed3b0877f7fd (patch)
treeca998bde0422823b64f325c4830c7d5a37beaf9a /src/mainwindow.cpp
parent856924aa05815c565bfd67ad8dff12127f545b0b (diff)
downloadkristall-0d1fd257093c58bfb606aaac530aed3b0877f7fd.tar.gz
First draft of session management. Always restores the latest session.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d9ee161..95e6278 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -29,6 +29,8 @@ MainWindow::MainWindow(QApplication * app, QWidget *parent) :
file_mime(new QLabel(this)),
load_time(new QLabel(this))
{
+ this->setAttribute(Qt::WA_DeleteOnClose);
+
ui->setupUi(this);
this->url_status->setElideMode(Qt::ElideMiddle);
@@ -177,6 +179,11 @@ BrowserTab * MainWindow::tabAt(int index) const
return qobject_cast<BrowserTab*>(this->ui->browser_tabs->widget(index));
}
+int MainWindow::tabCount() const
+{
+ return this->ui->browser_tabs->count();
+}
+
void MainWindow::setUrlPreview(const QUrl &url)
{
if(url.isValid()) {
@@ -323,8 +330,9 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
void MainWindow::closeEvent(QCloseEvent *event)
{
- kristall::saveWindowState();
-
+ if(kristall::getWindowCount() == 1) {
+ kristall::saveSession();
+ }
event->accept();
}
@@ -458,6 +466,7 @@ void MainWindow::on_actionNew_Tab_triggered()
void MainWindow::on_actionQuit_triggered()
{
+ kristall::saveSession();
QApplication::quit();
}
@@ -774,7 +783,7 @@ void MainWindow::on_actionNew_window_triggered()
void MainWindow::on_actionClose_Window_triggered()
{
- this->deleteLater();
+ this->close();
}
void MainWindow::on_favourites_view_activated(const QModelIndex &index)