mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +00:00
Needed restart delay when altering preferences. Delete day cache when session settings changed
This commit is contained in:
parent
a8aa7753cb
commit
7716d530f7
@ -47,9 +47,16 @@ Profile::Profile(QString path)
|
||||
machlist.clear();
|
||||
//m_first=m_last=NULL;
|
||||
}
|
||||
|
||||
Profile::~Profile()
|
||||
bool Profile::Save(QString filename)
|
||||
{
|
||||
if (p_profile==this) {
|
||||
QString cachefile=Get("{DataFolder}")+QDir::separator()+"cache.day";
|
||||
QFile f(cachefile);
|
||||
if (ExistsAndTrue("TrashDayCache")) {
|
||||
if (f.exists()) {
|
||||
f.remove();
|
||||
}
|
||||
} else {
|
||||
QMap<QDate,QList<Day *> >::iterator di;
|
||||
QHash<MachineID,QMap<QDate,QHash<ChannelID, EventDataType> > > cache;
|
||||
|
||||
@ -66,8 +73,6 @@ Profile::~Profile()
|
||||
}
|
||||
}
|
||||
}
|
||||
QString filename=Get("{DataFolder}")+QDir::separator()+"cache.day";
|
||||
QFile f(filename);
|
||||
if (f.open(QFile::WriteOnly)) {
|
||||
QDataStream out(&f);
|
||||
out.setVersion(QDataStream::Qt_4_6);
|
||||
@ -79,19 +84,17 @@ Profile::~Profile()
|
||||
out << mid;
|
||||
out << ci.value();
|
||||
}
|
||||
/*quint16 size=cache.size();
|
||||
out << size;
|
||||
QMap<QDate,QHash<ChannelID, EventDataType> >::iterator i;
|
||||
for (i=cache.begin();i!=cache.end();i++) {
|
||||
QDate a=i.key();
|
||||
out << a;
|
||||
}
|
||||
for (i=cache.begin();i!=cache.end();i++) {
|
||||
out << cache[i.key()];
|
||||
}*/
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
(*this)["TrashDayCache"]=false;
|
||||
}
|
||||
return Preferences::Save(filename);
|
||||
}
|
||||
|
||||
|
||||
Profile::~Profile()
|
||||
{
|
||||
for (QHash<MachineID,Machine *>::iterator i=machlist.begin(); i!=machlist.end(); i++) {
|
||||
delete i.value();
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
Profile();
|
||||
virtual ~Profile();
|
||||
|
||||
virtual bool Save(QString filename="");
|
||||
|
||||
bool is_first_day;
|
||||
QHash<MachineID,Machine *> machlist;
|
||||
void AddMachine(Machine *m);
|
||||
|
3
main.cpp
3
main.cpp
@ -89,6 +89,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (int i=1;i<args.size();i++) {
|
||||
if (args[i]=="-l") force_login_screen=true;
|
||||
if (args[i]=="-p") {
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
a.setApplicationName("SleepyHead");
|
||||
|
@ -319,14 +319,15 @@ void PreferencesDialog::Save()
|
||||
(*profile)["MaskStartDate"]=ui->startedUsingMask->date();
|
||||
(*profile)["GraphHeight"]=ui->graphHeight->value();
|
||||
|
||||
if ((*profile)["CombineCloserSessions"].toInt()!=ui->combineSlider->value()) needs_restart=true;
|
||||
if ((*profile)["IgnoreShorterSessions"].toInt()!=ui->IgnoreSlider->value()) needs_restart=true;
|
||||
if (((*profile)["DaySplitTime"].toTime()!=ui->timeEdit->time()) ||
|
||||
((*profile)["CombineCloserSessions"].toInt()!=ui->combineSlider->value()) ||
|
||||
((*profile)["IgnoreShorterSessions"].toInt()!=ui->IgnoreSlider->value())) {
|
||||
PROFILE["TrashDayCache"]=true;
|
||||
needs_restart=true;
|
||||
} else PROFILE["TrashDayCache"]=false;
|
||||
|
||||
(*profile)["CombineCloserSessions"]=ui->combineSlider->value();
|
||||
(*profile)["IgnoreShorterSessions"]=ui->IgnoreSlider->value();
|
||||
|
||||
if ((*profile)["DaySplitTime"].toTime()!=ui->timeEdit->time()) needs_restart=true;
|
||||
|
||||
(*profile)["DaySplitTime"]=ui->timeEdit->time();
|
||||
|
||||
(*profile)["AlwaysShowOverlayBars"]=ui->overlayFlagsCombo->currentIndex();
|
||||
@ -440,8 +441,8 @@ void PreferencesDialog::Save()
|
||||
file.close();
|
||||
}
|
||||
|
||||
PROFILE.Save();
|
||||
PREF.Save();
|
||||
//PROFILE.Save();
|
||||
//PREF.Save();
|
||||
|
||||
if (needs_restart) {
|
||||
if (QMessageBox::question(this,"Restart Required","One or more of the changes you have made will require this application to be restarted, in order for these changes to come into effect.\nWould you like do this now?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) {
|
||||
@ -455,6 +456,7 @@ void PreferencesDialog::Save()
|
||||
|
||||
QStringList args;
|
||||
args << "-n" << apppath; // -n option is important, as it opens a new process
|
||||
args << "-p";
|
||||
|
||||
if (QProcess::startDetached("/usr/bin/open",args)) {
|
||||
QApplication::instance()->exit();
|
||||
@ -469,7 +471,9 @@ void PreferencesDialog::Save()
|
||||
//if (QDesktopServices::openUrl(apppath)) {
|
||||
// QApplication::instance()->exit();
|
||||
//} else
|
||||
if (QProcess::startDetached(apppath)) {
|
||||
QStringList args;
|
||||
args << "-p";
|
||||
if (QProcess::startDetached(apppath,args)) {
|
||||
QApplication::instance()->exit();
|
||||
} else QMessageBox::warning(this,"Gah!","If you can read this, the restart command didn't work. Your going to have to do it yourself manually.",QMessageBox::Ok);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user