mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove the PlannerWidget from mainwindow.ui
Now it uses the states on the mainwindow.cpp and it's finally starting to be worth the hassle of reworking the UI. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
238c0573da
commit
2992d78f83
3 changed files with 21 additions and 50 deletions
|
@ -63,7 +63,9 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
|
|
||||||
registerApplicationState("Default", mainTab, diveListView, profileWidget, globeGps );
|
registerApplicationState("Default", mainTab, diveListView, profileWidget, globeGps );
|
||||||
registerApplicationState("AddDive", mainTab, diveListView, profileWidget, globeGps );
|
registerApplicationState("AddDive", mainTab, diveListView, profileWidget, globeGps );
|
||||||
|
registerApplicationState("EditDive", mainTab, diveListView, profileWidget, globeGps );
|
||||||
registerApplicationState("PlanDive", plannerWidget, plannerSettings, profileWidget, plannerDetails );
|
registerApplicationState("PlanDive", plannerWidget, plannerSettings, profileWidget, plannerDetails );
|
||||||
|
registerApplicationState("EditPlannedDive", plannerWidget, diveListView, profileWidget, globeGps );
|
||||||
|
|
||||||
ui.multiFilter->hide();
|
ui.multiFilter->hide();
|
||||||
// what is a sane order for those icons? we should have the ones the user is
|
// what is a sane order for those icons? we should have the ones the user is
|
||||||
|
@ -87,7 +89,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget(), SLOT(settingsChanged()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.plannerSettingsWidget, SLOT(settingsChanged()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.plannerSettingsWidget, SLOT(settingsChanged()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
|
||||||
connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
|
connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
|
||||||
|
@ -97,7 +99,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState()));
|
connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState()));
|
||||||
connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
|
connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
|
||||||
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
|
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
|
||||||
connect(ui.printPlan, SIGNAL(pressed()), ui.divePlannerWidget, SLOT(printDecoPlan()));
|
connect(ui.printPlan, SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
|
||||||
connect(ui.menu_Edit, SIGNAL(aboutToShow()), this, SLOT(checkForUndoAndRedo()));
|
connect(ui.menu_Edit, SIGNAL(aboutToShow()), this, SLOT(checkForUndoAndRedo()));
|
||||||
#ifdef NO_PRINTING
|
#ifdef NO_PRINTING
|
||||||
ui.printPlan->hide();
|
ui.printPlan->hide();
|
||||||
|
@ -114,7 +116,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
globe()->reload();
|
globe()->reload();
|
||||||
diveListView->expand(dive_list()->model()->index(0, 0));
|
diveListView->expand(dive_list()->model()->index(0, 0));
|
||||||
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
||||||
ui.divePlannerWidget->settingsChanged();
|
divePlannerWidget()->settingsChanged();
|
||||||
ui.plannerSettingsWidget->settingsChanged();
|
ui.plannerSettingsWidget->settingsChanged();
|
||||||
#ifdef NO_MARBLE
|
#ifdef NO_MARBLE
|
||||||
ui.globePane->hide();
|
ui.globePane->hide();
|
||||||
|
@ -385,7 +387,7 @@ void MainWindow::showProfile()
|
||||||
{
|
{
|
||||||
enableShortcuts();
|
enableShortcuts();
|
||||||
ui.newProfile->setProfileState();
|
ui.newProfile->setProfileState();
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
setApplicationState("Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPreferences_triggered()
|
void MainWindow::on_actionPreferences_triggered()
|
||||||
|
@ -527,8 +529,8 @@ void MainWindow::on_actionReplanDive_triggered()
|
||||||
|
|
||||||
ui.newProfile->setPlanState();
|
ui.newProfile->setPlanState();
|
||||||
ui.newProfile->clearHandlers();
|
ui.newProfile->clearHandlers();
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
setApplicationState("PlanDive");
|
||||||
ui.divePlannerWidget->setReplanButton(true);
|
divePlannerWidget()->setReplanButton(true);
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
||||||
reset_cylinders(&displayed_dive, true);
|
reset_cylinders(&displayed_dive, true);
|
||||||
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
||||||
|
@ -545,16 +547,16 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
|
|
||||||
// put us in PLAN mode
|
// put us in PLAN mode
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
|
setApplicationState("PlanDive");
|
||||||
|
|
||||||
ui.newProfile->setPlanState();
|
ui.newProfile->setPlanState();
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
|
||||||
|
|
||||||
// create a simple starting dive, using the first gas from the just copied cylidners
|
// create a simple starting dive, using the first gas from the just copied cylidners
|
||||||
setupForAddAndPlan("planned dive"); // don't translate, stored in XML file
|
setupForAddAndPlan("planned dive"); // don't translate, stored in XML file
|
||||||
DivePlannerPointsModel::instance()->setupStartTime();
|
DivePlannerPointsModel::instance()->setupStartTime();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||||
DivePictureModel::instance()->updateDivePictures();
|
DivePictureModel::instance()->updateDivePictures();
|
||||||
ui.divePlannerWidget->setReplanButton(false);
|
divePlannerWidget()->setReplanButton(false);
|
||||||
|
|
||||||
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
||||||
ui.globePane->setCurrentIndex(1);
|
ui.globePane->setCurrentIndex(1);
|
||||||
|
@ -563,6 +565,10 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivePlannerWidget* MainWindow::divePlannerWidget() {
|
||||||
|
return qobject_cast<DivePlannerWidget*>(applicationState["PlanDive"].topLeft);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionAddDive_triggered()
|
void MainWindow::on_actionAddDive_triggered()
|
||||||
{
|
{
|
||||||
if (!plannerStateClean())
|
if (!plannerStateClean())
|
||||||
|
@ -573,6 +579,7 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
dive_list()->clearSelection();
|
dive_list()->clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setApplicationState("AddDive");
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
|
|
||||||
// setup things so we can later create our starting dive
|
// setup things so we can later create our starting dive
|
||||||
|
@ -585,7 +592,6 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
information()->setCurrentIndex(0);
|
information()->setCurrentIndex(0);
|
||||||
|
|
||||||
information()->addDiveStarted();
|
information()->addDiveStarted();
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
|
||||||
|
|
||||||
ui.newProfile->setAddState();
|
ui.newProfile->setAddState();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||||
|
@ -1391,17 +1397,13 @@ void MainWindow::editCurrentDive()
|
||||||
disableShortcuts();
|
disableShortcuts();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
ui.newProfile->setAddState();
|
ui.newProfile->setAddState();
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
setApplicationState("EditDive");
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(d);
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
||||||
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||||
} else if (defaultDC == "planned dive") {
|
} else if (defaultDC == "planned dive") {
|
||||||
disableShortcuts();
|
disableShortcuts();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
//TODO: I BROKE THIS BY COMMENTING THE LINE BELOW
|
setApplicationState("EditPlannedDive");
|
||||||
// and I'm sleepy now, so I think I should not try to fix right away.
|
|
||||||
// we don't setCurrentIndex anymore, we ->setPlanState() or ->setAddState() on the ProfileView.
|
|
||||||
//ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
|
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
|
||||||
DivePlannerPointsModel::instance()->loadFromDive(d);
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
||||||
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||||
}
|
}
|
||||||
|
@ -1515,16 +1517,15 @@ void MainWindow::setApplicationState(const QByteArray& state) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// yes, index is zero both times. please don't change it.
|
// yes, index is zero both times. please don't change it.
|
||||||
if (ui.topSplitter->count()) {
|
if (ui.topSplitter->count() >= 2) {
|
||||||
ui.topSplitter->widget(0)->setParent(NULL);
|
ui.topSplitter->widget(0)->setParent(NULL);
|
||||||
ui.topSplitter->widget(0)->setParent(NULL);
|
ui.topSplitter->widget(0)->setParent(NULL);
|
||||||
}
|
}
|
||||||
if (ui.bottomSplitter->count()) {
|
if (ui.bottomSplitter->count() >= 2) {
|
||||||
ui.bottomSplitter->widget(0)->setParent(NULL);
|
ui.bottomSplitter->widget(0)->setParent(NULL);
|
||||||
ui.bottomSplitter->widget(0)->setParent(NULL);
|
ui.bottomSplitter->widget(0)->setParent(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WidgetForBorder curr = applicationState[state];
|
WidgetForBorder curr = applicationState[state];
|
||||||
ui.topSplitter->addWidget(curr.topLeft);
|
ui.topSplitter->addWidget(curr.topLeft);
|
||||||
ui.topSplitter->addWidget(curr.topRight);
|
ui.topSplitter->addWidget(curr.topRight);
|
||||||
|
|
|
@ -30,6 +30,7 @@ class QWebView;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class UpdateManager;
|
class UpdateManager;
|
||||||
class UserManual;
|
class UserManual;
|
||||||
|
class DivePlannerWidget;
|
||||||
class UndoBuffer;
|
class UndoBuffer;
|
||||||
|
|
||||||
enum MainWindowTitleFormat {
|
enum MainWindowTitleFormat {
|
||||||
|
@ -65,6 +66,7 @@ public:
|
||||||
void removeRecentFile(QStringList failedFiles);
|
void removeRecentFile(QStringList failedFiles);
|
||||||
DiveListView *dive_list();
|
DiveListView *dive_list();
|
||||||
GlobeGPS *globe();
|
GlobeGPS *globe();
|
||||||
|
DivePlannerWidget *divePlannerWidget();
|
||||||
void showError(QString message);
|
void showError(QString message);
|
||||||
void setTitle(enum MainWindowTitleFormat format);
|
void setTitle(enum MainWindowTitleFormat format);
|
||||||
|
|
||||||
|
|
|
@ -27,32 +27,6 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QStackedWidget" name="infoPane">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="page">
|
|
||||||
<layout class="QHBoxLayout" name="mainTabOuterLayout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="page_2">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="divePlannerLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="DivePlannerWidget" name="divePlannerWidget" native="true">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="ProfileWidget">
|
<widget class="QWidget" name="ProfileWidget">
|
||||||
<layout class="QGridLayout" name="profileInnerLayout">
|
<layout class="QGridLayout" name="profileInnerLayout">
|
||||||
<item row="0" column="0" rowspan="3">
|
<item row="0" column="0" rowspan="3">
|
||||||
|
@ -830,12 +804,6 @@ p, li { white-space: pre-wrap; }
|
||||||
<header>kmessagewidget.h</header>
|
<header>kmessagewidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>DivePlannerWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>diveplanner.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>ProfileWidget2</class>
|
<class>ProfileWidget2</class>
|
||||||
<extends>QGraphicsView</extends>
|
<extends>QGraphicsView</extends>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue