first attempt to make About window

This commit is contained in:
Blue 2022-04-03 23:53:46 +03:00
parent 4baa3bccbf
commit 27377e0ec5
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
10 changed files with 354 additions and 52 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;
}

View File

@ -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<QString, QVariant>& account)
@ -342,10 +347,10 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
if (node->type == Models::Item::reference) {
node = static_cast<Models::Reference*>(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<Models::Contact*>(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<Models::Reference*>(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;
}

View File

@ -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);

View File

@ -201,8 +201,15 @@
<addaction name="actionAddConference"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAboutSquawk"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuSettings"/>
<addaction name="menuHelp"/>
</widget>
<action name="actionAccounts">
<property name="icon">
@ -248,12 +255,18 @@
</action>
<action name="actionPreferences">
<property name="icon">
<iconset theme="settings-configure"/>
<iconset theme="settings-configure">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Preferences</string>
</property>
</action>
<action name="actionAboutSquawk">
<property name="text">
<string>About Squawk</string>
</property>
</action>
</widget>
<resources>
<include location="../resources/resources.qrc"/>

View File

@ -18,6 +18,9 @@ target_sources(squawk PRIVATE
newcontact.ui
room.cpp
room.h
about.cpp
about.h
about.ui
)
add_subdirectory(vcard)

29
ui/widgets/about.cpp Normal file
View File

@ -0,0 +1,29 @@
// 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/>.
#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;

43
ui/widgets/about.h Normal file
View File

@ -0,0 +1,43 @@
// 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 ABOUT_H
#define ABOUT_H
#include <QWidget>
#include <QScopedPointer>
#include <QApplication>
namespace Ui
{
class About;
}
/**
* @todo write docs
*/
class About : public QWidget
{
Q_OBJECT
public:
About(QWidget* parent = nullptr);
~About();
private:
QScopedPointer<Ui::About> m_ui;
};
#endif // ABOUT_H

186
ui/widgets/about.ui Normal file
View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QWidget" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>334</width>
<height>321</height>
</rect>
</property>
<property name="windowTitle">
<string>About Squawk</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="header">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Squawk</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item row="0" column="3" rowspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="4">
<widget class="QTabWidget" name="tabs">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="aboutTab">
<attribute name="title">
<string>About</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="description">
<property name="text">
<string>XMPP (jabber) messenger</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="copyright">
<property name="text">
<string>(c) 2019 - 2022, Yury Gubich</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLink">
<property name="text">
<string>&lt;a href=&quot;https://git.macaw.me/blue/squawk&quot;&gt;Project site&lt;/a&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="licenceLink">
<property name="text">
<string>&lt;a href=&quot;https://git.macaw.me/blue/squawk/src/branch/master/LICENSE.md&quot;&gt;License: GNU General Public License version 3&lt;/a&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="versionValue">
<property name="text">
<string>0.0.0</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="squawkIcon">
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../resources/resources.qrc">:/images/logo.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>