mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:43:25 +00:00
Cleanup: Make WindowsTitleUpdate a global object
WindowsTitleUpdate is such a trivial object (a QObject with a single signal and no own state), that it's not really understandable why it would need all that "singleton" boiler-plate. Just make it a default constructed/destructed global object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4bdd811f06
commit
7fe76a5dbd
5 changed files with 5 additions and 39 deletions
|
@ -1,33 +1,9 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "windowtitleupdate.h"
|
#include "windowtitleupdate.h"
|
||||||
|
|
||||||
WindowTitleUpdate *WindowTitleUpdate::m_instance = NULL;
|
WindowTitleUpdate windowTitleUpdate;
|
||||||
|
|
||||||
WindowTitleUpdate::WindowTitleUpdate(QObject *parent) : QObject(parent)
|
|
||||||
{
|
|
||||||
Q_ASSERT_X(m_instance == NULL, "WindowTitleUpdate", "WindowTitleUpdate recreated!");
|
|
||||||
|
|
||||||
m_instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowTitleUpdate *WindowTitleUpdate::instance()
|
|
||||||
{
|
|
||||||
return m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowTitleUpdate::~WindowTitleUpdate()
|
|
||||||
{
|
|
||||||
m_instance = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowTitleUpdate::emitSignal()
|
|
||||||
{
|
|
||||||
emit updateTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void updateWindowTitle()
|
extern "C" void updateWindowTitle()
|
||||||
{
|
{
|
||||||
WindowTitleUpdate *wt = WindowTitleUpdate::instance();
|
emit windowTitleUpdate.updateTitle();
|
||||||
if (wt)
|
|
||||||
wt->emitSignal();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,10 @@
|
||||||
class WindowTitleUpdate : public QObject
|
class WindowTitleUpdate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
explicit WindowTitleUpdate(QObject *parent = 0);
|
|
||||||
~WindowTitleUpdate();
|
|
||||||
static WindowTitleUpdate *instance();
|
|
||||||
void emitSignal();
|
|
||||||
signals:
|
signals:
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
private:
|
|
||||||
static WindowTitleUpdate *m_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern WindowTitleUpdate windowTitleUpdate;
|
||||||
|
|
||||||
#endif // WINDOWTITLEUPDATE_H
|
#endif // WINDOWTITLEUPDATE_H
|
||||||
|
|
|
@ -218,8 +218,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), mapWidget, SLOT(centerOnDiveSite(struct dive_site *)));
|
connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), mapWidget, SLOT(centerOnDiveSite(struct dive_site *)));
|
||||||
connect(this, &MainWindow::showError, ui.mainErrorMessage, &NotificationWidget::showError, Qt::AutoConnection);
|
connect(this, &MainWindow::showError, ui.mainErrorMessage, &NotificationWidget::showError, Qt::AutoConnection);
|
||||||
|
|
||||||
wtu = new WindowTitleUpdate();
|
connect(&windowTitleUpdate, &WindowTitleUpdate::updateTitle, this, &MainWindow::setAutomaticTitle);
|
||||||
connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle()));
|
|
||||||
#ifdef NO_PRINTING
|
#ifdef NO_PRINTING
|
||||||
plannerDetails->printPlan()->hide();
|
plannerDetails->printPlan()->hide();
|
||||||
ui.menuFile->removeAction(ui.actionPrint);
|
ui.menuFile->removeAction(ui.actionPrint);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "ui_plannerDetails.h"
|
#include "ui_plannerDetails.h"
|
||||||
#include "desktop-widgets/notificationwidget.h"
|
#include "desktop-widgets/notificationwidget.h"
|
||||||
#include "core/windowtitleupdate.h"
|
|
||||||
#include "core/gpslocation.h"
|
#include "core/gpslocation.h"
|
||||||
|
|
||||||
#define NUM_RECENT_FILES 4
|
#define NUM_RECENT_FILES 4
|
||||||
|
@ -253,7 +252,6 @@ private:
|
||||||
QHash<QByteArray, WidgetForQuadrant> applicationState;
|
QHash<QByteArray, WidgetForQuadrant> applicationState;
|
||||||
QHash<QByteArray, PropertiesForQuadrant> stateProperties;
|
QHash<QByteArray, PropertiesForQuadrant> stateProperties;
|
||||||
|
|
||||||
WindowTitleUpdate *wtu;
|
|
||||||
GpsLocation *locationProvider;
|
GpsLocation *locationProvider;
|
||||||
QMenu *connections;
|
QMenu *connections;
|
||||||
QAction *share_on_fb;
|
QAction *share_on_fb;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "git2.h"
|
#include "git2.h"
|
||||||
#include "core/subsurfacestartup.h"
|
#include "core/subsurfacestartup.h"
|
||||||
#include "core/divelogexportlogic.h"
|
#include "core/divelogexportlogic.h"
|
||||||
#include "core/windowtitleupdate.h"
|
|
||||||
#include "core/statistics.h"
|
#include "core/statistics.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -42,7 +41,6 @@ int main(int argc, char **argv)
|
||||||
qDebug() << "need --source and --output";
|
qDebug() << "need --source and --output";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
WindowTitleUpdate *wtu = new WindowTitleUpdate();
|
|
||||||
int ret = parse_file(qPrintable(source));
|
int ret = parse_file(qPrintable(source));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf(stderr, "parse_file returned %d\n", ret);
|
fprintf(stderr, "parse_file returned %d\n", ret);
|
||||||
|
|
Loading…
Add table
Reference in a new issue