mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-27 07:52:57 +02:00
fix: message field configuration in forums
This commit is contained in:
parent
d98e6fd51e
commit
72618f98d1
1 changed files with 46 additions and 13 deletions
|
@ -92,6 +92,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -119,6 +123,13 @@ using SetHistoryArgs = ComposeControls::SetHistoryArgs;
|
||||||
using VoiceRecordBar = Controls::VoiceRecordBar;
|
using VoiceRecordBar = Controls::VoiceRecordBar;
|
||||||
using ForwardPanel = Controls::ForwardPanel;
|
using ForwardPanel = Controls::ForwardPanel;
|
||||||
|
|
||||||
|
#define SWITCH_BUTTON(button, show_v) \
|
||||||
|
if (show_v) { \
|
||||||
|
(button)->show(); \
|
||||||
|
} else { \
|
||||||
|
(button)->hide(); \
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const ChatHelpers::PauseReason kDefaultPanelsLevel
|
const ChatHelpers::PauseReason kDefaultPanelsLevel
|
||||||
|
@ -1594,6 +1605,14 @@ void ComposeControls::init() {
|
||||||
updateAttachBotsMenu();
|
updateAttachBotsMenu();
|
||||||
}, _wrap->lifetime());
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
|
AyuSettings::get_historyUpdateReactive() | rpl::start_with_next([=]
|
||||||
|
{
|
||||||
|
updateSendButtonType();
|
||||||
|
updateControlsVisibility();
|
||||||
|
updateControlsGeometry(_wrap->size());
|
||||||
|
orderControls();
|
||||||
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
orderControls();
|
orderControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1603,6 +1622,11 @@ void ComposeControls::orderControls() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComposeControls::showRecordButton() const {
|
bool ComposeControls::showRecordButton() const {
|
||||||
|
const auto &settings = AyuSettings::getInstance();
|
||||||
|
if (!settings.showMicrophoneButtonInMessageField) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (_recordAvailability != Webrtc::RecordAvailability::None)
|
return (_recordAvailability != Webrtc::RecordAvailability::None)
|
||||||
&& !_voiceRecordBar->isListenState()
|
&& !_voiceRecordBar->isListenState()
|
||||||
&& !_voiceRecordBar->isRecordingByAnotherBar()
|
&& !_voiceRecordBar->isRecordingByAnotherBar()
|
||||||
|
@ -2685,17 +2709,19 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||||
// (_attachToggle|_replaceMedia) (_sendAs) -- _inlineResults ------ _tabbedPanel -- _fieldBarCancel
|
// (_attachToggle|_replaceMedia) (_sendAs) -- _inlineResults ------ _tabbedPanel -- _fieldBarCancel
|
||||||
// (_attachDocument|_attachPhoto) _field (_ttlInfo) (_scheduled) (_silent|_botCommandStart) _tabbedSelectorToggle _send
|
// (_attachDocument|_attachPhoto) _field (_ttlInfo) (_scheduled) (_silent|_botCommandStart) _tabbedSelectorToggle _send
|
||||||
|
|
||||||
|
const auto &settings = AyuSettings::getInstance();
|
||||||
|
|
||||||
const auto fieldWidth = size.width()
|
const auto fieldWidth = size.width()
|
||||||
- _attachToggle->width()
|
- (settings.showAttachButtonInMessageField ? _attachToggle->width() : 0)
|
||||||
- (_sendAs ? _sendAs->width() : 0)
|
- (_sendAs ? _sendAs->width() : 0)
|
||||||
- st::historySendRight
|
- st::historySendRight
|
||||||
- _send->width()
|
- _send->width()
|
||||||
- _tabbedSelectorToggle->width()
|
- (settings.showEmojiButtonInMessageField ? _tabbedSelectorToggle->width() : 0)
|
||||||
- (_likeShown ? _like->width() : 0)
|
- (_likeShown ? _like->width() : 0)
|
||||||
- (_botCommandShown ? _botCommandStart->width() : 0)
|
- (_botCommandShown && settings.showCommandsButtonInMessageField ? _botCommandStart->width() : 0)
|
||||||
- (_silent ? _silent->width() : 0)
|
- (_silent ? _silent->width() : 0)
|
||||||
- (_scheduled ? _scheduled->width() : 0)
|
- (_scheduled ? _scheduled->width() : 0)
|
||||||
- (_ttlInfo ? _ttlInfo->width() : 0);
|
- (_ttlInfo && settings.showAutoDeleteButtonInMessageField ? _ttlInfo->width() : 0);
|
||||||
{
|
{
|
||||||
const auto oldFieldHeight = _field->height();
|
const auto oldFieldHeight = _field->height();
|
||||||
_field->resizeToWidth(fieldWidth);
|
_field->resizeToWidth(fieldWidth);
|
||||||
|
@ -2712,8 +2738,10 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||||
if (_replaceMedia) {
|
if (_replaceMedia) {
|
||||||
_replaceMedia->moveToLeft(left, buttonsTop);
|
_replaceMedia->moveToLeft(left, buttonsTop);
|
||||||
}
|
}
|
||||||
|
if (settings.showAttachButtonInMessageField) {
|
||||||
_attachToggle->moveToLeft(left, buttonsTop);
|
_attachToggle->moveToLeft(left, buttonsTop);
|
||||||
left += _attachToggle->width();
|
left += _attachToggle->width();
|
||||||
|
}
|
||||||
if (_sendAs) {
|
if (_sendAs) {
|
||||||
_sendAs->moveToLeft(left, buttonsTop);
|
_sendAs->moveToLeft(left, buttonsTop);
|
||||||
left += _sendAs->width();
|
left += _sendAs->width();
|
||||||
|
@ -2730,8 +2758,10 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||||
auto right = st::historySendRight;
|
auto right = st::historySendRight;
|
||||||
_send->moveToRight(right, buttonsTop);
|
_send->moveToRight(right, buttonsTop);
|
||||||
right += _send->width();
|
right += _send->width();
|
||||||
|
if (settings.showEmojiButtonInMessageField) {
|
||||||
_tabbedSelectorToggle->moveToRight(right, buttonsTop);
|
_tabbedSelectorToggle->moveToRight(right, buttonsTop);
|
||||||
right += _tabbedSelectorToggle->width();
|
right += _tabbedSelectorToggle->width();
|
||||||
|
}
|
||||||
if (_like) {
|
if (_like) {
|
||||||
using Type = Controls::WriteRestrictionType;
|
using Type = Controls::WriteRestrictionType;
|
||||||
if (_writeRestriction.current().type == Type::PremiumRequired) {
|
if (_writeRestriction.current().type == Type::PremiumRequired) {
|
||||||
|
@ -2745,7 +2775,7 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||||
}
|
}
|
||||||
if (_botCommandStart) {
|
if (_botCommandStart) {
|
||||||
_botCommandStart->moveToRight(right, buttonsTop);
|
_botCommandStart->moveToRight(right, buttonsTop);
|
||||||
if (_botCommandShown) {
|
if (_botCommandShown && settings.showCommandsButtonInMessageField) {
|
||||||
right += _botCommandStart->width();
|
right += _botCommandStart->width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2757,7 +2787,7 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||||
_scheduled->moveToRight(right, buttonsTop);
|
_scheduled->moveToRight(right, buttonsTop);
|
||||||
right += _scheduled->width();
|
right += _scheduled->width();
|
||||||
}
|
}
|
||||||
if (_ttlInfo) {
|
if (_ttlInfo && settings.showAutoDeleteButtonInMessageField) {
|
||||||
_ttlInfo->move(size.width() - right - _ttlInfo->width(), buttonsTop);
|
_ttlInfo->move(size.width() - right - _ttlInfo->width(), buttonsTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2768,14 +2798,16 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComposeControls::updateControlsVisibility() {
|
void ComposeControls::updateControlsVisibility() {
|
||||||
|
const auto &settings = AyuSettings::getInstance();
|
||||||
|
|
||||||
if (_botCommandStart) {
|
if (_botCommandStart) {
|
||||||
_botCommandStart->setVisible(_botCommandShown);
|
SWITCH_BUTTON(_botCommandStart, _botCommandShown && settings.showCommandsButtonInMessageField);
|
||||||
}
|
}
|
||||||
if (_like) {
|
if (_like) {
|
||||||
_like->setVisible(_likeShown);
|
_like->setVisible(_likeShown);
|
||||||
}
|
}
|
||||||
if (_ttlInfo) {
|
if (_ttlInfo) {
|
||||||
_ttlInfo->show();
|
SWITCH_BUTTON(_ttlInfo, settings.showAutoDeleteButtonInMessageField);
|
||||||
}
|
}
|
||||||
if (_sendAs) {
|
if (_sendAs) {
|
||||||
_sendAs->show();
|
_sendAs->show();
|
||||||
|
@ -2784,11 +2816,12 @@ void ComposeControls::updateControlsVisibility() {
|
||||||
_replaceMedia->show();
|
_replaceMedia->show();
|
||||||
_attachToggle->hide();
|
_attachToggle->hide();
|
||||||
} else {
|
} else {
|
||||||
_attachToggle->show();
|
SWITCH_BUTTON(_attachToggle, settings.showAttachButtonInMessageField);
|
||||||
}
|
}
|
||||||
if (_scheduled) {
|
if (_scheduled) {
|
||||||
_scheduled->setVisible(!isEditingMessage());
|
_scheduled->setVisible(!isEditingMessage());
|
||||||
}
|
}
|
||||||
|
SWITCH_BUTTON(_tabbedSelectorToggle, settings.showEmojiButtonInMessageField);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComposeControls::updateLikeShown() {
|
bool ComposeControls::updateLikeShown() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue