From dbc2578c71a8e0495a394037acae855b617923e7 Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 4 Oct 2013 17:00:19 +0300 Subject: [PATCH] Added autosaving file each 5 minutes. --HG-- branch : develop --- mainwindow.cpp | 19 +++++++++++++++++++ mainwindow.h | 1 + 2 files changed, 20 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 0905ad7dd..b76be3b72 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -99,6 +99,11 @@ MainWindow::MainWindow(QWidget *parent) : fileName.clear(); changeInFile = false; + //Autosaving file each 5 minutes + QTimer *timer = new QTimer(this); + timer->setTimerType(Qt::VeryCoarseTimer); + connect(timer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); + timer->start(300000); } void MainWindow::ActionNewDraw(){ @@ -948,6 +953,20 @@ bool MainWindow::SafeSaveing(const QString &fileName) const{ return result; } +void MainWindow::AutoSavePattern(){ + if(!fileName.isEmpty()){ + bool result = SafeSaveing(fileName); + if(result){ + ui->actionSave->setEnabled(false); + changeInFile = false; + QFileInfo info(fileName); + QString title(info.fileName()); + title.append("-Valentina"); + setWindowTitle(title); + } + } +} + MainWindow::~MainWindow(){ CanselTool(); delete ui; diff --git a/mainwindow.h b/mainwindow.h index 188af09cf..4015d654f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -154,6 +154,7 @@ private: void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail); bool SafeSaveing(const QString &fileName)const; + void AutoSavePattern(); }; #endif // MAINWINDOW_H