mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-18 15:09:39 +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 <rdadd_cart.h>
|
||||||
#include <rdprofile.h>
|
#include <rdprofile.h>
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
|
#include <rdconf.h>
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Icons
|
// 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()
|
void RDCutDialog::LoadState()
|
||||||
{
|
{
|
||||||
if(getenv("HOME")==NULL) {
|
QString state_file = StateFile();
|
||||||
|
if (state_file == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RDProfile *p=new RDProfile();
|
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;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,11 +674,12 @@ void RDCutDialog::SaveState()
|
|||||||
{
|
{
|
||||||
FILE *f=NULL;
|
FILE *f=NULL;
|
||||||
|
|
||||||
if(getenv("HOME")==NULL) {
|
QString state_file = StateFile();
|
||||||
|
if (state_file == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((f=fopen(QString().sprintf("%s/.rdcartdialog",getenv("HOME")),"w"))==
|
|
||||||
NULL) {
|
if((f=fopen(state_file,"w"))==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(f,"[RDCartDialog]\n");
|
fprintf(f,"[RDCartDialog]\n");
|
||||||
|
@ -74,6 +74,7 @@ class RDCutDialog : public QDialog
|
|||||||
void RefreshCuts();
|
void RefreshCuts();
|
||||||
void SelectCut(QString cutname);
|
void SelectCut(QString cutname);
|
||||||
void BuildGroupList();
|
void BuildGroupList();
|
||||||
|
QString StateFile();
|
||||||
void LoadState();
|
void LoadState();
|
||||||
void SaveState();
|
void SaveState();
|
||||||
RDListView *cut_cart_list;
|
RDListView *cut_cart_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user