mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Only anim if not first dive when openning subsurface with a divelog.
The animation appeared when the user started subsurface with a default file, wich was a little annoying since it didn't had a 'from' position to go and it was also increasing it's size on some window managers that do subtle windows animations when a program starts. This patch treats the first dive opened when the program loads with a divelog pa rameter differently as the following ones storing the velocity value on a temporary, and reassigning it later. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b758210c19
commit
9cc942376e
4 changed files with 33 additions and 2 deletions
6
main.cpp
6
main.cpp
|
@ -48,8 +48,10 @@ int main(int argc, char **argv)
|
||||||
files.push_back(QString(prefs.default_filename));
|
files.push_back(QString(prefs.default_filename));
|
||||||
}
|
}
|
||||||
parse_xml_exit();
|
parse_xml_exit();
|
||||||
MainWindow::instance()->loadFiles(files);
|
MainWindow *m = MainWindow::instance();
|
||||||
MainWindow::instance()->importFiles(importedFiles);
|
m->setLoadedWithFiles( !files.isEmpty() || !importedFiles.isEmpty());
|
||||||
|
m->loadFiles(files);
|
||||||
|
m->importFiles(importedFiles);
|
||||||
if (!quit)
|
if (!quit)
|
||||||
run_ui();
|
run_ui();
|
||||||
exit_ui();
|
exit_ui();
|
||||||
|
|
|
@ -85,6 +85,16 @@ MainWindow::~MainWindow()
|
||||||
m_Instance = NULL;
|
m_Instance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setLoadedWithFiles(bool f)
|
||||||
|
{
|
||||||
|
filesAsArguments = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWindow::filesFromCommandLine() const
|
||||||
|
{
|
||||||
|
return filesAsArguments;
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow *MainWindow::instance()
|
MainWindow *MainWindow::instance()
|
||||||
{
|
{
|
||||||
return m_Instance;
|
return m_Instance;
|
||||||
|
|
|
@ -78,6 +78,8 @@ public:
|
||||||
void cleanUpEmpty();
|
void cleanUpEmpty();
|
||||||
void setToolButtonsEnabled(bool enabled);
|
void setToolButtonsEnabled(bool enabled);
|
||||||
ProfileWidget2 *graphics() const;
|
ProfileWidget2 *graphics() const;
|
||||||
|
void setLoadedWithFiles(bool filesFromCommandLine);
|
||||||
|
bool filesFromCommandLine() const;
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
/* file menu action */
|
/* file menu action */
|
||||||
|
@ -165,6 +167,7 @@ private:
|
||||||
void saveSplitterSizes();
|
void saveSplitterSizes();
|
||||||
QString lastUsedDir();
|
QString lastUsedDir();
|
||||||
void updateLastUsedDir(const QString &s);
|
void updateLastUsedDir(const QString &s);
|
||||||
|
bool filesAsArguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow *mainWindow();
|
MainWindow *mainWindow();
|
||||||
|
|
|
@ -316,12 +316,23 @@ void ProfileWidget2::setupSceneAndFlags()
|
||||||
// Currently just one dive, but the plan is to enable All of the selected dives.
|
// Currently just one dive, but the plan is to enable All of the selected dives.
|
||||||
void ProfileWidget2::plotDives(QList<dive *> dives)
|
void ProfileWidget2::plotDives(QList<dive *> dives)
|
||||||
{
|
{
|
||||||
|
static bool firstCall = true;
|
||||||
|
|
||||||
// I Know that it's a list, but currently we are
|
// I Know that it's a list, but currently we are
|
||||||
// using just the first.
|
// using just the first.
|
||||||
struct dive *d = dives.first();
|
struct dive *d = dives.first();
|
||||||
if (!d)
|
if (!d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int animSpeedBackup = -1;
|
||||||
|
if(firstCall && MainWindow::instance()->filesFromCommandLine()){
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup("Animations");
|
||||||
|
animSpeedBackup = s.value("animation_speed",500).toInt();
|
||||||
|
s.setValue("animation_speed",0);
|
||||||
|
firstCall = false;
|
||||||
|
}
|
||||||
|
|
||||||
// restore default zoom level and tooltip position
|
// restore default zoom level and tooltip position
|
||||||
if (zoomLevel) {
|
if (zoomLevel) {
|
||||||
const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel);
|
const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel);
|
||||||
|
@ -431,6 +442,11 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
|
||||||
// qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds;
|
// qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds;
|
||||||
}
|
}
|
||||||
diveComputerText->setText(currentdc->model);
|
diveComputerText->setText(currentdc->model);
|
||||||
|
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1){
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup("Animations");
|
||||||
|
s.setValue("animation_speed",animSpeedBackup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::settingsChanged()
|
void ProfileWidget2::settingsChanged()
|
||||||
|
|
Loading…
Add table
Reference in a new issue