2019-08-14 14:54:46 +00: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 14:54:34 +00:00
|
|
|
#ifndef SQUAWK_H
|
|
|
|
#define SQUAWK_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QCloseEvent>
|
2019-12-25 10:24:20 +00:00
|
|
|
#include <QSettings>
|
2023-11-05 01:12:15 +00:00
|
|
|
#include <QString>
|
2020-04-07 20:33:03 +00:00
|
|
|
#include <QInputDialog>
|
2019-12-25 10:24:20 +00:00
|
|
|
|
2019-03-30 20:13:13 +00:00
|
|
|
#include <deque>
|
2019-04-02 15:46:18 +00:00
|
|
|
#include <map>
|
2019-09-12 20:54:44 +00:00
|
|
|
#include <set>
|
2019-05-15 17:36:37 +00:00
|
|
|
#include <list>
|
2019-03-29 14:54:34 +00:00
|
|
|
|
2022-04-11 15:45:12 +00:00
|
|
|
#include "widgets/accounts/accounts.h"
|
2019-08-23 09:51:33 +00:00
|
|
|
#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"
|
2019-03-31 21:05:09 +00:00
|
|
|
#include "models/roster.h"
|
2023-02-20 18:12:32 +00:00
|
|
|
#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"
|
2019-03-31 21:05:09 +00:00
|
|
|
|
2021-05-11 17:29:08 +00:00
|
|
|
#include "shared/shared.h"
|
2022-04-18 16:54:42 +00:00
|
|
|
#include "shared/global.h"
|
2023-02-20 18:12:32 +00:00
|
|
|
#include "shared/info.h"
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class Squawk;
|
|
|
|
}
|
|
|
|
|
2022-04-22 15:26:18 +00:00
|
|
|
class Application;
|
|
|
|
|
2023-11-05 01:12:15 +00:00
|
|
|
class Squawk : public QMainWindow {
|
2019-03-29 14:54:34 +00:00
|
|
|
Q_OBJECT
|
2022-04-22 15:26:18 +00:00
|
|
|
friend class Application;
|
2019-03-29 14:54:34 +00:00
|
|
|
public:
|
2022-04-22 15:26:18 +00:00
|
|
|
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:
|
2022-04-22 15:26:18 +00:00
|
|
|
void closing();
|
2022-08-15 16:40:07 +00:00
|
|
|
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&);
|
2019-03-31 21:05:09 +00:00
|
|
|
void connectAccount(const QString&);
|
|
|
|
void disconnectAccount(const QString&);
|
2020-04-03 22:28:15 +00:00
|
|
|
void changeState(Shared::Availability state);
|
2019-06-14 16:36:04 +00:00
|
|
|
void removeContactRequest(const QString& account, const QString& jid);
|
2019-06-15 15:29:15 +00:00
|
|
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
2019-09-28 14:30:16 +00: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 08:47:40 +00:00
|
|
|
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);
|
2019-09-03 20:28:58 +00:00
|
|
|
void removeRoomRequest(const QString& account, const QString& jid);
|
2023-02-20 18:12:32 +00:00
|
|
|
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);
|
2022-08-15 16:40:07 +00:00
|
|
|
void changeTray(bool enabled, bool hide);
|
2022-04-22 15:26:18 +00: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 16:25:35 +00:00
|
|
|
void itemExpanded (const QModelIndex& index);
|
|
|
|
void itemCollapsed (const QModelIndex& index);
|
2019-03-30 20:13:13 +00:00
|
|
|
|
2022-04-22 15:26:18 +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();
|
2020-04-03 22:28:15 +00:00
|
|
|
void stateChanged(Shared::Availability state);
|
2023-02-20 18:12:32 +00:00
|
|
|
void responseInfo(const Shared::Info& info);
|
2022-04-24 15:52:29 +00:00
|
|
|
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;
|
2019-06-12 17:18:18 +00:00
|
|
|
QMenu* contextMenu;
|
2023-02-20 18:12:32 +00:00
|
|
|
std::map<QString, UI::Info*> infoWidgets;
|
2020-04-11 20:00:15 +00:00
|
|
|
Conversation* currentConversation;
|
2020-04-12 15:55:05 +00:00
|
|
|
QModelIndex restoreSelection;
|
2020-04-14 16:30:33 +00:00
|
|
|
bool needToRestore;
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent * event) override;
|
2022-04-22 15:26:18 +00:00
|
|
|
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();
|
2019-06-15 15:29:15 +00:00
|
|
|
void onNewContact();
|
2019-09-04 16:38:52 +00:00
|
|
|
void onNewConference();
|
2019-06-15 15:29:15 +00:00
|
|
|
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();
|
2023-02-20 18:12:32 +00:00
|
|
|
void onInfoClosed();
|
|
|
|
void onInfoSave(const Shared::Info& info, const QString& account);
|
|
|
|
void onActivateInfo(const QString& account, const QString& jid);
|
2019-03-31 21:05:09 +00:00
|
|
|
void onComboboxActivated(int index);
|
2019-04-09 15:04:08 +00:00
|
|
|
void onRosterItemDoubleClicked(const QModelIndex& item);
|
2019-06-12 17:18:18 +00:00
|
|
|
void onRosterContextMenu(const QPoint& point);
|
2020-04-11 20:00:15 +00:00
|
|
|
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
|
2020-04-12 15:55:05 +00:00
|
|
|
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
|