mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(extensions): UI updates for extension support
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.
This commit is contained in:
parent
5f5f612841
commit
b715815011
|
@ -362,6 +362,8 @@ set(${PROJECT_NAME}_SOURCES
|
||||||
src/widget/contentlayout.h
|
src/widget/contentlayout.h
|
||||||
src/widget/emoticonswidget.cpp
|
src/widget/emoticonswidget.cpp
|
||||||
src/widget/emoticonswidget.h
|
src/widget/emoticonswidget.h
|
||||||
|
src/widget/extensionstatus.cpp
|
||||||
|
src/widget/extensionstatus.h
|
||||||
src/widget/flowlayout.cpp
|
src/widget/flowlayout.cpp
|
||||||
src/widget/flowlayout.h
|
src/widget/flowlayout.h
|
||||||
src/widget/searchform.cpp
|
src/widget/searchform.cpp
|
||||||
|
|
1
img/status/extensions_available.svg
Normal file
1
img/status/extensions_available.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" ?><svg height="23px" version="1.1" viewBox="0 0 23 23" width="23px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#6FC062" id="Core" transform="translate(-253.000000, -211.000000)"><g id="extension" transform="translate(253.500000, 211.500000)"><path d="M18.5,10 L17,10 L17,6 C17,4.9 16.1,4 15,4 L11,4 L11,2.5 C11,1.1 9.9,0 8.5,0 C7.1,0 6,1.1 6,2.5 L6,4 L2,4 C0.9,4 0,4.9 0,6 L0,9.8 L1.5,9.8 C3,9.8 4.2,11 4.2,12.5 C4.2,14 3,15.2 1.5,15.2 L0,15.2 L0,19 C0,20.1 0.9,21 2,21 L5.8,21 L5.8,19.5 C5.8,18 7,16.8 8.5,16.8 C10,16.8 11.2,18 11.2,19.5 L11.2,21 L15,21 C16.1,21 17,20.1 17,19 L17,15 L18.5,15 C19.9,15 21,13.9 21,12.5 C21,11.1 19.9,10 18.5,10 L18.5,10 Z" id="Shape"/></g></g></g></svg>
|
After Width: | Height: | Size: 906 B |
1
img/status/extensions_partial.svg
Normal file
1
img/status/extensions_partial.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" ?><svg height="23px" version="1.1" viewBox="0 0 23 23" width="23px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#CDBE41" id="Core" transform="translate(-253.000000, -211.000000)"><g id="extension" transform="translate(253.500000, 211.500000)"><path d="M18.5,10 L17,10 L17,6 C17,4.9 16.1,4 15,4 L11,4 L11,2.5 C11,1.1 9.9,0 8.5,0 C7.1,0 6,1.1 6,2.5 L6,4 L2,4 C0.9,4 0,4.9 0,6 L0,9.8 L1.5,9.8 C3,9.8 4.2,11 4.2,12.5 C4.2,14 3,15.2 1.5,15.2 L0,15.2 L0,19 C0,20.1 0.9,21 2,21 L5.8,21 L5.8,19.5 C5.8,18 7,16.8 8.5,16.8 C10,16.8 11.2,18 11.2,19.5 L11.2,21 L15,21 C16.1,21 17,20.1 17,19 L17,15 L18.5,15 C19.9,15 21,13.9 21,12.5 C21,11.1 19.9,10 18.5,10 L18.5,10 Z" id="Shape"/></g></g></g></svg>
|
After Width: | Height: | Size: 906 B |
1
img/status/extensions_unavailable.svg
Normal file
1
img/status/extensions_unavailable.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" ?><svg height="23px" version="1.1" viewBox="0 0 23 23" width="23px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#C94F50" id="Core" transform="translate(-253.000000, -211.000000)"><g id="extension" transform="translate(253.500000, 211.500000)"><path d="M18.5,10 L17,10 L17,6 C17,4.9 16.1,4 15,4 L11,4 L11,2.5 C11,1.1 9.9,0 8.5,0 C7.1,0 6,1.1 6,2.5 L6,4 L2,4 C0.9,4 0,4.9 0,6 L0,9.8 L1.5,9.8 C3,9.8 4.2,11 4.2,12.5 C4.2,14 3,15.2 1.5,15.2 L0,15.2 L0,19 C0,20.1 0.9,21 2,21 L5.8,21 L5.8,19.5 C5.8,18 7,16.8 8.5,16.8 C10,16.8 11.2,18 11.2,19.5 L11.2,21 L15,21 C16.1,21 17,20.1 17,19 L17,15 L18.5,15 C19.9,15 21,13.9 21,12.5 C21,11.1 19.9,10 18.5,10 L18.5,10 Z" id="Shape"/></g></g></g></svg>
|
After Width: | Height: | Size: 906 B |
3
res.qrc
3
res.qrc
|
@ -28,6 +28,9 @@
|
||||||
<file>img/status/offline_notification.svg</file>
|
<file>img/status/offline_notification.svg</file>
|
||||||
<file>img/status/online.svg</file>
|
<file>img/status/online.svg</file>
|
||||||
<file>img/status/online_notification.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.svg</file>
|
||||||
<file>img/taskbar/dark/taskbar_online_event.svg</file>
|
<file>img/taskbar/dark/taskbar_online_event.svg</file>
|
||||||
<file>img/taskbar/dark/taskbar_away.svg</file>
|
<file>img/taskbar/dark/taskbar_away.svg</file>
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "chatformheader.h"
|
#include "chatformheader.h"
|
||||||
|
#include "extensionstatus.h"
|
||||||
|
|
||||||
|
#include "src/model/status.h"
|
||||||
|
|
||||||
#include "src/widget/gui.h"
|
#include "src/widget/gui.h"
|
||||||
#include "src/widget/maskablepixmapwidget.h"
|
#include "src/widget/maskablepixmapwidget.h"
|
||||||
|
@ -117,6 +120,11 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
|
||||||
avatar = new MaskablePixmapWidget(this, AVATAR_SIZE, ":/img/avatar_mask.svg");
|
avatar = new MaskablePixmapWidget(this, AVATAR_SIZE, ":/img/avatar_mask.svg");
|
||||||
avatar->setObjectName("avatar");
|
avatar->setObjectName("avatar");
|
||||||
|
|
||||||
|
nameLine = new QHBoxLayout();
|
||||||
|
nameLine->setSpacing(3);
|
||||||
|
|
||||||
|
extensionStatus = new ExtensionStatus();
|
||||||
|
|
||||||
nameLabel = new CroppingLabel();
|
nameLabel = new CroppingLabel();
|
||||||
nameLabel->setObjectName("nameLabel");
|
nameLabel->setObjectName("nameLabel");
|
||||||
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||||
|
@ -124,9 +132,12 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
|
||||||
nameLabel->setTextFormat(Qt::PlainText);
|
nameLabel->setTextFormat(Qt::PlainText);
|
||||||
connect(nameLabel, &CroppingLabel::editFinished, this, &ChatFormHeader::nameChanged);
|
connect(nameLabel, &CroppingLabel::editFinished, this, &ChatFormHeader::nameChanged);
|
||||||
|
|
||||||
|
nameLine->addWidget(extensionStatus);
|
||||||
|
nameLine->addWidget(nameLabel);
|
||||||
|
|
||||||
headTextLayout = new QVBoxLayout();
|
headTextLayout = new QVBoxLayout();
|
||||||
headTextLayout->addStretch();
|
headTextLayout->addStretch();
|
||||||
headTextLayout->addWidget(nameLabel);
|
headTextLayout->addLayout(nameLine);
|
||||||
headTextLayout->addStretch();
|
headTextLayout->addStretch();
|
||||||
|
|
||||||
micButton = createButton("micButton", this, &ChatFormHeader::micMuteToggle);
|
micButton = createButton("micButton", this, &ChatFormHeader::micMuteToggle);
|
||||||
|
@ -223,6 +234,11 @@ void ChatFormHeader::removeCallConfirm()
|
||||||
callConfirm.reset(nullptr);
|
callConfirm.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatFormHeader::updateExtensionSupport(ExtensionSet extensions)
|
||||||
|
{
|
||||||
|
extensionStatus->onExtensionSetUpdate(extensions);
|
||||||
|
}
|
||||||
|
|
||||||
void ChatFormHeader::updateCallButtons(bool online, bool audio, bool video)
|
void ChatFormHeader::updateCallButtons(bool online, bool audio, bool video)
|
||||||
{
|
{
|
||||||
const bool audioAvaliable = online && (mode & Mode::Audio);
|
const bool audioAvaliable = online && (mode & Mode::Audio);
|
||||||
|
|
|
@ -21,14 +21,19 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "src/core/extension.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class MaskablePixmapWidget;
|
class MaskablePixmapWidget;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
class QHBoxLayout;
|
||||||
class CroppingLabel;
|
class CroppingLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
class CallConfirmWidget;
|
class CallConfirmWidget;
|
||||||
|
class QLabel;
|
||||||
|
class ExtensionStatus;
|
||||||
|
|
||||||
class ChatFormHeader : public QWidget
|
class ChatFormHeader : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -64,6 +69,7 @@ public:
|
||||||
void showCallConfirm();
|
void showCallConfirm();
|
||||||
void removeCallConfirm();
|
void removeCallConfirm();
|
||||||
|
|
||||||
|
void updateExtensionSupport(ExtensionSet extensions);
|
||||||
void updateCallButtons(bool online, bool audio, bool video = false);
|
void updateCallButtons(bool online, bool audio, bool video = false);
|
||||||
void updateMuteMicButton(bool active, bool inputMuted);
|
void updateMuteMicButton(bool active, bool inputMuted);
|
||||||
void updateMuteVolButton(bool active, bool outputMuted);
|
void updateMuteVolButton(bool active, bool outputMuted);
|
||||||
|
@ -98,6 +104,8 @@ private:
|
||||||
Mode mode;
|
Mode mode;
|
||||||
MaskablePixmapWidget* avatar;
|
MaskablePixmapWidget* avatar;
|
||||||
QVBoxLayout* headTextLayout;
|
QVBoxLayout* headTextLayout;
|
||||||
|
QHBoxLayout* nameLine;
|
||||||
|
ExtensionStatus* extensionStatus;
|
||||||
CroppingLabel* nameLabel;
|
CroppingLabel* nameLabel;
|
||||||
|
|
||||||
QPushButton* callButton;
|
QPushButton* callButton;
|
||||||
|
|
54
src/widget/extensionstatus.cpp
Normal file
54
src/widget/extensionstatus.cpp
Normal file
|
@ -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
src/widget/extensionstatus.h
Normal file
34
src/widget/extensionstatus.h
Normal file
|
@ -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);
|
||||||
|
};
|
|
@ -181,6 +181,8 @@ ChatForm::ChatForm(Profile& profile, Friend* chatFriend, IChatLog& chatLog, IMes
|
||||||
|
|
||||||
connect(bodySplitter, &QSplitter::splitterMoved, this, &ChatForm::onSplitterMoved);
|
connect(bodySplitter, &QSplitter::splitterMoved, this, &ChatForm::onSplitterMoved);
|
||||||
|
|
||||||
|
connect(f, &Friend::extensionSupportChanged, this, &ChatForm::onExtensionSupportChanged);
|
||||||
|
|
||||||
updateCallButtons();
|
updateCallButtons();
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
@ -224,6 +226,11 @@ void ChatForm::onFileNameChanged(const ToxPk& friendPk)
|
||||||
"so you can save the file on Windows."));
|
"so you can save the file on Windows."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatForm::onExtensionSupportChanged(ExtensionSet extensions)
|
||||||
|
{
|
||||||
|
headWidget->updateExtensionSupport(extensions);
|
||||||
|
}
|
||||||
|
|
||||||
void ChatForm::onTextEditChanged()
|
void ChatForm::onTextEditChanged()
|
||||||
{
|
{
|
||||||
if (!Settings::getInstance().getTypingNotification()) {
|
if (!Settings::getInstance().getTypingNotification()) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ public slots:
|
||||||
void onAvEnd(uint32_t friendId, bool error);
|
void onAvEnd(uint32_t friendId, bool error);
|
||||||
void onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic);
|
void onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic);
|
||||||
void onFileNameChanged(const ToxPk& friendPk);
|
void onFileNameChanged(const ToxPk& friendPk);
|
||||||
|
void onExtensionSupportChanged(ExtensionSet extensions);
|
||||||
void clearChatArea();
|
void clearChatArea();
|
||||||
void onShowMessagesClicked();
|
void onShowMessagesClicked();
|
||||||
void onSplitterMoved(int pos, int index);
|
void onSplitterMoved(int pos, int index);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user