Git commit e3f71cd2d7dfbcfc8ad8cd63b7a73e89d4b3e9a9 by Simon St James. Committed on 17/06/2016 at 08:14. Pushed by sstjames into branch 'master'. Move some of the creation stuff in the constructor of EmulatedCommandBar in= to helper methods - looks a bit cleaner. M +50 -27 src/vimode/emulatedcommandbar/emulatedcommandbar.cpp M +12 -1 src/vimode/emulatedcommandbar/emulatedcommandbar.h http://commits.kde.org/ktexteditor/e3f71cd2d7dfbcfc8ad8cd63b7a73e89d4b3e9a9 diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp b/src/vim= ode/emulatedcommandbar/emulatedcommandbar.cpp index 6d071fa..527b9b4 100644 --- a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp +++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp @@ -73,27 +73,17 @@ EmulatedCommandBar::EmulatedCommandBar(InputModeManager= *viInputModeManager, QWi : KateViewBarWidget(false, parent) , m_viInputModeManager(viInputModeManager) , m_view(viInputModeManager->view()){ + QHBoxLayout *layout =3D new QHBoxLayout(); layout->setMargin(0); centralWidget()->setLayout(layout); - m_barTypeIndicator =3D new QLabel(this); - m_barTypeIndicator->setObjectName(QStringLiteral("bartypeindicator")); - layout->addWidget(m_barTypeIndicator); = - m_edit =3D new QLineEdit(this); - m_edit->setObjectName(QStringLiteral("commandtext")); - layout->addWidget(m_edit); + createAndAddBarTypeIndicator(layout); + createAndAddEditWidget(layout); + createAndAddExitStatusMessageDisplay(layout); + createAndInitExitStatusMessageDisplayTimer(); + createAndAddWaitingForRegisterIndicator(layout); = - m_exitStatusMessageDisplay =3D new QLabel(this); - m_exitStatusMessageDisplay->setObjectName(QStringLiteral("commandrespo= nsemessage")); - m_exitStatusMessageDisplay->setAlignment(Qt::AlignLeft); - layout->addWidget(m_exitStatusMessageDisplay); - - m_waitingForRegisterIndicator =3D new QLabel(this); - m_waitingForRegisterIndicator->setObjectName(QStringLiteral("waitingfo= rregisterindicator")); - m_waitingForRegisterIndicator->setVisible(false); - m_waitingForRegisterIndicator->setText(QStringLiteral("\"")); - layout->addWidget(m_waitingForRegisterIndicator); = m_matchHighligher.reset(new MatchHighlighter(m_view)); = @@ -112,17 +102,6 @@ EmulatedCommandBar::EmulatedCommandBar(InputModeManage= r *viInputModeManager, QWi connect(m_edit, SIGNAL(textChanged(QString)), this, SLOT(editTextChang= ed(QString))); = = - m_exitStatusMessageDisplayHideTimer =3D new QTimer(this); - m_exitStatusMessageDisplayHideTimer->setSingleShot(true); - connect(m_exitStatusMessageDisplayHideTimer, SIGNAL(timeout()), - this, SIGNAL(hideMe())); - // Make sure the timer is stopped when the user switches views. If not= , focus will be given to the - // wrong view when KateViewBar::hideCurrentBarWidget() is called as a = result of m_commandResponseMessageDisplayHide - // timing out. - connect(m_view, SIGNAL(focusOut(KTextEditor::View*)), m_exitStatusMess= ageDisplayHideTimer, SLOT(stop())); - // We can restart the timer once the view has focus again, though. - connect(m_view, SIGNAL(focusIn(KTextEditor::View*)), this, SLOT(startH= ideExitStatusMessageTimer())); - } = EmulatedCommandBar::~EmulatedCommandBar() @@ -418,3 +397,47 @@ void EmulatedCommandBar::hideAllWidgetsExcept(QWidget*= widgetToKeepVisible) = } = +void EmulatedCommandBar::createAndAddBarTypeIndicator(QLayout* layout) +{ + m_barTypeIndicator =3D new QLabel(this); + m_barTypeIndicator->setObjectName(QStringLiteral("bartypeindicator")); + layout->addWidget(m_barTypeIndicator); +} + +void EmulatedCommandBar::createAndAddEditWidget(QLayout* layout) +{ + m_edit =3D new QLineEdit(this); + m_edit->setObjectName(QStringLiteral("commandtext")); + layout->addWidget(m_edit); +} + +void EmulatedCommandBar::createAndAddExitStatusMessageDisplay(QLayout* lay= out) +{ + m_exitStatusMessageDisplay =3D new QLabel(this); + m_exitStatusMessageDisplay->setObjectName(QStringLiteral("commandrespo= nsemessage")); + m_exitStatusMessageDisplay->setAlignment(Qt::AlignLeft); + layout->addWidget(m_exitStatusMessageDisplay); +} + +void EmulatedCommandBar::createAndInitExitStatusMessageDisplayTimer() +{ + m_exitStatusMessageDisplayHideTimer =3D new QTimer(this); + m_exitStatusMessageDisplayHideTimer->setSingleShot(true); + connect(m_exitStatusMessageDisplayHideTimer, SIGNAL(timeout()), + this, SIGNAL(hideMe())); + // Make sure the timer is stopped when the user switches views. If not= , focus will be given to the + // wrong view when KateViewBar::hideCurrentBarWidget() is called as a = result of m_commandResponseMessageDisplayHide + // timing out. + connect(m_view, SIGNAL(focusOut(KTextEditor::View*)), m_exitStatusMess= ageDisplayHideTimer, SLOT(stop())); + // We can restart the timer once the view has focus again, though. + connect(m_view, SIGNAL(focusIn(KTextEditor::View*)), this, SLOT(startH= ideExitStatusMessageTimer())); +} + +void EmulatedCommandBar::createAndAddWaitingForRegisterIndicator(QLayout* = layout) +{ + m_waitingForRegisterIndicator =3D new QLabel(this); + m_waitingForRegisterIndicator->setObjectName(QStringLiteral("waitingfo= rregisterindicator")); + m_waitingForRegisterIndicator->setVisible(false); + m_waitingForRegisterIndicator->setText(QStringLiteral("\"")); + layout->addWidget(m_waitingForRegisterIndicator); +} diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.h b/src/vimod= e/emulatedcommandbar/emulatedcommandbar.h index 18f4ac9..d353684 100644 --- a/src/vimode/emulatedcommandbar/emulatedcommandbar.h +++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.h @@ -35,6 +35,7 @@ namespace KTextEditor { } = class QLabel; +class QLayout; = namespace KateVi { @@ -72,13 +73,16 @@ private: = InputModeManager *m_viInputModeManager; bool m_isActive =3D false; + bool m_wasAborted =3D true; Mode m_mode =3D NoMode; KTextEditor::ViewPrivate *m_view =3D nullptr; QLineEdit *m_edit =3D nullptr; + QLabel *m_barTypeIndicator =3D nullptr; void showBarTypeIndicator(Mode mode); - bool m_wasAborted =3D true; + bool m_suspendEditEventFiltering =3D false; + bool m_waitingForRegister =3D false ; QLabel *m_waitingForRegisterIndicator; bool m_insertedTextShouldBeEscapedForSearchingAsLiteral =3D false; @@ -109,6 +113,13 @@ private: QTimer *m_exitStatusMessageDisplayHideTimer; QLabel *m_exitStatusMessageDisplay; long m_exitStatusMessageHideTimeOutMS =3D 4000; + + void createAndAddBarTypeIndicator(QLayout* layout); + void createAndAddEditWidget(QLayout* layout); + void createAndAddExitStatusMessageDisplay(QLayout* layout); + void createAndInitExitStatusMessageDisplayTimer(); + void createAndAddWaitingForRegisterIndicator(QLayout* layout); + private Q_SLOTS: void editTextChanged(const QString &newText); void startHideExitStatusMessageTimer();