Added autosaving file each 5 minutes.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-04 17:00:19 +03:00
parent 016e539c6b
commit dbc2578c71
2 changed files with 20 additions and 0 deletions

View File

@ -99,6 +99,11 @@ MainWindow::MainWindow(QWidget *parent) :
fileName.clear(); fileName.clear();
changeInFile = false; 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(){ void MainWindow::ActionNewDraw(){
@ -948,6 +953,20 @@ bool MainWindow::SafeSaveing(const QString &fileName) const{
return result; 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(){ MainWindow::~MainWindow(){
CanselTool(); CanselTool();
delete ui; delete ui;

View File

@ -154,6 +154,7 @@ private:
void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,
const qint64 &idDetail); const qint64 &idDetail);
bool SafeSaveing(const QString &fileName)const; bool SafeSaveing(const QString &fileName)const;
void AutoSavePattern();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H