@@ -1980,41 +1980,45 @@ void MainWindow::buildMenu()
19801980 m_fileToolBar->addAction (action);
19811981 connect (action, SIGNAL (triggered ()), SLOT (saveFileAs ()));
19821982 // Initialize autosave feature
1983- m_autosaveInterval = 5 ; // Autosave interval in minutes
1984- m_autosaveTimer = new QTimer (this );
1985- connect (m_autosaveTimer, &QTimer::timeout, this , &MainWindow::autosaveDocument);
1986- m_autosaveTimer->start (m_autosaveInterval * 60000 ); // Convert minutes to milliseconds
1987-
1988- void MainWindow::autosaveDocument ()
1989- {
1983+ m_autosaveInterval = 5 ; // Autosave interval in minutes
1984+ m_autosaveTimer = new QTimer (this );
1985+ connect (m_autosaveTimer, &QTimer::timeout, this ,
1986+ &MainWindow::autosaveDocument);
1987+ m_autosaveTimer->start (m_autosaveInterval *
1988+ 60000 ); // Convert minutes to milliseconds
1989+
1990+ void MainWindow::autosaveDocument ()
1991+ {
19901992 if (!m_molecule || !m_moleculeDirty) {
1991- return ; // No molecule loaded or no changes made since the last save.
1993+ return ; // No molecule loaded or no changes made since the last save.
19921994 }
19931995
1994- QString autosaveDirPath = QStandardPaths::writableLocation (QStandardPaths::AppDataLocation) + " /autosave" ;
1996+ QString autosaveDirPath =
1997+ QStandardPaths::writableLocation (QStandardPaths::AppDataLocation) +
1998+ " /autosave" ;
19951999 QDir autosaveDir (autosaveDirPath);
19962000 if (!autosaveDir.exists ()) {
1997- autosaveDir.mkpath (" ." );
2001+ autosaveDir.mkpath (" ." );
19982002 }
19992003
20002004 // Construct autosave file name
20012005 QString autosaveFilename;
20022006 if (m_molecule->hasData (" fileName" )) {
2003- QFileInfo fileInfo (m_molecule->data (" fileName" ).toString ().c_str ());
2004- autosaveFilename = fileInfo.baseName () + " _autosave.cjson" ;
2007+ QFileInfo fileInfo (m_molecule->data (" fileName" ).toString ().c_str ());
2008+ autosaveFilename = fileInfo.baseName () + " _autosave.cjson" ;
20052009 } else {
2006- autosaveFilename = " unsaved_autosave.cjson" ;
2010+ autosaveFilename = " unsaved_autosave.cjson" ;
20072011 }
20082012 QString autosaveFilePath = autosaveDirPath + " /" + autosaveFilename;
20092013
20102014 // Use CJSON format for autosaving
20112015 Io::CjsonFormat writer;
20122016 if (!writer.writeFile (autosaveFilePath, *m_molecule)) {
2013- qWarning () << " Failed to autosave the document to" << autosaveFilePath;
2017+ qWarning () << " Failed to autosave the document to" << autosaveFilePath;
20142018 } else {
2015- qDebug () << " Document autosaved to" << autosaveFilePath;
2019+ qDebug () << " Document autosaved to" << autosaveFilePath;
20162020 }
2017- }
2021+ }
20182022
20192023 // Export action for menu
20202024 QStringList exportPath = path;
0 commit comments