Fix focus lost
parent
80ccbc51bf
commit
b945ab9725
|
@ -194,6 +194,8 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
|
|
||||||
SkeletonPartTreeWidget *partTreeWidget = new SkeletonPartTreeWidget(m_document, partListDocker);
|
SkeletonPartTreeWidget *partTreeWidget = new SkeletonPartTreeWidget(m_document, partListDocker);
|
||||||
|
|
||||||
|
partTreeWidget->setGraphicsFunctions(graphicsWidget);
|
||||||
|
|
||||||
partListDocker->setWidget(partTreeWidget);
|
partListDocker->setWidget(partTreeWidget);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, partListDocker);
|
addDockWidget(Qt::RightDockWidgetArea, partListDocker);
|
||||||
|
|
||||||
|
@ -656,6 +658,16 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState);
|
connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState);
|
||||||
|
|
||||||
connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady);
|
connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady);
|
||||||
|
|
||||||
|
QTimer *timer = new QTimer(this);
|
||||||
|
timer->setInterval(100);
|
||||||
|
connect(timer, &QTimer::timeout, [=] {
|
||||||
|
QWidget *focusedWidget = QApplication::focusWidget();
|
||||||
|
//qDebug() << (focusedWidget ? ("Focused on:" + QString(focusedWidget->metaObject()->className()) + " title:" + focusedWidget->windowTitle()) : "No Focus") << " isActive:" << isActiveWindow();
|
||||||
|
if (nullptr == focusedWidget && isActiveWindow())
|
||||||
|
graphicsWidget->setFocus();
|
||||||
|
});
|
||||||
|
timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonDocumentWindow *SkeletonDocumentWindow::createDocumentWindow()
|
SkeletonDocumentWindow *SkeletonDocumentWindow::createDocumentWindow()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "skeletonparttreewidget.h"
|
#include "skeletonparttreewidget.h"
|
||||||
#include "skeletonpartwidget.h"
|
#include "skeletonpartwidget.h"
|
||||||
|
#include "skeletongraphicswidget.h"
|
||||||
|
|
||||||
SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent) :
|
SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent) :
|
||||||
QTreeWidget(parent),
|
QTreeWidget(parent),
|
||||||
|
@ -611,3 +612,14 @@ QSize SkeletonPartTreeWidget::sizeHint() const
|
||||||
return QSize(size.width() * 1.35, size.height() * 5.5);
|
return QSize(size.width() * 1.35, size.height() * 5.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkeletonPartTreeWidget::setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions)
|
||||||
|
{
|
||||||
|
m_graphicsFunctions = graphicsFunctions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkeletonPartTreeWidget::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
QTreeWidget::keyPressEvent(event);
|
||||||
|
if (m_graphicsFunctions)
|
||||||
|
m_graphicsFunctions->keyPress(event);
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include "skeletondocument.h"
|
#include "skeletondocument.h"
|
||||||
|
|
||||||
|
class SkeletonGraphicsFunctions;
|
||||||
|
|
||||||
class SkeletonPartTreeWidget : public QTreeWidget
|
class SkeletonPartTreeWidget : public QTreeWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -38,6 +40,7 @@ signals:
|
||||||
public:
|
public:
|
||||||
SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent);
|
SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent);
|
||||||
QTreeWidgetItem *findComponentItem(QUuid componentId);
|
QTreeWidgetItem *findComponentItem(QUuid componentId);
|
||||||
|
void setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions);
|
||||||
public slots:
|
public slots:
|
||||||
void componentNameChanged(QUuid componentId);
|
void componentNameChanged(QUuid componentId);
|
||||||
void componentChildrenChanged(QUuid componentId);
|
void componentChildrenChanged(QUuid componentId);
|
||||||
|
@ -66,6 +69,7 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
virtual void mousePressEvent(QMouseEvent *event);
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
private:
|
private:
|
||||||
void addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem);
|
void addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem);
|
||||||
void deleteItemChildren(QTreeWidgetItem *item);
|
void deleteItemChildren(QTreeWidgetItem *item);
|
||||||
|
@ -73,6 +77,7 @@ private:
|
||||||
const SkeletonDocument *m_document = nullptr;
|
const SkeletonDocument *m_document = nullptr;
|
||||||
std::map<QUuid, QTreeWidgetItem *> m_partItemMap;
|
std::map<QUuid, QTreeWidgetItem *> m_partItemMap;
|
||||||
std::map<QUuid, QTreeWidgetItem *> m_componentItemMap;
|
std::map<QUuid, QTreeWidgetItem *> m_componentItemMap;
|
||||||
|
SkeletonGraphicsFunctions *m_graphicsFunctions = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue