Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A bunch of new stuff

  • Loading branch information...
commit ad017aa7dff6b3b5741e4ae3f8ea94ea06673aa3 1 parent 502f087
@bmcdorman bmcdorman 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
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
32 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>
@@ -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
13 src/source_file.cpp
@@ -638,6 +638,9 @@ void SourceFile::print()
void SourceFile::convertToProject()
{
+ Project::ProjectPtr project = mainWindow()->newProject();
+ fileSaveAs(project->location() + "/" + file().fileName());
+ setProject(project);
}
const bool SourceFile::changeTarget()
@@ -797,6 +800,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
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);
Please sign in to comment.
Something went wrong with that request. Please try again.