Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/kipr/kiss

  • Loading branch information...
commit de3d663e5bc3ffbc736876c3d9c3d0db54391fc7 2 parents 6bd7291 + f557560
Braden McDorman authored
View
15 include/file_utils.hpp
@@ -0,0 +1,15 @@
+#ifndef _FILE_UTILS_HPP_
+#define _FILE_UTILS_HPP_
+
+#include <QString>
+
+namespace Kiss
+{
+ class FileUtils
+ {
+ public:
+ static bool remove(const QString& path);
+ };
+}
+
+#endif
View
17 include/interface/target_filesystem_engine.hpp
@@ -0,0 +1,17 @@
+#ifndef _TARGET_FILESYSTEM_MODEL_HPP_
+#define _TARGET_FILESYSTEM_MODEL_HPP_
+
+#include <QAbstractFileEngine>
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class FilesystemEngine : public QAbstractFileEngine
+ {
+
+ };
+ }
+}
+
+#endif
View
4 include/main_window.hpp
@@ -81,7 +81,7 @@ namespace Kiss
bool openFile(const QString& filePath, const Project::ProjectPtr& project = Project::ProjectPtr());
bool memoryOpen(const QByteArray& ba, const QString& assocPath);
bool openProject(const QString& filePath);
- bool newProject(const QString& folderPath);
+ Project::ProjectPtr newProject(const QString& folderPath);
void initMenus(Tab *tab);
@@ -203,6 +203,8 @@ namespace Kiss
void showProjectDock(bool show = true);
void hideProjectDock();
+
+ void toggleCommunicationWidget();
QList<QObject *> tabs(const QString& type);
View
4 include/widgets/communication_progress_bar.hpp
@@ -20,8 +20,12 @@ namespace Kiss
Target::CommunicationManager *manager() const;
+ signals:
+ void clicked();
+
protected:
void paintEvent(QPaintEvent *event);
+ void mousePressEvent(QMouseEvent *event);
private slots:
void admitted();
View
1  plugins/interfaces/kovan/CMakeLists.txt
@@ -4,6 +4,7 @@ PROJECT(${PLUGIN_NAME})
cmake_minimum_required(VERSION 2.6.0)
IF(APPLE)
+SET(CMAKE_OSX_SYSROOT "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.6.sdk")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -g")
ENDIF(APPLE)
View
1  plugins/interfaces/kovan_serial/CMakeLists.txt
@@ -4,6 +4,7 @@ PROJECT(${PLUGIN_NAME})
cmake_minimum_required(VERSION 2.6.0)
IF(APPLE)
+SET(CMAKE_OSX_SYSROOT "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.6.sdk")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -g")
ENDIF(APPLE)
View
23 plugins/interfaces/kovan_serial/kovan_serial_interface.cpp
@@ -2,6 +2,8 @@
#include "kovan_proto_target.hpp"
#include <kovanserial/usb_serial.hpp>
+#include <kovanserial/kovan_serial.hpp>
+#include <kovanserial/transport_layer.hpp>
#include <QProcess>
#include <QDir>
@@ -26,13 +28,26 @@ PortSampler::~PortSampler()
void PortSampler::run()
{
+ QStringList paths;
#ifdef Q_OS_MAC
QDir dir("/dev/");
- const QStringList list = dir.entryList(QStringList() << "tty.usbmodem*", QDir::System);
-
+ QFileInfoList list = dir.entryInfoList(QStringList() << "tty.usbmodem*", QDir::System);
+ foreach(const QFileInfo &info, list) paths << info.filePath();
#elif defined(Q_OS_WIN)
qDebug() << "Device discovery not yet implemented for windows!";
#endif
+ foreach(const QString &path, paths) {
+ UsbSerial usb(path.toAscii());
+ if(!usb.makeAvailable()) {
+ qWarning() << "Failed to make port" << path << "available";
+ continue;
+ }
+ TransportLayer transport(&usb);
+ KovanSerial proto(&transport);
+ if(proto.knockKnock(350)) emit found(path);
+ proto.hangup();
+ usb.endSession();
+ }
}
KovanSerialInterface::KovanSerialInterface()
@@ -57,6 +72,10 @@ Kiss::Target::TargetPtr KovanSerialInterface::createTarget(const QString &addres
const bool KovanSerialInterface::scan(InterfaceResponder *responder)
{
m_responder = responder;
+ PortSampler *sampler = new PortSampler();
+ sampler->setAutoDelete(true);
+ connect(sampler, SIGNAL(found(QString)), SLOT(found(QString)));
+ QThreadPool::globalInstance()->start(sampler);
return true;
}
View
2  plugins/interfaces/shared/kovan_proto_target.cpp
@@ -89,7 +89,7 @@ const bool KovanProtoTarget::compile(quint64 id, const QString& name)
Packet p;
if(!m_transport.recv(p, 15000) || p.type != Command::FileHeader) {
- qWarning() << "Failed to recv results of compile";
+ qWarning() << "Failed to recv results of compile" << p.type;
emit response(Response(id, KEY_COMPILE, true));
m_transmitter->endSession();
return false;
View
25 src/file_utils.cpp
@@ -0,0 +1,25 @@
+#include "file_utils.hpp"
+
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+
+bool Kiss::FileUtils::remove(const QString& path)
+{
+ QDir dir(path);
+
+ if(!dir.exists()) return true;
+
+ QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot
+ | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files,
+ QDir::DirsFirst);
+
+ foreach(const QFileInfo& entry, entries) {
+ const QString entryPath = entry.absoluteFilePath();
+ if(!(entry.isDir() ? remove(entryPath) : QFile::remove(entryPath))) return false;
+ }
+
+ if(!dir.rmdir(path)) return false;
+
+ return true;
+}
View
22 src/interface/main_responder.cpp
@@ -23,12 +23,26 @@ void MainResponder::response(Target *target, const Response &response)
m_mainWindow->setStatusMessage(QObject::tr("Connection Failed!"), 5000);
return;
} else if(response.type() == "compile") {
+ bool success = false;
if(response.data().canConvert<bool>()) {
- m_mainWindow->setStatusMessage(response.data().toBool()
- ? QObject::tr("Compile Succeeded!")
- : QObject::tr("Compile Failed!"), 5000);
+ success = response.data().toBool();
} else if(response.data().canConvert<Compiler::OutputList>()) {
- m_mainWindow->setOutputList(response.data().value<Compiler::OutputList>());
+ Compiler::OutputList output = response.data().value<Compiler::OutputList>();
+ m_mainWindow->setOutputList(output);
+ success = Compiler::Output::isSuccess(output);
}
+ m_mainWindow->setStatusMessage(success
+ ? QObject::tr("Compile Succeeded!")
+ : QObject::tr("Compile Failed!"), 5000);
+ } else if(response.type() == "download") {
+ bool success = response.data().toBool();
+ m_mainWindow->setStatusMessage(success
+ ? QObject::tr("Download Succeeded!")
+ : QObject::tr("Download Failed!"), 5000);
+ } else if(response.type() == "run") {
+ bool success = response.data().toBool();
+ m_mainWindow->setStatusMessage(success
+ ? QObject::tr("Run Succeeded!")
+ : QObject::tr("Run Failed!"), 5000);
}
}
View
1  src/interface/target.cpp
@@ -15,7 +15,6 @@ Target::Target(Interface* interface, const QString& name)
Target::~Target()
{
-
}
Interface *Target::interface() const
View
36 src/main_window.cpp
@@ -37,6 +37,7 @@
#include "main_responder.hpp"
#include "communication_progress_bar.hpp"
#include "communication_manager.hpp"
+#include "file_utils.hpp"
#include <QToolTip>
#include <QMessageBox>
@@ -70,8 +71,8 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
m_currentTab(0),
m_templateManager(new Template::Manager),
- m_mainResponder(new Target::MainResponder(this)),
- m_commProgress(new CommunicationProgressBar(&Target::CommunicationManager::ref(), this))
+ m_commProgress(new CommunicationProgressBar(&Target::CommunicationManager::ref(), this)),
+ m_mainResponder(new Target::MainResponder(this))
{
QNetworkProxyFactory::setUseSystemConfiguration(true);
@@ -110,6 +111,10 @@ MainWindow::MainWindow(QWidget *parent)
ui_statusbar->addPermanentWidget(m_commProgress);
+ ui_comm->hide();
+
+ connect(m_commProgress, SIGNAL(clicked()), SLOT(toggleCommunicationWidget()));
+
initMenus();
setTitle("");
@@ -161,25 +166,16 @@ Project::ProjectPtr MainWindow::newProject()
Wizard::NewProject wizard(this);
if(wizard.exec() == QDialog::Rejected) return Project::ProjectPtr();
- const QString& saveLocation = wizard.saveLocation();
+ const QString &saveLocation = wizard.saveLocation();
if(QDir(saveLocation).exists()) {
QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Are You Sure?"),
- tr("Overwrite ") + saveLocation + "?",
+ tr("Overwrite %1?").arg(saveLocation),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if(ret == QMessageBox::No) return Project::ProjectPtr();
}
- Project::ProjectPtr project = Project::Project::create(saveLocation);
- if(!project) {
- Dialog::Message::showError(this, "simple_error", QStringList() <<
- tr("Failed to create project.") <<
- tr("Attempted save location: ") + saveLocation);
- return Project::ProjectPtr();
- }
-
- m_projectManager.openProject(project);
- return project;
+ return newProject(saveLocation);
}
void MainWindow::newFile()
@@ -267,11 +263,12 @@ bool MainWindow::openProject(const QString& filePath)
return project;
}
-bool MainWindow::newProject(const QString& folderPath)
+Project::ProjectPtr MainWindow::newProject(const QString& folderPath)
{
- if(!QDir().mkpath(folderPath)) return false;
+ if(!FileUtils::remove(folderPath)) return Project::ProjectPtr();
+ if(!QDir().mkpath(folderPath)) return Project::ProjectPtr();
Project::ProjectPtr project = Project::Project::create(folderPath);
- if(!project) return false;
+ if(!project) return Project::ProjectPtr();
m_projectManager.openProject(project);
qDebug() << "Creating project at" << folderPath;
@@ -648,6 +645,11 @@ void MainWindow::hideProjectDock()
showProjectDock(false);
}
+void MainWindow::toggleCommunicationWidget()
+{
+ ui_comm->setVisible(!ui_comm->isVisible());
+}
+
void MainWindow::openRecent()
{
QAction *action = qobject_cast<QAction*>(sender());
View
3  src/project/new_project_wizard.cpp
@@ -8,7 +8,8 @@
using namespace Kiss::Wizard;
-NewProject::NewProject(QWidget* parent) : QDialog(parent)
+NewProject::NewProject(QWidget* parent)
+ : QDialog(parent)
{
setupUi(this);
View
17 src/source_file.cpp
@@ -638,6 +638,11 @@ void SourceFile::print()
void SourceFile::convertToProject()
{
+ if(!save()) return;
+ Project::ProjectPtr project = mainWindow()->newProject();
+ fileSaveAs(project->location() + "/" + file().fileName());
+ project->setTarget(target());
+ setProject(project);
}
const bool SourceFile::changeTarget()
@@ -650,6 +655,8 @@ const bool SourceFile::changeTarget()
// This hooks up all important callbacks
target()->setResponder(mainWindow()->mainResponder());
+ updateTitle();
+
return true;
}
@@ -797,6 +804,14 @@ bool SourceFile::actionPreconditions()
Kiss::KarPtr SourceFile::archive() const
{
Kiss::KarPtr archive = Kiss::Kar::create();
- archive->addFile(file().fileName(), ui_editor->text().toAscii());
+ QString raw = ui_editor->text();
+ // TODO: This assumes our input language is C or C++
+ QStringList localIncludes = raw.split("\n").filter(QRegExp("^\\s*#include.*\".+\""));
+ foreach(const QString &localInclude, localIncludes) {
+ int start = localInclude.indexOf('\"');
+ int end = localInclude.indexOf('\"', start + 1);
+ QString path = QFileInfo(file().path() + "/" + localInclude.mid(start, end - start)).canonicalPath();
+ }
+ archive->addFile(file().fileName(), raw.toAscii());
return archive;
}
View
18 src/template_dialog.cpp
@@ -6,11 +6,26 @@
#include "template_pack.hpp"
#include <QItemSelection>
+#include <QItemDelegate>
#include <QDebug>
using namespace Kiss;
using namespace Kiss::Dialog;
+class ItemDelegate : public QItemDelegate
+{
+public:
+ ItemDelegate(QObject *parent = 0)
+ : QItemDelegate(parent)
+ {
+ }
+
+ QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ return QSize(100, 22);
+ }
+};
+
Dialog::Template::Template(Kiss::Template::Manager *manager, QWidget *parent)
: QDialog(parent),
m_manager(manager),
@@ -21,11 +36,13 @@ Dialog::Template::Template(Kiss::Template::Manager *manager, QWidget *parent)
m_model = new Kiss::Template::Model(m_manager, ui->templates);
m_model->setReadOnly(true);
ui->templates->setModel(m_model);
+ ui->templates->setItemDelegate(new ItemDelegate(this));
ui->removePack->setEnabled(false);
connect(ui->templates->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(selectionChanged(QItemSelection)));
connect(ui->removePack, SIGNAL(clicked()), this, SLOT(removeSelectedPack()));
m_helpText = ui->description->toPlainText();
+ ui->templates->expandAll();
}
Dialog::Template::~Template()
@@ -54,6 +71,7 @@ void Dialog::Template::selectionChanged(const QItemSelection& selection)
Kiss::Template::Pack *pack = m_model->indexToPack(index);
ui->removePack->setEnabled(m_model->isIndexPack(index));
+ ui->buttons->button(QDialogButtonBox::Ok)->setEnabled(!m_model->isIndexPack(index));
if(!pack) {
ui->description->setPlainText(m_helpText);
View
5 src/widgets/communication_progress_bar.cpp
@@ -32,6 +32,11 @@ void CommunicationProgressBar::paintEvent(QPaintEvent *event)
QProgressBar::paintEvent(event);
}
+void CommunicationProgressBar::mousePressEvent(QMouseEvent *event)
+{
+ emit clicked();
+}
+
void CommunicationProgressBar::admitted()
{
setMaximum(++m_total);
View
47 ui/NewProjectWizard.ui
@@ -6,10 +6,28 @@
<rect>
<x>0</x>
<y>0</y>
- <width>500</width>
- <height>115</height>
+ <width>450</width>
+ <height>145</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>400</width>
+ <height>145</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>1000</width>
+ <height>145</height>
+ </size>
+ </property>
<property name="windowTitle">
<string>New Project Wizard</string>
</property>
@@ -61,6 +79,18 @@
</item>
<item>
<widget class="QLineEdit" name="ui_saveLocation">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>22</height>
+ </size>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
@@ -82,6 +112,19 @@
</layout>
</item>
<item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
View
116 ui/TemplateDialog.ui
@@ -1,116 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>TemplateDialog</class>
- <widget class="QDialog" name="TemplateDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>666</width>
- <height>406</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Templates</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,3">
- <item>
- <widget class="QListWidget" name="ui_types"/>
- </item>
- <item>
- <widget class="QTreeWidget" name="ui_templates">
- <property name="iconSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <attribute name="headerVisible">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QPushButton" name="ui_install">
- <property name="text">
- <string>Install Template Pack...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="ui_remove">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Remove</string>
- </property>
- <property name="default">
- <bool>false</bool>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="ui_buttons">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>ui_buttons</sender>
- <signal>accepted()</signal>
- <receiver>TemplateDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>ui_buttons</sender>
- <signal>rejected()</signal>
- <receiver>TemplateDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
Please sign in to comment.
Something went wrong with that request. Please try again.