Commit 2a694024 authored by Laurent Montel's avatar Laurent Montel 😁

Move broadcaststatus from libkdepim

parent 2dfa6198
Pipeline #23287 passed with stage
in 9 minutes and 15 seconds
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.14.42")
set(PIM_VERSION "5.14.43")
project(pimcommon VERSION ${PIM_VERSION})
......
......@@ -91,6 +91,7 @@ set(libpimcommon_customtools_SRCS
set(libpimcommon_util_SRCS
util/pimutil.cpp
util/broadcaststatus.cpp
)
set(libpimcommon_migrate_SRCS
......@@ -237,6 +238,7 @@ ecm_generate_headers(PimCommon_CamelCasenetworkmanager_HEADERS
ecm_generate_headers(PimCommon_CamelCase_HEADERS
HEADER_NAMES
PimUtil
BroadcastStatus
REQUIRED_HEADERS PimCommon_HEADERS
PREFIX PimCommon
RELATIVE util
......
/*
broadcaststatus.cpp
This file is part of libkdepim.
Author: Don Sanders <sanders@kde.org>
Copyright (C) 2000 Don Sanders <sanders@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "broadcaststatus.h"
#include <QCoreApplication>
static PimCommon::BroadcastStatus *instance_;
static void deleteGlobalStaticBroadcastStatus()
{
delete instance_;
instance_ = nullptr;
}
namespace PimCommon {
BroadcastStatus *BroadcastStatus::instance()
{
if (!instance_) {
instance_ = new BroadcastStatus();
qAddPostRoutine(deleteGlobalStaticBroadcastStatus);
}
return instance_;
}
class BroadcastStatusPrivate
{
public:
BroadcastStatusPrivate()
{
}
QString mStatusMsg;
bool mTransientActive = false;
};
BroadcastStatus::BroadcastStatus()
: d(new PimCommon::BroadcastStatusPrivate)
{
}
BroadcastStatus::~BroadcastStatus()
{
instance_ = nullptr;
delete d;
}
void BroadcastStatus::setStatusMsg(const QString &message)
{
d->mStatusMsg = message;
if (!d->mTransientActive) {
Q_EMIT statusMsg(message);
}
}
void BroadcastStatus::setTransientStatusMsg(const QString &msg)
{
d->mTransientActive = true;
Q_EMIT statusMsg(msg);
}
void BroadcastStatus::reset()
{
d->mTransientActive = false;
// restore
Q_EMIT statusMsg(d->mStatusMsg);
}
}
/*
broadcaststatus.h
This file is part of libkdepim.
Copyright (C) 2000 Don Sanders <sanders@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PIMCOMMON_BROADCASTSTATUS_H
#define PIMCOMMON_BROADCASTSTATUS_H
#include "pimcommon_export.h"
#include <QObject>
#undef None
namespace PimCommon {
/**
Provides a singleton which broadcasts status messages by emitting
signals. Interested mainwindows can connect to the statusMsg()
signal and update statusBars or whatever they use for showing status.
*/
class BroadcastStatusPrivate;
class PIMCOMMON_EXPORT BroadcastStatus : public QObject
{
Q_OBJECT
public:
~BroadcastStatus() override;
/** Return the instance of the singleton object for this class */
static BroadcastStatus *instance();
public Q_SLOTS:
/**
Emit an update status bar signal. It's a slot so it can be hooked up
to other signals.
*/
void setStatusMsg(const QString &message);
/**
Set a status message that will go away again with the next call of
reset().
*/
void setTransientStatusMsg(const QString &msg);
/**
Reset the status message to what ever non-transient message was last
active or has since been set.
*/
void reset();
Q_SIGNALS:
/** Emitted when setStatusMsg is called. */
void statusMsg(const QString &);
protected:
BroadcastStatus();
BroadcastStatusPrivate *const d;
};
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment