mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-08-16 08:34:12 +02:00
Replace getenv("HOME") by RDGetHomeDir() in MainWidget::LoadGeometry/SaveGeometry. Create MainWidget::GeometryFile to share logic
This commit is contained in:
parent
eb8e95d994
commit
ea10c041fb
@ -2513,15 +2513,24 @@ int MainWidget::GetConnection(QString station,unsigned chan)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MainWidget::GeometryFile() {
|
||||||
|
bool home_found = false;
|
||||||
|
QString home = RDGetHomeDir(&home_found);
|
||||||
|
if (home_found) {
|
||||||
|
return home + "/" + RDCATCH_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"),RDCATCH_GEOMETRY_FILE));
|
|
||||||
resize(profile->intValue("RDCatch","Width",sizeHint().width()),
|
resize(profile->intValue("RDCatch","Width",sizeHint().width()),
|
||||||
profile->intValue("RDCatch","Height",sizeHint().height()));
|
profile->intValue("RDCatch","Height",sizeHint().height()));
|
||||||
|
|
||||||
@ -2531,12 +2540,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"),RDCATCH_GEOMETRY_FILE),
|
|
||||||
"w");
|
|
||||||
if(file==NULL) {
|
if(file==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,7 @@ class MainWidget : public QWidget
|
|||||||
RDListViewItem *GetItem(int id);
|
RDListViewItem *GetItem(int id);
|
||||||
int GetMonitor(int serial,int chan);
|
int GetMonitor(int serial,int chan);
|
||||||
int GetConnection(QString station,unsigned chan=0);
|
int GetConnection(QString station,unsigned chan=0);
|
||||||
|
QString GeometryFile();
|
||||||
void LoadGeometry();
|
void LoadGeometry();
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
std::vector<CatchMonitor *> catch_monitor;
|
std::vector<CatchMonitor *> catch_monitor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user