Commits

zjes committed b2fec5d

Add editor syslog console

Comments (0)

Files changed (28)

bin/python3/srv.zip

Binary file modified.

bin/syntax/python.xml

 		<list name="bindings">
 			<item> SIGNAL </item>
 			<item> SLOT </item>
-			<item> connect </item>
+                        <item> connect </item>
+                        <item> pyqtSignal </item>
+                        <item> pyqtSlot </item>
+                        <item> Signal </item>
+                        <item> Slot </item>
 		</list>
 		<list name="overloaders">
 			<item>__new__</item>

src/Core/FileNameSelect.cpp

         QFileDialog dlg(this);
         dlg.setFileMode(QFileDialog::DirectoryOnly);
         dlg.setWindowTitle(_caption);
-        qDebug() << info.absolutePath();
-        dlg.setDirectory(info.absoluteFilePath());
+        dlg.setDirectory(_txt->text().isEmpty() ? _defaultPath : info.absoluteFilePath());
         if (dlg.exec() == QDialog::Accepted)
             _txt->setText(dlg.directory().absolutePath());
     }

src/Editors/IEditor.h

     void modificationChanged(bool);
     void closeEditor();
     void errorListChanged(QAbstractTableModel*);
+    void editorModificationChanged(Editors::IEditor*,bool);
 public slots:
     virtual bool save() = 0;
     virtual bool load() = 0;

src/EditorsManager/EditorsContainer.cpp

         _place->addWidget(edt);
         _stack.prepend(fileName);
         edt->load();
+        connect(edt, SIGNAL(editorModificationChanged(Editors::IEditor*,bool)), SIGNAL(editorModificationChanged(Editors::IEditor*,bool)));
         _openedEditors[fileName] = edt;
         emit editorOpened(edt);
     }
 
 void EditorsContainer::closeCurrentEditor()
 {
-   closeEditor(_currentEditor->fileName());
+    if (_currentEditor)
+        closeEditor(_currentEditor->fileName());
 }
 
 Editors::IEditor * EditorsContainer::currenEditor()

src/EditorsManager/OpenedDocuments.cpp

 
 void OpenedDocuments::onEditorModified(Editors::IEditor* ed, bool modified)
 {
-    //Editors::IEditor *ed = _editors->currenEditor();
+    for(int ind = 0; ind < count(); ind++){
+        if (item(ind)->data(Qt::UserRole+1).toString() == ed->fileName()){
+            item(ind)->setText(item(ind)->data(Qt::UserRole+2).toString()+(modified ? " *" : ""));
+            break;
+        }
+    }
 }
 
 void OpenedDocuments::onEditorActivated(Editors::IEditor* ed)
     }
     QListWidgetItem *item = new QListWidgetItem(name);
     item->setData(Qt::UserRole+1, ed->fileName());
+    item->setData(Qt::UserRole+2, name);
     addItem(item);
 }
 

src/IconProvider/IconProvider.qrc

         <file>icons/buddytool.png</file>
         <file>icons/tabordertool.png</file>
         <file>icons/widgettool.png</file>
+        <file>icons/text-x-log.png</file>
     </qresource>
 </RCC>

src/IconProvider/icons/text-x-log.png

Added
New image

src/Main/CMakeLists.txt

     Consoles/ApplicationOutput.h
     Consoles/ApplicationConsoleHeader.h
 
+    Consoles/LogConsole.h
+    Consoles/LogOutput.h
+    Consoles/LogConsoleHeader.h
+
     Preferences/GeneralPrefs.h
 )
 
     Consoles/ApplicationOutput.cpp
     Consoles/ApplicationConsoleHeader.cpp
 
+    Consoles/LogConsole.cpp
+    Consoles/LogOutput.cpp
+    Consoles/LogConsoleHeader.cpp
+
     Preferences/GeneralPrefs.cpp
 )
 
     ConsoleWidget.ui
     Consoles/IssuesConsoleHeader.ui
     Consoles/ApplicationConsoleHeader.ui
+    Consoles/LogConsoleHeader.ui
 
     Preferences/GeneralPrefs.ui
 )

src/Main/ConsoleWidget.cpp

 
 #include "Consoles/IssuesConsole.h"
 #include "Consoles/ApplicationConsole.h"
+#include "Consoles/LogConsole.h"
 #include "Include/PynotoApplication.h"
 #include "Include/IIconProvider.h"
 #include "ConsoleWidget.h"
     _ui(new Ui::ConsoleWidget),
     _issues(new IssuesConsole(this)),
     _application(new ApplicationConsole(this)),
+    _log(new LogConsole(this)),
     _mode(-1)
 {
     _ui->setupUi(this);
     _ui->modes->addItem(tr("Issues"));
     _ui->modes->addItem(tr("Application output"));
     _ui->modes->addItem(tr("Search result"));
+    _ui->modes->addItem(tr("System log"));
 
     _ui->hideBtn->setIcon(Aux::icons()->icon("hide"));
     connect(_ui->hideBtn, SIGNAL(clicked()), SLOT(hide()));
 
     _ui->stack->addWidget(_issues->control());
     _ui->stack->addWidget(_application->control());
+    _ui->stack->addWidget(new QWidget(this));
+    _ui->stack->addWidget(_log->control());
     setVisible(false);
 }
 
         } else if (mode == 1) {
             _ui->headerPlace->layout()->addWidget(_application->header());
             _application->header()->show();
+        } else if (mode == 3) {
+            _ui->headerPlace->layout()->addWidget(_log->header());
+            _log->header()->show();
         }
 
         _mode = mode;

src/Main/ConsoleWidget.h

 
 class IssuesConsole;
 class ApplicationConsole;
+class LogConsole;
 
 class ConsoleWidget : public QWidget
 {
     Ui::ConsoleWidget *_ui;
     IssuesConsole * _issues;
     ApplicationConsole * _application;
+    LogConsole * _log;
 
     QButtonGroup * _buttonGroup;
     int _mode;

src/Main/Consoles/LogConsole.cpp

+#include "LogConsole.h"
+#include "LogConsoleHeader.h"
+#include "LogOutput.h"
+
+namespace Main {
+
+LogConsole::LogConsole(QWidget *parent):
+    QWidget(parent),
+    _header(new LogConsoleHeader(this)),
+    _output(new LogOutput(this))
+{
+    connect(_header, SIGNAL(clearConsole()), _output, SLOT(clearLog()));
+}
+
+QWidget * LogConsole::header()
+{
+    return _header;
+}
+
+QWidget * LogConsole::control()
+{
+    return _output;
+}
+
+}

src/Main/Consoles/LogConsole.h

+#ifndef _LOGCONSOLE_H_
+#define _LOGCONSOLE_H_
+
+#include <QWidget>
+
+
+namespace Main {
+
+class LogOutput;
+class LogConsoleHeader;
+
+class LogConsole : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit LogConsole(QWidget *parent = 0);
+    QWidget * header();
+    QWidget * control();
+private:
+    LogConsoleHeader * _header;
+    LogOutput * _output;
+};
+
+}
+
+#endif

src/Main/Consoles/LogConsoleHeader.cpp

+#include "LogConsoleHeader.h"
+#include "ui_LogConsoleHeader.h"
+#include "Include/PynotoApplication.h"
+#include "Include/IIconProvider.h"
+
+namespace Main {
+
+LogConsoleHeader::LogConsoleHeader(QWidget * parent):
+    QWidget(parent),
+    _ui(new Ui::LogConsoleHeader)
+{
+    _ui->setupUi(this);
+
+    _ui->clearBtn->setIcon(Aux::icons()->icon("edit-clear"));
+    _ui->clearBtn->setToolTip(tr("Clear console"));
+    connect(_ui->clearBtn, SIGNAL(clicked()), SIGNAL(clearConsole()));
+}
+
+LogConsoleHeader::~LogConsoleHeader()
+{
+    delete _ui;
+}
+
+}

src/Main/Consoles/LogConsoleHeader.h

+#ifndef _LOGCONSOLEHEADER_H_
+#define _LOGCONSOLEHEADER_H_
+#include <QWidget>
+
+namespace Ui { class LogConsoleHeader; }
+namespace Main {
+
+class LogConsoleHeader: public QWidget
+{
+    Q_OBJECT
+public:
+    LogConsoleHeader(QWidget * parent = NULL);
+    virtual ~LogConsoleHeader();
+signals:
+    void clearConsole();
+private:
+    Ui::LogConsoleHeader *_ui;
+};
+
+}
+
+#endif

src/Main/Consoles/LogConsoleHeader.ui

+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LogConsoleHeader</class>
+ <widget class="QWidget" name="LogConsoleHeader">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>471</width>
+    <height>22</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QToolButton" name="clearBtn">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer name="horizontalSpacer">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>40</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

src/Main/Consoles/LogOutput.cpp

+#include <QDebug>
+#include "LogOutput.h"
+#include "Include/PynotoApplication.h"
+#include "Include/IProjectPlugin.h"
+#include "Include/IPythonCode.h"
+
+namespace Main {
+
+LogOutput::LogOutput(QWidget* parent):
+    QPlainTextEdit(parent)
+{
+    Project::IProject *prj = Aux::plugin<Project::IProjectPlugin*>("project")->project();
+    connect(prj, SIGNAL(systemError(QString)), SLOT(appendLog(QString)));
+}
+
+LogOutput::~LogOutput()
+{
+}
+
+void LogOutput::clearLog()
+{
+    clear();
+}
+
+void LogOutput::appendLog(const QString& log)
+{
+    appendPlainText(log);
+}
+
+}

src/Main/Consoles/LogOutput.h

+#ifndef _LOGOUTPUT_H_
+#define _LOGOUTPUT_H_
+#include <QPlainTextEdit>
+
+namespace Main {
+
+class LogOutput: public QPlainTextEdit
+{
+    Q_OBJECT
+public:
+    LogOutput(QWidget* parent = NULL);
+    virtual ~LogOutput();
+public slots:
+    void appendLog(const QString& log);
+public slots:
+    void clearLog();
+};
+
+}
+
+#endif

src/Main/PynotoWindow.cpp

     createStatusBtn("Issues", "errors", 0);
     createStatusBtn("Application output", "system-run", 1);
     createStatusBtn("Search results", "search", 2);
+    createStatusBtn("System log", "text-x-log", 3);
 
     _statusGroup->setExclusive(true);
     connect(_statusGroup, SIGNAL(buttonClicked(int)), _console, SLOT(switchTo(int)));

src/Project/IProject.h

     void interpretChanged();
     void shownFilesChanged();
     void lintChanged();
+    void systemError(const QString& err);
 public slots:
     virtual void openFile(const QString& fileName, int offset = 0) = 0;
 signals:

src/Project/ProjectFile.cpp

 
 void ProjectFile::openFile(const QString& fileName, int offset)
 {
+    QStringList files = openedFiles();
+    if (!files.contains(fileName)){
+        files.append(fileName);
+        _settings->remove("openedFiles");
+        _settings->beginWriteArray("openedFiles");
+        for (int i = 0; i < files.length(); ++i) {
+            _settings->setArrayIndex(i);
+            _settings->setValue("file", files[i]);
+        }
+        _settings->endArray();
+
+    }
     emit openFileOffset(fileName, offset);
 }
 
         _pythonCode = Aux::plugin<PythonCode::IPythonCodePlugin*>("pythoncode")->python();
         _pythonCode->init(interpretExec(), path(), mainScript(), _settings->fileName());
     }
+    connect(_pythonCode, SIGNAL(systemError(QString)), SIGNAL(systemError(QString)));
     return _pythonCode;
 }
 
     }
 }
 
+QColor ProjectFile::color()
+{
+    return QColor(_settings->value("common/color", "transparent").toString());
+}
+
+void ProjectFile::setColor(const QColor& color)
+{
+    if (color.alpha() == 0)
+        _settings->setValue("common/color", "transparent");
+    else
+        _settings->setValue("common/color", color.name());
+}
+
 }

src/Project/ProjectFile.h

 #ifndef _PROJECT_H_
 #define _PROJECT_H_
 #include <QMap>
+#include <QColor>
 #include "IProject.h"
 
 class QSettings;
 
     QMap<QString, QVariant> codeCheck();
     void setCodeCheck(const QMap<QString, QVariant>& check);
+
+    QColor color();
+    void setColor(const QColor& color);
 public slots:
     virtual void openFile(const QString& fileName, int offset = 0);
 private:

src/Project/Properties/General.cpp

     _ui->mainScript->setText(_project->mainScript());
     _ui->mainScript->setDefaultPath(_project->path());
     _ui->edtFileToShow->setText(_project->shownFiles().join(";"));
+    _ui->projectColor->setColor(_project->color());
 
     refreshPyVersions();
     refreshGuiVersions();
     _project->setShownFiles(_ui->edtFileToShow->text().split(";"));
     _project->setInterpretName(_ui->cmbPyVersion->itemData(_ui->cmbPyVersion->currentIndex()).toString());
     _project->setGuiName(_ui->cmdFrameworks->itemData(_ui->cmdFrameworks->currentIndex()).toString());
+    _project->setColor(_ui->projectColor->color());
     return true;
 }
 

src/Project/Properties/General.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>533</width>
-    <height>426</height>
+    <width>531</width>
+    <height>424</height>
    </rect>
   </property>
   <property name="windowTitle">
        </property>
       </widget>
      </item>
+     <item row="5" column="0">
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>Project color:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="1">
+      <widget class="ColorChooser" name="projectColor" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
   </layout>
    <header>Core/FileNameSelect.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>ColorChooser</class>
+   <extends>QWidget</extends>
+   <header>Core/ColorChooser.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>

src/PythonCode/IPythonCode.h

     virtual void errorList(const QString& fileName, const QString & content) = 0;
     virtual void close() = 0;
 signals:
+    void systemError(const QString& logString);
     void errors(const QString& fileName, const QList<ErrorItem>& items);
     void complitition(const QString& fileName, int pos, const QString& word, const QList<Completition>& items);
 };

src/PythonCode/PythonCode.cpp

 
 void PythonCode::onError()
 {
-    qDebug() << "Error occured";
-    qDebug() << _proc->readAllStandardError();
+    //qDebug() << _proc->readAllStandardError();
+    emit systemError(_proc->readAllStandardError());
     if (_loop.isRunning()){
         _loop.exit();
     }

src/TextEditor/TextEditorImpl.cpp

     connect(_widget, SIGNAL(pasteAvailable(bool)), this, SIGNAL(pasteAvailable(bool)));
     connect(_widget, SIGNAL(redoAvailable(bool)), this, SIGNAL(redoAvailable(bool)));
     connect(_widget, SIGNAL(undoAvailable(bool)), this, SIGNAL(undoAvailable(bool)));
-    connect(_widget, SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool)));
+    connect(_widget, SIGNAL(modificationChanged(bool)), this, SLOT(onModificationChanged(bool)));
     connect(_widget, SIGNAL(errorListChanged(QAbstractTableModel*)), this, SIGNAL(errorListChanged(QAbstractTableModel*)));
 }
 
 
 }
 
+void TextEditorImpl::onModificationChanged(bool modified)
+{
+    emit modificationChanged(modified);
+    emit editorModificationChanged(this, modified);
+}
+
 bool TextEditorImpl::save()
 { return _widget->save(); }
 

src/TextEditor/TextEditorImpl.h

     virtual void replaceAll(const QString& text, const QString& repl);
     virtual void startIncrementalFind();
     virtual void checkIssues();
+
+private slots:
+    void onModificationChanged(bool modified);
 protected:
     TextEditorWidget *_widget;
 };