22 : QFrame(
nullptr, Qt::Popup)
23 , m_openPagesModel(model)
28 m_openPagesWidget =
new OpenPagesWidget(m_openPagesModel);
33 setFrameStyle(m_openPagesWidget->frameStyle());
35 m_openPagesWidget->setFrameStyle(QFrame::NoFrame);
38 m_openPagesWidget->installEventFilter(
this);
40 QVBoxLayout *layout =
new QVBoxLayout(
this);
41 layout->setContentsMargins(QMargins());
42 layout->addWidget(m_openPagesWidget);
44 connect(m_openPagesWidget, &OpenPagesWidget::closePage,
45 this, &OpenPagesSwitcher::closePage);
46 connect(m_openPagesWidget, &OpenPagesWidget::setCurrentPage,
47 this, &OpenPagesSwitcher::setCurrentPage);
98 if (object == m_openPagesWidget) {
99 if (event->type() == QEvent::KeyPress) {
100 QKeyEvent *ke =
static_cast<QKeyEvent*>(event);
101 if (ke->key() == Qt::Key_Escape) {
106 const int key = ke->key();
107 if (key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) {
108 emit setCurrentPage(m_openPagesWidget->currentIndex());
112 Qt::KeyboardModifier modifier = Qt::ControlModifier;
114 modifier = Qt::AltModifier;
116 if (key == Qt::Key_Backtab
117 && (ke->modifiers() == (modifier | Qt::ShiftModifier)))
119 else if (key == Qt::Key_Tab && (ke->modifiers() == modifier))
121 }
else if (event->type() == QEvent::KeyRelease) {
122 QKeyEvent *ke =
static_cast<QKeyEvent*>(event);
123 if (ke->modifiers() == 0
125 || (ke->modifiers() == Qt::AltModifier
126 && (ke->key() == Qt::Key_Alt || ke->key() == -1))) {
131 return QWidget::eventFilter(object, event);
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
~OpenPagesSwitcher() override
void focusInEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
void setVisible(bool visible) override
bool eventFilter(QObject *object, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
QT_BEGIN_NAMESPACE const int gWidth