2019-08-14 17:54:46 +03:00
|
|
|
/*
|
|
|
|
* 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 17:54:34 +03:00
|
|
|
#ifndef SQUAWK_H
|
|
|
|
#define SQUAWK_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QCloseEvent>
|
2019-12-25 13:24:20 +03:00
|
|
|
#include <QSettings>
|
2023-11-04 22:12:15 -03:00
|
|
|
#include <QString>
|
2020-04-07 23:33:03 +03:00
|
|
|
#include <QInputDialog>
|
2019-12-25 13:24:20 +03:00
|
|
|
|
2019-03-30 23:13:13 +03:00
|
|
|
#include <deque>
|
2019-04-02 18:46:18 +03:00
|
|
|
#include <map>
|
2019-09-12 23:54:44 +03:00
|
|
|
#include <set>
|
2019-05-15 20:36:37 +03:00
|
|
|
#include <list>
|
2019-03-29 17:54:34 +03:00
|
|
|
|
2022-04-11 18:45:12 +03:00
|
|
|
#include "widgets/accounts/accounts.h"
|
2019-08-23 12:51:33 +03:00
|
|
|
#include "widgets/chat.h"
|
2019-08-28 14:40:55 +03:00
|
|
|
#include "widgets/room.h"
|
2019-09-04 19:38:52 +03:00
|
|
|
#include "widgets/newcontact.h"
|
|
|
|
#include "widgets/joinconference.h"
|
2019-04-01 00:05:09 +03:00
|
|
|
#include "models/roster.h"
|
2023-02-20 21:12:32 +03:00
|
|
|
#include "widgets/info/info.h"
|
2022-01-16 22:54:57 +03:00
|
|
|
#include "widgets/settings/settings.h"
|
2022-04-03 23:53:46 +03:00
|
|
|
#include "widgets/about.h"
|
2019-04-01 00:05:09 +03:00
|
|
|
|
2021-05-11 20:29:08 +03:00
|
|
|
#include "shared/shared.h"
|
2022-04-18 19:54:42 +03:00
|
|
|
#include "shared/global.h"
|
2023-02-20 21:12:32 +03:00
|
|
|
#include "shared/info.h"
|
2019-03-29 17:54:34 +03:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class Squawk;
|
|
|
|
}
|
|
|
|
|
2022-04-22 18:26:18 +03:00
|
|
|
class Application;
|
|
|
|
|
2023-11-04 22:12:15 -03:00
|
|
|
class Squawk : public QMainWindow {
|
2019-03-29 17:54:34 +03:00
|
|
|
Q_OBJECT
|
2022-04-22 18:26:18 +03:00
|
|
|
friend class Application;
|
2019-03-29 17:54:34 +03:00
|
|
|
public:
|
2022-04-22 18:26:18 +03:00
|
|
|
explicit Squawk(Models::Roster& rosterModel, QWidget *parent = nullptr);
|
2019-03-29 17:54:34 +03:00
|
|
|
~Squawk() override;
|
2019-03-30 23:13:13 +03:00
|
|
|
|
|
|
|
signals:
|
2022-04-22 18:26:18 +03:00
|
|
|
void closing();
|
2022-08-15 19:40:07 +03:00
|
|
|
void quit();
|
2019-03-30 23:13:13 +03:00
|
|
|
void newAccountRequest(const QMap<QString, QVariant>&);
|
2019-05-29 18:05:54 +03:00
|
|
|
void removeAccountRequest(const QString&);
|
2019-04-01 00:05:09 +03:00
|
|
|
void connectAccount(const QString&);
|
|
|
|
void disconnectAccount(const QString&);
|
2020-04-04 01:28:15 +03:00
|
|
|
void changeState(Shared::Availability state);
|
2019-06-14 19:36:04 +03:00
|
|
|
void removeContactRequest(const QString& account, const QString& jid);
|
2019-06-15 18:29:15 +03:00
|
|
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
2019-09-28 17:30:16 +03:00
|
|
|
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
|
|
|
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
2019-10-01 11:47:40 +03:00
|
|
|
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
2019-09-04 19:38:52 +03:00
|
|
|
void addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin);
|
2019-09-03 23:28:58 +03:00
|
|
|
void removeRoomRequest(const QString& account, const QString& jid);
|
2023-02-20 21:12:32 +03:00
|
|
|
void requestInfo(const QString& account, const QString& jid);
|
|
|
|
void updateInfo(const QString& account, const Shared::Info& info);
|
2022-02-19 21:31:49 +03:00
|
|
|
void changeDownloadsPath(const QString& path);
|
2022-08-15 19:40:07 +03:00
|
|
|
void changeTray(bool enabled, bool hide);
|
2022-04-22 18:26:18 +03:00
|
|
|
|
|
|
|
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>&);
|
2022-08-17 19:25:35 +03:00
|
|
|
void itemExpanded (const QModelIndex& index);
|
|
|
|
void itemCollapsed (const QModelIndex& index);
|
2019-03-30 23:13:13 +03:00
|
|
|
|
2022-04-22 18:26:18 +03:00
|
|
|
public:
|
|
|
|
Models::Roster::ElId currentConversationId() const;
|
|
|
|
void closeCurrentConversation();
|
|
|
|
|
2019-03-30 23:13:13 +03:00
|
|
|
public slots:
|
2022-01-25 23:35:55 +03:00
|
|
|
void writeSettings();
|
2020-04-04 01:28:15 +03:00
|
|
|
void stateChanged(Shared::Availability state);
|
2023-02-20 21:12:32 +03:00
|
|
|
void responseInfo(const Shared::Info& info);
|
2022-04-24 18:52:29 +03:00
|
|
|
void select(QModelIndex index);
|
2019-03-30 23:13:13 +03:00
|
|
|
|
2019-03-29 17:54:34 +03:00
|
|
|
private:
|
|
|
|
QScopedPointer<Ui::Squawk> m_ui;
|
|
|
|
|
|
|
|
Accounts* accounts;
|
2022-01-16 22:54:57 +03:00
|
|
|
Settings* preferences;
|
2022-04-03 23:53:46 +03:00
|
|
|
About* about;
|
2022-04-18 19:54:42 +03:00
|
|
|
Models::Roster& rosterModel;
|
2019-06-12 20:18:18 +03:00
|
|
|
QMenu* contextMenu;
|
2023-02-20 21:12:32 +03:00
|
|
|
std::map<QString, UI::Info*> infoWidgets;
|
2020-04-11 23:00:15 +03:00
|
|
|
Conversation* currentConversation;
|
2020-04-12 18:55:05 +03:00
|
|
|
QModelIndex restoreSelection;
|
2020-04-14 19:30:33 +03:00
|
|
|
bool needToRestore;
|
2019-03-29 17:54:34 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent * event) override;
|
2022-04-22 18:26:18 +03:00
|
|
|
void expand(const QModelIndex& index);
|
2019-03-29 17:54:34 +03:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onAccounts();
|
2022-01-16 22:54:57 +03:00
|
|
|
void onPreferences();
|
2019-06-15 18:29:15 +03:00
|
|
|
void onNewContact();
|
2019-09-04 19:38:52 +03:00
|
|
|
void onNewConference();
|
2019-06-15 18:29:15 +03:00
|
|
|
void onNewContactAccepted();
|
2019-09-04 19:38:52 +03:00
|
|
|
void onJoinConferenceAccepted();
|
2022-06-03 09:44:48 +03:00
|
|
|
void onAccountsChanged();
|
2022-01-16 22:54:57 +03:00
|
|
|
void onAccountsClosed();
|
|
|
|
void onPreferencesClosed();
|
2023-02-20 21:12:32 +03:00
|
|
|
void onInfoClosed();
|
|
|
|
void onInfoSave(const Shared::Info& info, const QString& account);
|
|
|
|
void onActivateInfo(const QString& account, const QString& jid);
|
2019-04-01 00:05:09 +03:00
|
|
|
void onComboboxActivated(int index);
|
2019-04-09 18:04:08 +03:00
|
|
|
void onRosterItemDoubleClicked(const QModelIndex& item);
|
2019-06-12 20:18:18 +03:00
|
|
|
void onRosterContextMenu(const QPoint& point);
|
2020-04-11 23:00:15 +03:00
|
|
|
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
|
2020-04-12 18:55:05 +03:00
|
|
|
void onContextAboutToHide();
|
2022-04-03 23:53:46 +03:00
|
|
|
void onAboutSquawkCalled();
|
|
|
|
void onAboutSquawkClosed();
|
2019-03-29 17:54:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SQUAWK_H
|