squawk/ui/squawk.h

140 lines
4.7 KiB
C
Raw Normal View History

/*
* 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/>.
*/
2019-03-29 14:54:34 +00:00
#ifndef SQUAWK_H
#define SQUAWK_H
#include <QMainWindow>
#include <QScopedPointer>
#include <QCloseEvent>
#include <QSettings>
#include <QInputDialog>
2019-03-30 20:13:13 +00:00
#include <deque>
2019-04-02 15:46:18 +00:00
#include <map>
#include <set>
#include <list>
2019-03-29 14:54:34 +00:00
2022-04-11 15:45:12 +00:00
#include "widgets/accounts/accounts.h"
#include "widgets/chat.h"
2019-08-28 11:40:55 +00:00
#include "widgets/room.h"
2019-09-04 16:38:52 +00:00
#include "widgets/newcontact.h"
#include "widgets/joinconference.h"
#include "models/roster.h"
#include "widgets/info/info.h"
2022-01-16 19:54:57 +00:00
#include "widgets/settings/settings.h"
2022-04-03 20:53:46 +00:00
#include "widgets/about.h"
2021-05-11 17:29:08 +00:00
#include "shared/shared.h"
2022-04-18 16:54:42 +00:00
#include "shared/global.h"
#include "shared/info.h"
2019-03-29 14:54:34 +00:00
namespace Ui {
class Squawk;
}
class Application;
2019-03-29 14:54:34 +00:00
class Squawk : public QMainWindow
{
Q_OBJECT
friend class Application;
2019-03-29 14:54:34 +00:00
public:
explicit Squawk(Models::Roster& rosterModel, QWidget *parent = nullptr);
2019-03-29 14:54:34 +00:00
~Squawk() override;
2019-03-30 20:13:13 +00:00
signals:
void closing();
void quit();
2019-03-30 20:13:13 +00:00
void newAccountRequest(const QMap<QString, QVariant>&);
2019-05-29 15:05:54 +00:00
void removeAccountRequest(const QString&);
void connectAccount(const QString&);
void disconnectAccount(const QString&);
void changeState(Shared::Availability state);
2019-06-14 16:36:04 +00:00
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);
2019-09-04 16:38:52 +00:00
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);
2022-02-19 18:31:49 +00:00
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);
2019-03-30 20:13:13 +00:00
public:
Models::Roster::ElId currentConversationId() const;
void closeCurrentConversation();
2019-03-30 20:13:13 +00:00
public slots:
2022-01-25 20:35:55 +00:00
void writeSettings();
void stateChanged(Shared::Availability state);
void responseInfo(const Shared::Info& info);
void select(QModelIndex index);
2019-03-30 20:13:13 +00:00
2019-03-29 14:54:34 +00:00
private:
QScopedPointer<Ui::Squawk> m_ui;
Accounts* accounts;
2022-01-16 19:54:57 +00:00
Settings* preferences;
2022-04-03 20:53:46 +00:00
About* about;
2022-04-18 16:54:42 +00:00
Models::Roster& rosterModel;
QMenu* contextMenu;
std::map<QString, UI::Info*> infoWidgets;
2020-04-11 20:00:15 +00:00
Conversation* currentConversation;
QModelIndex restoreSelection;
bool needToRestore;
2019-03-29 14:54:34 +00:00
protected:
void closeEvent(QCloseEvent * event) override;
void expand(const QModelIndex& index);
2019-03-29 14:54:34 +00:00
private slots:
void onAccounts();
2022-01-16 19:54:57 +00:00
void onPreferences();
void onNewContact();
2019-09-04 16:38:52 +00:00
void onNewConference();
void onNewContactAccepted();
2019-09-04 16:38:52 +00:00
void onJoinConferenceAccepted();
2022-06-03 06:44:48 +00:00
void onAccountsChanged();
2022-01-16 19:54:57 +00:00
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);
2019-04-09 15:04:08 +00:00
void onRosterItemDoubleClicked(const QModelIndex& item);
void onRosterContextMenu(const QPoint& point);
2020-04-11 20:00:15 +00:00
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
void onContextAboutToHide();
2022-04-03 20:53:46 +00:00
void onAboutSquawkCalled();
void onAboutSquawkClosed();
2019-03-29 14:54:34 +00:00
};
#endif // SQUAWK_H