mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-31 15:59:54 +00:00
Version 1.8.2: Fix build for Qt 5.3.2.
This commit is contained in:
parent
288c1130b9
commit
ee96d78656
@ -52,6 +52,13 @@ public slots:
|
||||
void psMacDelete();
|
||||
void psMacSelectAll();
|
||||
|
||||
void psMacBold();
|
||||
void psMacItalic();
|
||||
void psMacUnderline();
|
||||
void psMacStrikeOut();
|
||||
void psMacMonospace();
|
||||
void psMacClearFormat();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *evt) override;
|
||||
|
||||
|
@ -208,6 +208,25 @@ private:
|
||||
@end // @implementation MainWindowObserver
|
||||
|
||||
namespace Platform {
|
||||
namespace {
|
||||
|
||||
void SendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
||||
const auto focused = QApplication::focusWidget();
|
||||
if (qobject_cast<QLineEdit*>(focused) || qobject_cast<QTextEdit*>(focused) || qobject_cast<HistoryInner*>(focused)) {
|
||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers));
|
||||
}
|
||||
}
|
||||
|
||||
void ForceDisabled(QAction *action, bool disabled) {
|
||||
if (action->isEnabled()) {
|
||||
if (disabled) action->setDisabled(true);
|
||||
} else if (!disabled) {
|
||||
action->setDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MainWindow::Private::Private(not_null<MainWindow*> window)
|
||||
: _public(window)
|
||||
@ -638,23 +657,6 @@ void MainWindow::psFirstShow() {
|
||||
createGlobalMenu();
|
||||
}
|
||||
|
||||
namespace {
|
||||
void _sendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
if (qobject_cast<QLineEdit*>(focused) || qobject_cast<QTextEdit*>(focused) || qobject_cast<HistoryInner*>(focused)) {
|
||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers));
|
||||
}
|
||||
}
|
||||
void _forceDisabled(QAction *action, bool disabled) {
|
||||
if (action->isEnabled()) {
|
||||
if (disabled) action->setDisabled(true);
|
||||
} else if (!disabled) {
|
||||
action->setDisabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::createGlobalMenu() {
|
||||
auto main = psMainMenu.addMenu(qsl("Telegram"));
|
||||
auto about = main->addAction(tr::lng_mac_menu_about_telegram(tr::now, lt_telegram, qsl("Telegram")));
|
||||
@ -681,48 +683,12 @@ void MainWindow::createGlobalMenu() {
|
||||
psDelete = edit->addAction(tr::lng_mac_menu_delete(tr::now), this, SLOT(psMacDelete()), QKeySequence(Qt::ControlModifier | Qt::Key_Backspace));
|
||||
|
||||
edit->addSeparator();
|
||||
psBold = edit->addAction(
|
||||
tr::lng_menu_formatting_bold(tr::now),
|
||||
this,
|
||||
[=] {
|
||||
_sendKeySequence(Qt::Key_B, Qt::ControlModifier);
|
||||
},
|
||||
QKeySequence::Bold);
|
||||
psItalic = edit->addAction(
|
||||
tr::lng_menu_formatting_italic(tr::now),
|
||||
this,
|
||||
[=] {
|
||||
_sendKeySequence(Qt::Key_I, Qt::ControlModifier);
|
||||
},
|
||||
QKeySequence::Italic);
|
||||
psUnderline = edit->addAction(
|
||||
tr::lng_menu_formatting_underline(tr::now),
|
||||
this,
|
||||
[=] {
|
||||
_sendKeySequence(Qt::Key_U, Qt::ControlModifier);
|
||||
},
|
||||
QKeySequence::Underline);
|
||||
psStrikeOut = edit->addAction(
|
||||
tr::lng_menu_formatting_strike_out(tr::now),
|
||||
this,
|
||||
[=] {
|
||||
_sendKeySequence(Qt::Key_X, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
},
|
||||
Ui::kStrikeOutSequence);
|
||||
psMonospace = edit->addAction(
|
||||
tr::lng_menu_formatting_monospace(tr::now),
|
||||
this,
|
||||
[=] {
|
||||
_sendKeySequence(Qt::Key_M, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
},
|
||||
Ui::kMonospaceSequence);
|
||||
psClearFormat = edit->addAction(
|
||||
tr::lng_menu_formatting_clear(tr::now),
|
||||
this,
|
||||
[=] {
|
||||
_sendKeySequence(Qt::Key_N, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
},
|
||||
Ui::kClearFormatSequence);
|
||||
psBold = edit->addAction(tr::lng_menu_formatting_bold(tr::now), this, SLOT(psMacBold()), QKeySequence::Bold);
|
||||
psItalic = edit->addAction(tr::lng_menu_formatting_italic(tr::now), this, SLOT(psMacItalic()), QKeySequence::Italic);
|
||||
psUnderline = edit->addAction(tr::lng_menu_formatting_underline(tr::now), this, SLOT(psMacUnderline()), QKeySequence::Underline);
|
||||
psStrikeOut = edit->addAction(tr::lng_menu_formatting_strike_out(tr::now), this, SLOT(psMacStrikeOut()), Ui::kStrikeOutSequence);
|
||||
psMonospace = edit->addAction(tr::lng_menu_formatting_monospace(tr::now), this, SLOT(psMacMonospace()), Ui::kMonospaceSequence);
|
||||
psClearFormat = edit->addAction(tr::lng_menu_formatting_clear(tr::now), this, SLOT(psMacClearFormat()), Ui::kClearFormatSequence);
|
||||
|
||||
edit->addSeparator();
|
||||
psSelectAll = edit->addAction(tr::lng_mac_menu_select_all(tr::now), this, SLOT(psMacSelectAll()), QKeySequence::SelectAll);
|
||||
@ -752,31 +718,55 @@ void MainWindow::createGlobalMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::psMacUndo() {
|
||||
_sendKeySequence(Qt::Key_Z, Qt::ControlModifier);
|
||||
SendKeySequence(Qt::Key_Z, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacRedo() {
|
||||
_sendKeySequence(Qt::Key_Z, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
SendKeySequence(Qt::Key_Z, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacCut() {
|
||||
_sendKeySequence(Qt::Key_X, Qt::ControlModifier);
|
||||
SendKeySequence(Qt::Key_X, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacCopy() {
|
||||
_sendKeySequence(Qt::Key_C, Qt::ControlModifier);
|
||||
SendKeySequence(Qt::Key_C, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacPaste() {
|
||||
_sendKeySequence(Qt::Key_V, Qt::ControlModifier);
|
||||
SendKeySequence(Qt::Key_V, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacDelete() {
|
||||
_sendKeySequence(Qt::Key_Delete);
|
||||
SendKeySequence(Qt::Key_Delete);
|
||||
}
|
||||
|
||||
void MainWindow::psMacSelectAll() {
|
||||
_sendKeySequence(Qt::Key_A, Qt::ControlModifier);
|
||||
SendKeySequence(Qt::Key_A, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacBold() {
|
||||
SendKeySequence(Qt::Key_B, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacItalic() {
|
||||
SendKeySequence(Qt::Key_I, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacUnderline() {
|
||||
SendKeySequence(Qt::Key_U, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacStrikeOut() {
|
||||
SendKeySequence(Qt::Key_X, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacMonospace() {
|
||||
SendKeySequence(Qt::Key_M, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psMacClearFormat() {
|
||||
SendKeySequence(Qt::Key_N, Qt::ControlModifier | Qt::ShiftModifier);
|
||||
}
|
||||
|
||||
void MainWindow::psInitSysMenu() {
|
||||
@ -821,26 +811,26 @@ void MainWindow::updateGlobalMenuHook() {
|
||||
const auto locked = Core::App().locked();
|
||||
const auto inactive = !logged || locked;
|
||||
const auto support = logged && account().session().supportMode();
|
||||
_forceDisabled(psLogout, !logged && !locked);
|
||||
_forceDisabled(psUndo, !canUndo);
|
||||
_forceDisabled(psRedo, !canRedo);
|
||||
_forceDisabled(psCut, !canCut);
|
||||
_forceDisabled(psCopy, !canCopy);
|
||||
_forceDisabled(psPaste, !canPaste);
|
||||
_forceDisabled(psDelete, !canDelete);
|
||||
_forceDisabled(psSelectAll, !canSelectAll);
|
||||
_forceDisabled(psContacts, inactive || support);
|
||||
_forceDisabled(psAddContact, inactive);
|
||||
_forceDisabled(psNewGroup, inactive || support);
|
||||
_forceDisabled(psNewChannel, inactive || support);
|
||||
_forceDisabled(psShowTelegram, App::wnd()->isActive());
|
||||
ForceDisabled(psLogout, !logged && !locked);
|
||||
ForceDisabled(psUndo, !canUndo);
|
||||
ForceDisabled(psRedo, !canRedo);
|
||||
ForceDisabled(psCut, !canCut);
|
||||
ForceDisabled(psCopy, !canCopy);
|
||||
ForceDisabled(psPaste, !canPaste);
|
||||
ForceDisabled(psDelete, !canDelete);
|
||||
ForceDisabled(psSelectAll, !canSelectAll);
|
||||
ForceDisabled(psContacts, inactive || support);
|
||||
ForceDisabled(psAddContact, inactive);
|
||||
ForceDisabled(psNewGroup, inactive || support);
|
||||
ForceDisabled(psNewChannel, inactive || support);
|
||||
ForceDisabled(psShowTelegram, App::wnd()->isActive());
|
||||
|
||||
_forceDisabled(psBold, !showTouchBarItem);
|
||||
_forceDisabled(psItalic, !showTouchBarItem);
|
||||
_forceDisabled(psUnderline, !showTouchBarItem);
|
||||
_forceDisabled(psStrikeOut, !showTouchBarItem);
|
||||
_forceDisabled(psMonospace, !showTouchBarItem);
|
||||
_forceDisabled(psClearFormat, !showTouchBarItem);
|
||||
ForceDisabled(psBold, !showTouchBarItem);
|
||||
ForceDisabled(psItalic, !showTouchBarItem);
|
||||
ForceDisabled(psUnderline, !showTouchBarItem);
|
||||
ForceDisabled(psStrikeOut, !showTouchBarItem);
|
||||
ForceDisabled(psMonospace, !showTouchBarItem);
|
||||
ForceDisabled(psClearFormat, !showTouchBarItem);
|
||||
}
|
||||
|
||||
bool MainWindow::psFilterNativeEvent(void *event) {
|
||||
|
Loading…
Reference in New Issue
Block a user