Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Several changes

  • Loading branch information...
commit a86ffde0913fc8c45a77722c486cd6008130553e 1 parent f8397cd
@bmcdorman bmcdorman authored
Showing with 216 additions and 913 deletions.
  1. +0 −47 include/CommunicationQueue.h
  2. +0 −77 include/KissArchive.h
  3. +5 −2 include/MainWindow.h
  4. +0 −15 include/QUserInfo.h
  5. +0 −81 include/Repository.h
  6. +4 −1 include/TemplateManager.h
  7. +6 −0 include/interface/QtTargetResponder.h
  8. +6 −1 include/interface/Target.h
  9. +3 −0  include/interface/TargetResponder.h
  10. +4 −4 include/menus/ProjectMenu.h
  11. +1 −1  include/project/ProjectsModel.h
  12. +3 −0  plugins/interfaces/shared/Keys.h
  13. +55 −1 plugins/interfaces/shared/SerialDevice.cpp
  14. +3 −0  plugins/interfaces/shared/SerialDevice.h
  15. +6 −1 plugins/interfaces/shared/SerialIODevice.cpp
  16. +53 −0 plugins/interfaces/shared/TcpSocketDevice.cpp
  17. +3 −0  plugins/interfaces/shared/TcpSocketDevice.h
  18. +1 −0  rc/rc.qrc
  19. +0 −46 src/CommunicationQueue.cpp
  20. +0 −277 src/KissArchive.cpp
  21. +29 −42 src/MainWindow.cpp
  22. +0 −29 src/QUserInfo.cpp
  23. +0 −204 src/Repository.cpp
  24. +2 −1  src/SourceFile.cpp
  25. +1 −1  src/dialogs/ProjectSaveAs.cpp
  26. +15 −0 src/interface/QtTargetResponder.cpp
  27. +3 −0  src/interface/Target.cpp
  28. +0 −65 src/main.cpp
  29. +1 −8 src/menus/DeveloperMenu.cpp
  30. +0 −4 src/menus/MainWindowMenu.cpp
  31. +12 −5 src/menus/ProjectMenu.cpp
View
47 include/CommunicationQueue.h
@@ -1,47 +0,0 @@
-#ifndef _COMMUNICATIONQUEUE_H_
-#define _COMMUNICATIONQUEUE_H_
-
-#include <QQueue>
-#include <QString>
-#include <QByteArray>
-#include <QSharedPointer>
-
-class TinyArchive;
-
-class CommunicationEntry
-{
-public:
- enum Type {
- Unknown = 0,
- Download,
- Compile,
- Run,
- Authenticate,
- Disconnect,
- Custom
- };
-
- CommunicationEntry(const Type& type);
- CommunicationEntry(const Type& type, const QString& name, TinyArchive *archive = 0);
- CommunicationEntry(const QString& custom, const QByteArray& payload = QByteArray());
-
- const CommunicationEntry::Type& type() const;
- const QString& custom() const;
- const QByteArray& payload() const;
- const QString& name() const;
- TinyArchive *archive() const;
-private:
- CommunicationEntry(const CommunicationEntry& rhs);
- CommunicationEntry& operator=(const CommunicationEntry& rhs);
-
- Type m_type;
- QString m_name;
- QString m_custom;
- QByteArray m_payload;
- TinyArchive *m_archive;
-};
-
-typedef QSharedPointer<CommunicationEntry> CommunicationEntryPtr;
-typedef QQueue<CommunicationEntryPtr> CommunicationQueue;
-
-#endif
View
77 include/KissArchive.h
@@ -1,77 +0,0 @@
-/**************************************************************************
- * Copyright 2007-2012 KISS Institute for Practical Robotics *
- * *
- * This file is part of KISS (Kipr's Instructional Software System). *
- * *
- * KISS 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. *
- * *
- * KISS 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 KISS. Check the LICENSE file in the project root. *
- * If not, see <http://www.gnu.org/licenses/>. *
- **************************************************************************/
-
-#ifndef __KISSARCHIVE_H__
-#define __KISSARCHIVE_H__
-
-#include <QStringList>
-#include <QIODevice>
-
-#define KISS_ARCHIVE_VERSION 1
-#define KISS_ARCHIVE_FILE "installed"
-
-/*! \struct KissReturn
- * \brief Holds a KissArchive command return value
- */
-struct KissReturn
-{
- KissReturn(const bool& error, const QString& message = "") : error(error), message(message) {}
-
- /*! True if error occurred */
- bool error;
- /*! Holds message of error if an error occurred */
- QString message;
-};
-
-/*! \class KissArchive
- * \brief Holds methods to manipulate Kiss Archives
- */
-class KissArchive
-{
-public:
- /*!
- * Creates a kiss archive
- * \param name Name of Package
- * \param version Version of Package, for upgrades
- * \param platforms 3 character code for platform(s) "osx", "win", "nix"
- * \param files files, relatived
- * \param out Output IODevice
- * \return see KissReturn
- *//*!
- * Installs a kiss archive. Stores information in file called "installed"
- * \param in kiss archive pointer
- * \return see KissReturn
- */
- static KissReturn create(const QString& name, unsigned version,
- const QStringList& platforms, const QStringList& files,
- QIODevice* out);
- /*!
- * Installs a kiss archive. Stores information in file called "installed"
- * \param in kiss archive pointer
- * \return see KissReturn
- */
- static KissReturn install(QIODevice* in);
- static KissReturn uninstall(const QString& name);
- static QStringList list(QIODevice* in);
- static const unsigned version(const QString& name);
- static QStringList installed();
-};
-
-#endif
View
7 include/MainWindow.h
@@ -173,8 +173,11 @@ public slots:
bool closeNode(const TinyNode* node);
void about();
void settings();
- void managePackages();
- void installLocalPackage();
+
+ void projectAddNew();
+ void projectAddExisting();
+ void projectRemoveExisting();
+ void projectExtractTo();
void showProjectDock(bool show = true);
void hideProjectDock();
View
15 include/QUserInfo.h
@@ -1,15 +0,0 @@
-#ifndef _QUSERINFO_H_
-#define _QUSERINFO_H_
-
-#include <QString>
-
-class QUserInfo
-{
-public:
- static QString username();
-
-private:
-
-};
-
-#endif
View
81 include/Repository.h
@@ -1,81 +0,0 @@
-/**************************************************************************
- * Copyright 2007-2012 KISS Institute for Practical Robotics *
- * *
- * This file is part of KISS (Kipr's Instructional Software System). *
- * *
- * KISS 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. *
- * *
- * KISS 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 KISS. Check the LICENSE file in the project root. *
- * If not, see <http://www.gnu.org/licenses/>. *
- **************************************************************************/
-
-#ifndef __REPOSITORY_H__
-#define __REPOSITORY_H__
-
-#include "BuildOptions.h"
-
-#include <QObject>
-
-class Repository;
-
-#ifdef BUILD_REPOSITORY_TAB
-
-#include "ui_Repository.h"
-#include "Tab.h"
-
-#include <QWidget>
-#include <QMenu>
-#include <QMenuBar>
-#include <QToolBar>
-#include <QNetworkReply>
-#include <QNetworkAccessManager>
-
-class MainWindow;
-
-class Repository : public QWidget, public TabbedWidget, private Ui::Repository
-{
- Q_OBJECT
-public:
- Repository(MainWindow* parent = 0);
-
- void activate();
-
- bool beginSetup();
- void completeSetup();
-
- bool close();
-
-public slots:
- void refreshSettings();
-
-private slots:
- void on_ui_mark_clicked();
- void on_ui_unmark_clicked();
- void on_ui_uninstall_clicked();
- void on_ui_begin_clicked();
- void on_ui_source_clicked();
-
- void downloadProgress(qint64, qint64);
-
- void finished(QNetworkReply* reply);
- void downloadFinished(QNetworkReply* reply);
-private:
- void next();
-
- QNetworkAccessManager m_network;
- QMap<QString, QString> m_locations;
- QString m_source;
-};
-
-#endif
-
-#endif
View
5 include/TemplateManager.h
@@ -36,11 +36,14 @@ class TemplateManager : public Singleton<TemplateManager>
QStringList templates(const QString& type, const QString& _template);
QIcon templateIcon(const QString& type, const QString& _template);
- QStringList userTemplates(const QString& type);
+
bool addUserTemplate(const QString& type, const QString& name, const QString& content);
bool deleteUserTemplate(const QString& type, const QString& name);
+ QStringList userTemplateTypes() const;
+ QStringList userTemplates(const QString& type);
QString pathForUserTemplate(const QString& type, const QString& _template);
+
QString pathForTemplate(const QString& type, const QString& _template);
bool isTemplateDirectory(const QString& type, const QString& _template);
View
6 include/interface/QtTargetResponder.h
@@ -11,6 +11,9 @@ Q_OBJECT
virtual void compileResponse(Target *target, CompileResult results);
virtual void downloadResponse(Target *target, bool success);
virtual void runResponse(Target *target, bool success);
+ virtual void listResponse(Target *target, const QStringList& programs);
+ virtual void deleteResponse(Target *target, bool success);
+ virtual void interactionResponse(Target *target, const QString& ret);
virtual void unknownResponse(Target *target, const QByteArray& payload);
virtual void customResponse(Target *target, const QString& type, const QByteArray& payload);
virtual void communicationError(Target *target);
@@ -23,6 +26,9 @@ Q_OBJECT
void compileFinished(CompileResult results);
void downloadFinished(bool success);
void runFinished(bool success);
+ void listFinished(const QStringList& programs);
+ void deleteFinished(bool success);
+ void interactionFinished(const QString& ret);
void customFinished(const QString& type, const QByteArray& payload);
void unknownFinished(const QByteArray& payload);
void communicationError();
View
7 include/interface/Target.h
@@ -3,7 +3,7 @@
#include "Named.h"
#include "CommunicationQueue.h"
-#include <TinyArchive.h>
+#include <tinyarchive.hpp>
#include <kiss-compiler/Compiler.h>
#include <QObject>
@@ -54,6 +54,11 @@ class Target
virtual const bool compile(const QString& name) = 0;
virtual const bool download(const QString& name, TinyArchive* archive) = 0;
virtual const bool run(const QString& name) = 0;
+
+ virtual const bool list() = 0;
+ virtual const bool deleteProgram(const QString& name) = 0;
+ virtual const bool interaction(const QString& command) = 0;
+
virtual const bool authenticate(const QByteArray& hash) = 0;
virtual const bool sendCustom(const QString& custom, const QByteArray& payload = QByteArray()) = 0;
View
3  include/interface/TargetResponder.h
@@ -19,6 +19,9 @@ class TargetResponder
virtual void compileResponse(Target *target, CompileResult results) = 0;
virtual void downloadResponse(Target *target, bool success) = 0;
virtual void runResponse(Target *target, bool success) = 0;
+ virtual void listResponse(Target *target, const QStringList& programs) = 0;
+ virtual void deleteResponse(Target *target, bool success) = 0;
+ virtual void interactionResponse(Target *target, const QString& ret) = 0;
virtual void unknownResponse(Target *target, const QByteArray& payload) = 0;
virtual void customResponse(Target *target, const QString& type, const QByteArray& payload) = 0;
virtual void communicationError(Target *target) = 0;
View
8 include/menus/ProjectMenu.h
@@ -48,10 +48,10 @@ public slots:
void update();
private:
- MenuNode* addFile;
- MenuNode* deleteFile;
- MenuNode* extractFile;
- MenuNode* extractProject;
+ MenuNode* addExistingFile;
+ MenuNode* addNewFile;
+ MenuNode* removeExistingFile;
+ MenuNode* extractTo;
};
#endif
View
2  include/project/ProjectsModel.h
@@ -3,7 +3,7 @@
#include <QStandardItemModel>
#include <QMap>
-#include <TinyArchive.h>
+#include <tinyarchive.hpp>
class ProjectManager;
class Project;
View
3  plugins/interfaces/shared/Keys.h
@@ -5,6 +5,9 @@
#define COMPILE_KEY "compile"
#define DOWNLOAD_KEY "download"
#define RUN_KEY "run"
+#define LIST_KEY "list"
+#define DELETE_KEY "delete"
+#define INTERACTION_KEY "interaction"
#define LOCKED_KEY "locked"
#define AUTHENTICATE_KEY "authenticate"
View
56 plugins/interfaces/shared/SerialDevice.cpp
@@ -91,6 +91,47 @@ const bool SerialDevice::run(const QString& name)
return true;
}
+const bool SerialDevice::list()
+{
+ if(!connect()) return false;
+ QByteArray block;
+ QDataStream dataStream(&block, QIODevice::WriteOnly);
+ dataStream << (quint32)0;
+ dataStream << QString(LIST_KEY);
+ dataStream.device()->seek(0);
+ dataStream << (quint32)(block.size() - sizeof(quint32));
+ m_device.write(block);
+ return true;
+}
+
+const bool SerialDevice::deleteProgram(const QString& name)
+{
+ if(!connect()) return false;
+ QByteArray block;
+ QDataStream dataStream(&block, QIODevice::WriteOnly);
+ dataStream << (quint32)0;
+ dataStream << QString(DELETE_KEY);
+ dataStream << name;
+ dataStream.device()->seek(0);
+ dataStream << (quint32)(block.size() - sizeof(quint32));
+ m_device.write(block);
+ return true;
+}
+
+const bool SerialDevice::interaction(const QString& command)
+{
+ if(!connect()) return false;
+ QByteArray block;
+ QDataStream dataStream(&block, QIODevice::WriteOnly);
+ dataStream << (quint32)0;
+ dataStream << QString(INTERACTION_KEY);
+ dataStream << command;
+ dataStream.device()->seek(0);
+ dataStream << (quint32)(block.size() - sizeof(quint32));
+ m_device.write(block);
+ return true;
+}
+
const bool SerialDevice::authenticate(const QByteArray& hash)
{
if(!connect()) return false;
@@ -127,7 +168,7 @@ const bool SerialDevice::sendCustom(const QString& custom, const QByteArray& pay
void SerialDevice::readyRead()
{
for(;;) {
- qDebug() << "ReadyRead w/" << m_device.bytesAvailable();
+ qDebug() << "Serial ReadyRead w/" << m_device.bytesAvailable();
if(!m_payload && m_device.bytesAvailable() < sizeof(quint32)) return;
if(!m_payload && m_device.bytesAvailable() >= sizeof(quint32)) {
QDataStream stream(&m_device);
@@ -170,6 +211,18 @@ void SerialDevice::processPayload(const QByteArray& payload)
} else if(command == RUN_KEY) {
stream >> success;
responder()->runResponse(this, success);
+ } else if(command == LIST_KEY) {
+ QStringList programs;
+ stream >> programs;
+ success = true;
+ responder()->listResponse(this, programs);
+ } else if(command == DELETE_KEY) {
+ stream >> success;
+ responder()->deleteResponse(this, success);
+ } else if(command == INTERACTION_KEY) {
+ QString ret;
+ stream >> ret;
+ responder()->interactionResponse(this, ret);
} else if(command == AUTHENTICATE_KEY) {
stream >> success;
bool tryAgain = false;
@@ -190,6 +243,7 @@ bool SerialDevice::connect()
{
if(m_device.isOpen()) return true;
m_device.open(QIODevice::ReadWrite);
+ qDebug() << "Connecting serial port";
return m_device.isOpen();
}
View
3  plugins/interfaces/shared/SerialDevice.h
@@ -24,6 +24,9 @@ Q_OBJECT
virtual const bool compile(const QString& name);
virtual const bool download(const QString& name, TinyArchive* archive);
virtual const bool run(const QString& name);
+ virtual const bool list();
+ virtual const bool deleteProgram(const QString& name);
+ virtual const bool interaction(const QString& command);
virtual const bool authenticate(const QByteArray& hash);
virtual const bool sendCustom(const QString& custom, const QByteArray& payload);
private slots:
View
7 plugins/interfaces/shared/SerialIODevice.cpp
@@ -11,11 +11,13 @@
#include <windows.h>
#endif
+#include <QDebug>
+
SerialIODevice::SerialIODevice(const QString& path)
: m_path(path),
m_baudRate(115200)
{
-
+ qDebug() << "Created serial device at" << m_path << "with BR" << m_baudRate;
}
SerialIODevice::~SerialIODevice()
@@ -62,6 +64,7 @@ bool SerialIODevice::open(QIODevice::OpenMode mode)
if(m_fd <= 0) return false;
::fcntl(m_fd, F_SETFL, ~O_NDELAY & ::fcntl(m_fd, F_GETFL, 0));
#endif
+ qDebug() << "Opening serial port";
configurePort();
return QIODevice::open(ReadWrite);
}
@@ -77,6 +80,7 @@ void SerialIODevice::close()
::close(m_fd);
m_fd = -1;
#endif
+ qDebug() << "Closing serial port";
QIODevice::close();
}
@@ -125,6 +129,7 @@ void SerialIODevice::configurePort()
tcsetattr(m_fd, TCSADRAIN, &tio);
#endif
+ qDebug() << "Configured serial port";
}
void SerialIODevice::setBaudRate(const quint32& baudRate)
View
53 plugins/interfaces/shared/TcpSocketDevice.cpp
@@ -91,6 +91,47 @@ const bool TcpSocketDevice::run(const QString& name)
return true;
}
+const bool TcpSocketDevice::list()
+{
+ if(!connect()) return false;
+ QByteArray block;
+ QDataStream dataStream(&block, QIODevice::WriteOnly);
+ dataStream << (quint32)0;
+ dataStream << QString(LIST_KEY);
+ dataStream.device()->seek(0);
+ dataStream << (quint32)(block.size() - sizeof(quint32));
+ m_socket.write(block);
+ return true;
+}
+
+const bool TcpSocketDevice::deleteProgram(const QString& name)
+{
+ if(!connect()) return false;
+ QByteArray block;
+ QDataStream dataStream(&block, QIODevice::WriteOnly);
+ dataStream << (quint32)0;
+ dataStream << QString(DELETE_KEY);
+ dataStream << name;
+ dataStream.device()->seek(0);
+ dataStream << (quint32)(block.size() - sizeof(quint32));
+ m_socket.write(block);
+ return true;
+}
+
+const bool TcpSocketDevice::interaction(const QString& command)
+{
+ if(!connect()) return false;
+ QByteArray block;
+ QDataStream dataStream(&block, QIODevice::WriteOnly);
+ dataStream << (quint32)0;
+ dataStream << QString(INTERACTION_KEY);
+ dataStream << command;
+ dataStream.device()->seek(0);
+ dataStream << (quint32)(block.size() - sizeof(quint32));
+ m_socket.write(block);
+ return true;
+}
+
const bool TcpSocketDevice::authenticate(const QByteArray& hash)
{
if(!connect()) return false;
@@ -177,6 +218,18 @@ void TcpSocketDevice::processPayload(const QByteArray& payload)
} else if(command == RUN_KEY) {
stream >> success;
responder()->runResponse(this, success);
+ } else if(command == LIST_KEY) {
+ QStringList programs;
+ stream >> programs;
+ success = true;
+ responder()->listResponse(this, programs);
+ } else if(command == DELETE_KEY) {
+ stream >> success;
+ responder()->deleteResponse(this, success);
+ } else if(command == INTERACTION_KEY) {
+ QString ret;
+ stream >> ret;
+ responder()->interactionResponse(this, ret);
} else if(command == AUTHENTICATE_KEY) {
stream >> success;
bool tryAgain = false;
View
3  plugins/interfaces/shared/TcpSocketDevice.h
@@ -26,6 +26,9 @@ Q_OBJECT
virtual const bool compile(const QString& name);
virtual const bool download(const QString& name, TinyArchive* archive);
virtual const bool run(const QString& name);
+ virtual const bool list();
+ virtual const bool deleteProgram(const QString& name);
+ virtual const bool interaction(const QString& command);
virtual const bool authenticate(const QByteArray& hash);
virtual const bool sendCustom(const QString& custom, const QByteArray& payload);
View
1  rc/rc.qrc
@@ -67,6 +67,7 @@
<file>messages/kipr_script_exception.txt</file>
<file>messages/about_kiss.txt</file>
<file>messages/build_error.txt</file>
+ <file>messages/under_construction.txt</file>
<file>webtab_fail/index.html</file>
<file>icon_set/icons/Locked.png</file>
<file>logos/icon.png</file>
View
46 src/CommunicationQueue.cpp
@@ -1,46 +0,0 @@
-#include "CommunicationQueue.h"
-#include "TinyArchive.h"
-
-CommunicationEntry::CommunicationEntry(const Type& type)
- : m_type(type)
-{
-
-}
-
-CommunicationEntry::CommunicationEntry(const CommunicationEntry::Type& type, const QString& name, TinyArchive *archive)
- : m_type(type), m_name(name), m_archive(archive)
-{
-}
-
-CommunicationEntry::CommunicationEntry(const QString& custom, const QByteArray& payload)
- : m_type(Custom), m_name(""), m_custom(custom), m_payload(payload), m_archive(0)
-{
-}
-
-const CommunicationEntry::Type& CommunicationEntry::type() const
-{
- return m_type;
-}
-
-const QString& CommunicationEntry::custom() const
-{
- return m_custom;
-}
-
-const QByteArray& CommunicationEntry::payload() const
-{
- return m_payload;
-}
-
-const QString& CommunicationEntry::name() const
-{
- return m_name;
-}
-
-TinyArchive *CommunicationEntry::archive() const
-{
- return m_archive;
-}
-
-CommunicationEntry::CommunicationEntry(const CommunicationEntry&) {}
-CommunicationEntry& CommunicationEntry::operator=(const CommunicationEntry&) { return *this; }
View
277 src/KissArchive.cpp
@@ -1,277 +0,0 @@
-/**************************************************************************
- * Copyright 2007-2011 KISS Institute for Practical Robotics *
- * *
- * This file is part of KISS (Kipr's Instructional Software System). *
- * *
- * KISS 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. *
- * *
- * KISS 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 KISS. Check the LICENSE file in the project root. *
- * If not, see <http://www.gnu.org/licenses/>. *
- **************************************************************************/
-
-#include "KissArchive.h"
-#include "Kiss.h"
-
-#include <QFile>
-#include <QFileInfo>
-#include <QDir>
-#include <QDebug>
-#include <QSettings>
-#include <QString>
-
-#define INSTALLED_VERSION_STRING "/version"
-#define INSTALLED_DIRS_STRING "/dirs"
-#define INSTALLED_FILES_STRING "/files"
-
-const static unsigned char kissMagic[2] = {0xB3, 0x7A};
-const static unsigned kissVersion = KISS_ARCHIVE_VERSION;
-
-/**
- * Writes a KISS Archive to the QIODevice specified
- *
- * Contents of a created archive: (Integer - 4 Byte Unsigned; String - x Bytes)
- *
- * 2 Bytes - 0xB37A magic
- * Integer - Number of platforms
- * numPlatforms * 3 Bytes - Platforms supported (3 chars per platform)
- * Integer - KISS Archiver version
- * Integer - Length of Name String
- * String - Name
- * Integer - Package version
- * Integer - Number of Files
- * for(0 to numberFiles) [
- * Integer - File Name length
- * String - File Name
- * Integer - File length
- * String - File data
- * ]
- *
- */
-KissReturn KissArchive::create(const QString& name, unsigned pVersion, const QStringList& platforms, const QStringList& files, QIODevice* out)
-{
- QStringList noBlanks;
- foreach(const QString& str, files) {
- if(!str.isEmpty()) noBlanks << str;
- }
-
- unsigned size = (unsigned)noBlanks.size();
- out->write((const char*)kissMagic, 2);
-
- unsigned numPlatforms = platforms.size();
- out->write((char*)&numPlatforms, sizeof(unsigned));
- foreach(const QString& platform, platforms) {
- if(platform.size() != 3) qWarning() << "Platform" << platform << "not 3 bytes";
- out->write(platform.toLocal8Bit(), 3);
- }
-
- out->write((char*)&kissVersion, sizeof(unsigned));
- unsigned nameSize = (unsigned)name.length();
- out->write((char*)&nameSize, sizeof(unsigned));
- out->write(name.toLocal8Bit(), nameSize);
- out->write((char*)&pVersion, sizeof(unsigned));
-
- out->write((char*)&size, sizeof(unsigned));
- foreach(const QString& file, noBlanks) {
- if(file.isEmpty()) continue;
- QFile f(file);
- if (!f.open(QIODevice::ReadOnly)) return KissReturn(true, QObject::tr("Unable to open ") + file + QObject::tr(" for reading."));
-
- unsigned strLength = file.length();
- out->write((char*)&strLength, sizeof(unsigned));
- out->write(file.toLocal8Bit());
-
- const QByteArray& data = qCompress(f.readAll());
- unsigned dataLength = data.size();
- out->write((char*)&dataLength, sizeof(unsigned));
- out->write(data);
- }
- return KissReturn(false);
-}
-
-/**
- * Install a package given from a QIODevice
- */
-KissReturn KissArchive::install(QIODevice* in)
-{
- QStringList files;
- QStringList dirs;
-
- // Reads the file's "magic" to make sure we have a Kiss Archive
- char magic[2];
- in->read(magic, 2);
- if(magic[0] != kissMagic[0] || magic[1] != kissMagic[1]) {
- qWarning() << "Bad Magic";
- return KissReturn(true, QObject::tr("Bad Magic. Probably not a KISS Archive"));
- }
-
- // Read platforms, halt if current platform not detected
- unsigned numPlatforms = 0;
- in->read((char*)&numPlatforms, sizeof(unsigned));
- bool match = false;
- for(unsigned i = 0; i < numPlatforms; ++i) {
- if(QString(in->read(3).data()) == OS_NAME) {
- match = true;
- }
- }
- if(!match) {
- qWarning() << "Incorrect OS";
- return KissReturn(true, QObject::tr("This OS is not supported by the archive"));
- }
-
- // Checks the Kiss Archive Specification version, so we know how to extract
- unsigned version = 0;
- in->read((char*)&version, sizeof(unsigned));
- if(kissVersion != version) {
- return KissReturn(true, QObject::tr("Version mismatch. Expected: ") + kissVersion + QObject::tr(", got ") + version);
- }
-
- // Reads archive name and internal version
- unsigned nameSize = 0;
- in->read((char*)&nameSize, sizeof(unsigned));
- QString name(in->read(nameSize).data());
- unsigned pVersion = 0;
- in->read((char*)&pVersion, sizeof(unsigned));
-
- if(KissArchive::version(name) >= pVersion) {
- qWarning() << "Higher version already installed. Skipping.";
- return KissReturn(true, QObject::tr("Higher version of same archive already installed"));
- } else if(KissArchive::version(name) < pVersion) {
- uninstall(name);
- }
-
- // Recursively extract files and dirs
- unsigned numFiles = 0;
- in->read((char*)&numFiles, sizeof(unsigned));
- for(unsigned i = 0; i < numFiles; ++i) {
- unsigned strLength = 0;
- in->read((char*)&strLength, sizeof(unsigned));
- QString str = QString(in->read(strLength).data());
-
- files << str;
-
- unsigned dataLength = 0;
- in->read((char*)&dataLength, sizeof(unsigned));
- const QByteArray& data = qUncompress(in->read(dataLength));
-
- if(str.isEmpty()) continue;
-
- QFile f(str);
- const QString& filePath = QFileInfo(str).path();
- QDir dir;
- if(!dir.exists(filePath)) {
- dir.mkpath(filePath);
- dirs.prepend(filePath);
- }
- if(!f.open(QIODevice::WriteOnly)) {
- qWarning() << "Unable to open" << str << "for writing.";
- }
- f.write(data);
- }
- qWarning() << files;
-
- QSettings installed(KISS_ARCHIVE_FILE, QSettings::IniFormat);
- installed.setValue(name + INSTALLED_VERSION_STRING, pVersion);
- installed.setValue(name + INSTALLED_FILES_STRING, files);
- installed.setValue(name + INSTALLED_DIRS_STRING, dirs);
- installed.sync();
-
- return KissReturn(false);
-}
-
-/**
- * Uninstalls a package from KISS's directory structure
- */
-KissReturn KissArchive::uninstall(const QString& name)
-{
- QSettings installed(KISS_ARCHIVE_FILE, QSettings::IniFormat);
- if(!installed.childGroups().contains(name)) return KissReturn(true, QObject::tr("No such archive installed"));
-
- const QStringList& files = installed.value(name + INSTALLED_FILES_STRING).toStringList();
- foreach(const QString& file, files) {
- if(!QFile(file).remove()) qWarning() << "Failed to remove file" << file;
- const QDir& dir = QFileInfo(file).dir();
- if(dir.entryList(QDir::NoDotAndDotDot).size() == 0) dir.rmdir(dir.absolutePath());
- }
-
- const QStringList& dirs = installed.value(name + INSTALLED_DIRS_STRING).toStringList();
- foreach(const QString& dir, dirs) {
- QDir().rmdir(dir);
- }
- installed.remove(name);
- installed.sync();
-
- return KissReturn(false);
-}
-
-QStringList KissArchive::list(QIODevice* in)
-{
- QStringList files;
- QStringList dirs;
-
- // Reads the file's "magic" to make sure we have a Kiss Archive
- char magic[2];
- in->read(magic, 2);
- if(magic[0] != kissMagic[0] || magic[1] != kissMagic[1]) {
- qWarning() << "Bad Magic";
- return QStringList();
- }
-
- // Read platforms, halt if current platform not detected
- unsigned numPlatforms = 0;
- in->read((char*)&numPlatforms, sizeof(unsigned));
- in->read(numPlatforms * 3);
-
- // Checks the Kiss Archive Specification version, so we know how to extract
- unsigned version = 0;
- in->read((char*)&version, sizeof(unsigned));
- if(kissVersion != version) {
- qWarning() << "Version mismatch. Expected:" << kissVersion << ", got" << version;
- return QStringList();
- }
-
- // Reads archive name and internal version
- unsigned nameSize = 0;
- in->read((char*)&nameSize, sizeof(unsigned));
- QString name(in->read(nameSize).data());
- unsigned pVersion = 0;
- in->read((char*)&pVersion, sizeof(unsigned));
-
- // Recursively extract files and dirs
- unsigned numFiles = 0;
- in->read((char*)&numFiles, sizeof(unsigned));
- for(unsigned i = 0; i < numFiles; ++i) {
- unsigned strLength = 0;
- in->read((char*)&strLength, sizeof(unsigned));
- QString str = QString(in->read(strLength).data());
-
- files << str;
-
- unsigned dataLength = 0;
- in->read((char*)&dataLength, sizeof(unsigned));
- in->read(dataLength);
- }
-
- return files;
-}
-
-/**
- * Returns the package's version, if that package is installed
- */
-const unsigned KissArchive::version(const QString& name)
-{
- return QSettings(KISS_ARCHIVE_FILE, QSettings::IniFormat).value(name + INSTALLED_VERSION_STRING, 0).toUInt();
-}
-
-/**
- * List the installed packages, as declared in the file "installed"
- */
-QStringList KissArchive::installed() { return QSettings(KISS_ARCHIVE_FILE, QSettings::IniFormat).childGroups(); }
View
71 src/MainWindow.cpp
@@ -23,14 +23,12 @@
#include "SourceFile.h"
#include "WebTab.h"
#include "WelcomeTab.h"
-#include "KissArchive.h"
-#include "Repository.h"
#include "MessageDialog.h"
#include "Menus.h"
#include "Project.h"
#include "ProjectSettingsTab.h"
#include "ProjectManager.h"
-#include <TinyArchive.h>
+#include <tinyarchive.hpp>
#include "Log.h"
#include "LexerFactory.h" // Used to query supported extensions
@@ -71,6 +69,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_currentTab(0)
setupUi(this);
m_projectsModel.setProjectManager(&ProjectManager::ref());
ui_projects->setModel(&m_projectsModel);
+ ui_projects->viewport()->setAcceptDrops(true);
+ ui_projects->setDropIndicatorShown(true);
+ ui_projects->setDragDropMode(QAbstractItemView::DropOnly);
// ui_projects->hide(); // Disabled for now
@@ -217,6 +218,7 @@ bool MainWindow::openProject(const QString& filePath)
bool MainWindow::newProject(const QString& filePath)
{
+ if(!QDir().mkpath(QFileInfo(filePath).path())) return false;
Project* project = Project::create(filePath);
Log::ref().info(QString("Creating project at %1").arg(filePath));
if(project) ProjectManager::ref().openProject(project);
@@ -250,6 +252,9 @@ void MainWindow::initMenus()
ProjectMenu* projectMenu = new ProjectMenu();
m_menuManager.registerMenus(projectMenu);
+ projectMenu->setActive(this);
+ projectMenu->connect(&ProjectManager::ref(), SIGNAL(projectOpened(Project *)), SLOT(update()));
+ projectMenu->connect(&ProjectManager::ref(), SIGNAL(projectClosed(Project *)), SLOT(update()));
m_menuables.append(projectMenu);
#ifdef BUILD_WEB_TAB
@@ -527,44 +532,32 @@ void MainWindow::on_ui_removeFile_clicked()
// ui_projects->expandAll();
}
-void MainWindow::managePackages()
+void MainWindow::projectAddNew()
{
-#ifdef BUILD_REPOSITORY_TAB
- addTab(new Repository(this));
-#endif
+ on_ui_addFile_clicked();
}
-void MainWindow::installLocalPackage()
+void MainWindow::projectAddExisting()
{
- QSettings settings;
- QString openPath = settings.value(OPEN_PATH, QDir::homePath()).toString();
+ Project *project = activeProject();
+ if(!project) return;
+ QString openPath = QSettings().value(OPEN_PATH, QDir::homePath()).toString();
QStringList filters = Lexer::Factory::ref().formattedExtensions();
+ filters << "KISS Project (*.kissproj)";
filters.removeDuplicates();
- QStringList filePaths = QFileDialog::getOpenFileNames(this, tr("Open Packages"), openPath, "KISS Archives (*.kiss)");
- foreach(const QString& filePath, filePaths) {
- if(filePath.isEmpty())
- continue;
-
- QFileInfo fileInfo(filePath);
- settings.setValue(OPEN_PATH, fileInfo.absolutePath());
-
- QFile f(filePath);
- if(!f.open(QIODevice::ReadOnly)) {
- MessageDialog::showError(this, "simple_error", QStringList() <<
- tr("Installation of KISS Archive ") + fileInfo.fileName() + tr(" failed.") <<
- tr("Unable to open package file for reading."));
- return;
- }
-
- KissReturn ret(KissArchive::install(&f));
- if(ret.error) {
- MessageDialog::showError(this, "simple_error", QStringList() <<
- tr("Installation of KISS Archive ") + fileInfo.fileName() + tr(" failed.") <<
- ret.message);
- return;
- }
- }
- if(filePaths.size() > 0) QMessageBox::information(this, tr("Install Complete!"), tr("Please restart KISS"));
+ QStringList files = QFileDialog::getOpenFileNames(this, tr("Select One or More Files to Add"), openPath,
+ filters.join(";;") + ";;All Files (*)");
+ foreach(const QString& file, files) project->addFile(file);
+}
+
+void MainWindow::projectRemoveExisting()
+{
+ on_ui_removeFile_clicked();
+}
+
+void MainWindow::projectExtractTo()
+{
+ MessageDialog::showMessage(this, "Under Construction!", "under_construction", QStringList() << tr("Do not extract projects."));
}
void MainWindow::showProjectDock(bool show)
@@ -673,12 +666,6 @@ void MainWindow::projectClicked(const QModelIndex& index)
void MainWindow::projectFileClicked(const QModelIndex& index)
{
// Project* project = m_projectsModel.indexToProject(index);
-
- #if 0
-
-
-
- #endif
}
void MainWindow::projectOpened(Project* project)
@@ -819,8 +806,8 @@ Project* MainWindow::activeProject() const
if(loadedProjects.size() == 0) return 0;
if(loadedProjects.size() == 1) return loadedProjects[0];
- if(m_currentTab && m_currentTab->isProjectAssociated()) return m_currentTab->associatedProject();
const QModelIndexList& list = ui_projects->selectionModel()->selectedRows();
+ if(m_currentTab && m_currentTab->isProjectAssociated()) return m_currentTab->associatedProject();
return list.size() > 0 ? m_projectsModel.indexToProject(list[0]) : 0;
}
View
29 src/QUserInfo.cpp
@@ -1,29 +0,0 @@
-#include "QUserInfo.h"
-
-#ifdef Q_OS_WIN
-#include <windows.h>
-#else
-#include <unistd.h>
-#endif
-
-#define SIZE 256
-
-QString QUserInfo::username()
-{
- QString ret;
-#ifdef Q_OS_WIN
- LPTSTR str = malloc(SIZE);
- LPDWORD size = SIZE;
-#ifdef UNICODE
- if(!GetUserName(str, size)) ret = "";
- else ret = QString::fromUtf16(str);
-#else
- if(!GetUserName(str, size)) ret = "";
- else ret = QString::fromAscii(str);
-#endif
- free(str);
-#else
- ret = QString::fromUtf8(getlogin());
-#endif
- return ret;
-}
View
204 src/Repository.cpp
@@ -1,204 +0,0 @@
-/**************************************************************************
- * Copyright 2007-2012 KISS Institute for Practical Robotics *
- * *
- * This file is part of KISS (Kipr's Instructional Software System). *
- * *
- * KISS 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. *
- * *
- * KISS 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 KISS. Check the LICENSE file in the project root. *
- * If not, see <http://www.gnu.org/licenses/>. *
- **************************************************************************/
-
-#include "Repository.h"
-
-#ifdef BUILD_REPOSITORY_TAB
-
-#include <QDebug>
-#include "KissArchive.h"
-#include "MainWindow.h"
-#include "Kiss.h"
-#include "SourceDialog.h"
-
-#include <QCoreApplication>
-#include "ResourceHelper.h"
-
-#define DELIM "\t"
-
-#define TYPE_AVAIL 1001
-#define TYPE_INSTALLED 1002
-#define DEFAULT_SOURCE "http://files.kipr.org/kiss/"
-
-#define AVAILABLE_LST "available.lst"
-
-Repository::Repository(MainWindow* parent) : QWidget(parent), TabbedWidget(this, parent), m_source(DEFAULT_SOURCE) { setupUi(this); }
-
-void Repository::activate() { mainWindow()->setTitle(m_source); }
-bool Repository::beginSetup() { return true; }
-
-void Repository::completeSetup()
-{
- mainWindow()->setTabName(this, tr("Repository"));
-
- // Just in case this isn't the first call to completeSetup
- disconnect(&m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));
- disconnect(&m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));
-
- connect(&m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));
-
- m_network.get(QNetworkRequest(QUrl(m_source + AVAILABLE_LST)));
-
- ui_list->clear();
- m_locations.clear();
- ui_installList->clear();
- foreach(const QString& name, KissArchive::installed()) {
- QListWidgetItem* item = new QListWidgetItem(name + " - v" + QString::number(KissArchive::version(name)), ui_installList, TYPE_INSTALLED);
- item->setData(Qt::UserRole, name);
- ui_installList->addItem(item);
- }
-
- ui_availGroup->setTitle(m_source + "available.lst");
- mainWindow()->setTitle(m_source);
-}
-
-bool Repository::close() { return true; }
-void Repository::refreshSettings() {}
-
-void Repository::on_ui_mark_clicked()
-{
- QListWidgetItem* item = ui_list->currentItem();
- if(!item) return;
- QListWidgetItem* nItem = new QListWidgetItem(ResourceHelper::ref().icon("tick"), item->text(), ui_stagedList, TYPE_AVAIL);
- nItem->setData(Qt::UserRole, item->data(Qt::UserRole));
- ui_stagedList->addItem(nItem);
- delete ui_list->takeItem(ui_list->row(item));
-}
-
-void Repository::on_ui_unmark_clicked()
-{
- QListWidgetItem* item = ui_stagedList->currentItem();
- if(!item) return;
- QListWidgetItem* nItem = new QListWidgetItem(item->text(), ui_list, item->type());
- nItem->setData(Qt::UserRole, item->data(Qt::UserRole));
- if(item->type() == TYPE_AVAIL) ui_list->addItem(nItem);
- else ui_installList->addItem(nItem);
-
- delete ui_stagedList->takeItem(ui_stagedList->row(item));
-}
-
-void Repository::on_ui_uninstall_clicked()
-{
- QListWidgetItem* item = ui_installList->currentItem();
- if(!item) return;
- QListWidgetItem* nItem = new QListWidgetItem(ResourceHelper::ref().icon("cross.png"), item->text(), ui_stagedList, TYPE_INSTALLED);
- nItem->setData(Qt::UserRole, item->data(Qt::UserRole));
- ui_stagedList->addItem(nItem);
- delete ui_installList->takeItem(ui_installList->row(item));
-}
-
-void Repository::on_ui_begin_clicked()
-{
- mainWindow()->closeAllOthers(this);
- // TargetManager::ref().unloadAll();
-
- disconnect(&m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));
- disconnect(&m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));
- connect(&m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));
- next();
-}
-
-void Repository::on_ui_source_clicked()
-{
- SourceDialog sourceDialog(this);
- sourceDialog.setSource(m_source);
- if(sourceDialog.exec() == QDialog::Rejected) return;
- m_source = sourceDialog.source();
- completeSetup();
-}
-
-void Repository::finished(QNetworkReply* reply)
-{
- ui_list->clear();
- m_locations.clear();
- if(reply->error() != QNetworkReply::NoError) {
- ui_log->addItem(tr("Error fetching list (") + QString::number(reply->error()) + tr(") from ") + m_source);
- return;
- }
- QStringList lines = QString(reply->readAll()).split('\n');
- lines = lines.filter(OS_NAME);
- foreach(const QString& line, lines) {
- QString name = line.section(DELIM, 1, 1) + " - v" + line.section(DELIM, 2, 2);
- ui_list->addItem(new QListWidgetItem(name, ui_list, TYPE_AVAIL));
- qWarning() << line.section(DELIM, 1, 1) << line.section(DELIM, 2, 2) << line.section(DELIM, 3, 3);
- m_locations[name] = line.section(DELIM, 3, 3);
- }
-}
-
-void Repository::downloadFinished(QNetworkReply* reply)
-{
- if(reply->error() != QNetworkReply::NoError) {
- ui_log->addItem(tr("Error fetching (") + QString::number(reply->error()) + tr(") from ") + reply->request().url().toString());
- next();
- return;
- }
-
- disconnect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
- ui_log->addItem(tr("Installing ") + reply->request().url().toString() + "...");
- KissReturn ret(KissArchive::install(reply));
- if(ret.error) {
- ui_log->addItem(ret.message);
- ui_log->addItem(tr("Install ") + reply->request().url().toString() + " FAILED");
- }
- next();
-}
-
-void Repository::downloadProgress(qint64 finished, qint64 total)
-{
- ui_progressBar->setMinimum(0);
- ui_progressBar->setMaximum(total);
- ui_progressBar->setValue(finished);
-}
-
-void Repository::next()
-{
- QListWidgetItem* item = ui_stagedList->takeItem(0);
- ui_progressBar->setEnabled(item != 0);
- ui_mark->setEnabled(item == 0);
- ui_unmark->setEnabled(item == 0);
- ui_list->setEnabled(item == 0);
- ui_installList->setEnabled(item == 0);
- ui_stagedList->setEnabled(item == 0);
- ui_source->setEnabled(item == 0);
- ui_uninstall->setEnabled(item == 0);
- ui_begin->setEnabled(item == 0);
-
- if(!item) {
- ui_log->addItem(tr("Complete!"));
- ui_log->addItem(tr("Please restart KISS."));
- completeSetup();
- return;
- }
-
- if(item->type() == TYPE_INSTALLED) {
- ui_log->addItem(tr("Uninstalling ") + item->text() + "...");
- KissReturn ret(KissArchive::uninstall(item->data(Qt::UserRole).toString()));
- if(ret.error) ui_log->addItem(ret.message);
- next();
- return;
- }
-
- ui_log->addItem(tr("Downloading ") + item->text() + "...");
-
- QNetworkReply* reply = m_network.get(QNetworkRequest(QUrl(m_source + m_locations[item->text()])));
- connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
-}
-
-#endif
View
3  src/SourceFile.cpp
@@ -138,7 +138,8 @@ void SourceFile::activate()
mainWindow()->activateMenuable(TargetMenu::menuName(), this);
}
-bool SourceFile::beginSetup() {
+bool SourceFile::beginSetup()
+{
setParentUnit(isProjectAssociated() ? associatedProject() : 0);
if(isNewFile()) { if(!selectTemplate()) return false; }
else setLexer(Lexer::Factory::ref().constructor(associatedFileSuffix()));
View
2  src/dialogs/ProjectSaveAs.cpp
@@ -55,7 +55,7 @@ void ProjectSaveAs::on_ui_filename_textChanged(const QString& text)
ui_error->setText("");
if(invalidText) ui_error->setText(tr("Invalid file name"));
- if(!invalidText && !text.contains('.')) {
+ if(!invalidText && text.section('.', 1).isEmpty()) {
ui_error->setText(tr("File does not have an extension"));
invalid |= true;
}
View
15 src/interface/QtTargetResponder.cpp
@@ -20,6 +20,21 @@ void QtTargetResponder::runResponse(Target *target, bool success)
emit runFinished(success);
}
+void QtTargetResponder::listResponse(Target *target, const QStringList& programs)
+{
+ emit listFinished(programs);
+}
+
+void QtTargetResponder::deleteResponse(Target *target, bool success)
+{
+ emit deleteFinished(success);
+}
+
+void QtTargetResponder::interactionResponse(Target *target, const QString& ret)
+{
+ emit interactionFinished(ret);
+}
+
void QtTargetResponder::customResponse(Target *target, const QString& type, const QByteArray& payload)
{
emit customFinished(type, payload);
View
3  src/interface/Target.cpp
@@ -87,6 +87,9 @@ const bool Target::executeEntry(const CommunicationEntry *entry)
case CommunicationEntry::Download: return download(entry->name(), entry->archive());
case CommunicationEntry::Compile: return compile(entry->name());
case CommunicationEntry::Run: return run(entry->name());
+ case CommunicationEntry::List: return list();
+ case CommunicationEntry::Delete: return deleteProgram(entry->name());
+ case CommunicationEntry::Interaction: return interaction(entry->name());
case CommunicationEntry::Disconnect: return disconnect();
default: qCritical() << "Target does not know how to execute queue entry of type" << entry->type();
}
View
65 src/main.cpp
@@ -24,7 +24,6 @@
#include "MainWindow.h"
#include "WelcomeTab.h"
#include "DeclarativeTab.h"
-#include "KissArchive.h"
#include "LogStreamBuf.h"
#include "AudioTutorial.h"
#include "Log.h"
@@ -37,65 +36,6 @@
using namespace std;
-void createArchive(const QString& name, const unsigned version, const QString& platforms, const QString& fileList, const QString& out) {
- QFile f(fileList);
- if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
- qWarning() << "Unable to open" << fileList << "for reading.";
- return;
- }
- QFile outf(out);
- if(!outf.open(QIODevice::WriteOnly)) {
- qWarning() << "Unable to open" << out << "for writing.";
- return;
- }
- KissReturn ret = KissArchive::create(name, version, platforms.split(','),
- QString(f.readAll().data()).split('\n'),
- &outf);
-
- if(ret.error) qWarning() << "Archive creation failed!" << ret.message;
-}
-
-void handleArgs()
-{
- const QStringList& args = QApplication::arguments();
- if(args[1] == "--createArchive") {
- if(args.size() != 7) {
- qWarning() << "Wrong number of arguments";
- return;
- }
- createArchive(args[2], args[3].toUInt(), args[4], args[5], args[6]);
- } if(args[1] == "--uninstall") {
- if(args.size() != 3) {
- qWarning() << "Wrong number of arguments";
- return;
- }
- KissArchive::uninstall(args[2]);
- } else if(args[1] == "--install") {
- foreach(const QString arg, args.mid(2)) {
- QFile f(arg);
- if(!f.open(QIODevice::ReadOnly)) {
- qWarning() << "Unable to open" << arg << "for reading";
- continue;
- }
-
- KissArchive::install(&f);
- }
- } else if(args[1] == "--list") {
- foreach(const QString arg, args.mid(2)) {
- qWarning() << arg << ":";
- QFile f(arg);
- if(!f.open(QIODevice::ReadOnly)) {
- qWarning() << "Unable to open" << arg << "for reading";
- continue;
- }
-
- foreach(const QString& file, KissArchive::list(&f)) {
- qWarning() << "\t" << file;
- }
- }
- }
-}
-
int main(int argc, char **argv)
{
QApplication application(argc, argv);
@@ -113,11 +53,6 @@ int main(int argc, char **argv)
// Creates everything we need
KissStandardEnvironment::createStandardEnvironment();
- if(QApplication::arguments().size() > 1 && QApplication::arguments()[1].startsWith("--")) {
- handleArgs();
- return 0;
- }
-
QPixmap splashPixmap(":/splash_screen.png");
QSplashScreen splash(splashPixmap);
splash.raise();
View
9 src/menus/DeveloperMenu.cpp
@@ -22,7 +22,6 @@
#ifdef BUILD_DEVELOPER_TOOLS
-#include "KissArchive.h"
#include <kiss-compiler/ArchiveWriter.h>
#include "ProjectManager.h"
#include <QFileDialog>
@@ -38,19 +37,13 @@ DeveloperMenu::DeveloperMenu(MainWindow* mainWindow) : ConcreteMenuable(menuName
#ifdef BUILD_DECLARATIVE_TAB
developer->children.append(node(declTab = action("Create Declarative Tab")));
#endif
- developer->children.append(MenuNode::separator());
- developer->children.append(node(uninstallAll = action("Uninstall All Packages")));
m_actions.append(developer);
}
void DeveloperMenu::triggered()
{
QAction* _ = (QAction*)sender();
- if(_ == uninstallAll) {
- QStringList installed = KissArchive::installed();
- foreach(const QString& install, installed) KissArchive::uninstall(install);
- qWarning() << "Uninstalled all packages.";
- } else if(_ == writeFullProject) {
+ if(_ == writeFullProject) {
Project* project = m_mainWindow->activeProject();
ArchiveWriter* writer = ProjectManager::ref().archiveWriter(project);
if(!writer) return;
View
4 src/menus/MainWindowMenu.cpp
@@ -33,10 +33,6 @@
MainWindowMenu::MainWindowMenu(MainWindow* mainWindow) : ConcreteMenuable(menuName()), m_mainWindow(mainWindow)
{
MenuNode* packages = new MenuNode("Packages");
-#ifdef BUILD_REPOSITORY_TAB
- packages->children.append(node(activeAction("", "Manage Packages", QKeySequence::UnknownKey, this, "managePackages")));
-#endif
- packages->children.append(node(activeAction("cog_go", "Install Local Packages...", QKeySequence::UnknownKey, this, "installLocalPackage")));
m_file.append(packages);
m_file.append(node(m_hideErrors = action("Hide Errors", QKeySequence::UnknownKey)));
m_file.append(MenuNode::separator());
View
17 src/menus/ProjectMenu.cpp
@@ -1,12 +1,13 @@
#include "ProjectMenu.h"
+#include "MainWindow.h"
ProjectMenu::ProjectMenu() : ConcreteMenuable(menuName())
{
MenuNode* project = node(action("Project"));
- project->children.append(node(action("Add Existing Files...", QKeySequence::UnknownKey)));
- project->children.append(node(action("Add New File...", QKeySequence::UnknownKey)));
- project->children.append(node(action("Remove Selected Files", QKeySequence::UnknownKey)));
- project->children.append(node(action("Extract to...", QKeySequence::UnknownKey)));
+ project->children.append(addExistingFile = node(activeAction("Add Existing Files...", QKeySequence::UnknownKey, this, "projectAddExisting")));
+ project->children.append(addNewFile = node(activeAction("Add New File...", QKeySequence::UnknownKey, this, "projectAddNew")));
+ project->children.append(removeExistingFile = node(activeAction("Remove Selected Files", QKeySequence::UnknownKey, this, "projectRemoveExisting")));
+ project->children.append(extractTo = node(activeAction("Extract to...", QKeySequence::UnknownKey, this, "projectExtractTo")));
m_actions.append(project);
}
@@ -32,5 +33,11 @@ void ProjectMenu::triggered()
void ProjectMenu::update()
{
-
+ MainWindow *mainWindow = qobject_cast<MainWindow *>(active());
+ if(!mainWindow) return;
+ Project *active = mainWindow->activeProject();
+ addExistingFile->rawAction->setEnabled(active);
+ addNewFile->rawAction->setEnabled(active);
+ removeExistingFile->rawAction->setEnabled(active);
+ extractTo->rawAction->setEnabled(active);
}
Please sign in to comment.
Something went wrong with that request. Please try again.