mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Get rid of Q_OBJECT in HistoryInner
This commit is contained in:
parent
f469cab7b0
commit
1c8d4ee7ab
3 changed files with 7 additions and 10 deletions
|
@ -72,9 +72,6 @@ class HistoryWidget;
|
||||||
class HistoryInner
|
class HistoryInner
|
||||||
: public Ui::RpWidget
|
: public Ui::RpWidget
|
||||||
, public Ui::AbstractTooltipShower {
|
, public Ui::AbstractTooltipShower {
|
||||||
// The Q_OBJECT meta info is used for qobject_cast!
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Element = HistoryView::Element;
|
using Element = HistoryView::Element;
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ void SendKeySequence(
|
||||||
const auto focused = QApplication::focusWidget();
|
const auto focused = QApplication::focusWidget();
|
||||||
if (qobject_cast<QLineEdit*>(focused)
|
if (qobject_cast<QLineEdit*>(focused)
|
||||||
|| qobject_cast<QTextEdit*>(focused)
|
|| qobject_cast<QTextEdit*>(focused)
|
||||||
|| qobject_cast<HistoryInner*>(focused)) {
|
|| dynamic_cast<HistoryInner*>(focused)) {
|
||||||
QApplication::postEvent(
|
QApplication::postEvent(
|
||||||
focused,
|
focused,
|
||||||
new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
||||||
|
@ -826,12 +826,12 @@ void MainWindow::updateGlobalMenuHook() {
|
||||||
canRedo = edit->document()->isRedoAvailable();
|
canRedo = edit->document()->isRedoAvailable();
|
||||||
canPaste = clipboardHasText;
|
canPaste = clipboardHasText;
|
||||||
if (canCopy) {
|
if (canCopy) {
|
||||||
if (const auto inputField = qobject_cast<Ui::InputField*>(
|
if (const auto inputField = dynamic_cast<Ui::InputField*>(
|
||||||
focused->parentWidget())) {
|
focused->parentWidget())) {
|
||||||
markdownEnabled = inputField->isMarkdownEnabled();
|
markdownEnabled = inputField->isMarkdownEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (const auto list = qobject_cast<HistoryInner*>(focused)) {
|
} else if (const auto list = dynamic_cast<HistoryInner*>(focused)) {
|
||||||
canCopy = list->canCopySelected();
|
canCopy = list->canCopySelected();
|
||||||
canDelete = list->canDeleteSelected();
|
canDelete = list->canDeleteSelected();
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ namespace {
|
||||||
|
|
||||||
void SendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
void SendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
||||||
const auto focused = QApplication::focusWidget();
|
const auto focused = QApplication::focusWidget();
|
||||||
if (qobject_cast<QLineEdit*>(focused) || qobject_cast<QTextEdit*>(focused) || qobject_cast<HistoryInner*>(focused)) {
|
if (qobject_cast<QLineEdit*>(focused) || qobject_cast<QTextEdit*>(focused) || dynamic_cast<HistoryInner*>(focused)) {
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers));
|
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers));
|
||||||
}
|
}
|
||||||
|
@ -628,12 +628,12 @@ void MainWindow::updateGlobalMenuHook() {
|
||||||
canRedo = edit->document()->isRedoAvailable();
|
canRedo = edit->document()->isRedoAvailable();
|
||||||
canPaste = clipboardHasText;
|
canPaste = clipboardHasText;
|
||||||
if (canCopy) {
|
if (canCopy) {
|
||||||
if (const auto inputField = qobject_cast<Ui::InputField*>(
|
if (const auto inputField = dynamic_cast<Ui::InputField*>(
|
||||||
focused->parentWidget())) {
|
focused->parentWidget())) {
|
||||||
canApplyMarkdown = inputField->isMarkdownEnabled();
|
canApplyMarkdown = inputField->isMarkdownEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (auto list = qobject_cast<HistoryInner*>(focused)) {
|
} else if (auto list = dynamic_cast<HistoryInner*>(focused)) {
|
||||||
canCopy = list->canCopySelected();
|
canCopy = list->canCopySelected();
|
||||||
canDelete = list->canDeleteSelected();
|
canDelete = list->canDeleteSelected();
|
||||||
}
|
}
|
||||||
|
@ -669,7 +669,7 @@ void MainWindow::updateGlobalMenuHook() {
|
||||||
bool MainWindow::eventFilter(QObject *obj, QEvent *evt) {
|
bool MainWindow::eventFilter(QObject *obj, QEvent *evt) {
|
||||||
QEvent::Type t = evt->type();
|
QEvent::Type t = evt->type();
|
||||||
if (t == QEvent::FocusIn || t == QEvent::FocusOut) {
|
if (t == QEvent::FocusIn || t == QEvent::FocusOut) {
|
||||||
if (qobject_cast<QLineEdit*>(obj) || qobject_cast<QTextEdit*>(obj) || qobject_cast<HistoryInner*>(obj)) {
|
if (qobject_cast<QLineEdit*>(obj) || qobject_cast<QTextEdit*>(obj) || dynamic_cast<HistoryInner*>(obj)) {
|
||||||
updateGlobalMenu();
|
updateGlobalMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue