mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-14 08:39:31 +02:00
Replace getenv("HOME") by RDGetHomeDir() in RDCutDialog::LoadState/SaveState. Create RDCutDialog::StateFile to share logic
This commit is contained in:
parent
ea73b88634
commit
135e200331
@ -35,6 +35,8 @@
|
||||
#include <rdadd_cart.h>
|
||||
#include <rdprofile.h>
|
||||
#include <rddb.h>
|
||||
#include <rdconf.h>
|
||||
|
||||
|
||||
//
|
||||
// Icons
|
||||
@ -641,14 +643,29 @@ void RDCutDialog::BuildGroupList()
|
||||
}
|
||||
}
|
||||
|
||||
QString RDCutDialog::StateFile() {
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
return QString().sprintf("%s/.rdcartdialog",(const char *)home);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void RDCutDialog::LoadState()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString state_file = StateFile();
|
||||
if (state_file == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
RDProfile *p=new RDProfile();
|
||||
p->setSource(QString().sprintf("%s/.rdcartdialog",getenv("HOME")));
|
||||
p->setSource(state_file);
|
||||
|
||||
bool value_read = false;
|
||||
cart_limit_box->setChecked(p->boolValue("RDCartDialog", "LimitSearch", true, &value_read));
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
@ -657,11 +674,12 @@ void RDCutDialog::SaveState()
|
||||
{
|
||||
FILE *f=NULL;
|
||||
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString state_file = StateFile();
|
||||
if (state_file == NULL) {
|
||||
return;
|
||||
}
|
||||
if((f=fopen(QString().sprintf("%s/.rdcartdialog",getenv("HOME")),"w"))==
|
||||
NULL) {
|
||||
|
||||
if((f=fopen(state_file,"w"))==NULL) {
|
||||
return;
|
||||
}
|
||||
fprintf(f,"[RDCartDialog]\n");
|
||||
|
@ -74,6 +74,7 @@ class RDCutDialog : public QDialog
|
||||
void RefreshCuts();
|
||||
void SelectCut(QString cutname);
|
||||
void BuildGroupList();
|
||||
QString StateFile();
|
||||
void LoadState();
|
||||
void SaveState();
|
||||
RDListView *cut_cart_list;
|
||||
|
Loading…
x
Reference in New Issue
Block a user