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