2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Merge branch 'master' into video

Conflicts:
	Telegram/SourceFiles/mainwidget.cpp
	Telegram/SourceFiles/structs.cpp
This commit is contained in:
John Preston
2016-07-05 20:42:47 +03:00
46 changed files with 448 additions and 150 deletions

View File

@@ -114,10 +114,16 @@ CountryInput::CountryInput(QWidget *parent, const style::countryInput &st) : QWi
void CountryInput::paintEvent(QPaintEvent *e) {
QPainter p(this);
p.fillRect(_inner, _st.bgColor->b);
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setBrush(_st.bgColor);
p.setPen(Qt::NoPen);
p.drawRoundedRect(_inner, st::msgRadius, st::msgRadius);
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
p.drawPixmap(_arrowRect.x(), _arrowRect.top(), _arrow);
p.setFont(_st.font->f);
p.setFont(_st.font);
p.setPen(st::windowTextFg);
p.drawText(rect().marginsRemoved(_st.textMrg), _text, QTextOption(_st.align));
}

View File

@@ -101,7 +101,15 @@ void FlatButton::paintEvent(QPaintEvent *e) {
QRect r(0, height() - _st.height, width(), _st.height);
p.setOpacity(_opacity);
p.fillRect(r, a_bg.current());
if (_st.radius > 0) {
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setPen(Qt::NoPen);
p.setBrush(QBrush(a_bg.current()));
p.drawRoundedRect(r, _st.radius, _st.radius);
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
} else {
p.fillRect(r, a_bg.current());
}
p.setFont((_state & StateOver) ? _st.overFont : _st.font);
p.setRenderHint(QPainter::TextAntialiasing);

View File

@@ -347,7 +347,7 @@ void Checkbox::paintEvent(QPaintEvent *e) {
} else {
p.setBrush(st::white);
}
p.drawRoundedRect(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2, _st.thickness / 2, _st.thickness / 2, _st.thickness / 2)), st::msgRadius - (_st.thickness / 2), st::msgRadius - (_st.thickness / 2));
p.drawRoundedRect(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2., _st.thickness / 2., _st.thickness / 2., _st.thickness / 2.)), st::msgRadius - (_st.thickness / 2.), st::msgRadius - (_st.thickness / 2.));
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
if (checked > 0) {
@@ -485,9 +485,9 @@ void Radiobutton::paintEvent(QPaintEvent *e) {
pen.setWidth(_st.thickness);
p.setPen(pen);
p.setBrush(Qt::NoBrush);
//int32 skip = qCeil(_st.thickness / 2);
//int32 skip = qCeil(_st.thickness / 2.);
//p.drawEllipse(_checkRect.marginsRemoved(QMargins(skip, skip, skip, skip)));
p.drawEllipse(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2, _st.thickness / 2, _st.thickness / 2, _st.thickness / 2)));
p.drawEllipse(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2., _st.thickness / 2., _st.thickness / 2., _st.thickness / 2.)));
if (checked > 0) {
p.setPen(Qt::NoPen);

View File

@@ -174,14 +174,15 @@ QRect FlatInput::getTextRect() const {
void FlatInput::paintEvent(QPaintEvent *e) {
Painter p(this);
p.fillRect(rect(), a_bgColor.current());
if (_st.borderWidth) {
QBrush b(a_borderColor.current());
p.fillRect(0, 0, width() - _st.borderWidth, _st.borderWidth, b);
p.fillRect(width() - _st.borderWidth, 0, _st.borderWidth, height() - _st.borderWidth, b);
p.fillRect(_st.borderWidth, height() - _st.borderWidth, width() - _st.borderWidth, _st.borderWidth, b);
p.fillRect(0, _st.borderWidth, _st.borderWidth, height() - _st.borderWidth, b);
}
p.setRenderHint(QPainter::HighQualityAntialiasing);
auto pen = QPen(a_borderColor.current());
pen.setWidth(_st.borderWidth);
p.setPen(pen);
p.setBrush(QBrush(a_bgColor.current()));
p.drawRoundedRect(QRectF(0, 0, width(), height()).marginsRemoved(QMarginsF(_st.borderWidth / 2., _st.borderWidth / 2., _st.borderWidth / 2., _st.borderWidth / 2.)), st::msgRadius - (_st.borderWidth / 2.), st::msgRadius - (_st.borderWidth / 2.));
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
if (_st.imgRect.pxWidth()) {
p.drawSprite(_st.imgPos, _st.imgRect);
}
@@ -344,6 +345,13 @@ void FlatInput::keyPressEvent(QKeyEvent *e) {
emit cancelled();
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
emit submitted(ctrl && shift);
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto selected = selectedText();
if (!selected.isEmpty() && echoMode() == QLineEdit::Normal) {
QApplication::clipboard()->setText(selected, QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
}
}
@@ -765,11 +773,11 @@ void InputArea::startBorderAnimation() {
}
void InputArea::focusInEvent(QFocusEvent *e) {
_inner.setFocus();
QTimer::singleShot(0, &_inner, SLOT(setFocus()));
}
void InputArea::mousePressEvent(QMouseEvent *e) {
_inner.setFocus();
QTimer::singleShot(0, &_inner, SLOT(setFocus()));
}
void InputArea::contextMenuEvent(QContextMenuEvent *e) {
@@ -1228,6 +1236,14 @@ void InputArea::InputAreaInner::keyPressEvent(QKeyEvent *e) {
e->ignore();
} else if (f()->_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
e->ignore();
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto cursor = textCursor();
int start = cursor.selectionStart(), end = cursor.selectionEnd();
if (end > start) {
QApplication::clipboard()->setText(f()->getText(start, end), QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
} else {
QTextCursor tc(textCursor());
if (enter && ctrl) {
@@ -1457,11 +1473,11 @@ void InputField::startBorderAnimation() {
}
void InputField::focusInEvent(QFocusEvent *e) {
_inner.setFocus();
QTimer::singleShot(0, &_inner, SLOT(setFocus()));
}
void InputField::mousePressEvent(QMouseEvent *e) {
_inner.setFocus();
QTimer::singleShot(0, &_inner, SLOT(setFocus()));
}
void InputField::contextMenuEvent(QContextMenuEvent *e) {
@@ -1943,6 +1959,14 @@ void InputField::InputFieldInner::keyPressEvent(QKeyEvent *e) {
e->ignore();
} else if (f()->_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
e->ignore();
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto cursor = textCursor();
int start = cursor.selectionStart(), end = cursor.selectionEnd();
if (end > start) {
QApplication::clipboard()->setText(f()->getText(start, end), QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
} else {
QTextCursor tc(textCursor());
if (enter && ctrl) {
@@ -2337,6 +2361,13 @@ void MaskedInputField::keyPressEvent(QKeyEvent *e) {
emit cancelled();
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
emit submitted(ctrl && shift);
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto selected = selectedText();
if (!selected.isEmpty() && echoMode() == QLineEdit::Normal) {
QApplication::clipboard()->setText(selected, QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
}
}

View File

@@ -235,6 +235,12 @@ public:
bool hasFocus() const {
return _inner.hasFocus();
}
void setFocus() {
_inner.setFocus();
}
void clearFocus() {
_inner.clearFocus();
}
public slots:

View File

@@ -304,6 +304,13 @@ void FlatLabel::keyPressEvent(QKeyEvent *e) {
onCopySelectedText();
e->accept();
}
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
if (!selection.empty()) {
QApplication::clipboard()->setText(_text.originalText(selection, _contextExpandLinksMode), QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
}
}

View File

@@ -1337,6 +1337,15 @@ void FlatTextarea::keyPressEvent(QKeyEvent *e) {
}
} else if (e->key() == Qt::Key_Search || e == QKeySequence::Find) {
e->ignore();
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto cursor = textCursor();
int start = cursor.selectionStart(), end = cursor.selectionEnd();
if (end > start) {
TagList tags;
QApplication::clipboard()->setText(getTextPart(start, end, &tags), QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
} else {
QTextCursor tc(textCursor());
if (enter && ctrl) {

View File

@@ -521,8 +521,9 @@ PopupMenu::~PopupMenu() {
clearActions(true);
delete _menu;
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
if (App::wnd()) {
App::wnd()->activateWindow();
if (auto w = App::wnd()) {
w->onReActivate();
QTimer::singleShot(200, w, SLOT(onReActivate()));
}
#endif
}