mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Continue to separate logic code from UI code
We don't want to call into the MainWindow from C code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e86fd45efd
commit
ccd2cb2502
4 changed files with 17 additions and 9 deletions
|
@ -1731,10 +1731,10 @@ void MainWindow::setApplicationState(const QByteArray& state) {
|
||||||
if (!applicationState.keys().contains(state))
|
if (!applicationState.keys().contains(state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (currentApplicationState == state)
|
if (getCurrentAppState() == state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentApplicationState = state;
|
setCurrentAppState(state);
|
||||||
|
|
||||||
#define SET_CURRENT_INDEX( X ) \
|
#define SET_CURRENT_INDEX( X ) \
|
||||||
if (applicationState[state].X) { \
|
if (applicationState[state].X) { \
|
||||||
|
@ -1762,8 +1762,3 @@ void MainWindow::setApplicationState(const QByteArray& state) {
|
||||||
}
|
}
|
||||||
#undef SET_CURRENT_INDEX
|
#undef SET_CURRENT_INDEX
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::inPlanner()
|
|
||||||
{
|
|
||||||
return (currentApplicationState == "PlanDive" || currentApplicationState == "EditPlannedDive");
|
|
||||||
}
|
|
||||||
|
|
|
@ -243,7 +243,6 @@ private:
|
||||||
QHash<QByteArray, WidgetForQuadrant> applicationState;
|
QHash<QByteArray, WidgetForQuadrant> applicationState;
|
||||||
QHash<QByteArray, PropertiesForQuadrant> stateProperties;
|
QHash<QByteArray, PropertiesForQuadrant> stateProperties;
|
||||||
|
|
||||||
QByteArray currentApplicationState;
|
|
||||||
WindowTitleUpdate *wtu;
|
WindowTitleUpdate *wtu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
14
qthelper.cpp
14
qthelper.cpp
|
@ -1274,7 +1274,19 @@ extern "C" void parse_display_units(char *line)
|
||||||
qDebug() << line;
|
qDebug() << line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QByteArray currentApplicationState;
|
||||||
|
|
||||||
|
QByteArray getCurrentAppState()
|
||||||
|
{
|
||||||
|
return currentApplicationState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCurrentAppState(QByteArray state)
|
||||||
|
{
|
||||||
|
currentApplicationState = state;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" bool in_planner()
|
extern "C" bool in_planner()
|
||||||
{
|
{
|
||||||
return MainWindow::instance()->inPlanner();
|
return (currentApplicationState == "PlanDive" || currentApplicationState == "EditPlannedDive");
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ fraction_t string_to_fraction(const char *str);
|
||||||
int getCloudURL(QString &filename);
|
int getCloudURL(QString &filename);
|
||||||
void loadPreferences();
|
void loadPreferences();
|
||||||
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
||||||
|
QByteArray getCurrentAppState();
|
||||||
|
void setCurrentAppState(QByteArray state);
|
||||||
extern "C" bool in_planner();
|
extern "C" bool in_planner();
|
||||||
|
|
||||||
#endif // QTHELPER_H
|
#endif // QTHELPER_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue