mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 19:53:24 +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
|
||||
#include "windowtitleupdate.h"
|
||||
|
||||
WindowTitleUpdate *WindowTitleUpdate::m_instance = NULL;
|
||||
|
||||
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();
|
||||
}
|
||||
WindowTitleUpdate windowTitleUpdate;
|
||||
|
||||
extern "C" void updateWindowTitle()
|
||||
{
|
||||
WindowTitleUpdate *wt = WindowTitleUpdate::instance();
|
||||
if (wt)
|
||||
wt->emitSignal();
|
||||
emit windowTitleUpdate.updateTitle();
|
||||
}
|
||||
|
|
|
@ -7,15 +7,10 @@
|
|||
class WindowTitleUpdate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WindowTitleUpdate(QObject *parent = 0);
|
||||
~WindowTitleUpdate();
|
||||
static WindowTitleUpdate *instance();
|
||||
void emitSignal();
|
||||
signals:
|
||||
void updateTitle();
|
||||
private:
|
||||
static WindowTitleUpdate *m_instance;
|
||||
};
|
||||
|
||||
extern WindowTitleUpdate windowTitleUpdate;
|
||||
|
||||
#endif // WINDOWTITLEUPDATE_H
|
||||
|
|
|
@ -218,8 +218,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
|||
connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), mapWidget, SLOT(centerOnDiveSite(struct dive_site *)));
|
||||
connect(this, &MainWindow::showError, ui.mainErrorMessage, &NotificationWidget::showError, Qt::AutoConnection);
|
||||
|
||||
wtu = new WindowTitleUpdate();
|
||||
connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle()));
|
||||
connect(&windowTitleUpdate, &WindowTitleUpdate::updateTitle, this, &MainWindow::setAutomaticTitle);
|
||||
#ifdef NO_PRINTING
|
||||
plannerDetails->printPlan()->hide();
|
||||
ui.menuFile->removeAction(ui.actionPrint);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include "ui_plannerDetails.h"
|
||||
#include "desktop-widgets/notificationwidget.h"
|
||||
#include "core/windowtitleupdate.h"
|
||||
#include "core/gpslocation.h"
|
||||
|
||||
#define NUM_RECENT_FILES 4
|
||||
|
@ -253,7 +252,6 @@ private:
|
|||
QHash<QByteArray, WidgetForQuadrant> applicationState;
|
||||
QHash<QByteArray, PropertiesForQuadrant> stateProperties;
|
||||
|
||||
WindowTitleUpdate *wtu;
|
||||
GpsLocation *locationProvider;
|
||||
QMenu *connections;
|
||||
QAction *share_on_fb;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "git2.h"
|
||||
#include "core/subsurfacestartup.h"
|
||||
#include "core/divelogexportlogic.h"
|
||||
#include "core/windowtitleupdate.h"
|
||||
#include "core/statistics.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -42,7 +41,6 @@ int main(int argc, char **argv)
|
|||
qDebug() << "need --source and --output";
|
||||
exit(1);
|
||||
}
|
||||
WindowTitleUpdate *wtu = new WindowTitleUpdate();
|
||||
int ret = parse_file(qPrintable(source));
|
||||
if (ret) {
|
||||
fprintf(stderr, "parse_file returned %d\n", ret);
|
||||
|
|
Loading…
Add table
Reference in a new issue