Skip to content

Commit

Permalink
feat(extensions): UI updates for extension support
Browse files Browse the repository at this point in the history
Added a UI element to indicate extension support of the chatroom. For
all groups it will always be red since we do not support extensions in
groups. In a 1-1 chat the indicator will either be green/yellow/red
depending on if the friend has support for all/some/none of qTox's
desired extension set.
  • Loading branch information
sphaerophoria authored and anthonybilinski committed Jan 30, 2021
1 parent 5f5f612 commit b715815
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ set(${PROJECT_NAME}_SOURCES
src/widget/contentlayout.h
src/widget/emoticonswidget.cpp
src/widget/emoticonswidget.h
src/widget/extensionstatus.cpp
src/widget/extensionstatus.h
src/widget/flowlayout.cpp
src/widget/flowlayout.h
src/widget/searchform.cpp
Expand Down
1 change: 1 addition & 0 deletions img/status/extensions_available.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/status/extensions_partial.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/status/extensions_unavailable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<file>img/status/offline_notification.svg</file>
<file>img/status/online.svg</file>
<file>img/status/online_notification.svg</file>
<file>img/status/extensions_available.svg</file>
<file>img/status/extensions_partial.svg</file>
<file>img/status/extensions_unavailable.svg</file>
<file>img/taskbar/dark/taskbar_online.svg</file>
<file>img/taskbar/dark/taskbar_online_event.svg</file>
<file>img/taskbar/dark/taskbar_away.svg</file>
Expand Down
18 changes: 17 additions & 1 deletion src/widget/chatformheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/

#include "chatformheader.h"
#include "extensionstatus.h"

#include "src/model/status.h"

#include "src/widget/gui.h"
#include "src/widget/maskablepixmapwidget.h"
Expand Down Expand Up @@ -117,16 +120,24 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
avatar = new MaskablePixmapWidget(this, AVATAR_SIZE, ":/img/avatar_mask.svg");
avatar->setObjectName("avatar");

nameLine = new QHBoxLayout();
nameLine->setSpacing(3);

extensionStatus = new ExtensionStatus();

nameLabel = new CroppingLabel();
nameLabel->setObjectName("nameLabel");
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
nameLabel->setEditable(true);
nameLabel->setTextFormat(Qt::PlainText);
connect(nameLabel, &CroppingLabel::editFinished, this, &ChatFormHeader::nameChanged);

nameLine->addWidget(extensionStatus);
nameLine->addWidget(nameLabel);

headTextLayout = new QVBoxLayout();
headTextLayout->addStretch();
headTextLayout->addWidget(nameLabel);
headTextLayout->addLayout(nameLine);
headTextLayout->addStretch();

micButton = createButton("micButton", this, &ChatFormHeader::micMuteToggle);
Expand Down Expand Up @@ -223,6 +234,11 @@ void ChatFormHeader::removeCallConfirm()
callConfirm.reset(nullptr);
}

void ChatFormHeader::updateExtensionSupport(ExtensionSet extensions)
{
extensionStatus->onExtensionSetUpdate(extensions);
}

void ChatFormHeader::updateCallButtons(bool online, bool audio, bool video)
{
const bool audioAvaliable = online && (mode & Mode::Audio);
Expand Down
8 changes: 8 additions & 0 deletions src/widget/chatformheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@

#include <QWidget>

#include "src/core/extension.h"

#include <memory>

class MaskablePixmapWidget;
class QVBoxLayout;
class QHBoxLayout;
class CroppingLabel;
class QPushButton;
class QToolButton;
class CallConfirmWidget;
class QLabel;
class ExtensionStatus;

class ChatFormHeader : public QWidget
{
Expand Down Expand Up @@ -64,6 +69,7 @@ class ChatFormHeader : public QWidget
void showCallConfirm();
void removeCallConfirm();

void updateExtensionSupport(ExtensionSet extensions);
void updateCallButtons(bool online, bool audio, bool video = false);
void updateMuteMicButton(bool active, bool inputMuted);
void updateMuteVolButton(bool active, bool outputMuted);
Expand Down Expand Up @@ -98,6 +104,8 @@ private slots:
Mode mode;
MaskablePixmapWidget* avatar;
QVBoxLayout* headTextLayout;
QHBoxLayout* nameLine;
ExtensionStatus* extensionStatus;
CroppingLabel* nameLabel;

QPushButton* callButton;
Expand Down
54 changes: 54 additions & 0 deletions src/widget/extensionstatus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright © 2019-2020 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre 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.
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
*/

#include "extensionstatus.h"

#include <QIcon>

ExtensionStatus::ExtensionStatus(QWidget* parent)
: QLabel(parent)
{
// Initialize with 0 extensions
onExtensionSetUpdate(ExtensionSet());
}

void ExtensionStatus::onExtensionSetUpdate(ExtensionSet extensionSet)
{
QString iconName;
QString hoverText;
if (extensionSet.all()) {
iconName = ":/img/status/extensions_available.svg";
hoverText = tr("All extensions supported");
} else if (extensionSet.none()) {
iconName = ":/img/status/extensions_unavailable.svg";
hoverText = tr("No extensions supported");
} else {
iconName = ":/img/status/extensions_partial.svg";
hoverText = tr("Not all extensions supported");
}

hoverText += "\n";
hoverText += tr("Multipart Messages: ");
hoverText += extensionSet[ExtensionType::messages] ? "" : "";

auto pixmap = QIcon(iconName).pixmap(QSize(16, 16));

setPixmap(pixmap);
setToolTip(hoverText);
}
34 changes: 34 additions & 0 deletions src/widget/extensionstatus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright © 2019-2020 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre 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.
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "src/core/extension.h"

#include <QLabel>

class ExtensionStatus : public QLabel
{
Q_OBJECT
public:
ExtensionStatus(QWidget* parent = nullptr);

public slots:
void onExtensionSetUpdate(ExtensionSet extensionSet);
};
7 changes: 7 additions & 0 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ ChatForm::ChatForm(Profile& profile, Friend* chatFriend, IChatLog& chatLog, IMes

connect(bodySplitter, &QSplitter::splitterMoved, this, &ChatForm::onSplitterMoved);

connect(f, &Friend::extensionSupportChanged, this, &ChatForm::onExtensionSupportChanged);

updateCallButtons();

setAcceptDrops(true);
Expand Down Expand Up @@ -224,6 +226,11 @@ void ChatForm::onFileNameChanged(const ToxPk& friendPk)
"so you can save the file on Windows."));
}

void ChatForm::onExtensionSupportChanged(ExtensionSet extensions)
{
headWidget->updateExtensionSupport(extensions);
}

void ChatForm::onTextEditChanged()
{
if (!Settings::getInstance().getTypingNotification()) {
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/chatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public slots:
void onAvEnd(uint32_t friendId, bool error);
void onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic);
void onFileNameChanged(const ToxPk& friendPk);
void onExtensionSupportChanged(ExtensionSet extensions);
void clearChatArea();
void onShowMessagesClicked();
void onSplitterMoved(int pos, int index);
Expand Down

0 comments on commit b715815

Please sign in to comment.