Add a Send button that can be used to send messages (#4607)

This button is disabled by default, and can be enabled with the "Show send message button" setting.
This commit is contained in:
pajlada 2023-05-07 15:18:07 +02:00 committed by GitHub
parent 280b6d934e
commit caa0220ce6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 15 deletions

View file

@ -2,6 +2,7 @@
## Unversioned ## Unversioned
- Minor: Added a Send button in the input box so you can click to send a message. This is disabled by default and can be enabled with the "Show send message button" setting. (#4607)
- Minor: Improved error messages when the updater fails a download. (#4594) - Minor: Improved error messages when the updater fails a download. (#4594)
- Minor: Added `/shield` and `/shieldoff` commands to toggle shield mode. (#4580) - Minor: Added `/shield` and `/shieldoff` commands to toggle shield mode. (#4580)
- Bugfix: Fixed the menu warping on macOS on Qt6. (#4595) - Bugfix: Fixed the menu warping on macOS on Qt6. (#4595)

View file

@ -51,6 +51,8 @@ set(SOURCE_FILES
common/WindowDescriptors.cpp common/WindowDescriptors.cpp
common/WindowDescriptors.hpp common/WindowDescriptors.hpp
common/enums/MessageOverflow.hpp
controllers/accounts/Account.cpp controllers/accounts/Account.cpp
controllers/accounts/Account.hpp controllers/accounts/Account.hpp
controllers/accounts/AccountController.cpp controllers/accounts/AccountController.cpp

View file

@ -9,6 +9,7 @@
#include <set> #include <set>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <vector>
namespace chatterino { namespace chatterino {

View file

@ -0,0 +1,18 @@
#pragma once
namespace chatterino {
// MessageOverflow is used for controlling how to guide the user into not
// sending a message that will be discarded by Twitch
enum MessageOverflow {
// Allow overflowing characters to be inserted into the input box, but highlight them in red
Highlight,
// Prevent more characters from being inserted into the input box
Prevent,
// Do nothing
Allow,
};
} // namespace chatterino

View file

@ -2,7 +2,8 @@
#include "controllers/highlights/HighlightPhrase.hpp" #include "controllers/highlights/HighlightPhrase.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include <QSet>
namespace chatterino { namespace chatterino {

View file

@ -2,13 +2,13 @@
#include "BaseSettings.hpp" #include "BaseSettings.hpp"
#include "common/Channel.hpp" #include "common/Channel.hpp"
#include "common/enums/MessageOverflow.hpp"
#include "common/SignalVector.hpp" #include "common/SignalVector.hpp"
#include "controllers/logging/ChannelLog.hpp" #include "controllers/logging/ChannelLog.hpp"
#include "singletons/Toasts.hpp" #include "singletons/Toasts.hpp"
#include "util/RapidJsonSerializeQString.hpp" #include "util/RapidJsonSerializeQString.hpp"
#include "util/StreamerMode.hpp" #include "util/StreamerMode.hpp"
#include "widgets/Notebook.hpp" #include "widgets/Notebook.hpp"
#include "widgets/splits/SplitInput.hpp"
#include <pajlada/settings/setting.hpp> #include <pajlada/settings/setting.hpp>
#include <pajlada/settings/settinglistener.hpp> #include <pajlada/settings/settinglistener.hpp>
@ -509,6 +509,8 @@ public:
IntSetting lastSelectChannelTab = {"/ui/lastSelectChannelTab", 0}; IntSetting lastSelectChannelTab = {"/ui/lastSelectChannelTab", 0};
IntSetting lastSelectIrcConn = {"/ui/lastSelectIrcConn", 0}; IntSetting lastSelectIrcConn = {"/ui/lastSelectIrcConn", 0};
BoolSetting showSendButton = {"/ui/showSendButton", false};
// Similarity // Similarity
BoolSetting similarityEnabled = {"/similarity/similarityEnabled", false}; BoolSetting similarityEnabled = {"/similarity/similarityEnabled", false};
BoolSetting colorSimilarDisabled = {"/similarity/colorSimilarDisabled", BoolSetting colorSimilarDisabled = {"/similarity/colorSimilarDisabled",

View file

@ -11,6 +11,7 @@
#include "util/CombinePath.hpp" #include "util/CombinePath.hpp"
#include "util/PostToThread.hpp" #include "util/PostToThread.hpp"
#include <QApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>

View file

@ -1014,6 +1014,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
helixTimegateModerators->setMinimumWidth( helixTimegateModerators->setMinimumWidth(
helixTimegateModerators->minimumSizeHint().width()); helixTimegateModerators->minimumSizeHint().width());
layout.addCheckbox(
"Show send message button", s.showSendButton, false,
"Show a Send button next to each split input that can be "
"clicked to send the message");
layout.addStretch(); layout.addStretch();
// invisible element for width // invisible element for width

View file

@ -1,6 +1,7 @@
#include "widgets/splits/SplitInput.hpp" #include "widgets/splits/SplitInput.hpp"
#include "Application.hpp" #include "Application.hpp"
#include "common/enums/MessageOverflow.hpp"
#include "common/QLogging.hpp" #include "common/QLogging.hpp"
#include "controllers/commands/CommandController.hpp" #include "controllers/commands/CommandController.hpp"
#include "controllers/hotkeys/HotkeyController.hpp" #include "controllers/hotkeys/HotkeyController.hpp"
@ -114,6 +115,28 @@ void SplitInput::initLayout()
connect(textEdit.getElement(), &ResizingTextEdit::textChanged, this, connect(textEdit.getElement(), &ResizingTextEdit::textChanged, this,
&SplitInput::editTextChanged); &SplitInput::editTextChanged);
hboxLayout.emplace<EffectLabel>().assign(&this->ui_.sendButton);
this->ui_.sendButton->getLabel().setText("SEND");
this->ui_.sendButton->hide();
QObject::connect(this->ui_.sendButton, &EffectLabel::leftClicked, [this] {
std::vector<QString> arguments;
this->handleSendMessage(arguments);
});
getSettings()->showSendButton.connect(
[this](const bool value, auto) {
if (value)
{
this->ui_.sendButton->show();
}
else
{
this->ui_.sendButton->hide();
}
},
this->managedConnections_);
// right box // right box
auto box = hboxLayout.emplace<QVBoxLayout>().withoutMargin(); auto box = hboxLayout.emplace<QVBoxLayout>().withoutMargin();
box->setSpacing(0); box->setSpacing(0);

View file

@ -23,19 +23,6 @@ class MessageThread;
class ResizingTextEdit; class ResizingTextEdit;
class ChannelView; class ChannelView;
// MessageOverflow is used for controlling how to guide the user into not
// sending a message that will be discarded by Twitch
enum MessageOverflow {
// Allow overflowing characters to be inserted into the input box, but highlight them in red
Highlight,
// Prevent more characters from being inserted into the input box
Prevent,
// Do nothing
Allow,
};
class SplitInput : public BaseWidget class SplitInput : public BaseWidget
{ {
Q_OBJECT Q_OBJECT
@ -132,6 +119,7 @@ protected:
struct { struct {
ResizingTextEdit *textEdit; ResizingTextEdit *textEdit;
QLabel *textEditLength; QLabel *textEditLength;
EffectLabel *sendButton;
EffectLabel *emoteButton; EffectLabel *emoteButton;
QHBoxLayout *hbox; QHBoxLayout *hbox;