squawk/ui/squawk.h

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 <QString>
#include <QInputDialog>
#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/info/info.h"
#include "widgets/settings/settings.h"
#include "widgets/about.h"
#include "shared/shared.h"
#include "shared/global.h"
#include "shared/info.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 quit();
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 requestInfo(const QString& account, const QString& jid);
void updateInfo(const QString& account, const Shared::Info& info);
void changeDownloadsPath(const QString& path);
void changeTray(bool enabled, bool hide);
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>&);
void itemExpanded (const QModelIndex& index);
void itemCollapsed (const QModelIndex& index);
public:
Models::Roster::ElId currentConversationId() const;
void closeCurrentConversation();
public slots:
void writeSettings();
void stateChanged(Shared::Availability state);
void responseInfo(const Shared::Info& info);
void select(QModelIndex index);
private:
QScopedPointer<Ui::Squawk> m_ui;
Accounts* accounts;
Settings* preferences;
About* about;
Models::Roster& rosterModel;
QMenu* contextMenu;
std::map<QString, UI::Info*> infoWidgets;
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 onAccountsChanged();
void onAccountsClosed();
void onPreferencesClosed();
void onInfoClosed();
void onInfoSave(const Shared::Info& info, const QString& account);
void onActivateInfo(const QString& account, const QString& jid);
void onComboboxActivated(int index);
void onRosterItemDoubleClicked(const QModelIndex& item);
void onRosterContextMenu(const QPoint& point);
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
void onContextAboutToHide();
void onAboutSquawkCalled();
void onAboutSquawkClosed();
};
#endif // SQUAWK_H