From 7bd43bfaaf5fb444ea766aa90498de3f3b75aaaf Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 4 Oct 2013 12:12:46 -0300 Subject: Fix the first load of Subsurface - "File not found" error. The first time the user loads subsurface, the default_filename is not configured yet, but yet the software tries to load "", sending an error message that this file doesn't exists. Signed-off-by: Tomaz Canabrava Signed-off-by: Taiane Ramos --- main.cpp | 5 +++-- qt-ui/mainwindow.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index a6e39ec53..f12d293d6 100644 --- a/main.cpp +++ b/main.cpp @@ -52,9 +52,10 @@ int main(int argc, char **argv) } } if (no_filenames) { - files.push_back( QString(prefs.default_filename) ); + QString defaultFile(prefs.default_filename); + if (!defaultFile.isEmpty()) + files.push_back( QString(prefs.default_filename) ); } - parse_xml_exit(); subsurface_command_line_exit(&argc, &argv); mainWindow()->loadFiles(files); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 9a26404e2..eda19164d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -748,6 +748,9 @@ void MainWindow::setTitle(enum MainWindowTitleFormat format) void MainWindow::importFiles(const QStringList fileNames) { + if (fileNames.isEmpty()) + return; + QByteArray fileNamePtr; char *error = NULL; for (int i = 0; i < fileNames.size(); ++i) { @@ -771,6 +774,9 @@ void MainWindow::importFiles(const QStringList fileNames) void MainWindow::loadFiles(const QStringList fileNames) { + if (fileNames.isEmpty()) + return; + char *error = NULL; QByteArray fileNamePtr; -- cgit v1.2.3-70-g09d2 From a5b351ed720597ea62ee0254e60e47a4f87ce1d2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 4 Oct 2013 12:28:40 -0300 Subject: Fixed First run of subsurface - Start on Fullscreen. For a new installation, subsurface will now start on fullscreen, this fixes the bug where subsurface would start using the interface file ( mainwindow.ui ) configured size, and that silly monster always changes when editing something. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index eda19164d..af83c21a3 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "divelistview.h" #include "starwidget.h" @@ -503,7 +504,7 @@ void MainWindow::initialUiSetup() int i; settings.beginGroup("MainWindow"); - QSize sz = settings.value("size").value(); + QSize sz = settings.value("size", qApp->desktop()->size()).value(); resize(sz); ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); -- cgit v1.2.3-70-g09d2 From 30bee57b60526dcdf675a0606e72b980a67af17b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 4 Oct 2013 13:17:37 -0300 Subject: Code Cleanup - Uneeded preferences stored at the old prefs setting Those preferences removed ( basically the ones about visibility of the List View of the Table ) are now managed by the Qt Settings system, and thus there's no need to have them there. wich gave us a pretty good cleanup. Signed-off-by: Tomaz Canabrava --- pref.h | 12 ------------ prefs.c | 17 ----------------- qt-ui/mainwindow.cpp | 20 -------------------- subsurfacestartup.c | 1 - 4 files changed, 50 deletions(-) diff --git a/pref.h b/pref.h index 8098c2799..8d181f20a 100644 --- a/pref.h +++ b/pref.h @@ -6,17 +6,6 @@ extern "C" { #endif /* can't use 'bool' for the boolean values - different size in C and C++ */ -typedef struct { - short cylinder; - short temperature; - short totalweight; - short suit; - short nitrox; - short sac; - short otu; - short maxcns; -} visible_cols_t; - typedef struct { short po2; short pn2; @@ -30,7 +19,6 @@ struct preferences { const char *divelist_font; const char *default_filename; double font_size; - visible_cols_t visible_cols; partial_pressure_graphs_t pp_graphs; short mod; double mod_ppO2; diff --git a/prefs.c b/prefs.c index d1073c88f..b2cbea751 100644 --- a/prefs.c +++ b/prefs.c @@ -81,15 +81,6 @@ void save_preferences(void) SAVE_UNIT("fahrenheit", temperature, FAHRENHEIT); SAVE_UNIT("lbs", weight, LBS); - SAVE_BOOL("TEMPERATURE", visible_cols.temperature); - SAVE_BOOL("TOTALWEIGHT", visible_cols.totalweight); - SAVE_BOOL("SUIT", visible_cols.suit); - SAVE_BOOL("CYLINDER", visible_cols.cylinder); - SAVE_BOOL("NITROX", visible_cols.nitrox); - SAVE_BOOL("SAC", visible_cols.sac); - SAVE_BOOL("OTU", visible_cols.otu); - SAVE_BOOL("MAXCNS", visible_cols.maxcns); - SAVE_STRING("divelist_font", divelist_font); SAVE_BOOL("po2graph", pp_graphs.po2); @@ -144,14 +135,6 @@ void load_preferences(void) GET_UNIT("lbs", weight, KG, LBS); /* an unset key is 'default' */ - GET_BOOL("CYLINDER", visible_cols.cylinder); - GET_BOOL("TEMPERATURE", visible_cols.temperature); - GET_BOOL("TOTALWEIGHT", visible_cols.totalweight); - GET_BOOL("SUIT", visible_cols.suit); - GET_BOOL("NITROX", visible_cols.nitrox); - GET_BOOL("OTU", visible_cols.otu); - GET_BOOL("MAXCNS", visible_cols.maxcns); - GET_BOOL("SAC", visible_cols.sac); GET_BOOL("po2graph", pp_graphs.po2); GET_BOOL("pn2graph", pp_graphs.pn2); GET_BOOL("phegraph", pp_graphs.phe); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index af83c21a3..4b296aa14 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -549,16 +549,6 @@ void MainWindow::readSettings() GET_UNIT("weight", weight, units::LBS, units::KG); } s.endGroup(); - s.beginGroup("DisplayListColumns"); - GET_BOOL("CYLINDER", visible_cols.cylinder); - GET_BOOL("TEMPERATURE", visible_cols.temperature); - GET_BOOL("TOTALWEIGHT", visible_cols.totalweight); - GET_BOOL("SUIT", visible_cols.suit); - GET_BOOL("NITROX", visible_cols.nitrox); - GET_BOOL("OTU", visible_cols.otu); - GET_BOOL("MAXCNS", visible_cols.maxcns); - GET_BOOL("SAC", visible_cols.sac); - s.endGroup(); s.beginGroup("TecDetails"); GET_BOOL("po2graph", pp_graphs.po2); GET_BOOL("pn2graph", pp_graphs.pn2); @@ -616,16 +606,6 @@ void MainWindow::writeSettings() SAVE_VALUE("temperature", units.temperature); SAVE_VALUE("weight", units.weight); settings.endGroup(); - settings.beginGroup("DisplayListColumns"); - SAVE_VALUE("TEMPERATURE", visible_cols.temperature); - SAVE_VALUE("TOTALWEIGHT", visible_cols.totalweight); - SAVE_VALUE("SUIT", visible_cols.suit); - SAVE_VALUE("CYLINDER", visible_cols.cylinder); - SAVE_VALUE("NITROX", visible_cols.nitrox); - SAVE_VALUE("SAC", visible_cols.sac); - SAVE_VALUE("OTU", visible_cols.otu); - SAVE_VALUE("MAXCNS", visible_cols.maxcns); - settings.endGroup(); settings.beginGroup("TecDetails"); SAVE_VALUE("po2graph", pp_graphs.po2); SAVE_VALUE("pn2graph", pp_graphs.pn2); diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 954840928..741606ee4 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -6,7 +6,6 @@ struct preferences prefs; struct preferences default_prefs = { .units = SI_UNITS, .unit_system = METRIC, - .visible_cols = { TRUE, FALSE, }, .pp_graphs = { .po2 = FALSE, .pn2 = FALSE, -- cgit v1.2.3-70-g09d2 From 3c97cc5b6aef9dad9b8a9067b8c3e207a67ab314 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 4 Oct 2013 14:28:49 -0300 Subject: Fix showing all columns by default on first run. Some columns are a nice addition, but not a must have, and thus are hidden-by-default, uncluttering the user interface. This was discussed with a few designers before writting the code, and also discussed with dirk on irc. Signed-off-by: Tomaz Canabrava --- qt-ui/divelistview.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 0996130c4..6ed77fb19 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -192,7 +192,16 @@ void DiveListView::reloadHeaderActions() QString title = QString("%1").arg(model()->headerData(i, Qt::Horizontal).toString()); QString settingName = QString("showColumn%1").arg(i); QAction *a = new QAction(title, header()); - bool shown = s.value(settingName, true).toBool(); + bool showHeaderFirstRun = !( + i == DiveTripModel::MAXCNS + || i == DiveTripModel::NITROX + || i == DiveTripModel::OTU + || i == DiveTripModel::TEMPERATURE + || i == DiveTripModel::TOTALWEIGHT + || i == DiveTripModel::SUIT + || i == DiveTripModel::CYLINDER + || i == DiveTripModel::SAC ); + bool shown = s.value(settingName, showHeaderFirstRun).toBool(); a->setCheckable(true); a->setChecked(shown); a->setProperty("index", i); -- cgit v1.2.3-70-g09d2 From 834800a1794f1ed92f447a2995767ce820473fed Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 4 Oct 2013 15:07:36 -0300 Subject: Fix display sane values on subsurface at first time opening. This patch fixes some unsane values that was being retrieved by the ui-files on first time opening. it creates a basic layout of the application using the current desktop size. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 4b296aa14..bbacc74a1 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -506,9 +506,28 @@ void MainWindow::initialUiSetup() settings.beginGroup("MainWindow"); QSize sz = settings.value("size", qApp->desktop()->size()).value(); resize(sz); - ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); - ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); - ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray()); + + if (settings.value("mainSplitter").isValid()){ + ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); + ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); + ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray()); + } else { + QList mainSizes; + mainSizes.append( qApp->desktop()->size().height() * 0.7 ); + mainSizes.append( qApp->desktop()->size().height() * 0.3 ); + ui.mainSplitter->setSizes( mainSizes ); + + QList infoProfileSizes; + infoProfileSizes.append( qApp->desktop()->size().width() * 0.3 ); + infoProfileSizes.append( qApp->desktop()->size().width() * 0.7 ); + ui.infoProfileSplitter->setSizes(infoProfileSizes); + + QList listGlobeSizes; + listGlobeSizes.append( qApp->desktop()->size().width() * 0.7 ); + listGlobeSizes.append( qApp->desktop()->size().width() * 0.3 ); + ui.listGlobeSplitter->setSizes(listGlobeSizes); + } + settings.endGroup(); settings.beginGroup("ListWidget"); -- cgit v1.2.3-70-g09d2