Skip to content

Commit

Permalink
Merge pull request sonic-pi-net#486 from josephwilk/remove_json
Browse files Browse the repository at this point in the history
Replace JSON with properties file
  • Loading branch information
samaaron committed May 15, 2015
2 parents e97307b + 46d4b05 commit a764506
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
10 changes: 4 additions & 6 deletions app/gui/qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,18 @@ MainWindow::MainWindow(QApplication &app, bool i18n, QSplashScreen* splash)

// Syntax highlighting

QString themeFilename = QDir::homePath() + QDir::separator() + ".sonic-pi" + QDir::separator() + "theme.json";
QString themeFilename = QDir::homePath() + QDir::separator() + ".sonic-pi" + QDir::separator() + "theme.properties";
QFile themeFile(themeFilename);
SonicPiTheme *theme;
if(themeFile.exists()){
qDebug() << "[GUI] Custom colors";
themeFile.open(QIODevice::ReadOnly);
QByteArray rawData = themeFile.readAll();
QJsonDocument doc(QJsonDocument::fromJson(rawData));
theme = new SonicPiTheme(this, doc.object());
QSettings settings(themeFilename, QSettings::IniFormat);
theme = new SonicPiTheme(this, settings);
lexer = new SonicPiLexer(theme);
}
else{
qDebug() << "[GUI] Default colors";
theme = new SonicPiTheme(this, QJsonObject());
theme = new SonicPiTheme(this, QSettings());
lexer = new SonicPiLexer(theme);
}

Expand Down
1 change: 0 additions & 1 deletion app/gui/qt/sonicpilexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


#include <Qsci/qscilexerruby.h>
#include <QJsonObject>

#include "sonicpitheme.h"

Expand Down
1 change: 0 additions & 1 deletion app/gui/qt/sonicpiscintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


#include <Qsci/qsciscintilla.h>
#include <QJsonObject>
#include "sonicpitheme.h"

class SonicPiLexer;
Expand Down
10 changes: 5 additions & 5 deletions app/gui/qt/sonicpitheme.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

#include "sonicpitheme.h"

SonicPiTheme::SonicPiTheme(QObject *parent, const QJsonObject& settings) : QObject(parent)
SonicPiTheme::SonicPiTheme(QObject *parent, const QSettings& settings) : QObject(parent)
{
QJsonObject themeSettings = QJsonObject();
QMap<QString, QString> themeSettings;
themeSettings["Foreground"] = "black";
themeSettings["Background"] = "white";

Expand Down Expand Up @@ -70,16 +70,16 @@ SonicPiTheme::SonicPiTheme(QObject *parent, const QJsonObject& settings) : QObje
themeSettings["FoldMarginForeground"] = "whitesmoke";


QStringList customSettings = settings.keys();
QStringList customSettings = settings.allKeys();
for(int idx=0; idx < customSettings.size(); idx++){
themeSettings[customSettings[idx]] = settings[customSettings[idx]];
themeSettings[customSettings[idx]] = settings.value(customSettings[idx]).toString();
}

this->theme = themeSettings;
}

QColor SonicPiTheme::color(QString key){
return theme[key].toString();
return theme[key];
}

SonicPiTheme::~SonicPiTheme(){}
Expand Down
5 changes: 2 additions & 3 deletions app/gui/qt/sonicpitheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
#include <QtCore>
#include <QObject>
#include <QColor>
#include <QJsonObject>

class SonicPiTheme : public QObject
{
Q_OBJECT
public:
explicit SonicPiTheme(QObject *parent = 0, const QJsonObject& settings = QJsonObject());
explicit SonicPiTheme(QObject *parent = 0, const QSettings& settings = QSettings());
~SonicPiTheme();
QColor color(QString);

private:
QJsonObject theme;
QMap<QString, QString> theme;

signals:

Expand Down

0 comments on commit a764506

Please sign in to comment.