Untangle Profile from MainWindow: files on command line

There's no reason why this should be on the MainWindow widget.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-11-05 10:05:22 -08:00
parent 533d724d1b
commit 081295cb40
5 changed files with 18 additions and 15 deletions

View file

@ -317,16 +317,6 @@ void MainWindow::setDefaultState() {
}
}
void MainWindow::setLoadedWithFiles(bool f)
{
filesAsArguments = f;
}
bool MainWindow::filesFromCommandLine() const
{
return filesAsArguments;
}
MainWindow *MainWindow::instance()
{
return m_Instance;

View file

@ -88,8 +88,6 @@ public:
void setToolButtonsEnabled(bool enabled);
ProfileWidget2 *graphics() const;
PlannerDetails *plannerDetails() const;
void setLoadedWithFiles(bool filesFromCommandLine);
bool filesFromCommandLine() const;
void printPlan();
void checkSurvey(QSettings *s);
void setApplicationState(const QByteArray& state);

View file

@ -31,6 +31,9 @@
#include "mainwindow.h"
#include "preferences/preferencesdialog.h"
// a couple of helpers we need
extern bool haveFilesOnCommandLine();
/* This is the global 'Item position' variable.
* it should tell you where to position things up
* on the canvas.
@ -529,7 +532,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
// special handling for the first time we display things
int animSpeedBackup = 0;
if (firstCall && MainWindow::instance()->filesFromCommandLine()) {
if (firstCall && haveFilesOnCommandLine()) {
animSpeedBackup = prefs.animation_speed;
prefs.animation_speed = 0;
firstCall = false;
@ -673,7 +676,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
if (dcText.isEmpty())
dcText = tr("Unknown dive computer");
diveComputerText->setText(dcText);
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != 0) {
if (haveFilesOnCommandLine() && animSpeedBackup != 0) {
prefs.animation_speed = animSpeedBackup;
}

View file

@ -71,3 +71,8 @@ double get_screen_dpi()
QDesktopWidget *mydesk = qApp->desktop();
return mydesk->physicalDpiX();
}
bool haveFilesOnCommandLine()
{
return false;
}

View file

@ -21,6 +21,8 @@
QTranslator *qtTranslator, *ssrfTranslator;
static bool filesOnCommandLine = false;
int main(int argc, char **argv)
{
int i;
@ -77,7 +79,7 @@ int main(int argc, char **argv)
}
}
MainWindow *m = MainWindow::instance();
m->setLoadedWithFiles(!files.isEmpty() || !importedFiles.isEmpty());
filesOnCommandLine = !files.isEmpty() || !importedFiles.isEmpty();
m->loadFiles(files);
m->importFiles(importedFiles);
// in case something has gone wrong make sure we show the error message
@ -98,3 +100,8 @@ int main(int argc, char **argv)
free_prefs();
return 0;
}
bool haveFilesOnCommandLine()
{
return filesOnCommandLine;
}