aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/codetester/CodeTesterWindow.cpp
diff options
context:
space:
mode:
authorGravatar wodim2017-09-03 22:37:17 +0200
committerGravatar GitHub2017-09-03 22:37:17 +0200
commit5f0e412722823e1d4a3061d7b85a2ee2bf84464b (patch)
tree13b3fbf67a078b4ee5aafef2728e464cfc2c48ba /src/modules/codetester/CodeTesterWindow.cpp
parentKviKvsPopupMenu: Code cleanup (diff)
downloadKVIrc-5f0e412722823e1d4a3061d7b85a2ee2bf84464b.tar.gz
KVIrc-5f0e412722823e1d4a3061d7b85a2ee2bf84464b.tar.bz2
KVIrc-5f0e412722823e1d4a3061d7b85a2ee2bf84464b.zip
Improve the script tester a little bit (#2282)
* Fix the code editor not being focused by default in the script tester dialog, add a "find" button, and fix the colour of the find lineedit. * Add a dedicated ircview for the code tester.
Diffstat (limited to 'src/modules/codetester/CodeTesterWindow.cpp')
-rw-r--r--src/modules/codetester/CodeTesterWindow.cpp46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/modules/codetester/CodeTesterWindow.cpp b/src/modules/codetester/CodeTesterWindow.cpp
index 1e8b4a762..91a95a193 100644
--- a/src/modules/codetester/CodeTesterWindow.cpp
+++ b/src/modules/codetester/CodeTesterWindow.cpp
@@ -34,6 +34,7 @@
#include "KviConsoleWindow.h"
#include "KviKvsScript.h"
#include "KviKvsVariantList.h"
+#include "KviIrcView.h"
#include <QPushButton>
#include <QLayout>
@@ -44,11 +45,19 @@
extern std::unordered_set<CodeTesterWindow *> g_pCodeTesterWindowList;
-CodeTesterWidget::CodeTesterWidget(QWidget * par)
- : QWidget(par)
+CodeTesterWindow::CodeTesterWindow()
+ : KviWindow(KviWindow::ScriptEditor, "codetester", nullptr)
{
+ g_pCodeTesterWindowList.insert(this);
setObjectName("code_tester");
- QGridLayout * g = new QGridLayout(this);
+
+ m_pSplitter = new KviTalSplitter(Qt::Horizontal, this);
+ m_pSplitter->setObjectName("main_splitter");
+ m_pSplitter->setChildrenCollapsible(false);
+
+ // layouts can't be added to splitters directly, so we embed the layout in a widget.
+ QWidget * l = new QWidget(this);
+ QGridLayout * g = new QGridLayout(l);
m_pEditor = KviScriptEditor::createInstance(this);
g->addWidget(m_pEditor, 0, 0, 1, 4);
@@ -61,36 +70,29 @@ CodeTesterWidget::CodeTesterWidget(QWidget * par)
m_pParams = new QLineEdit(this);
m_pParams->setToolTip(__tr2qs_ctx("Here you can specify a semicolon-separated list of parameters that will be available in the code as $0, $1, $2, ..", "editor"));
g->addWidget(m_pParams, 1, 2);
+
+ m_pSplitter->addWidget(l);
+
+ m_pIrcView = new KviIrcView(m_pSplitter, this);
+
+ QList<int> li { width() / 2, width() / 2 };
+ m_pSplitter->setSizes(li);
}
-CodeTesterWidget::~CodeTesterWidget()
+CodeTesterWindow::~CodeTesterWindow()
{
KviScriptEditor::destroyInstance(m_pEditor);
+ g_pCodeTesterWindowList.erase(this);
}
-//#warning "Allow to bind the command to a specified window"
-
-void CodeTesterWidget::execute()
+void CodeTesterWindow::execute()
{
QString buffer;
m_pEditor->getText(buffer);
KviConsoleWindow * pConsole = g_pApp->activeConsole();
QStringList slParams = m_pParams->text().split(';');
KviKvsVariantList params{&slParams};
- KviKvsScript::run(buffer, pConsole, &params);
-}
-
-CodeTesterWindow::CodeTesterWindow()
- : KviWindow(KviWindow::ScriptEditor, "codetester", nullptr)
-{
- g_pCodeTesterWindowList.insert(this);
-
- m_pTester = new CodeTesterWidget(this);
-}
-
-CodeTesterWindow::~CodeTesterWindow()
-{
- g_pCodeTesterWindowList.erase(this);
+ KviKvsScript::run(buffer, this, &params);
}
QPixmap * CodeTesterWindow::myIconPtr()
@@ -100,7 +102,7 @@ QPixmap * CodeTesterWindow::myIconPtr()
void CodeTesterWindow::resizeEvent(QResizeEvent *)
{
- m_pTester->setGeometry(0, 0, width(), height());
+ m_pSplitter->setGeometry(0, 0, width(), height());
}
void CodeTesterWindow::fillCaptionBuffers()