mirror of https://github.com/procxx/kepka.git
Added checkbox to send photo as file for edit media.
This commit is contained in:
parent
6735605f21
commit
820c7ba84e
|
@ -643,6 +643,8 @@ usernameTextStyle: TextStyle(boxTextStyle, passcodeTextStyle) {
|
||||||
}
|
}
|
||||||
usernameDefaultFg: windowSubTextFg;
|
usernameDefaultFg: windowSubTextFg;
|
||||||
|
|
||||||
|
editMediaCheckboxMargins: margins(0px, 15px, 23px, 15px);
|
||||||
|
|
||||||
downloadPathSkip: 10px;
|
downloadPathSkip: 10px;
|
||||||
|
|
||||||
colorEditWidth: 390px;
|
colorEditWidth: 390px;
|
||||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
|
#include "ui/widgets/checkbox.h"
|
||||||
|
|
||||||
EditCaptionBox::EditCaptionBox(
|
EditCaptionBox::EditCaptionBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
@ -247,6 +248,22 @@ EditCaptionBox::EditCaptionBox(
|
||||||
_field->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
_field->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
_field->setMarkdownReplacesEnabled(rpl::single(true));
|
_field->setMarkdownReplacesEnabled(rpl::single(true));
|
||||||
_field->setEditLinkCallback(DefaultEditLinkCallback(_field));
|
_field->setEditLinkCallback(DefaultEditLinkCallback(_field));
|
||||||
|
|
||||||
|
auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
|
||||||
|
this,
|
||||||
|
object_ptr<Ui::Checkbox>(
|
||||||
|
this,
|
||||||
|
lang(lng_send_file),
|
||||||
|
false,
|
||||||
|
st::defaultBoxCheckbox),
|
||||||
|
st::editMediaCheckboxMargins);
|
||||||
|
_wayWrap = r.data();
|
||||||
|
_wayWrap->toggle(false, anim::type::instant);
|
||||||
|
|
||||||
|
r->entity()->checkedChanges(
|
||||||
|
) | rpl::start_with_next([&](bool checked) {
|
||||||
|
_asFile = checked;
|
||||||
|
}, _wayWrap->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditCaptionBox::emojiFilter(not_null<QEvent*> event) {
|
bool EditCaptionBox::emojiFilter(not_null<QEvent*> event) {
|
||||||
|
@ -345,6 +362,7 @@ void EditCaptionBox::prepare() {
|
||||||
_gifw = _gifh = _gifx = 0;
|
_gifw = _gifh = _gifx = 0;
|
||||||
|
|
||||||
auto isGif = false;
|
auto isGif = false;
|
||||||
|
_wayWrap->toggle(_isImage, anim::type::instant);
|
||||||
|
|
||||||
using Info = FileMediaInformation;
|
using Info = FileMediaInformation;
|
||||||
if (const auto image = base::get_if<Info::Image>(fileMedia)
|
if (const auto image = base::get_if<Info::Image>(fileMedia)
|
||||||
|
@ -450,6 +468,9 @@ void EditCaptionBox::setupEmojiPanel() {
|
||||||
|
|
||||||
void EditCaptionBox::updateBoxSize() {
|
void EditCaptionBox::updateBoxSize() {
|
||||||
auto newHeight = st::boxPhotoPadding.top() + st::boxPhotoCaptionSkip + _field->height() + errorTopSkip() + st::normalFont->height;
|
auto newHeight = st::boxPhotoPadding.top() + st::boxPhotoCaptionSkip + _field->height() + errorTopSkip() + st::normalFont->height;
|
||||||
|
if (_isImage) {
|
||||||
|
newHeight += _wayWrap->height() / 2;
|
||||||
|
}
|
||||||
if (_photo || _animated) {
|
if (_photo || _animated) {
|
||||||
newHeight += std::max(_thumbh, _gifh);
|
newHeight += std::max(_thumbh, _gifh);
|
||||||
} else if (_thumbw) {
|
} else if (_thumbw) {
|
||||||
|
@ -564,6 +585,14 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
void EditCaptionBox::resizeEvent(QResizeEvent *e) {
|
void EditCaptionBox::resizeEvent(QResizeEvent *e) {
|
||||||
BoxContent::resizeEvent(e);
|
BoxContent::resizeEvent(e);
|
||||||
|
|
||||||
|
if (_isImage) {
|
||||||
|
_wayWrap->resize(st::sendMediaPreviewSize, _wayWrap->height());
|
||||||
|
_wayWrap->moveToLeft(
|
||||||
|
st::boxPhotoPadding.left(),
|
||||||
|
st::boxPhotoPadding.top() + _thumbh);
|
||||||
|
}
|
||||||
|
|
||||||
_field->resize(st::sendMediaPreviewSize, _field->height());
|
_field->resize(st::sendMediaPreviewSize, _field->height());
|
||||||
_field->moveToLeft(st::boxPhotoPadding.left(), height() - st::normalFont->height - errorTopSkip() - _field->height());
|
_field->moveToLeft(st::boxPhotoPadding.left(), height() - st::normalFont->height - errorTopSkip() - _field->height());
|
||||||
_emojiToggle->moveToLeft(
|
_emojiToggle->moveToLeft(
|
||||||
|
@ -620,7 +649,7 @@ void EditCaptionBox::save() {
|
||||||
|
|
||||||
Auth().api().editMedia(
|
Auth().api().editMedia(
|
||||||
std::move(_preparedList),
|
std::move(_preparedList),
|
||||||
_isImage ? SendMediaType::Photo : SendMediaType::File,
|
(!_asFile && _isImage) ? SendMediaType::Photo : SendMediaType::File,
|
||||||
_field->getTextWithAppliedMarkdown(),
|
_field->getTextWithAppliedMarkdown(),
|
||||||
ApiWrap::SendOptions(item->history()));
|
ApiWrap::SendOptions(item->history()));
|
||||||
closeBox();
|
closeBox();
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "storage/storage_media_prepare.h"
|
#include "storage/storage_media_prepare.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
class TabbedPanel;
|
class TabbedPanel;
|
||||||
|
@ -25,6 +26,7 @@ class Media;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class InputField;
|
class InputField;
|
||||||
class EmojiButton;
|
class EmojiButton;
|
||||||
|
class Checkbox;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -99,6 +101,8 @@ private:
|
||||||
bool _previewCancelled = false;
|
bool _previewCancelled = false;
|
||||||
mtpRequestId _saveRequestId = 0;
|
mtpRequestId _saveRequestId = 0;
|
||||||
|
|
||||||
|
bool _asFile = false;
|
||||||
|
Ui::SlideWrap<Ui::RpWidget> *_wayWrap = nullptr;
|
||||||
QString _newMediaPath;
|
QString _newMediaPath;
|
||||||
|
|
||||||
QString _error;
|
QString _error;
|
||||||
|
|
Loading…
Reference in New Issue