diff --git a/CHANGELOG.md b/CHANGELOG.md index a6445ec..f563c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Squawk 0.2.2 (UNRELEASED) +### Bug fixes + +### Improvements + +### New features + + ## Squawk 0.2.1 (Apr 02, 2022) ### Bug fixes - build in release mode now no longer spams warnings diff --git a/CMakeLists.txt b/CMakeLists.txt index 717cf91..7d0ee7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.4) -project(squawk VERSION 0.2.1 LANGUAGES CXX) +project(squawk VERSION 0.2.2 LANGUAGES CXX) cmake_policy(SET CMP0076 NEW) cmake_policy(SET CMP0079 NEW) diff --git a/core/main.cpp b/core/main.cpp index f842c80..7d3c3ab 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -45,19 +45,11 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); SignalCatcher sc(&app); -#ifdef Q_OS_WIN - // Windows need an organization name for QSettings to work - // https://doc.qt.io/qt-5/qsettings.html#basic-usage - { - const QString& orgName = QApplication::organizationName(); - if (orgName.isNull() || orgName.isEmpty()) { - QApplication::setOrganizationName("squawk"); - } - } -#endif + QApplication::setApplicationName("squawk"); + QApplication::setOrganizationName("macaw.me"); QApplication::setApplicationDisplayName("Squawk"); - QApplication::setApplicationVersion("0.2.1"); + QApplication::setApplicationVersion("0.2.2"); QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); @@ -199,8 +191,8 @@ int main(int argc, char *argv[]) if (coreThread->isRunning()) { //coreThread->wait(); - //todo if I uncomment that, the app will no quit if it has reconnected at least once - //it feels like a symptom of something badly desinged in the core coreThread + //todo if I uncomment that, the app will not quit if it has reconnected at least once + //it feels like a symptom of something badly desinged in the core thread //need to investigate; } diff --git a/ui/squawk.cpp b/ui/squawk.cpp index 3ebb6a5..4594c01 100644 --- a/ui/squawk.cpp +++ b/ui/squawk.cpp @@ -24,16 +24,17 @@ Squawk::Squawk(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::Squawk), - accounts(0), - preferences(0), + accounts(nullptr), + preferences(nullptr), + about(nullptr), rosterModel(), conversations(), contextMenu(new QMenu()), dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()), vCards(), requestedAccountsForPasswords(), - prompt(0), - currentConversation(0), + prompt(nullptr), + currentConversation(nullptr), restoreSelection(), needToRestore(false) { @@ -72,6 +73,7 @@ Squawk::Squawk(QWidget *parent) : connect(&rosterModel, &Models::Roster::fileDownloadRequest, this, &Squawk::fileDownloadRequest); connect(&rosterModel, &Models::Roster::localPathInvalid, this, &Squawk::localPathInvalid); connect(contextMenu, &QMenu::aboutToHide, this, &Squawk::onContextAboutToHide); + connect(m_ui->actionAboutSquawk, &QAction::triggered, this, &Squawk::onAboutSquawkCalled); //m_ui->mainToolBar->addWidget(m_ui->comboBox); if (testAttribute(Qt::WA_TranslucentBackground)) { @@ -101,7 +103,7 @@ Squawk::~Squawk() { void Squawk::onAccounts() { - if (accounts == 0) { + if (accounts == nullptr) { accounts = new Accounts(rosterModel.accountsModel); accounts->setAttribute(Qt::WA_DeleteOnClose); connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed); @@ -121,7 +123,7 @@ void Squawk::onAccounts() void Squawk::onPreferences() { - if (preferences == 0) { + if (preferences == nullptr) { preferences = new Settings(); preferences->setAttribute(Qt::WA_DeleteOnClose); connect(preferences, &Settings::destroyed, this, &Squawk::onPreferencesClosed); @@ -189,12 +191,15 @@ void Squawk::onJoinConferenceAccepted() void Squawk::closeEvent(QCloseEvent* event) { - if (accounts != 0) { + if (accounts != nullptr) { accounts->close(); } - if (preferences != 0) { + if (preferences != nullptr) { preferences->close(); } + if (about != nullptr) { + about->close(); + } for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) { disconnect(itr->second, &Conversation::destroyed, this, &Squawk::onConversationClosed); @@ -214,12 +219,12 @@ void Squawk::closeEvent(QCloseEvent* event) void Squawk::onAccountsClosed() { - accounts = 0; + accounts = nullptr; } void Squawk::onPreferencesClosed() { - preferences = 0; + preferences = nullptr; } void Squawk::newAccount(const QMap& account) @@ -342,10 +347,10 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) if (node->type == Models::Item::reference) { node = static_cast(node)->dereference(); } - Models::Contact* contact = 0; - Models::Room* room = 0; + Models::Contact* contact = nullptr; + Models::Room* room = nullptr; QString res; - Models::Roster::ElId* id = 0; + Models::Roster::ElId* id = nullptr; switch (node->type) { case Models::Item::contact: contact = static_cast(node); @@ -365,17 +370,17 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) break; } - if (id != 0) { + if (id != nullptr) { Conversations::const_iterator itr = conversations.find(*id); Models::Account* acc = rosterModel.getAccount(id->account); - Conversation* conv = 0; + Conversation* conv = nullptr; bool created = false; if (itr != conversations.end()) { conv = itr->second; - } else if (contact != 0) { + } else if (contact != nullptr) { created = true; conv = new Chat(acc, contact); - } else if (room != 0) { + } else if (room != nullptr) { created = true; conv = new Room(acc, room); @@ -384,7 +389,7 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) } } - if (conv != 0) { + if (conv != nullptr) { if (created) { conv->setAttribute(Qt::WA_DeleteOnClose); subscribeConversation(conv); @@ -543,9 +548,9 @@ void Squawk::removeAccount(const QString& account) } } - if (currentConversation != 0 && currentConversation->getAccount() == account) { + if (currentConversation != nullptr && currentConversation->getAccount() == account) { currentConversation->deleteLater(); - currentConversation = 0; + currentConversation = nullptr; m_ui->filler->show(); } @@ -710,7 +715,7 @@ void Squawk::onRosterContextMenu(const QPoint& point) connect(unsub, &QAction::triggered, [this, id]() { emit setRoomAutoJoin(id.account, id.name, false); if (conversations.find(id) == conversations.end() - && (currentConversation == 0 || currentConversation->getId() != id) + && (currentConversation == nullptr || currentConversation->getId() != id) ) { //to leave the room if it's not opened in a conversation window emit setRoomJoined(id.account, id.name, false); } @@ -721,7 +726,7 @@ void Squawk::onRosterContextMenu(const QPoint& point) connect(unsub, &QAction::triggered, [this, id]() { emit setRoomAutoJoin(id.account, id.name, true); if (conversations.find(id) == conversations.end() - && (currentConversation == 0 || currentConversation->getId() != id) + && (currentConversation == nullptr || currentConversation->getId() != id) ) { //to join the room if it's not already joined emit setRoomJoined(id.account, id.name, true); } @@ -928,7 +933,7 @@ void Squawk::requestPassword(const QString& account) void Squawk::checkNextAccountForPassword() { - if (prompt == 0 && requestedAccountsForPasswords.size() > 0) { + if (prompt == nullptr && requestedAccountsForPasswords.size() > 0) { prompt = new QInputDialog(this); QString accName = requestedAccountsForPasswords.front(); connect(prompt, &QDialog::accepted, this, &Squawk::onPasswordPromptAccepted); @@ -951,7 +956,7 @@ void Squawk::onPasswordPromptAccepted() void Squawk::onPasswordPromptDone() { prompt->deleteLater(); - prompt = 0; + prompt = nullptr; requestedAccountsForPasswords.pop_front(); checkNextAccountForPassword(); } @@ -986,10 +991,10 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn if (node->type == Models::Item::reference) { node = static_cast(node)->dereference(); } - Models::Contact* contact = 0; - Models::Room* room = 0; + Models::Contact* contact = nullptr; + Models::Room* room = nullptr; QString res; - Models::Roster::ElId* id = 0; + Models::Roster::ElId* id = nullptr; bool hasContext = true; switch (node->type) { case Models::Item::contact: @@ -1018,7 +1023,7 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn } if (hasContext && QGuiApplication::mouseButtons() & Qt::RightButton) { - if (id != 0) { + if (id != nullptr) { delete id; } needToRestore = true; @@ -1026,10 +1031,10 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn return; } - if (id != 0) { - if (currentConversation != 0) { + if (id != nullptr) { + if (currentConversation != nullptr) { if (currentConversation->getId() == *id) { - if (contact != 0) { + if (contact != nullptr) { currentConversation->setPalResource(res); } return; @@ -1041,9 +1046,9 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn } Models::Account* acc = rosterModel.getAccount(id->account); - if (contact != 0) { + if (contact != nullptr) { currentConversation = new Chat(acc, contact); - } else if (room != 0) { + } else if (room != nullptr) { currentConversation = new Room(acc, room); if (!room->getJoined()) { @@ -1064,16 +1069,16 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn delete id; } else { - if (currentConversation != 0) { + if (currentConversation != nullptr) { currentConversation->deleteLater(); - currentConversation = 0; + currentConversation = nullptr; m_ui->filler->show(); } } } else { - if (currentConversation != 0) { + if (currentConversation != nullptr) { currentConversation->deleteLater(); - currentConversation = 0; + currentConversation = nullptr; m_ui->filler->show(); } } @@ -1086,3 +1091,22 @@ void Squawk::onContextAboutToHide() m_ui->roster->selectionModel()->setCurrentIndex(restoreSelection, QItemSelectionModel::ClearAndSelect); } } + +void Squawk::onAboutSquawkCalled() +{ + if (about == nullptr) { + about = new About(); + about->setAttribute(Qt::WA_DeleteOnClose); + connect(about, &Settings::destroyed, this, &Squawk::onAboutSquawkClosed); + about->show(); + } else { + about->raise(); + about->activateWindow(); + about->show(); + } +} + +void Squawk::onAboutSquawkClosed() +{ + about = nullptr; +} diff --git a/ui/squawk.h b/ui/squawk.h index 7bd2e10..95c5ce3 100644 --- a/ui/squawk.h +++ b/ui/squawk.h @@ -39,6 +39,7 @@ #include "models/roster.h" #include "widgets/vcard/vcard.h" #include "widgets/settings/settings.h" +#include "widgets/about.h" #include "shared/shared.h" @@ -120,6 +121,7 @@ private: Accounts* accounts; Settings* preferences; + About* about; Models::Roster rosterModel; Conversations conversations; QMenu* contextMenu; @@ -163,6 +165,8 @@ private slots: void onPasswordPromptRejected(); void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous); void onContextAboutToHide(); + void onAboutSquawkCalled(); + void onAboutSquawkClosed(); void onUnnoticedMessage(const QString& account, const Shared::Message& msg); diff --git a/ui/squawk.ui b/ui/squawk.ui index 840dfee..a8b0730 100644 --- a/ui/squawk.ui +++ b/ui/squawk.ui @@ -201,8 +201,15 @@ + + + Help + + + + @@ -248,12 +255,18 @@ - + + .. Preferences + + + About Squawk + + diff --git a/ui/widgets/CMakeLists.txt b/ui/widgets/CMakeLists.txt index f3a2afe..7ba83d2 100644 --- a/ui/widgets/CMakeLists.txt +++ b/ui/widgets/CMakeLists.txt @@ -18,6 +18,9 @@ target_sources(squawk PRIVATE newcontact.ui room.cpp room.h + about.cpp + about.h + about.ui ) add_subdirectory(vcard) diff --git a/ui/widgets/about.cpp b/ui/widgets/about.cpp new file mode 100644 index 0000000..4631065 --- /dev/null +++ b/ui/widgets/about.cpp @@ -0,0 +1,29 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// 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 . + +#include "about.h" +#include "ui_about.h" + +About::About(QWidget* parent): + QWidget(parent), + m_ui(new Ui::About) +{ + m_ui->setupUi(this); + m_ui->versionValue->setText(QApplication::applicationVersion()); + setWindowFlag(Qt::Tool); +} + +About::~About() = default; diff --git a/ui/widgets/about.h b/ui/widgets/about.h new file mode 100644 index 0000000..89d879d --- /dev/null +++ b/ui/widgets/about.h @@ -0,0 +1,43 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// 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 . + +#ifndef ABOUT_H +#define ABOUT_H + +#include +#include +#include + +namespace Ui +{ +class About; +} + +/** + * @todo write docs + */ +class About : public QWidget +{ + Q_OBJECT +public: + About(QWidget* parent = nullptr); + ~About(); + +private: + QScopedPointer m_ui; +}; + +#endif // ABOUT_H diff --git a/ui/widgets/about.ui b/ui/widgets/about.ui new file mode 100644 index 0000000..ab54df5 --- /dev/null +++ b/ui/widgets/about.ui @@ -0,0 +1,186 @@ + + + About + + + + 0 + 0 + 334 + 321 + + + + About Squawk + + + + 0 + + + + + + 12 + + + + Squawk + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + About + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + XMPP (jabber) messenger + + + + + + + (c) 2019 - 2022, Yury Gubich + + + + + + + <a href="https://git.macaw.me/blue/squawk">Project site</a> + + + Qt::RichText + + + true + + + + + + + <a href="https://git.macaw.me/blue/squawk/src/branch/master/LICENSE.md">License: GNU General Public License version 3</a> + + + Qt::RichText + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 0.0.0 + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Version + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 50 + 50 + + + + + + + :/images/logo.svg + + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + +