refactoring: UI squawk now belongs to a new class, it enables me doing trayed mode, when main window is destroyed
This commit is contained in:
parent
83cb220175
commit
721d3a1a89
16 changed files with 908 additions and 769 deletions
|
@ -95,8 +95,6 @@ Shared::Global::Global():
|
|||
}),
|
||||
defaultSystemStyle(QApplication::style()->objectName()),
|
||||
defaultSystemPalette(QApplication::palette()),
|
||||
rosterModel(new Models::Roster()),
|
||||
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()),
|
||||
pluginSupport({
|
||||
{"KWallet", false},
|
||||
{"openFileManagerWindowJob", false},
|
||||
|
@ -352,44 +350,6 @@ void Shared::Global::setStyle(const QString& style)
|
|||
}
|
||||
}
|
||||
|
||||
void Shared::Global::notify(const QString& account, const Shared::Message& msg)
|
||||
{
|
||||
QString name = QString(instance->rosterModel->getContactName(account, msg.getPenPalJid()));
|
||||
QString path = QString(instance->rosterModel->getContactIconPath(account, msg.getPenPalJid(), msg.getPenPalResource()));
|
||||
QVariantList args;
|
||||
args << QString();
|
||||
|
||||
args << qHash(msg.getId());
|
||||
if (path.size() > 0) {
|
||||
args << path;
|
||||
} else {
|
||||
args << QString("mail-message"); //TODO should here better be unknown user icon?
|
||||
}
|
||||
if (msg.getType() == Shared::Message::groupChat) {
|
||||
args << msg.getFromResource() + " from " + name;
|
||||
} else {
|
||||
args << name;
|
||||
}
|
||||
|
||||
QString body(msg.getBody());
|
||||
QString oob(msg.getOutOfBandUrl());
|
||||
if (body == oob) {
|
||||
body = tr("Attached file");
|
||||
}
|
||||
|
||||
args << body;
|
||||
args << QStringList();
|
||||
args << QVariantMap({
|
||||
{"desktop-entry", QString(QCoreApplication::applicationName())},
|
||||
{"category", QString("message")},
|
||||
// {"sound-file", "/path/to/macaw/squawk"},
|
||||
{"sound-name", QString("message-new-instant")}
|
||||
});
|
||||
args << -1;
|
||||
instance->dbus.callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
||||
}
|
||||
|
||||
|
||||
#define FROM_INT_INPL(Enum) \
|
||||
template<> \
|
||||
Enum Shared::Global::fromInt(int src) \
|
||||
|
|
|
@ -42,18 +42,11 @@
|
|||
#include <QProcess>
|
||||
#include <QDesktopServices>
|
||||
#include <QRegularExpression>
|
||||
#include <QDBusInterface>
|
||||
|
||||
class Squawk;
|
||||
namespace Models {
|
||||
class Roster;
|
||||
}
|
||||
|
||||
namespace Shared {
|
||||
|
||||
class Global {
|
||||
Q_DECLARE_TR_FUNCTIONS(Global)
|
||||
friend class ::Squawk;
|
||||
public:
|
||||
struct FileInfo {
|
||||
enum class Preview {
|
||||
|
@ -71,8 +64,6 @@ namespace Shared {
|
|||
|
||||
Global();
|
||||
|
||||
static void notify(const QString& account, const Shared::Message& msg);
|
||||
|
||||
static Global* getInstance();
|
||||
static QString getName(Availability av);
|
||||
static QString getName(ConnectionState cs);
|
||||
|
@ -130,8 +121,6 @@ namespace Shared {
|
|||
|
||||
private:
|
||||
static Global* instance;
|
||||
Models::Roster* rosterModel;
|
||||
QDBusInterface dbus;
|
||||
|
||||
std::map<QString, bool> pluginSupport;
|
||||
std::map<QString, FileInfo> fileCache;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue