mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Fix focus and qml parenting with qml root
This commit is contained in:
parent
b106eafb0e
commit
aaae72a4f2
21 changed files with 15 additions and 38 deletions
|
@ -26,7 +26,7 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
target: MainWindow
|
||||
target: TimelineManager
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
@ -21,7 +21,6 @@ ApplicationWindow {
|
|||
minimumHeight: stack.implicitHeight
|
||||
width: stack.implicitWidth
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(dialog)
|
||||
|
||||
StackView {
|
||||
id: stack
|
||||
|
|
|
@ -12,8 +12,6 @@ import QtQuick.Layouts 1.12
|
|||
import im.nheko 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
//Component.onCompleted: Nheko.reparent(win)
|
||||
|
||||
id: win
|
||||
|
||||
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3)
|
||||
|
|
|
@ -28,7 +28,6 @@ ApplicationWindow {
|
|||
color: Nheko.colors.base
|
||||
modality: Qt.NonModal
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(win)
|
||||
|
||||
Component {
|
||||
id: packEditor
|
||||
|
|
|
@ -18,7 +18,6 @@ ApplicationWindow {
|
|||
|
||||
modality: Qt.NonModal
|
||||
flags: Qt.Dialog
|
||||
Component.onCompleted: Nheko.reparent(inputDialog)
|
||||
width: 350
|
||||
height: fontMetrics.lineSpacing * 7
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ ApplicationWindow {
|
|||
palette: Nheko.colors
|
||||
color: Nheko.colors.window
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(inviteDialogRoot)
|
||||
|
||||
Shortcut {
|
||||
sequence: "Ctrl+Enter"
|
||||
|
|
|
@ -17,7 +17,6 @@ ApplicationWindow {
|
|||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
palette: Nheko.colors
|
||||
color: Nheko.colors.window
|
||||
Component.onCompleted: Nheko.reparent(joinRoomRoot)
|
||||
width: 350
|
||||
height: fontMetrics.lineSpacing * 7
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ ApplicationWindow {
|
|||
|
||||
modality: Qt.NonModal
|
||||
flags: Qt.Dialog
|
||||
Component.onCompleted: Nheko.reparent(inputDialog)
|
||||
width: 350
|
||||
height: fontMetrics.lineSpacing * 7
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ ApplicationWindow {
|
|||
palette: Nheko.colors
|
||||
color: Nheko.colors.window
|
||||
flags: Qt.Tool | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(rawMessageRoot)
|
||||
|
||||
Shortcut {
|
||||
sequence: StandardKey.Cancel
|
||||
|
|
|
@ -22,7 +22,6 @@ ApplicationWindow {
|
|||
palette: Nheko.colors
|
||||
color: Nheko.colors.window
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(readReceiptsRoot)
|
||||
|
||||
Shortcut {
|
||||
sequence: StandardKey.Cancel
|
||||
|
|
|
@ -22,7 +22,6 @@ ApplicationWindow {
|
|||
color: Nheko.colors.window
|
||||
modality: Qt.WindowModal
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(roomDirectoryWindow)
|
||||
title: qsTr("Explore Public Rooms")
|
||||
|
||||
Shortcut {
|
||||
|
|
|
@ -24,7 +24,6 @@ ApplicationWindow {
|
|||
palette: Nheko.colors
|
||||
color: Nheko.colors.window
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(roomMembersRoot)
|
||||
|
||||
Shortcut {
|
||||
sequence: StandardKey.Cancel
|
||||
|
|
|
@ -23,7 +23,6 @@ ApplicationWindow {
|
|||
color: Nheko.colors.window
|
||||
modality: Qt.NonModal
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(roomSettingsDialog)
|
||||
title: qsTr("Room Settings")
|
||||
|
||||
Shortcut {
|
||||
|
|
|
@ -13,9 +13,6 @@ import QtQuick.Window 2.13
|
|||
import im.nheko 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
// this does not work in ApplicationWindow, just in Window
|
||||
//transientParent: Nheko.mainwindow()
|
||||
|
||||
id: userProfileDialog
|
||||
|
||||
property var profile
|
||||
|
@ -29,7 +26,6 @@ ApplicationWindow {
|
|||
title: profile.isGlobalUserProfile ? qsTr("Global User Profile") : qsTr("Room User Profile")
|
||||
modality: Qt.NonModal
|
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
Component.onCompleted: Nheko.reparent(userProfileDialog)
|
||||
|
||||
Shortcut {
|
||||
sequence: StandardKey.Cancel
|
||||
|
|
|
@ -175,8 +175,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
|||
&ChatPage::initializeEmptyViews,
|
||||
view_manager_,
|
||||
&TimelineViewManager::initializeRoomlist);
|
||||
connect(
|
||||
this, &ChatPage::chatFocusChanged, view_manager_, &TimelineViewManager::chatFocusChanged);
|
||||
connect(this, &ChatPage::syncUI, this, [this](const mtx::responses::Sync &sync) {
|
||||
view_manager_->sync(sync);
|
||||
|
||||
|
|
|
@ -143,7 +143,6 @@ signals:
|
|||
void retrievedPresence(const QString &statusMsg, mtx::presence::PresenceState state);
|
||||
void themeChanged();
|
||||
void decryptSidebarChanged();
|
||||
void chatFocusChanged(const bool focused);
|
||||
|
||||
//! Signals for device verificaiton
|
||||
void receivedDeviceVerificationAccept(const mtx::events::msg::KeyVerificationAccept &message);
|
||||
|
|
|
@ -130,8 +130,6 @@ MainWindow::MainWindow(QWindow *parent)
|
|||
|
||||
connect(chat_page_, SIGNAL(contentLoaded()), this, SLOT(removeOverlayProgressBar()));
|
||||
|
||||
connect(this, &MainWindow::focusChanged, chat_page_, &ChatPage::chatFocusChanged);
|
||||
|
||||
// connect(login_page_, &LoginPage::loginOk, this, [this](const mtx::responses::Login &res) {
|
||||
// http::client()->set_user(res.user_id);
|
||||
// showChatPage();
|
||||
|
@ -342,10 +340,6 @@ MainWindow::event(QEvent *event)
|
|||
|
||||
if (type == QEvent::Close) {
|
||||
closeEvent(static_cast<QCloseEvent *>(event));
|
||||
} else if (type == QEvent::WindowActivate) {
|
||||
emit focusChanged(true);
|
||||
} else if (type == QEvent::WindowDeactivate) {
|
||||
emit focusChanged(false);
|
||||
}
|
||||
|
||||
return QQuickView::event(event);
|
||||
|
|
|
@ -91,7 +91,6 @@ private slots:
|
|||
virtual void setWindowTitle(int notificationCount);
|
||||
|
||||
signals:
|
||||
void focusChanged(const bool focused);
|
||||
void reload();
|
||||
void secretsChanged();
|
||||
|
||||
|
|
|
@ -1031,7 +1031,7 @@ TimelineModel::setCurrentIndex(int index)
|
|||
if (index != oldIndex)
|
||||
emit currentIndexChanged(index);
|
||||
|
||||
if (!MainWindow::instance()->isActive())
|
||||
if (MainWindow::instance() != QGuiApplication::focusWindow())
|
||||
return;
|
||||
|
||||
if (!currentId.startsWith('m')) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "TimelineViewManager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDropEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QMetaType>
|
||||
|
@ -157,6 +158,16 @@ TimelineViewManager::TimelineViewManager(CallManager *, ChatPage *parent)
|
|||
isInitialSync_ = true;
|
||||
emit initialSyncChanged(true);
|
||||
});
|
||||
connect(qobject_cast<QApplication *>(QApplication::instance()),
|
||||
&QApplication::focusWindowChanged,
|
||||
this,
|
||||
&TimelineViewManager::focusChanged);
|
||||
}
|
||||
|
||||
bool
|
||||
TimelineViewManager::isWindowFocused() const
|
||||
{
|
||||
return MainWindow::instance() == QApplication::focusWindow();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -41,8 +41,7 @@ class TimelineViewManager : public QObject
|
|||
|
||||
Q_PROPERTY(
|
||||
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
|
||||
Q_PROPERTY(
|
||||
bool isWindowFocused MEMBER isWindowFocused_ READ isWindowFocused NOTIFY focusChanged)
|
||||
Q_PROPERTY(bool isWindowFocused READ isWindowFocused NOTIFY focusChanged)
|
||||
|
||||
public:
|
||||
TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr);
|
||||
|
@ -54,7 +53,7 @@ public:
|
|||
void clearAll() { rooms_->clear(); }
|
||||
|
||||
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
||||
bool isWindowFocused() const { return isWindowFocused_; }
|
||||
bool isWindowFocused() const;
|
||||
Q_INVOKABLE void openImageOverlay(TimelineModel *room, QString mxcUrl, QString eventId);
|
||||
Q_INVOKABLE void openImagePackSettings(QString roomid);
|
||||
Q_INVOKABLE void saveMedia(QString mxcUrl);
|
||||
|
@ -93,11 +92,6 @@ public slots:
|
|||
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
||||
void receivedSessionKey(const std::string &room_id, const std::string &session_id);
|
||||
void initializeRoomlist();
|
||||
void chatFocusChanged(bool focused)
|
||||
{
|
||||
isWindowFocused_ = focused;
|
||||
emit focusChanged();
|
||||
}
|
||||
|
||||
void showEvent(const QString &room_id, const QString &event_id);
|
||||
|
||||
|
@ -117,7 +111,6 @@ public slots:
|
|||
|
||||
private:
|
||||
bool isInitialSync_ = true;
|
||||
bool isWindowFocused_ = false;
|
||||
|
||||
RoomlistModel *rooms_ = nullptr;
|
||||
CommunitiesModel *communities_ = nullptr;
|
||||
|
|
Loading…
Reference in a new issue