[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor] src/vimode/emulatedcommandbar: Move some of the creation stuff in the constructor of E
From: Simon St James <kdedevel () etotheipiplusone ! com>
Date: 2016-06-17 8:18:10
Message-ID: E1bDoyg-0002ZN-QK () scm ! kde ! org
[Download RAW message or body]
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 into 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/vimode/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 = new QHBoxLayout();
layout->setMargin(0);
centralWidget()->setLayout(layout);
- m_barTypeIndicator = new QLabel(this);
- m_barTypeIndicator->setObjectName(QStringLiteral("bartypeindicator"));
- layout->addWidget(m_barTypeIndicator);
- m_edit = new QLineEdit(this);
- m_edit->setObjectName(QStringLiteral("commandtext"));
- layout->addWidget(m_edit);
+ createAndAddBarTypeIndicator(layout);
+ createAndAddEditWidget(layout);
+ createAndAddExitStatusMessageDisplay(layout);
+ createAndInitExitStatusMessageDisplayTimer();
+ createAndAddWaitingForRegisterIndicator(layout);
- m_exitStatusMessageDisplay = new QLabel(this);
- m_exitStatusMessageDisplay->setObjectName(QStringLiteral("commandresponsemessage"));
- m_exitStatusMessageDisplay->setAlignment(Qt::AlignLeft);
- layout->addWidget(m_exitStatusMessageDisplay);
-
- m_waitingForRegisterIndicator = new QLabel(this);
- m_waitingForRegisterIndicator->setObjectName(QStringLiteral("waitingforregisterindicator"));
- 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(InputModeManager \
*viInputModeManager, QWi
connect(m_edit, SIGNAL(textChanged(QString)), this, \
SLOT(editTextChanged(QString)));
- m_exitStatusMessageDisplayHideTimer = 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_exitStatusMessageDisplayHideTimer, SLOT(stop()));
- // We can restart the timer once the view has focus again, though.
- connect(m_view, SIGNAL(focusIn(KTextEditor::View*)), this, \
SLOT(startHideExitStatusMessageTimer()));
-
}
EmulatedCommandBar::~EmulatedCommandBar()
@@ -418,3 +397,47 @@ void EmulatedCommandBar::hideAllWidgetsExcept(QWidget* \
widgetToKeepVisible)
}
+void EmulatedCommandBar::createAndAddBarTypeIndicator(QLayout* layout)
+{
+ m_barTypeIndicator = new QLabel(this);
+ m_barTypeIndicator->setObjectName(QStringLiteral("bartypeindicator"));
+ layout->addWidget(m_barTypeIndicator);
+}
+
+void EmulatedCommandBar::createAndAddEditWidget(QLayout* layout)
+{
+ m_edit = new QLineEdit(this);
+ m_edit->setObjectName(QStringLiteral("commandtext"));
+ layout->addWidget(m_edit);
+}
+
+void EmulatedCommandBar::createAndAddExitStatusMessageDisplay(QLayout* layout)
+{
+ m_exitStatusMessageDisplay = new QLabel(this);
+ m_exitStatusMessageDisplay->setObjectName(QStringLiteral("commandresponsemessage"));
+ m_exitStatusMessageDisplay->setAlignment(Qt::AlignLeft);
+ layout->addWidget(m_exitStatusMessageDisplay);
+}
+
+void EmulatedCommandBar::createAndInitExitStatusMessageDisplayTimer()
+{
+ m_exitStatusMessageDisplayHideTimer = 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_exitStatusMessageDisplayHideTimer, SLOT(stop())); + // We can restart the timer \
once the view has focus again, though. + connect(m_view, \
SIGNAL(focusIn(KTextEditor::View*)), this, SLOT(startHideExitStatusMessageTimer())); \
+} +
+void EmulatedCommandBar::createAndAddWaitingForRegisterIndicator(QLayout* layout)
+{
+ m_waitingForRegisterIndicator = new QLabel(this);
+ m_waitingForRegisterIndicator->setObjectName(QStringLiteral("waitingforregisterindicator"));
+ m_waitingForRegisterIndicator->setVisible(false);
+ m_waitingForRegisterIndicator->setText(QStringLiteral("\""));
+ layout->addWidget(m_waitingForRegisterIndicator);
+}
diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.h \
b/src/vimode/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 = false;
+ bool m_wasAborted = true;
Mode m_mode = NoMode;
KTextEditor::ViewPrivate *m_view = nullptr;
QLineEdit *m_edit = nullptr;
+
QLabel *m_barTypeIndicator = nullptr;
void showBarTypeIndicator(Mode mode);
- bool m_wasAborted = true;
+
bool m_suspendEditEventFiltering = false;
+
bool m_waitingForRegister = false ;
QLabel *m_waitingForRegisterIndicator;
bool m_insertedTextShouldBeEscapedForSearchingAsLiteral = false;
@@ -109,6 +113,13 @@ private:
QTimer *m_exitStatusMessageDisplayHideTimer;
QLabel *m_exitStatusMessageDisplay;
long m_exitStatusMessageHideTimeOutMS = 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();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic