forked from blue/squawk
140 lines
4.7 KiB
C++
140 lines
4.7 KiB
C++
/*
|
|
* 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 SQUAWK_H
|
|
#define SQUAWK_H
|
|
|
|
#include <QMainWindow>
|
|
#include <QScopedPointer>
|
|
#include <QCloseEvent>
|
|
#include <QSettings>
|
|
#include <QInputDialog>
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <deque>
|
|
#include <map>
|
|
#include <set>
|
|
#include <list>
|
|
|
|
#include "widgets/accounts/accounts.h"
|
|
#include "widgets/chat.h"
|
|
#include "widgets/room.h"
|
|
#include "widgets/newcontact.h"
|
|
#include "widgets/joinconference.h"
|
|
#include "models/roster.h"
|
|
#include "widgets/vcard/vcard.h"
|
|
#include "widgets/settings/settings.h"
|
|
#include "widgets/about.h"
|
|
|
|
#include "shared/shared.h"
|
|
#include "shared/global.h"
|
|
|
|
namespace Ui {
|
|
class Squawk;
|
|
}
|
|
|
|
class Application;
|
|
|
|
class Squawk : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
friend class Application;
|
|
public:
|
|
explicit Squawk(Models::Roster& rosterModel, QWidget *parent = nullptr);
|
|
~Squawk() override;
|
|
|
|
signals:
|
|
void closing();
|
|
void newAccountRequest(const QMap<QString, QVariant>&);
|
|
void removeAccountRequest(const QString&);
|
|
void connectAccount(const QString&);
|
|
void disconnectAccount(const QString&);
|
|
void changeState(Shared::Availability state);
|
|
void removeContactRequest(const QString& account, const QString& jid);
|
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
|
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
|
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
|
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
|
void addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin);
|
|
void removeRoomRequest(const QString& account, const QString& jid);
|
|
void requestVCard(const QString& account, const QString& jid);
|
|
void uploadVCard(const QString& account, const Shared::VCard& card);
|
|
void changeDownloadsPath(const QString& path);
|
|
|
|
void notify(const QString& account, const Shared::Message& msg);
|
|
void changeSubscription(const Models::Roster::ElId& id, bool subscribe);
|
|
void openedConversation();
|
|
void openConversation(const Models::Roster::ElId& id, const QString& resource = "");
|
|
|
|
void modifyAccountRequest(const QString&, const QMap<QString, QVariant>&);
|
|
|
|
public:
|
|
Models::Roster::ElId currentConversationId() const;
|
|
void closeCurrentConversation();
|
|
static QSystemTrayIcon *trayIcon;
|
|
|
|
public slots:
|
|
void writeSettings();
|
|
void stateChanged(Shared::Availability state);
|
|
void responseVCard(const QString& jid, const Shared::VCard& card);
|
|
void select(QModelIndex index);
|
|
|
|
private:
|
|
void createTrayIcon();
|
|
|
|
QScopedPointer<Ui::Squawk> m_ui;
|
|
|
|
Accounts* accounts;
|
|
Settings* preferences;
|
|
About* about;
|
|
Models::Roster& rosterModel;
|
|
QMenu* contextMenu;
|
|
std::map<QString, VCard*> vCards;
|
|
Conversation* currentConversation;
|
|
QModelIndex restoreSelection;
|
|
bool needToRestore;
|
|
|
|
protected:
|
|
void closeEvent(QCloseEvent * event) override;
|
|
void expand(const QModelIndex& index);
|
|
|
|
private slots:
|
|
void onAccounts();
|
|
void onPreferences();
|
|
void onNewContact();
|
|
void onNewConference();
|
|
void onNewContactAccepted();
|
|
void onJoinConferenceAccepted();
|
|
void onAccountsSizeChanged(unsigned int size);
|
|
void onAccountsClosed();
|
|
void onPreferencesClosed();
|
|
void onVCardClosed();
|
|
void onVCardSave(const Shared::VCard& card, const QString& account);
|
|
void onActivateVCard(const QString& account, const QString& jid, bool edition = false);
|
|
void onComboboxActivated(int index);
|
|
void onRosterItemDoubleClicked(const QModelIndex& item);
|
|
void onRosterContextMenu(const QPoint& point);
|
|
void onItemCollepsed(const QModelIndex& index);
|
|
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
|
|
void onContextAboutToHide();
|
|
void onAboutSquawkCalled();
|
|
void onAboutSquawkClosed();
|
|
};
|
|
|
|
#endif // SQUAWK_H
|