Skip to content

Commit

Permalink
Merge pull request #29 from parallaxinc/preferences
Browse files Browse the repository at this point in the history
New Preferences dialog, faster editing, now with indent guides
  • Loading branch information
bweir committed Jan 18, 2016
2 parents 688efe7 + c9c7e65 commit ecbe9b6
Show file tree
Hide file tree
Showing 38 changed files with 2,325 additions and 977 deletions.
2 changes: 1 addition & 1 deletion src/memorymap
1 change: 0 additions & 1 deletion src/propelleride/buildmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ BuildManager::BuildManager(QWidget *parent)
: QFrame(parent)
{
ui.setupUi(this);
setWindowFlags(Qt::Dialog);

hideDetails();

Expand Down
64 changes: 15 additions & 49 deletions src/propelleride/colorchooser.cpp
Original file line number Diff line number Diff line change
@@ -1,81 +1,47 @@
#include "colorchooser.h"

#include <QColor>
#include <QPixmap>
#include <QPainter>
#include <QMouseEvent>
#include <QColorDialog>

/*
* This source file is part of EasyPaint.
*
* Copyright (c) 2012 LSPaint <https://github.com/Gr1N/LSPaint>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "colorscheme.h"

ColorChooser::ColorChooser(ColorScheme::Color newkey, QString hex, QWidget *parent) :
ColorChooser::ColorChooser(QWidget *parent) :
QLabel(parent)
{
//setFrameStyle(QFrame::Raised | QFrame::Box);
mCurrentColor = new QColor(hex);
mPixmapColor = new QPixmap(80, 20);
mPainterColor = new QPainter(mPixmapColor);
mPainterColor->fillRect(0, 0, 80, 20, *mCurrentColor);
mPainterColor->end();
setMargin(3);
setAlignment(Qt::AlignHCenter);
setPixmap(*mPixmapColor);
key = newkey;
}

ColorChooser::~ColorChooser()
{
delete mCurrentColor;
delete mPainterColor;
delete mPixmapColor;
}

void ColorChooser::setColor(const QColor &color)
void ColorChooser::setKey(int key)
{
*mCurrentColor = color;
mPainterColor->begin(mPixmapColor);
mPainterColor->fillRect(0, 0, 80, 20, *mCurrentColor);
mPainterColor->end();
setPixmap(*mPixmapColor);
_key = key;
}

void ColorChooser::setColor(QColor color)
{
_color = color;
QPalette p = this->palette();
p.setColor(QPalette::Window, color);
this->setPalette(p);
}

void ColorChooser::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
QColor color = QColorDialog::getColor(*mCurrentColor, this);
QColor color = QColorDialog::getColor(_color, this);
if(color.isValid())
{
setColor(color);
emit sendColor(key, color);
emit sendColor(_key, _color);
}
}
}

void ColorChooser::updateColor()
{
setColor(Singleton<ColorScheme>::Instance().getColor(key));
setColor(Singleton<ColorScheme>::Instance().getColor((ColorScheme::Color) _key));
}
42 changes: 5 additions & 37 deletions src/propelleride/colorchooser.h
Original file line number Diff line number Diff line change
@@ -1,53 +1,21 @@
#pragma once

/*
* This source file is part of EasyPaint.
*
* Copyright (c) 2012 LSPaint <https://github.com/Gr1N/LSPaint>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <QLabel>

#include "colorscheme.h"


class ColorChooser : public QLabel
{
Q_OBJECT

public:
explicit ColorChooser(ColorScheme::Color newkey,
QString hex,
QWidget *parent = 0);
explicit ColorChooser(QWidget *parent = 0);
~ColorChooser();

private:
QColor *mCurrentColor;
QPixmap *mPixmapColor;
QPainter *mPainterColor;
ColorScheme::Color key;
int _key;
QColor _color;

public slots:
void setColor(const QColor &color);
void setKey(int key);
void setColor(QColor color);
void updateColor();

signals:
Expand Down
36 changes: 25 additions & 11 deletions src/propelleride/colorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <QDebug>
#include <QFontDatabase>

#include "logging.h"

ColorScheme::ColorScheme(QObject * parent) :
QObject(parent)
{
Expand All @@ -25,32 +27,43 @@ void ColorScheme::defaults()
colors[SyntaxNumbers] = (struct colorcontainer) { QColor("#ff7fff") , "Syntax_Numbers" };
colors[SyntaxOperators] = (struct colorcontainer) { QColor("#6565ff") , "Syntax_Operators" };
colors[SyntaxKeywords] = (struct colorcontainer) { QColor("#ffffff") , "Syntax_Keywords" };
colors[SyntaxQuotes] = (struct colorcontainer) { QColor("#a2b2ff") , "Syntax_Quotes" };
colors[SyntaxQuotes] = (struct colorcontainer) { QColor("#a2b2ff") , "Syntax_Strings" };
colors[SyntaxComments] = (struct colorcontainer) { QColor("#cccccc") , "Syntax_Comments" };

}


void ColorScheme::save()
{
QSettings settings;
save(&settings);
}

void ColorScheme::save(const QString & filename)
{
QSettings settings(filename, QSettings::IniFormat);
save(&settings);
}

void ColorScheme::save(QSettings * settings)
{
qCDebug(ideTheme) << "saving" << settings->fileName();

settings.beginGroup("Colors");
settings->beginGroup("Colors");

QMap<ColorScheme::Color, colorcontainer>::iterator i;
for (i = colors.begin(); i != colors.end(); ++i)
{
settings.setValue(i.value().key,i.value().color.name());
settings->setValue(i.value().key,i.value().color.name());
}

settings.endGroup();
settings->endGroup();

settings.beginGroup("Font");
settings->beginGroup("Font");

settings.setValue("Family", font.family());
settings.setValue("Size", font.pointSize());
settings->setValue("Family", font.family());
settings->setValue("Size", font.pointSize());

settings.endGroup();
settings->endGroup();

}

Expand All @@ -68,6 +81,8 @@ void ColorScheme::load(const QString & filename)

void ColorScheme::load(QSettings * settings)
{
qCDebug(ideTheme) << "loading" << settings->fileName();

settings->beginGroup("Colors");

QMap<ColorScheme::Color, colorcontainer>::iterator i;
Expand All @@ -88,6 +103,7 @@ void ColorScheme::load(QSettings * settings)

settings->beginGroup("Font");


if (!settings->contains("Family") || settings->value("Family").toString().isEmpty())
{
font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
Expand All @@ -110,8 +126,6 @@ void ColorScheme::load(QSettings * settings)
);

settings->endGroup();

qDebug() << "Setting font:" << font.family();
}

void ColorScheme::setColor(ColorScheme::Color key, const QColor & color)
Expand Down
7 changes: 5 additions & 2 deletions src/propelleride/colorscheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ class ColorScheme : public QObject
public slots:

void save();
void save(const QString & filename);
void save(QSettings * settings);

void load();
void load(const QString & filename);
void load(QSettings * settings);

void defaults();

public:
void load(QSettings * settings);

QColor getColor(ColorScheme::Color key);
void setColor(ColorScheme::Color key, const QColor & newcolor);

Expand Down
Loading

0 comments on commit ecbe9b6

Please sign in to comment.