mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 00:53:53 +02:00
Replace getenv("HOME") by RDGetHomeDir() in rdlibrary MainWidget::LoadGeometry/SaveGeometry. Create MainWidget::GeometryFile to share logic
This commit is contained in:
@@ -1405,16 +1405,24 @@ QString MainWidget::GetTypeFilter()
|
||||
return type_filter;
|
||||
}
|
||||
|
||||
QString MainWidget::GeometryFile() {
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
return home + "/" + RDLIBRARY_GEOMETRY_FILE;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::LoadGeometry()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString geometry_file = GeometryFile();
|
||||
if(geometry_file==NULL) {
|
||||
return;
|
||||
}
|
||||
RDProfile *profile=new RDProfile();
|
||||
profile->
|
||||
setSource(QString().sprintf("%s/%s",getenv("HOME"),
|
||||
RDLIBRARY_GEOMETRY_FILE));
|
||||
profile->setSource(geometry_file);
|
||||
resize(profile->intValue("RDLibrary","Width",sizeHint().width()),
|
||||
profile->intValue("RDLibrary","Height",sizeHint().height()));
|
||||
lib_shownotes_box->
|
||||
@@ -1426,12 +1434,11 @@ void MainWidget::LoadGeometry()
|
||||
|
||||
void MainWidget::SaveGeometry()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString geometry_file = GeometryFile();
|
||||
if(geometry_file==NULL) {
|
||||
return;
|
||||
}
|
||||
FILE *file=fopen((const char *)QString().
|
||||
sprintf("%s/%s",getenv("HOME"),RDLIBRARY_GEOMETRY_FILE),
|
||||
"w");
|
||||
FILE *file=fopen(geometry_file,"w");
|
||||
if(file==NULL) {
|
||||
return;
|
||||
}
|
||||
|
@@ -105,6 +105,7 @@ class MainWidget : public QWidget
|
||||
const QDateTime ¤t_datetime);
|
||||
void SetCaption(QString user);
|
||||
QString GetTypeFilter();
|
||||
QString GeometryFile();
|
||||
void LoadGeometry();
|
||||
void SaveGeometry();
|
||||
void LockUser();
|
||||
|
Reference in New Issue
Block a user