Skip to content

Commit

Permalink
try to clean up tab to shift focus behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Apr 16, 2024
1 parent a88645f commit 62048b6
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/Form_Files/FindReplace.ui
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,12 @@ Valid only when searching HTML files.</string>
<tabstops>
<tabstop>cbFind</tabstop>
<tabstop>cbReplace</tabstop>
<tabstop>tbRegexOptions</tabstop>
<tabstop>chkOptionWrap</tabstop>
<tabstop>chkOptionTextOnly</tabstop>
<tabstop>cbSearchMode</tabstop>
<tabstop>cbLookWhere</tabstop>
<tabstop>cbSearchDirection</tabstop>
<tabstop>tbRegexOptions</tabstop>
<tabstop>chkOptionWrap</tabstop>
<tabstop>chkOptionTextOnly</tabstop>
<tabstop>findNext</tabstop>
<tabstop>replaceFind</tabstop>
<tabstop>replaceCurrent</tabstop>
Expand Down
10 changes: 10 additions & 0 deletions src/MainUI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6223,6 +6223,16 @@ void MainWindow::ExtendUI()
ui.tbAutomate2->setDefaultAction(ui.actionAutomate2);
ui.tbAutomate3->setDefaultAction(ui.actionAutomate3);

#if 1
// use this code to disable any QToolButtons with pull down menus
// from inadvertantly being on the tab to shift focus chain
ui.tbHeadings->setFocusPolicy(Qt::ClickFocus);
ui.tbCase->setFocusPolicy(Qt::ClickFocus);
ui.tbAutomate1->setFocusPolicy(Qt::ClickFocus);
ui.tbAutomate2->setFocusPolicy(Qt::ClickFocus);
ui.tbAutomate3->setFocusPolicy(Qt::ClickFocus);
#endif

UpdateClipsUI();
}

Expand Down
75 changes: 54 additions & 21 deletions src/MainUI/PreviewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <QTimer>
#include <QProgressBar>
#include <QApplication>
#include <QToolButton>
#include <QDebug>

#include "MainUI/PreviewWindow.h"
Expand Down Expand Up @@ -68,9 +69,15 @@ static const QString MATHJAX3_CONFIG =
PreviewWindow::PreviewWindow(QWidget *parent)
:
QDockWidget(tr("Preview"), parent),
m_MainWidget(new QWidget(this)),
m_MainWidget(new QFrame(this)),
m_binspect(new QToolButton(m_MainWidget)),
m_bselect(new QToolButton(m_MainWidget)),
m_bcopy(new QToolButton(m_MainWidget)),
m_breload(new QToolButton(m_MainWidget)),
m_bcycle(new QToolButton(m_MainWidget)),
m_bprint(new QToolButton(m_MainWidget)),
m_wrapper(new QWidget(m_MainWidget)),
m_Layout(new QVBoxLayout(m_MainWidget)),
m_Layout(new QVBoxLayout()),
m_buttons(new QHBoxLayout()),
m_overlayBase(new OverlayHelperWidget(this)),
m_Preview(new ViewPreview(m_overlayBase)),
Expand All @@ -92,7 +99,24 @@ PreviewWindow::PreviewWindow(QWidget *parent)
SetupOverlayTimer();
LoadSettings();
ConnectSignalsToSlots();
setFocusPolicy(Qt::StrongFocus);
setFocusProxy(m_MainWidget);
m_MainWidget->setFocusPolicy(Qt::StrongFocus);
m_wrapper->setFocusPolicy(Qt::NoFocus);
m_Preview->setFocusPolicy(Qt::StrongFocus);

m_binspect->setFocusPolicy(Qt::StrongFocus);
m_bselect->setFocusPolicy(Qt::StrongFocus);
m_bcopy->setFocusPolicy(Qt::StrongFocus);
m_breload->setFocusPolicy(Qt::StrongFocus);
m_bcycle->setFocusPolicy(Qt::StrongFocus);
m_bprint->setFocusPolicy(Qt::StrongFocus);

setTabOrder(m_binspect, m_bselect);
setTabOrder(m_bselect, m_bcopy);
setTabOrder(m_bcopy, m_breload);
setTabOrder(m_breload, m_bcycle);
setTabOrder(m_bcycle, m_bprint);
setTabOrder(m_bprint, m_Preview);
}

PreviewWindow::~PreviewWindow()
Expand Down Expand Up @@ -238,63 +262,72 @@ void PreviewWindow::SetupView()
// QWebEngineView events are routed to their parent
m_Preview->installEventFilter(this);

#if 1 //!defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
// this may be needed by all platforms in the future
QWidget * fp = m_Preview->focusProxy();
if (fp) fp->installEventFilter(this);
#endif

m_Layout->setContentsMargins(0, 0, 0, 0);

// use a QWidget wrapper around the QWebEnginePreview
// with a single pixel margin to use as focus indicator
m_wrapper->setObjectName("PreviewWrapper");
m_wrapper->setFocusProxy(m_Preview);
// m_wrapper->setAttribute(Qt::WA_StyledBackground, true);
QVBoxLayout * wl = new QVBoxLayout(m_wrapper);
wl->setContentsMargins(1,1,1,1);
wl->addWidget(m_Preview);

m_Layout->setContentsMargins(0, 0, 0, 0);
m_Layout->addWidget(m_wrapper);

m_inspectAction = new QAction(QIcon(":/main/inspect.svg"),"", this);
m_inspectAction ->setEnabled(true);
m_inspectAction->setToolTip(tr("Inspect Page"));
m_binspect->setDefaultAction(m_inspectAction);
m_binspect->setAutoRaise(true);

m_selectAction = new QAction(QIcon(":/main/edit-select-all.svg"),"", this);
m_selectAction ->setEnabled(true);
m_selectAction->setToolTip(tr("Select-All"));
m_bselect->setDefaultAction(m_selectAction);
m_bselect->setAutoRaise(true);

m_copyAction = new QAction(QIcon(":/main/edit-copy.svg"),"", this);
m_copyAction ->setEnabled(true);
m_copyAction->setToolTip(tr("Copy Selection To ClipBoard"));
m_bcopy->setDefaultAction(m_copyAction);
m_bcopy->setAutoRaise(true);

m_reloadAction = new QAction(QIcon(":/main/reload-page.svg"),"", this);
m_reloadAction ->setEnabled(true);
m_reloadAction->setToolTip(tr("Update Preview Window"));
m_breload->setDefaultAction(m_reloadAction);
m_breload->setAutoRaise(true);

m_cycleCSSAction = new QAction(QIcon(":/main/cycle-css.svg"),"", this);
m_cycleCSSAction ->setEnabled(false);
m_cycleCSSAction->setToolTip(tr("Cycle Custom CSS Files"));
m_bcycle->setDefaultAction(m_cycleCSSAction);
m_bcycle->setAutoRaise(true);

QIcon pricon;
pricon.addFile(":/main/document-print.svg", QSize(), QIcon::Normal);
pricon.addFile(":/main/busy-working.svg", QSize(), QIcon::Disabled);
m_webviewPrint = new QAction(pricon, "", this);
m_webviewPrint ->setEnabled(true);
m_webviewPrint->setToolTip(tr("Print Preview View"));

QToolBar * tb = new QToolBar();
tb->addAction(m_inspectAction);
tb->addAction(m_selectAction);
tb->addAction(m_copyAction);
tb->addAction(m_reloadAction);
tb->addAction(m_cycleCSSAction);
tb->addAction(m_webviewPrint);
tb->addWidget(m_progress);

m_buttons->setContentsMargins(0,0,0,0);
m_buttons->addWidget(tb);
m_bprint->setDefaultAction(m_webviewPrint);
m_bprint->setAutoRaise(true);

m_buttons->setContentsMargins(1,1,1,1);
m_buttons->addWidget(m_binspect);
m_buttons->addWidget(m_bselect);
m_buttons->addWidget(m_bcopy);
m_buttons->addWidget(m_breload);
m_buttons->addWidget(m_bcycle);
m_buttons->addWidget(m_bprint);
m_buttons->addWidget(m_progress);

m_Layout->addLayout(m_buttons);

m_MainWidget->setLayout(m_Layout);

setWidget(m_MainWidget);
QApplication::restoreOverrideCursor();
}
Expand Down
10 changes: 9 additions & 1 deletion src/MainUI/PreviewWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class QHBoxLayout;
class QProgressBar;
class OverlayHelperWidget;
class WebViewPrinter;
class QToolButton;

class PreviewWindow : public QDockWidget
{
Expand Down Expand Up @@ -131,7 +132,13 @@ public slots:

const QString titleText();

QWidget *m_MainWidget;
QFrame *m_MainWidget;
QToolButton * m_binspect;
QToolButton * m_bselect;
QToolButton * m_bcopy;
QToolButton * m_breload;
QToolButton * m_bcycle;
QToolButton * m_bprint;
QWidget *m_wrapper;
QVBoxLayout *m_Layout;
QHBoxLayout *m_buttons;
Expand Down Expand Up @@ -164,6 +171,7 @@ public slots:
bool m_skipPrintPreview;
WebViewPrinter *m_WebViewPrinter;
bool m_use_focus_highlight;

};

#endif // PREVIEWWINDOW_H
8 changes: 7 additions & 1 deletion src/ViewEditors/CodeViewEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ CodeViewEditor::CodeViewEditor(HighlighterType high_type, bool check_spelling, Q
m_Highlighter = NULL;
}

setFocusPolicy(Qt::StrongFocus);

// if we use the following we can get instances
// of accidental insertion of tabs into CodeView
// when simply trying to shift focus
// setFocusPolicy(Qt::StrongFocus);
setFocusPolicy(Qt::ClickFocus);

ConnectSignalsToSlots();
SetAppearance();
}
Expand Down

0 comments on commit 62048b6

Please sign in to comment.