forked from blue/squawk
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
111
main/application.h
Normal file
111
main/application.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
// Squawk messenger.
|
||||
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
//
|
||||
// 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusInterface>
|
||||
|
||||
#include "dialogqueue.h"
|
||||
#include "core/squawk.h"
|
||||
|
||||
#include "ui/squawk.h"
|
||||
#include "ui/models/roster.h"
|
||||
#include "ui/widgets/conversation.h"
|
||||
|
||||
#include "shared/message.h"
|
||||
#include "shared/enums.h"
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class Application : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Application(Core::Squawk* core);
|
||||
~Application();
|
||||
|
||||
bool isConverstationOpened(const Models::Roster::ElId& id) const;
|
||||
|
||||
signals:
|
||||
void sendMessage(const QString& account, const Shared::Message& data);
|
||||
void replaceMessage(const QString& account, const QString& originalId, const Shared::Message& data);
|
||||
void resendMessage(const QString& account, const QString& jid, const QString& id);
|
||||
|
||||
void changeState(Shared::Availability state);
|
||||
|
||||
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||
void subscribeContact(const QString& account, const QString& jid, const QString& reason);
|
||||
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
||||
|
||||
void quitting();
|
||||
void readyToQuit();
|
||||
|
||||
public slots:
|
||||
void readSettings();
|
||||
void quit();
|
||||
|
||||
protected slots:
|
||||
void notify(const QString& account, const Shared::Message& msg);
|
||||
void setState(Shared::Availability availability);
|
||||
|
||||
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
||||
void removeAccount(const QString& account);
|
||||
void openConversation(const Models::Roster::ElId& id, const QString& resource = "");
|
||||
|
||||
void addGroup(const QString& account, const QString& name);
|
||||
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
||||
|
||||
void requestPassword(const QString& account, bool authenticationError);
|
||||
|
||||
void writeSettings();
|
||||
|
||||
private slots:
|
||||
void onConversationClosed();
|
||||
void changeSubscription(const Models::Roster::ElId& id, bool subscribe);
|
||||
void onSquawkOpenedConversation();
|
||||
void onConversationMessage(const Shared::Message& msg);
|
||||
void onConversationReplaceMessage(const QString& originalId, const Shared::Message& msg);
|
||||
void onConversationResend(const QString& id);
|
||||
void stateChanged(Shared::Availability state);
|
||||
void onSquawkClosing();
|
||||
void onSquawkDestroyed();
|
||||
|
||||
private:
|
||||
void createMainWindow();
|
||||
void subscribeConversation(Conversation* conv);
|
||||
void checkForTheLastWindow();
|
||||
|
||||
private:
|
||||
typedef std::map<Models::Roster::ElId, Conversation*> Conversations;
|
||||
|
||||
Shared::Availability availability;
|
||||
Core::Squawk* core;
|
||||
Squawk* squawk;
|
||||
QDBusInterface notifications;
|
||||
Models::Roster roster;
|
||||
Conversations conversations;
|
||||
DialogQueue dialogueQueue;
|
||||
bool nowQuitting;
|
||||
bool destroyingSquawk;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_H
|
Loading…
Add table
Add a link
Reference in a new issue