diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ # Subdirectories ######################################################################### add_subdirectory(lib) +add_subdirectory(scripteditor) include_directories( lib ${CMAKE_CURRENT_BINARY_DIR}/lib) if(BUILD_TESTING) @@ -70,7 +71,7 @@ actionbar.cpp worksheettoolbutton.cpp imagesettingsdialog.cpp - scripteditorwidget.cpp + scripteditor/scripteditorwidget.cpp resultitem.cpp textresultitem.cpp imageresultitem.cpp diff --git a/src/backends/R/rserver/rserver.cpp b/src/backends/R/rserver/rserver.cpp --- a/src/backends/R/rserver/rserver.cpp +++ b/src/backends/R/rserver/rserver.cpp @@ -127,6 +127,9 @@ autoload(); + // Set gui editor for R + runCommand(QLatin1String("options(editor = 'cantor_scripteditor') \n"),true); + //Setting up some settings dependent stuff if(RServerSettings::self()->integratePlots()) { diff --git a/src/cantor_part.cpp b/src/cantor_part.cpp --- a/src/cantor_part.cpp +++ b/src/cantor_part.cpp @@ -55,7 +55,7 @@ #include "worksheet.h" #include "worksheetview.h" #include "searchbar.h" -#include "scripteditorwidget.h" +#include "scripteditor/scripteditorwidget.h" #include "lib/backend.h" #include "lib/extension.h" #include "lib/assistant.h" diff --git a/src/scripteditor/CMakeLists.txt b/src/scripteditor/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/scripteditor/CMakeLists.txt @@ -0,0 +1,10 @@ +set( scripteditor_SRCS + main.cpp + scripteditorwidget.cpp +) + +add_executable( cantor_scripteditor ${scripteditor_SRCS} ) + +target_link_libraries(cantor_scripteditor KF5::TextEditor) + +install(TARGETS cantor_scripteditor ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) \ No newline at end of file diff --git a/src/scripteditor/main.cpp b/src/scripteditor/main.cpp new file mode 100644 --- /dev/null +++ b/src/scripteditor/main.cpp @@ -0,0 +1,44 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + --- + Copyright (C) 2018 Sirgienko Nikita + */ + +#include +#include +#include +#include "scripteditorwidget.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + ScriptEditorWidget* editor = new ScriptEditorWidget(QLatin1String(""),QLatin1String("")); + + if (argc == 2) + { + // Open file, passed in arguments + QString filename = QLatin1String(argv[1]); + QUrl path = QUrl::fromLocalFile(filename); + qDebug() << "open " << path; + editor->open(path); + } + + editor->show(); + + return app.exec(); +} \ No newline at end of file diff --git a/src/scripteditorwidget.h b/src/scripteditor/scripteditorwidget.h rename from src/scripteditorwidget.h rename to src/scripteditor/scripteditorwidget.h --- a/src/scripteditorwidget.h +++ b/src/scripteditor/scripteditorwidget.h @@ -38,6 +38,7 @@ public: explicit ScriptEditorWidget( const QString& filter, const QString& highlightingMode, QWidget* parent = nullptr ); ~ScriptEditorWidget() override; + void open(QUrl url); Q_SIGNALS: void runScript(const QString& filename); diff --git a/src/scripteditorwidget.cpp b/src/scripteditor/scripteditorwidget.cpp rename from src/scripteditorwidget.cpp rename to src/scripteditor/scripteditorwidget.cpp --- a/src/scripteditorwidget.cpp +++ b/src/scripteditor/scripteditorwidget.cpp @@ -97,7 +97,11 @@ void ScriptEditorWidget::open() { QUrl url = QFileDialog::getOpenFileUrl(this, QString(), QUrl(), m_filter); + m_script->openUrl(url); +} +void ScriptEditorWidget::open(QUrl url) +{ m_script->openUrl(url); }