Added Ctrl+E and Ctrl+O shortcut to edit media.

This commit is contained in:
23rd 2019-03-30 11:53:28 +03:00 committed by John Preston
parent be2b2cbf7e
commit 6e69069ba2
2 changed files with 20 additions and 2 deletions

View File

@ -407,7 +407,7 @@ void EditCaptionBox::createEditMediaButton() {
} }
}; };
addButton(langFactory(lng_edit_media), [=] { const auto buttonCallback = [=] {
const auto filters = _isNotAlbum const auto filters = _isNotAlbum
? QStringList(FileDialog::AllFilesFilter()) ? QStringList(FileDialog::AllFilesFilter())
: QStringList(qsl("Image and Video Files (*.png *.jpg *.mp4)")); : QStringList(qsl("Image and Video Files (*.png *.jpg *.mp4)"));
@ -416,7 +416,13 @@ void EditCaptionBox::createEditMediaButton() {
lang(lng_choose_file), lang(lng_choose_file),
filters.join(qsl(";;")), filters.join(qsl(";;")),
crl::guard(this, callback)); crl::guard(this, callback));
}); };
_editMediaClicks.events() | rpl::start_with_next([=] {
buttonCallback();
}, lifetime());
addButton(langFactory(lng_edit_media), buttonCallback);
} }
void EditCaptionBox::prepare() { void EditCaptionBox::prepare() {
@ -719,3 +725,12 @@ void EditCaptionBox::setName(QString nameString, qint64 size) {
_name.maxWidth(), _name.maxWidth(),
st::normalFont->width(_status)); st::normalFont->width(_status));
} }
void EditCaptionBox::keyPressEvent(QKeyEvent *e) {
if ((e->key() == Qt::Key_E || e->key() == Qt::Key_O)
&& e->modifiers() == Qt::ControlModifier) {
_editMediaClicks.fire({});
} else {
e->ignore();
}
}

View File

@ -10,6 +10,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" #include "ui/wrap/slide_wrap.h"
#include <rpl/event_stream.h>
namespace ChatHelpers { namespace ChatHelpers {
class TabbedPanel; class TabbedPanel;
@ -46,6 +47,7 @@ protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
private: private:
void updateBoxSize(); void updateBoxSize();
@ -108,6 +110,7 @@ private:
QString _newMediaPath; QString _newMediaPath;
bool _isAllowedEditMedia = false; bool _isAllowedEditMedia = false;
bool _isNotAlbum; bool _isNotAlbum;
rpl::event_stream<> _editMediaClicks;
QString _error; QString _error;