OSDN Git Service

[denncoCreator] Implemented external editor support feature.
authortkawata <tkawata@users.sourceforge.jp>
Wed, 19 Dec 2012 13:52:41 +0000 (22:52 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Wed, 19 Dec 2012 13:52:41 +0000 (22:52 +0900)
Source/codeeditor/dccellscriptseditorpagewidget.cpp
Source/codeeditor/dccellscriptseditorpagewidget.h
Source/codeeditor/dccellscriptseditortabwidget.cpp
Source/denncoCreator.pro
Source/dialog/dccodeeditorexternaleditorsettingdialog.cpp [new file with mode: 0644]
Source/dialog/dccodeeditorexternaleditorsettingdialog.h [new file with mode: 0644]
Source/mainwindow.cpp
Source/mainwindow.h

index 7b38ac7..7c03031 100644 (file)
 #include "dccodeeditor.h"
 #include "dccell.h"
 #include "dccellcode.h"
+#include "mainwindow.h"
+#include "dialog/dccodeeditorexternaleditorsettingdialog.h"
+
+static const char* S_EXTERNAL_EDITOR_BUTTON_LABEL1 = "Use external editor...";
+static const char* S_EXTERNAL_EDITOR_BUTTON_LABEL2 = "Editor script";
 
 DCCellScriptsEditorPageWidget::DCCellScriptsEditorPageWidget(DCCell *targetCell, QWidget *parent) :
-    QWidget(parent), d_cell(targetCell), d_modified(false)
+    QWidget(parent), d_cell(targetCell), d_modified(false),
+    d_customScriptExternalMode(false), d_cellCodeScriptExternalMode(false)
 {
     if (d_cell->getIsCellCodeAssgined())
     {
@@ -44,17 +50,27 @@ DCCellScriptsEditorPageWidget::DCCellScriptsEditorPageWidget(DCCell *targetCell,
     d_customScriptEditor = new DCCodeEditor(this);
     d_cellCodeScriptEditor = new DCCodeEditor(this);
 
-    QVBoxLayout *customScriptEditorLayout = new QVBoxLayout;
-    customScriptEditorLayout->addWidget(new QLabel(tr("custom script")));
-    customScriptEditorLayout->addWidget(d_customScriptEditor);
+    QVBoxLayout *customScriptEditorBaseLayout = new QVBoxLayout;
+    QHBoxLayout *customScriptEditorTopLayout = new QHBoxLayout;
+    customScriptEditorTopLayout->addWidget(new QLabel(tr("custom script")));
+    d_customScriptEditExternalButton = new QPushButton(tr(S_EXTERNAL_EDITOR_BUTTON_LABEL1));
+    customScriptEditorTopLayout->addStretch();
+    customScriptEditorTopLayout->addWidget(d_customScriptEditExternalButton);
+    customScriptEditorBaseLayout->addLayout(customScriptEditorTopLayout);
+    customScriptEditorBaseLayout->addWidget(d_customScriptEditor);
     QWidget *customScriptWidget = new QWidget;
-    customScriptWidget->setLayout(customScriptEditorLayout);
-
-    QVBoxLayout *cellCodeScriptEditorLayout = new QVBoxLayout;
-    cellCodeScriptEditorLayout->addWidget(new QLabel(tr("cell code script")));
-    cellCodeScriptEditorLayout->addWidget(d_cellCodeScriptEditor);
+    customScriptWidget->setLayout(customScriptEditorBaseLayout);
+
+    QVBoxLayout *cellCodeScriptEditorBaseLayout = new QVBoxLayout;
+    QHBoxLayout *cellCodeScriptEditorTopLayout = new QHBoxLayout;
+    cellCodeScriptEditorTopLayout->addWidget(new QLabel(tr("cell code script")));
+    d_cellCodeScriptEditExternalButton = new QPushButton(tr(S_EXTERNAL_EDITOR_BUTTON_LABEL1));
+    cellCodeScriptEditorTopLayout->addStretch();
+    cellCodeScriptEditorTopLayout->addWidget(d_cellCodeScriptEditExternalButton);
+    cellCodeScriptEditorBaseLayout->addLayout(cellCodeScriptEditorTopLayout);
+    cellCodeScriptEditorBaseLayout->addWidget(d_cellCodeScriptEditor);
     QWidget *cellCodeScriptWidget = new QWidget;
-    cellCodeScriptWidget->setLayout(cellCodeScriptEditorLayout);
+    cellCodeScriptWidget->setLayout(cellCodeScriptEditorBaseLayout);
 
     d_splitter->addWidget(customScriptWidget);
     d_splitter->addWidget(cellCodeScriptWidget);
@@ -76,6 +92,8 @@ DCCellScriptsEditorPageWidget::DCCellScriptsEditorPageWidget(DCCell *targetCell,
     connect(&d_cellCodeScriptFolder, SIGNAL(modificationStatusChanged(bool)), this, SLOT(folderCellCodeScriptModifiedStatusChanged(bool)));
     connect(&d_customScriptFolder, SIGNAL(fileModifiedByExternalEditor(qint64)), this, SLOT(folderCustomScriptFileModifiedByExternalEditor(qint64)));
     connect(&d_cellCodeScriptFolder, SIGNAL(fileModifiedByExternalEditor(qint64)), this, SLOT(folderCellCodeScriptFileModifiedByExternalEditor(qint64)));
+    connect(d_customScriptEditExternalButton, SIGNAL(clicked()), this, SLOT(useExternalEditorForCustomScriptPressed()));
+    connect(d_cellCodeScriptEditExternalButton, SIGNAL(clicked()), this, SLOT(useExternalEditorForCellCodeScriptPressed()));
 
     loadScripts();
 }
@@ -86,10 +104,12 @@ bool DCCellScriptsEditorPageWidget::loadScripts()
     d_cellCodeScriptEditor->disconnect(this);
 
     d_customScriptEditor->setPlainText(d_customScriptFolder.getCurrentScript());
+    d_customScriptEditor->setReadOnly(d_customScriptExternalMode);
     if (d_cell->getIsCellCodeAssgined())
     {
         d_cellCodeScriptEditor->setPlainText(d_cellCodeScriptFolder.getCurrentScript());
-        d_cellCodeScriptEditor->setReadOnly(false);
+        d_cellCodeScriptEditor->setReadOnly(d_cellCodeScriptExternalMode);
+        d_cellCodeScriptEditExternalButton->setEnabled(true);
         d_cellCodeScriptEditor->document()->setModified(false);
         d_splitter->widget(1)->show();
     }
@@ -97,6 +117,7 @@ bool DCCellScriptsEditorPageWidget::loadScripts()
     {
         d_cellCodeScriptEditor->setPlainText("");
         d_cellCodeScriptEditor->setReadOnly(true);
+        d_cellCodeScriptEditExternalButton->setEnabled(false);
         d_splitter->widget(1)->hide();
     }
 
@@ -115,6 +136,13 @@ DCCellScriptsEditorPageWidget::~DCCellScriptsEditorPageWidget()
         disconnect(d_cell, 0, this, 0);
     }
     this->disconnect();
+
+    QList<QProcess*>::iterator it = d_processes.begin();
+    while (it != d_processes.end())
+    {
+        delete (*it);
+        it = d_processes.erase(it);
+    }
 }
 
 //slot
@@ -137,6 +165,7 @@ void DCCellScriptsEditorPageWidget::assignedCellCodeChanged()
         d_cellCodeScriptFolder.attach(cellCode);
         d_cellCodeScriptEditor->setPlainText(d_cellCodeScriptFolder.getCurrentScript());
         d_cellCodeScriptEditor->setReadOnly(false);
+        d_cellCodeScriptEditExternalButton->setEnabled(true);
         d_splitter->widget(1)->show();
         d_splitter->setStretchFactor(0,1);
         d_splitter->setStretchFactor(1,4);
@@ -146,6 +175,7 @@ void DCCellScriptsEditorPageWidget::assignedCellCodeChanged()
     {
         d_cellCodeScriptEditor->setPlainText("");
         d_cellCodeScriptEditor->setReadOnly(true);
+        d_cellCodeScriptEditExternalButton->setEnabled(false);
         d_splitter->widget(1)->hide();
     }
 
@@ -207,6 +237,54 @@ void DCCellScriptsEditorPageWidget::folderCellCodeScriptFileModifiedByExternalEd
     emit cellCodeScriptModifiedByExternalEditor(this,notifiedTime);
 }
 
+//slot
+void DCCellScriptsEditorPageWidget::useExternalEditorForCustomScriptPressed()
+{
+    if (d_customScriptExternalMode)
+    {
+        d_customScriptExternalMode = false;
+        d_customScriptEditor->setReadOnly(false);
+        d_customScriptEditExternalButton->setText(tr(S_EXTERNAL_EDITOR_BUTTON_LABEL1));
+    }
+    else
+    {
+        if (openExternalEditor(d_cell->getWorkFilePathForCustomScript()))
+        {
+            saveCustomScriptOnlyToFile(true);
+            d_customScriptExternalMode = true;
+            d_customScriptEditor->setReadOnly(true);
+            d_customScriptEditExternalButton->setText(tr(S_EXTERNAL_EDITOR_BUTTON_LABEL2));
+        }
+    }
+
+}
+
+//slot
+void DCCellScriptsEditorPageWidget::useExternalEditorForCellCodeScriptPressed()
+{
+    if (!d_cell->getIsCellCodeAssgined())
+        return;
+
+    if (d_cellCodeScriptExternalMode)
+    {
+        d_cellCodeScriptExternalMode = false;
+        d_cellCodeScriptEditor->setReadOnly(false);
+        d_cellCodeScriptEditExternalButton->setText(tr(S_EXTERNAL_EDITOR_BUTTON_LABEL1));
+    }
+    else
+    {
+        DCCellCode *cellCode = d_cell->getCellCode();
+        if (openExternalEditor(cellCode->getWorkFilePathForCellCodeScript()))
+        {
+            saveCellCodeScriptOnlyToFile(true);
+            d_cellCodeScriptExternalMode = true;
+            d_cellCodeScriptEditor->setReadOnly(true);
+            d_cellCodeScriptEditExternalButton->setText(tr(S_EXTERNAL_EDITOR_BUTTON_LABEL2));
+        }
+    }
+
+}
+
 void DCCellScriptsEditorPageWidget::updateModifiedStatus()
 {
     bool modified = d_customScriptFolder.getIsModified();
@@ -220,6 +298,53 @@ void DCCellScriptsEditorPageWidget::updateModifiedStatus()
     }
 }
 
+bool DCCellScriptsEditorPageWidget::openExternalEditor(const QString& path)
+{
+    QString editorPath = MainWindow::readSettingsForExternalScriptEditorPath();
+    if (editorPath.isEmpty() || editorPath.length() == 0)
+    {
+        DCCodeEditorExternalEditorSettingDialog dialog;
+        dialog.exec();
+        editorPath = MainWindow::readSettingsForExternalScriptEditorPath();
+    }
+    if (editorPath.isEmpty() || editorPath.length() == 0)
+        return false;
+
+    QString parameterOrg = MainWindow::readSettingsForExternalScriptEditorParameters();
+    QString parameter = "";
+    int i = 0;
+    int j = parameterOrg.indexOf(QRegExp("%F[ \t\"']|%F$"),i);
+    while (j >= 0)
+    {
+        parameter += parameterOrg.mid(i, j-i);
+        parameter += path;
+        i = j + 2;
+        if (i > parameterOrg.length())
+            break;
+        j = parameterOrg.indexOf(QRegExp("%F[ \t\"']|%F$"),i);
+    }
+    if (i < parameterOrg.length())
+        parameter += parameterOrg.mid(i);
+
+    QList<QProcess*>::iterator it = d_processes.begin();
+    while (it != d_processes.end())
+    {
+        if ((*it)->state() != QProcess::Running)
+        {
+            delete (*it);
+            it = d_processes.erase(it);
+        }
+        else
+            ++it;
+    }
+    QProcess *newProcess = new QProcess;
+    newProcess->start("\"" + editorPath + "\" " + parameter);
+
+    d_processes.append(newProcess);
+
+    return true;
+}
+
 bool DCCellScriptsEditorPageWidget::getIsModified() const
 {
     return d_modified;
@@ -230,6 +355,8 @@ void DCCellScriptsEditorPageWidget::setReadOnly(bool readOnly)
 {
     d_customScriptEditor->setReadOnly(readOnly);
     d_cellCodeScriptEditor->setReadOnly(readOnly);
+    d_customScriptEditExternalButton->setEnabled(!readOnly);
+    d_cellCodeScriptEditExternalButton->setEnabled(!readOnly);
 }
 
 
@@ -385,12 +512,14 @@ void DCCellScriptsEditorPageWidget::reloadCellCodeScript()
         d_cellCodeScriptEditor->setPlainText(d_cellCodeScriptFolder.getCurrentScript(true));
         d_cellCodeScriptEditor->setReadOnly(false);
         d_cellCodeScriptEditor->document()->setModified(false);
+        d_cellCodeScriptEditExternalButton->setEnabled(true);
         d_splitter->widget(1)->show();
     }
     else
     {
         d_cellCodeScriptEditor->setPlainText("");
         d_cellCodeScriptEditor->setReadOnly(true);
+        d_cellCodeScriptEditExternalButton->setEnabled(false);
         d_splitter->widget(1)->hide();
     }
 
index 888948f..524af2b 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <QWidget>
 #include <QSplitter>
+#include <QPushButton>
+#include <QProcess>
 
 #include "dceditscriptfolder.h"
 
@@ -44,10 +46,17 @@ class DCCellScriptsEditorPageWidget : public QWidget
     DCEditScriptFolder  d_customScriptFolder;
     DCEditScriptFolder  d_cellCodeScriptFolder;
 
+    QPushButton         *d_customScriptEditExternalButton;
+    QPushButton         *d_cellCodeScriptEditExternalButton;
+    bool                d_customScriptExternalMode;
+    bool                d_cellCodeScriptExternalMode;
+    QList<QProcess*>    d_processes;
+
     bool            loadCustomScript(bool forceReload = false);
     bool            loadCellCodeScript(bool forceReload = false);
     bool            loadScripts();
     void            updateModifiedStatus();
+    bool            openExternalEditor(const QString& path);
 
 public:
     DCCellScriptsEditorPageWidget(DCCell *targetCell, QWidget *parent = 0);
@@ -58,6 +67,8 @@ public:
     bool            getIsCellCodeModifiedByExternalEditor() const;
     qint64          getCustomScriptLoadedTime() const;
     qint64          getCellCodeScriptLoadedTime() const;
+    bool            getIsCustomScriptExternalMode() const { return d_customScriptExternalMode; }
+    bool            getIsCellCodeScriptExternalMode() const { return d_cellCodeScriptExternalMode; }
 
     void            setReadOnly(bool readOnly);
     QSet<DCVCPage*> saveScriptsToFile(bool saveModifiedOnly);
@@ -88,6 +99,9 @@ private slots:
     void folderCellCodeScriptModifiedStatusChanged(bool modified);
     void folderCustomScriptFileModifiedByExternalEditor(qint64 notifiedTime);
     void folderCellCodeScriptFileModifiedByExternalEditor(qint64 notifiedTime);
+
+    void useExternalEditorForCustomScriptPressed();
+    void useExternalEditorForCellCodeScriptPressed();
 };
 
 #endif // DCCELLCODEEDITORPAGEWIDGET_H
index 419a0d2..ae99faf 100644 (file)
@@ -181,28 +181,34 @@ void DCCellScriptsEditorTabWidget::slotTabPageCustomScriptModifiedByExternal(QWi
     if (currentWidget() == tabPage)
     {
         DCCellScriptsEditorPageWidget *pageWidget = dynamic_cast<DCCellScriptsEditorPageWidget*>(currentWidget());
-
-        {
-            QMutexLocker locker(&mutex);
-            if (pendingPages.contains(tabPage))
-            {
-                return;
-            }
-            pendingPages.append(tabPage);
-        }
-
-        QMessageBox::StandardButton ret;
-        ret = QMessageBox::warning(this, tr("Cell scripts editor"),
-            tr("The custom script has been modified by other editor.\n"
-            "Do you want to reload ?"),
-            QMessageBox::Yes | QMessageBox::No);
-        if (ret == QMessageBox::Yes)
+        if (pageWidget->getIsCustomScriptExternalMode())
         {
             pageWidget->reloadCustomScript();
         }
+        else
         {
-            QMutexLocker locker(&mutex);
-            pendingPages.removeOne(tabPage);
+            {
+                QMutexLocker locker(&mutex);
+                if (pendingPages.contains(tabPage))
+                {
+                    return;
+                }
+                pendingPages.append(tabPage);
+            }
+
+            QMessageBox::StandardButton ret;
+            ret = QMessageBox::warning(this, tr("Cell scripts editor"),
+                tr("The custom script has been modified by other editor.\n"
+                "Do you want to reload ?"),
+                QMessageBox::Yes | QMessageBox::No);
+            if (ret == QMessageBox::Yes)
+            {
+                pageWidget->reloadCustomScript();
+            }
+            {
+                QMutexLocker locker(&mutex);
+                pendingPages.removeOne(tabPage);
+            }
         }
     }
 }
@@ -215,28 +221,34 @@ void DCCellScriptsEditorTabWidget::slotTabPageCellCodeModifiedByExternal(QWidget
     if (currentWidget() == tabPage)
     {
         DCCellScriptsEditorPageWidget *pageWidget = dynamic_cast<DCCellScriptsEditorPageWidget*>(currentWidget());
-
-        {
-            QMutexLocker locker(&mutex);
-            if (pendingPages.contains(tabPage))
-            {
-                return;
-            }
-            pendingPages.append(tabPage);
-        }
-
-        QMessageBox::StandardButton ret;
-        ret = QMessageBox::warning(this, tr("Cell scripts editor"),
-            tr("The cell code script has been modified by other editor.\n"
-            "Do you want to reload ?"),
-            QMessageBox::Yes | QMessageBox::No);
-        if (ret == QMessageBox::Yes)
+        if (pageWidget->getIsCellCodeScriptExternalMode())
         {
             pageWidget->reloadCellCodeScript();
         }
+        else
         {
-            QMutexLocker locker(&mutex);
-            pendingPages.removeOne(tabPage);
+            {
+                QMutexLocker locker(&mutex);
+                if (pendingPages.contains(tabPage))
+                {
+                    return;
+                }
+                pendingPages.append(tabPage);
+            }
+
+            QMessageBox::StandardButton ret;
+            ret = QMessageBox::warning(this, tr("Cell scripts editor"),
+                tr("The cell code script has been modified by other editor.\n"
+                "Do you want to reload ?"),
+                QMessageBox::Yes | QMessageBox::No);
+            if (ret == QMessageBox::Yes)
+            {
+                pageWidget->reloadCellCodeScript();
+            }
+            {
+                QMutexLocker locker(&mutex);
+                pendingPages.removeOne(tabPage);
+            }
         }
     }
 }
index a1b94f8..7423ca2 100644 (file)
@@ -101,7 +101,8 @@ HEADERS       = mainwindow.h \
     dialog/dcmanagecellcodedialog.h \
     engine/versioninfo.h \
     codeeditor/dceditscriptfolder.h \
-    codeeditor/dccodeeditorscriptmanager.h
+    codeeditor/dccodeeditorscriptmanager.h \
+    dialog/dccodeeditorexternaleditorsettingdialog.h
 
 SOURCES       = main.cpp \
                 mainwindow.cpp \
@@ -196,7 +197,8 @@ SOURCES       = main.cpp \
     codeeditor/dccellscriptseditorpagewidget.cpp \
     dialog/dcmanagecellcodedialog.cpp \
     codeeditor/dceditscriptfolder.cpp \
-    codeeditor/dccodeeditorscriptmanager.cpp
+    codeeditor/dccodeeditorscriptmanager.cpp \
+    dialog/dccodeeditorexternaleditorsettingdialog.cpp
 
 RESOURCES     = denncoCreator.qrc
 
diff --git a/Source/dialog/dccodeeditorexternaleditorsettingdialog.cpp b/Source/dialog/dccodeeditorexternaleditorsettingdialog.cpp
new file mode 100644 (file)
index 0000000..10d023e
--- /dev/null
@@ -0,0 +1,114 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// 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 3 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, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on Dec-19, 2012.
+//
+#include "dccodeeditorexternaleditorsettingdialog.h"
+
+#include <QFileDialog>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QTextLine>
+#include <QGroupBox>
+
+#include "mainwindow.h"
+
+DCCodeEditorExternalEditorSettingDialog::DCCodeEditorExternalEditorSettingDialog(QWidget *parent) :
+    QDialog(parent), d_ok(false)
+{
+    setWindowTitle(tr("Choose external editor"));
+    QString instruction =
+            "<br><p>Executable:<ul><li>set the file path for the external editor.</li></ul></p>"
+            "<p>Parameter: <ul><li>Set the parameters to pass to the executable file.<br>"
+            "%F will be replaced to the file name of the script file to edit. </li></ul></p><br>";
+
+    QLabel *instructionLabel = new QLabel;
+    instructionLabel->setTextFormat(Qt::RichText);
+    instructionLabel->setWordWrap(true);
+    instructionLabel->setFrameStyle(QFrame::Box);
+    instructionLabel->setLineWidth(1);
+    instructionLabel->setText(instruction);
+    QGridLayout *gridLayout = new QGridLayout;
+    d_executableText = new QLineEdit;
+    d_chooseFileButton = new QPushButton(tr("Choose..."));
+    gridLayout->addWidget(new QLabel(tr("Executable:")), 0,0);
+    gridLayout->addWidget(d_executableText, 0,1);
+    gridLayout->addWidget(d_chooseFileButton, 0, 2);
+
+    d_parameterText = new QLineEdit;
+    gridLayout->addWidget(new QLabel(tr("Parameter:")), 1,0);
+    gridLayout->addWidget(d_parameterText, 1,1,1,2);
+
+    d_okButton = new QPushButton(tr("OK"));
+    d_cancelButton = new QPushButton(tr("Cancel"));
+    QHBoxLayout *buttonLayout = new QHBoxLayout;
+    buttonLayout->addStretch();
+    buttonLayout->addWidget(d_okButton);
+    buttonLayout->addWidget(d_cancelButton);
+
+    QVBoxLayout *layoutBase = new QVBoxLayout;
+    layoutBase->addWidget(instructionLabel);
+    layoutBase->addLayout(gridLayout);
+    layoutBase->addLayout(buttonLayout);
+
+    setLayout(layoutBase);
+
+    d_executableText->setText(MainWindow::readSettingsForExternalScriptEditorPath());
+    QString parameter = MainWindow::readSettingsForExternalScriptEditorParameters();
+    if (parameter.isEmpty() || parameter.length() == 0)
+    {
+        parameter = "\"%F\"";
+    }
+    d_parameterText->setText(parameter);
+
+    connect(d_chooseFileButton, SIGNAL(clicked()), this, SLOT(chooseFileButtonPressed()));
+    connect(d_okButton, SIGNAL(clicked()), this, SLOT(okButtonPressed()));
+    connect(d_cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonPressed()));
+}
+
+DCCodeEditorExternalEditorSettingDialog::~DCCodeEditorExternalEditorSettingDialog()
+{
+
+}
+
+bool DCCodeEditorExternalEditorSettingDialog::getResult() const
+{
+    return d_ok;
+}
+
+void DCCodeEditorExternalEditorSettingDialog::chooseFileButtonPressed()
+{
+    QFileDialog dialog(this, tr("Choose editor"), d_executableText->text());
+    dialog.setAcceptMode(QFileDialog::AcceptOpen);
+    dialog.setFileMode(QFileDialog::ExistingFile);
+    if (dialog.exec())
+    {
+        d_executableText->setText(dialog.selectedFiles().at(0));
+    }
+}
+
+void DCCodeEditorExternalEditorSettingDialog::okButtonPressed()
+{
+    MainWindow::writeSettingsForExternalScriptEditorPath(d_executableText->text());
+    MainWindow::writeSettingsForExternalScriptEditorParameters(d_parameterText->text());
+    d_ok = true;
+    close();
+}
+
+void DCCodeEditorExternalEditorSettingDialog::cancelButtonPressed()
+{
+    close();
+}
diff --git a/Source/dialog/dccodeeditorexternaleditorsettingdialog.h b/Source/dialog/dccodeeditorexternaleditorsettingdialog.h
new file mode 100644 (file)
index 0000000..339f3d8
--- /dev/null
@@ -0,0 +1,52 @@
+//  Copyright (c) 2012 Dennco Project
+//
+// 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 3 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, see <http://www.gnu.org/licenses/>.
+
+//
+//  Created by tkawata on Dec-19, 2012.
+//
+#ifndef DCCODEEDITOREXTERNALEDITORSETTINGDIALOG_H
+#define DCCODEEDITOREXTERNALEDITORSETTINGDIALOG_H
+
+#include <QDialog>
+#include <QLineEdit>
+#include <QPushButton>
+
+class DCCodeEditorExternalEditorSettingDialog : public QDialog
+{
+    Q_OBJECT
+
+    bool        d_ok;
+    QLineEdit  *d_executableText;
+    QLineEdit  *d_parameterText;
+
+    QPushButton *d_chooseFileButton;
+    QPushButton *d_okButton;
+    QPushButton *d_cancelButton;
+
+public:
+    explicit DCCodeEditorExternalEditorSettingDialog(QWidget *parent = 0);
+    virtual ~DCCodeEditorExternalEditorSettingDialog();
+
+    bool getResult() const;
+signals:
+    
+public slots:
+    void    chooseFileButtonPressed();
+    void    okButtonPressed();
+    void    cancelButtonPressed();
+    
+};
+
+#endif // DCCODEEDITOREXTERNALEDITORSETTINGDIALOG_H
index 9e9294f..03c3369 100644 (file)
@@ -30,6 +30,7 @@
 #include "utils/dcskeltoncreatorutil.h"
 #include "dialog/dcinputnewcontentdirdialog.h"
 #include "dialog/dcmanagecellcodedialog.h"
+#include "dialog/dccodeeditorexternaleditorsettingdialog.h"
 #include "dccellscriptseditorwindow.h"
 
 #include <QCloseEvent>
@@ -196,6 +197,12 @@ bool MainWindow::saveAs()
     return false;
 }
 
+void MainWindow::doExternalEditorSetting()
+{
+    DCCodeEditorExternalEditorSettingDialog dialog(this);
+    dialog.exec();
+}
+
 void MainWindow::about()
 {
    QMessageBox::about(this, tr("About Application"),
@@ -285,6 +292,10 @@ void MainWindow::createActions()
 
     connect(playAct, SIGNAL(triggered()), this, SLOT(playContent()));
 
+    externalEditorSettingAct = new QAction(tr("&External editor..."), this);
+    externalEditorSettingAct->setStatusTip(tr("Setup properties for external code editor."));
+    connect(externalEditorSettingAct, SIGNAL(triggered()), this, SLOT(doExternalEditorSetting()));
+
     aboutAct = new QAction(tr("&About"), this);
     aboutAct->setStatusTip(tr("Show the application's About box"));
     connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
@@ -323,6 +334,8 @@ void MainWindow::createMenus()
 
     menuBar()->addSeparator();
 
+    settingMenu = menuBar()->addMenu(tr("&Setting"));
+    settingMenu->addAction(externalEditorSettingAct);
     helpMenu = menuBar()->addMenu(tr("&Help"));
     helpMenu->addAction(aboutAct);
 }
@@ -394,6 +407,34 @@ void MainWindow::writeSettingsForCellScriptsEditorGeometory(const QByteArray &va
     settings.setValue("segeometory", value);
 }
 
+//static
+QString MainWindow::readSettingsForExternalScriptEditorPath()
+{
+    QSettings settings("dennco project", "dennco creator");
+    return settings.value("external editor path").toString();
+}
+
+//static
+QString MainWindow::readSettingsForExternalScriptEditorParameters()
+{
+    QSettings settings("dennco project", "dennco creator");
+    return settings.value("external editor param").toString();
+}
+
+//static
+void MainWindow::writeSettingsForExternalScriptEditorPath(const QString &arg)
+{
+    QSettings settings("dennco project", "dennco creator");
+    settings.setValue("external editor path", arg);
+}
+
+//static
+void MainWindow::writeSettingsForExternalScriptEditorParameters(const QString &arg)
+{
+    QSettings settings("dennco project", "dennco creator");
+    settings.setValue("external editor param", arg);
+}
+
 bool MainWindow::maybeSave()
 {
     if (d_creator->getCurrentContent())
index 73909dc..3347141 100644 (file)
@@ -41,6 +41,10 @@ public:
 
     static QByteArray readSettingsForCellScriptsEditorGeometory();
     static void writeSettingsForCellScriptsEditorGeometory(const QByteArray &value);
+    static QString readSettingsForExternalScriptEditorPath();
+    static QString readSettingsForExternalScriptEditorParameters();
+    static void writeSettingsForExternalScriptEditorPath(const QString& arg);
+    static void writeSettingsForExternalScriptEditorParameters(const QString& arg);
 
 protected:
     void closeEvent(QCloseEvent *event);
@@ -56,6 +60,7 @@ private slots:
     bool save();
     bool save(bool showMessage);
     bool saveAs();
+    void doExternalEditorSetting();
     void about();
     void documentWasModified();
     void playContent();
@@ -81,6 +86,7 @@ private:
     QMenu *openRecentMenu;
     QMenu *editMenu;
     QMenu *helpMenu;
+    QMenu *settingMenu;
     QToolBar *fileToolBar;
     QToolBar *editToolBar;
     QToolBar *playToolBar;
@@ -94,6 +100,7 @@ private:
     QAction *copyAct;
     QAction *playAct;
     QAction *pasteAct;
+    QAction *externalEditorSettingAct;
     QAction *aboutAct;
     QList<QAction*> openRecentActs;