Remember toolbars visibility and don't ask on exit

We are anyway asking if we have some files not saved.
This commit is contained in:
Adam Strzelecki 2022-01-31 23:12:54 +01:00 committed by Adam Strzelecki
parent 3de324644d
commit 8621131c73
4 changed files with 43 additions and 17 deletions

View File

@ -189,6 +189,11 @@ bool loadSettings()
if (settings.contains("fullTraceName")) QucsSettings.fullTraceName = settings.value("fullTraceName").toBool();
else QucsSettings.fullTraceName = false;
QucsSettings.FileToolbar = settings.contains("FileToolbar") ? settings.value("FileToolbar").toBool() : true;
QucsSettings.EditToolbar = settings.contains("EditToolbar") ? settings.value("EditToolbar").toBool() : true;
QucsSettings.ViewToolbar = settings.contains("ViewToolbar") ? settings.value("ViewToolbar").toBool() : true;
QucsSettings.WorkToolbar = settings.contains("WorkToolbar") ? settings.value("WorkToolbar").toBool() : true;
QucsSettings.RecentDocs = settings.value("RecentDocs").toString().split("*",qucs::SkipEmptyParts);
QucsSettings.numRecentDocs = QucsSettings.RecentDocs.count();
@ -270,6 +275,10 @@ bool saveApplSettings()
settings.setValue("fullTraceName",QucsSettings.fullTraceName);
settings.setValue("panelIconsTheme",QucsSettings.panelIconsTheme);
settings.setValue("compIconsTheme",QucsSettings.compIconsTheme);
settings.setValue("FileToolbar", QucsSettings.FileToolbar);
settings.setValue("EditToolbar", QucsSettings.EditToolbar);
settings.setValue("ViewToolbar", QucsSettings.ViewToolbar);
settings.setValue("WorkToolbar", QucsSettings.WorkToolbar);
// Copy the list of directory paths in which Qucs should
// search for subcircuit schematics from qucsPathList

View File

@ -106,6 +106,11 @@ struct tQucsSettings {
bool hasDarkTheme;
bool fullTraceName;
bool FileToolbar;
bool EditToolbar;
bool ViewToolbar;
bool WorkToolbar;
};
extern tQucsSettings QucsSettings; // extern because nearly everywhere used

View File

@ -174,6 +174,11 @@ QucsApp::QucsApp()
initCursorMenu();
Module::registerModules ();
fileToolbar->setVisible(QucsSettings.FileToolbar);
editToolbar->setVisible(QucsSettings.EditToolbar);
viewToolbar->setVisible(QucsSettings.ViewToolbar);
workToolbar->setVisible(QucsSettings.WorkToolbar);
// instance of small text search dialog
SearchDia = new SearchDialog(this);
@ -1990,15 +1995,11 @@ void QucsApp::slotFileQuit()
statusBar()->showMessage(tr("Exiting application..."));
slotHideEdit(); // disable text edit of component property
int exit = QMessageBox::information(this,
tr("Quit..."), tr("Do you really want to quit?"),
tr("Yes"), tr("No"));
if(exit == 0)
if(closeAllFiles()) {
emit signalKillEmAll(); // kill all subprocesses
qApp->quit();
}
saveSettings();
if(closeAllFiles()) {
emit signalKillEmAll(); // kill all subprocesses
qApp->quit();
}
statusBar()->showMessage(tr("Ready."));
}
@ -2007,14 +2008,7 @@ void QucsApp::slotFileQuit()
// To get all close events.
void QucsApp::closeEvent(QCloseEvent* Event)
{
qDebug()<<"x"<<pos().x()<<" ,y"<<pos().y();
qDebug()<<"dx"<<size().width()<<" ,dy"<<size().height();
QucsSettings.x=pos().x();
QucsSettings.y=pos().y();
QucsSettings.dx=size().width();
QucsSettings.dy=size().height();
saveApplSettings();
saveSettings();
if(closeAllFiles()) {
emit signalKillEmAll(); // kill all subprocesses
Event->accept();
@ -2024,6 +2018,23 @@ void QucsApp::closeEvent(QCloseEvent* Event)
Event->ignore();
}
//-----------------------------------------------------------------
// Saves settings
void QucsApp::saveSettings()
{
qDebug()<<"x"<<pos().x()<<" ,y"<<pos().y();
qDebug()<<"dx"<<size().width()<<" ,dy"<<size().height();
QucsSettings.x=pos().x();
QucsSettings.y=pos().y();
QucsSettings.dx=size().width();
QucsSettings.dy=size().height();
QucsSettings.FileToolbar = fileToolbar->isVisible();
QucsSettings.EditToolbar = editToolbar->isVisible();
QucsSettings.ViewToolbar = viewToolbar->isVisible();
QucsSettings.WorkToolbar = workToolbar->isVisible();
saveApplSettings();
}
// --------------------------------------------------------------------
// Is called when the toolbar button is pressed to go into a subcircuit.
void QucsApp::slotIntoHierarchy()

View File

@ -260,6 +260,7 @@ private:
void updateRecentFilesList(QString s);
void successExportMessages(bool ok);
void fillLibrariesTreeView (void);
void saveSettings();
public: