mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-02 14:17:09 +01: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;
|
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()
|
void MainWidget::LoadGeometry()
|
||||||
{
|
{
|
||||||
if(getenv("HOME")==NULL) {
|
QString geometry_file = GeometryFile();
|
||||||
|
if(geometry_file==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RDProfile *profile=new RDProfile();
|
RDProfile *profile=new RDProfile();
|
||||||
profile->
|
profile->setSource(geometry_file);
|
||||||
setSource(QString().sprintf("%s/%s",getenv("HOME"),
|
|
||||||
RDLIBRARY_GEOMETRY_FILE));
|
|
||||||
resize(profile->intValue("RDLibrary","Width",sizeHint().width()),
|
resize(profile->intValue("RDLibrary","Width",sizeHint().width()),
|
||||||
profile->intValue("RDLibrary","Height",sizeHint().height()));
|
profile->intValue("RDLibrary","Height",sizeHint().height()));
|
||||||
lib_shownotes_box->
|
lib_shownotes_box->
|
||||||
@@ -1426,12 +1434,11 @@ void MainWidget::LoadGeometry()
|
|||||||
|
|
||||||
void MainWidget::SaveGeometry()
|
void MainWidget::SaveGeometry()
|
||||||
{
|
{
|
||||||
if(getenv("HOME")==NULL) {
|
QString geometry_file = GeometryFile();
|
||||||
|
if(geometry_file==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FILE *file=fopen((const char *)QString().
|
FILE *file=fopen(geometry_file,"w");
|
||||||
sprintf("%s/%s",getenv("HOME"),RDLIBRARY_GEOMETRY_FILE),
|
|
||||||
"w");
|
|
||||||
if(file==NULL) {
|
if(file==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class MainWidget : public QWidget
|
|||||||
const QDateTime ¤t_datetime);
|
const QDateTime ¤t_datetime);
|
||||||
void SetCaption(QString user);
|
void SetCaption(QString user);
|
||||||
QString GetTypeFilter();
|
QString GetTypeFilter();
|
||||||
|
QString GeometryFile();
|
||||||
void LoadGeometry();
|
void LoadGeometry();
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
void LockUser();
|
void LockUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user