Merge branch 'master' of https://github.com/olive-editor/olive
This commit is contained in:
@@ -344,7 +344,7 @@ void ViewerDisplayWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
text_edit->setGeometry(transformed_geom.toRect());
|
||||
|
||||
ViewerTextEditorToolBar *toolbar = new ViewerTextEditorToolBar(this);
|
||||
toolbar->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
|
||||
toolbar->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||
toolbar->resize(toolbar->sizeHint());
|
||||
|
||||
QPoint pos = mapToGlobal(QPoint(transformed_geom.x(), transformed_geom.y() - toolbar->height()));
|
||||
@@ -376,6 +376,12 @@ void ViewerDisplayWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
// Start text cursor where the user clicked
|
||||
text_edit->setTextCursor(text_edit->cursorForPosition(text_edit_pos));
|
||||
|
||||
// HACK: On macOS, for some reason the QDockWidget receives focus before the
|
||||
// ViewerTextEditor, causing the editor to close prematurely. However this only
|
||||
// happens the first time the editor receives focus and not subsequent times, so
|
||||
// if we get it to only listen after the first one, this solves the problem.
|
||||
text_edit->SetListenToFocusEvents(true);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ namespace olive {
|
||||
ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent) :
|
||||
super(parent),
|
||||
transparent_clone_(nullptr),
|
||||
block_update_toolbar_signal_(false)
|
||||
block_update_toolbar_signal_(false),
|
||||
listen_to_focus_events_(false)
|
||||
{
|
||||
// Ensure default text color is white
|
||||
QPalette p = palette();
|
||||
@@ -175,6 +176,10 @@ void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar, const QTe
|
||||
|
||||
void ViewerTextEditor::FocusChanged(QWidget *old, QWidget *now)
|
||||
{
|
||||
if (!listen_to_focus_events_) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget *test = now;
|
||||
|
||||
if (!test) {
|
||||
|
||||
@@ -134,6 +134,8 @@ public:
|
||||
|
||||
void ConnectToolBar(ViewerTextEditorToolBar *toolbar);
|
||||
|
||||
void SetListenToFocusEvents(bool e) { listen_to_focus_events_ = e; }
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
@@ -152,6 +154,8 @@ private:
|
||||
|
||||
bool block_update_toolbar_signal_;
|
||||
|
||||
bool listen_to_focus_events_;
|
||||
|
||||
private slots:
|
||||
void FocusChanged(QWidget *old, QWidget *now);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user