Changeset View
Changeset View
Standalone View
Standalone View
addons/replicode/replicodeview.cpp
Show All 30 Lines | |||||
31 | 31 | | |||
32 | ReplicodeView::ReplicodeView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow* mainWindow) : | 32 | ReplicodeView::ReplicodeView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow* mainWindow) : | ||
33 | QObject(mainWindow), | 33 | QObject(mainWindow), | ||
34 | m_mainWindow(mainWindow), | 34 | m_mainWindow(mainWindow), | ||
35 | m_executor(nullptr) | 35 | m_executor(nullptr) | ||
36 | { | 36 | { | ||
37 | m_runAction = new QAction(QIcon(QStringLiteral("code-block")), i18n("Run replicode"), this); | 37 | m_runAction = new QAction(QIcon(QStringLiteral("code-block")), i18n("Run replicode"), this); | ||
38 | actionCollection()->setDefaultShortcut(m_runAction, Qt::Key_F8); | 38 | actionCollection()->setDefaultShortcut(m_runAction, Qt::Key_F8); | ||
39 | connect(m_runAction, SIGNAL(triggered()), SLOT(runReplicode())); | 39 | connect(m_runAction, &QAction::triggered, this, &ReplicodeView::runReplicode); | ||
40 | actionCollection()->addAction(QStringLiteral("katereplicode_run"), m_runAction); | 40 | actionCollection()->addAction(QStringLiteral("katereplicode_run"), m_runAction); | ||
41 | 41 | | |||
42 | m_stopAction = new QAction(QIcon(QStringLiteral("process-stop")), i18n("Stop replicode"), this); | 42 | m_stopAction = new QAction(QIcon(QStringLiteral("process-stop")), i18n("Stop replicode"), this); | ||
43 | actionCollection()->setDefaultShortcut(m_stopAction, Qt::Key_F9); | 43 | actionCollection()->setDefaultShortcut(m_stopAction, Qt::Key_F9); | ||
44 | connect(m_stopAction, SIGNAL(triggered()), SLOT(stopReplicode())); | 44 | connect(m_stopAction, &QAction::triggered, this, &ReplicodeView::stopReplicode); | ||
45 | actionCollection()->addAction(QStringLiteral("katereplicode_stop"), m_stopAction); | 45 | actionCollection()->addAction(QStringLiteral("katereplicode_stop"), m_stopAction); | ||
46 | m_stopAction->setEnabled(false); | 46 | m_stopAction->setEnabled(false); | ||
47 | 47 | | |||
48 | m_toolview = m_mainWindow->createToolView( | 48 | m_toolview = m_mainWindow->createToolView( | ||
49 | plugin, | 49 | plugin, | ||
50 | QStringLiteral("kate_private_plugin_katereplicodeplugin_run"), | 50 | QStringLiteral("kate_private_plugin_katereplicodeplugin_run"), | ||
51 | KTextEditor::MainWindow::Bottom, | 51 | KTextEditor::MainWindow::Bottom, | ||
52 | SmallIcon(QStringLiteral("code-block")), | 52 | SmallIcon(QStringLiteral("code-block")), | ||
53 | i18n("Replicode Output")); | 53 | i18n("Replicode Output")); | ||
54 | m_replicodeOutput = new QListWidget(m_toolview); | 54 | m_replicodeOutput = new QListWidget(m_toolview); | ||
55 | m_replicodeOutput->setSelectionMode(QAbstractItemView::ContiguousSelection); | 55 | m_replicodeOutput->setSelectionMode(QAbstractItemView::ContiguousSelection); | ||
56 | connect(m_replicodeOutput, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(outputClicked(QListWidgetItem*))); | 56 | connect(m_replicodeOutput, &QListWidget::itemActivated, this, &ReplicodeView::outputClicked); | ||
57 | m_mainWindow->hideToolView(m_toolview); | 57 | m_mainWindow->hideToolView(m_toolview); | ||
58 | 58 | | |||
59 | m_configSidebar = m_mainWindow->createToolView( | 59 | m_configSidebar = m_mainWindow->createToolView( | ||
60 | plugin, | 60 | plugin, | ||
61 | QStringLiteral("kate_private_plugin_katereplicodeplugin_config") | 61 | QStringLiteral("kate_private_plugin_katereplicodeplugin_config") | ||
62 | , KTextEditor::MainWindow::Right, | 62 | , KTextEditor::MainWindow::Right, | ||
63 | SmallIcon(QStringLiteral("code-block")), | 63 | SmallIcon(QStringLiteral("code-block")), | ||
64 | i18n("Replicode Config")); | 64 | i18n("Replicode Config")); | ||
65 | m_configView = new ReplicodeConfig(m_configSidebar); | 65 | m_configView = new ReplicodeConfig(m_configSidebar); | ||
66 | 66 | | |||
67 | m_runButton = new QPushButton(i18nc("shortcut for action", "Run (%1)", m_runAction->shortcut().toString())); | 67 | m_runButton = new QPushButton(i18nc("shortcut for action", "Run (%1)", m_runAction->shortcut().toString())); | ||
68 | m_stopButton = new QPushButton(i18nc("shortcut for action", "Stop (%1)", m_stopAction->shortcut().toString())); | 68 | m_stopButton = new QPushButton(i18nc("shortcut for action", "Stop (%1)", m_stopAction->shortcut().toString())); | ||
69 | m_stopButton->setEnabled(false); | 69 | m_stopButton->setEnabled(false); | ||
70 | 70 | | |||
71 | QFormLayout *l = qobject_cast<QFormLayout*>(m_configView->widget(0)->layout()); | 71 | QFormLayout *l = qobject_cast<QFormLayout*>(m_configView->widget(0)->layout()); | ||
72 | Q_ASSERT(l); | 72 | Q_ASSERT(l); | ||
73 | l->addRow(m_runButton, m_stopButton); | 73 | l->addRow(m_runButton, m_stopButton); | ||
74 | connect(m_runButton, SIGNAL(clicked()), m_runAction, SLOT(trigger())); | 74 | connect(m_runButton, &QPushButton::clicked, m_runAction, &QAction::trigger); | ||
75 | connect(m_stopButton, SIGNAL(clicked()), m_stopAction, SLOT(trigger())); | 75 | connect(m_stopButton, &QPushButton::clicked, m_stopAction, &QAction::trigger); | ||
76 | 76 | | |||
77 | m_mainWindow->guiFactory()->addClient(this); | 77 | m_mainWindow->guiFactory()->addClient(this); | ||
78 | connect(m_mainWindow, SIGNAL(viewChanged(KTextEditor::View*)), SLOT(viewChanged())); | 78 | connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, &ReplicodeView::viewChanged); | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | ReplicodeView::~ReplicodeView() | 81 | ReplicodeView::~ReplicodeView() | ||
82 | { | 82 | { | ||
83 | m_mainWindow->guiFactory()->removeClient(this); | 83 | m_mainWindow->guiFactory()->removeClient(this); | ||
84 | delete m_executor; | 84 | delete m_executor; | ||
85 | } | 85 | } | ||
86 | 86 | | |||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 98 | { | |||
142 | m_configView->load(); | 142 | m_configView->load(); | ||
143 | m_configView->settingsObject()->save(); | 143 | m_configView->settingsObject()->save(); | ||
144 | 144 | | |||
145 | m_replicodeOutput->clear(); | 145 | m_replicodeOutput->clear(); | ||
146 | 146 | | |||
147 | if (m_executor) delete m_executor; | 147 | if (m_executor) delete m_executor; | ||
148 | m_executor = new QProcess(this); | 148 | m_executor = new QProcess(this); | ||
149 | m_executor->setWorkingDirectory(sourceFile.canonicalPath()); | 149 | m_executor->setWorkingDirectory(sourceFile.canonicalPath()); | ||
150 | connect(m_executor, SIGNAL(readyReadStandardError()), SLOT(gotStderr())); | 150 | connect(m_executor, &QProcess::readyReadStandardError, this, &ReplicodeView::gotStderr); | ||
151 | connect(m_executor, SIGNAL(readyReadStandardOutput()), SLOT(gotStdout())); | 151 | connect(m_executor, &QProcess::readyReadStandardOutput, this, &ReplicodeView::gotStdout); | ||
152 | connect(m_executor, SIGNAL(finished(int)), SLOT(replicodeFinished())); | 152 | connect(m_executor, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &ReplicodeView::replicodeFinished); | ||
153 | connect(m_executor, SIGNAL(error(QProcess::ProcessError)), SLOT(runErrored(QProcess::ProcessError))); | 153 | connect(m_executor, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), this, &ReplicodeView::runErrored); | ||
154 | qDebug() << executorPath << sourceFile.canonicalPath(); | 154 | qDebug() << executorPath << sourceFile.canonicalPath(); | ||
155 | m_completed = false; | 155 | m_completed = false; | ||
156 | m_executor->start(executorPath, QStringList(), QProcess::ReadOnly); | 156 | m_executor->start(executorPath, QStringList(), QProcess::ReadOnly); | ||
157 | 157 | | |||
158 | m_runAction->setEnabled(false); | 158 | m_runAction->setEnabled(false); | ||
159 | m_runButton->setEnabled(false); | 159 | m_runButton->setEnabled(false); | ||
160 | m_stopAction->setEnabled(true); | 160 | m_stopAction->setEnabled(true); | ||
161 | m_stopButton->setEnabled(true); | 161 | m_stopButton->setEnabled(true); | ||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |