Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lions and Tigers and Code, oh my\!

  • Loading branch information...
commit cdf083aa1e12bf4bbcfb4e6a925fb65463d5efcf 1 parent 2b38881
@bmcdorman bmcdorman authored
View
3  include/MainWindow.h
@@ -23,6 +23,7 @@
#include "ui_MainWindow.h"
#include "EditorSettingsDialog.h"
+#include "ThemeSettingsDialog.h"
#include "TabbedWidget.h"
#include <Qsci/qscilexercpp.h>
@@ -173,6 +174,7 @@ public slots:
bool closeNode(const TinyNode* node);
void about();
void settings();
+ void theme();
void projectAddNew();
void projectAddExisting();
@@ -212,6 +214,7 @@ private slots:
private:
TabbedWidget* m_currentTab;
EditorSettingsDialog m_editorSettingsDialog;
+ ThemeSettingsDialog m_themeSettingsDialog;
QMap<QWidget*, TabbedWidget*> m_lookup;
MenuManager m_menuManager;
QList<Menuable*> m_menuables;
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 "TabbedWidget.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
4 include/dialogs/EditorSettingsDialog.h
@@ -27,11 +27,7 @@
#include <QObject>
#define EDITOR "Editor"
-#define LEXER "Lexer"
-#define FONT "font"
#define ENABLED "enabled"
-#define FONT_SIZE "fontsize"
-#define BACKGROUND_COLOR "backgroundcolor"
#define AUTO_COMPLETION "autocompletion"
#define API_SOURCE "apisource"
#define DOC_SOURCE "docsource"
View
39 include/dialogs/ThemeSettingsDialog.h
@@ -1,11 +1,16 @@
-#ifndef THEMESETTINGSDIALOG_H
-#define THEMESETTINGSDIALOG_H
+#ifndef _THEMESETTINGSDIALOG_H_
+#define _THEMESETTINGSDIALOG_H_
#include <QDialog>
#include <QMap>
#include <QAbstractButton>
#include "ColorBox.h"
+#define LEXER "Lexer"
+#define FONT "font"
+#define FONT_SIZE "fontsize"
+#define BACKGROUND_COLOR "backgroundcolor"
+
namespace Ui
{
class ThemeSettingsDialog;
@@ -13,24 +18,36 @@ namespace Ui
class ThemeSettingsDialog : public QDialog
{
- Q_OBJECT
-
+Q_OBJECT
public:
- ThemeSettingsDialog(QMap<QString, QColor> lexerSettings, QColor backgroundColor, QFont font, int fontSize, QWidget *parent = 0);
+ ThemeSettingsDialog(QWidget *parent = 0);
~ThemeSettingsDialog();
- QMap<QString, QColor> settings();
- QColor backgroundColor();
- QFont font();
- int fontSize();
+ virtual int exec();
+
+ const QMap<QString, QColor>& settings() const;
+ QColor backgroundColor() const;
+ QFont font() const;
+ int fontSize() const;
+
+ void readSettings();
+ void writeSettings();
+
+public slots:
+ void setDefaults();
private slots:
void settingChanged(QColor color);
private:
+ void updateBoxes();
+
Ui::ThemeSettingsDialog *ui;
QMap<QString, QColor> m_lexerSettings;
- ColorBox **boxes;
+ ColorBox **m_boxes;
+ int m_fontSize;
+ QFont m_font;
+ QColor m_backgroundColor;
};
-#endif // THEMESETTINGSDIALOG_H
+#endif
View
BIN  rc/icon_set/icons/color_swatch.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1  rc/rc.qrc
@@ -30,6 +30,7 @@
<file>icon_set/icons/disk.png</file>
<file>icon_set/icons/folder.png</file>
<file>icon_set/icons/page_white.png</file>
+ <file>icon_set/icons/color_swatch.png</file>
</qresource>
<qresource prefix="/shortcuts/target">
<file>icon_set/icons/report.png</file>
View
14 src/MainWindow.cpp
@@ -62,7 +62,9 @@
#define OPEN_PATH "openpath"
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_currentTab(0)
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent),
+ m_currentTab(0)
{
QNetworkProxyFactory::setUseSystemConfiguration(true);
@@ -474,7 +476,15 @@ void MainWindow::about()
<< KISS_C_VERSION_CODENAME);
}
-void MainWindow::settings() { if(m_editorSettingsDialog.exec()) emit settingsUpdated(); }
+void MainWindow::settings()
+{
+ if(m_editorSettingsDialog.exec()) emit settingsUpdated();
+}
+
+void MainWindow::theme()
+{
+ if(m_themeSettingsDialog.exec()) emit settingsUpdated();
+}
void MainWindow::on_ui_tabWidget_currentChanged(int i)
{
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
- TCHAR str[SIZE + 1];
- DWORD size = SIZE + 1;
-#ifdef UNICODE
- if(!GetUserName((TCHAR*)str, &size)) ret = "";
- else ret = QString::fromUtf16(str);
-#else
- if(!GetUserName((TCHAR*)str, &size)) ret = "";
- else ret = QString::fromAscii(str);
-#endif
-
-#else
- ret = QString::fromUtf8(getlogin());
-#endif
- return ret;
-}
View
47 src/dialogs/EditorSettingsDialog.cpp
@@ -19,7 +19,6 @@
**************************************************************************/
#include "EditorSettingsDialog.h"
-#include "ThemeSettingsDialog.h"
#include "LexerFactory.h"
#include <QSettings>
@@ -56,13 +55,6 @@ int EditorSettingsDialog::exec()
void EditorSettingsDialog::on_ui_themeSettingsButton_clicked()
{
- ThemeSettingsDialog diag(m_lexerSettings, m_backgroundColor, m_font, m_fontSize);
- if(diag.exec()) {
- m_lexerSettings = diag.settings();
- m_backgroundColor = diag.backgroundColor();
- m_font = diag.font();
- m_fontSize = diag.fontSize();
- }
}
void EditorSettingsDialog::on_ui_buttonBox_clicked(QAbstractButton *button)
@@ -79,18 +71,6 @@ void EditorSettingsDialog::saveSettings()
{
QSettings settings;
settings.beginGroup(EDITOR);
- settings.setValue(BACKGROUND_COLOR, m_backgroundColor);
- settings.setValue(FONT, m_font);
- settings.setValue(FONT_SIZE, m_fontSize);
-
- settings.beginGroup(LEXER);
- QMap<QString, QColor>::const_iterator i = m_lexerSettings.constBegin();
- while (i != m_lexerSettings.constEnd()) {
- settings.setValue(i.key(), i.value());
- ++i;
- }
- Lexer::Settings::ref().setSettings(m_lexerSettings);
- settings.endGroup();
settings.beginGroup(AUTO_COMPLETION);
settings.setValue(ENABLED, ui_autoCompletionEnabledCheckBox->isChecked());
@@ -121,33 +101,6 @@ void EditorSettingsDialog::readSettings()
QSettings settings;
settings.beginGroup(EDITOR);
- m_backgroundColor = settings.value(BACKGROUND_COLOR, QColor(255, 255, 255)).value<QColor>();
-
- // Figure out the font and set it
- #ifdef Q_OS_WIN32
- QString fontString = settings.value(FONT, "Courier New").toString();
- #elif defined(Q_OS_MAC)
- QString fontString = settings.value(FONT, "Monaco").toString();
- #else
- QString fontString = settings.value(FONT, "Monospace").toString();
- #endif
-
- m_font = QFont(fontString);
-
- // Figure out the font size and set the widget
- #ifdef Q_OS_MAC
- m_fontSize = settings.value(FONT_SIZE, 12).toInt();
- #else
- m_fontSize = settings.value(FONT_SIZE, 10).toInt();
- #endif
-
- // Read the lexer settings
- m_lexerSettings.clear();
- settings.beginGroup(LEXER);
- QStringList keys = settings.childKeys();
- foreach(QString key, keys) m_lexerSettings.insert(key, settings.value(key).value<QColor>());
-
- settings.endGroup();
// Set the auto completion settings from the application config
settings.beginGroup(AUTO_COMPLETION);
View
160 src/dialogs/ThemeSettingsDialog.cpp
@@ -1,73 +1,163 @@
#include "ThemeSettingsDialog.h"
#include "ui_ThemeSettingsDialog.h"
+
+#include "EditorSettingsDialog.h"
#include "SyntaxStandards.h"
+#include "LexerFactory.h"
+#include <QSettings>
+#include <QColor>
+#include <QMap>
#include <QDebug>
-ThemeSettingsDialog::ThemeSettingsDialog(QMap<QString, QColor> lexerSettings, QColor backgroundColor, QFont font, int fontSize, QWidget *parent)
- : QDialog(parent), m_lexerSettings(lexerSettings)
+ThemeSettingsDialog::ThemeSettingsDialog(QWidget *parent)
+ : QDialog(parent)
{
ui = new Ui::ThemeSettingsDialog();
ui->setupUi(this);
- ui->ui_table->setColumnWidth(0, 180);
+ ui->table->setColumnWidth(0, 180);
- const int rows = ui->ui_table->rowCount();
- boxes = new ColorBox *[rows];
+ const int rows = ui->table->rowCount();
+ m_boxes = new ColorBox *[rows];
for(int i = 0; i < rows; ++i) {
- boxes[i] = new ColorBox(ui->ui_table);
- boxes[i]->setProperty("row", i);
- connect(boxes[i], SIGNAL(colorChanged(QColor)), SLOT(settingChanged(QColor)));
- ui->ui_table->setCellWidget(i, 1, boxes[i]);
+ m_boxes[i] = new ColorBox(ui->table);
+ m_boxes[i]->setProperty("row", i);
+ connect(m_boxes[i], SIGNAL(colorChanged(QColor)), SLOT(settingChanged(QColor)));
+ ui->table->setCellWidget(i, 1, m_boxes[i]);
}
-
- boxes[0]->setColor(m_lexerSettings.value(DEFAULT, SyntaxStandards::defaultColor()));
- boxes[1]->setColor(m_lexerSettings.value(COMMENT, SyntaxStandards::commentColor()));
- boxes[2]->setColor(m_lexerSettings.value(DOC_COMMENT, SyntaxStandards::docColor()));
- boxes[3]->setColor(m_lexerSettings.value(NUMBER, SyntaxStandards::numberColor()));
- boxes[4]->setColor(m_lexerSettings.value(KEYWORD, SyntaxStandards::keywordColor()));
- boxes[5]->setColor(m_lexerSettings.value(STRING, SyntaxStandards::stringColor()));
- boxes[6]->setColor(m_lexerSettings.value(PREPROCESSOR, SyntaxStandards::preprocessorColor()));
- boxes[7]->setColor(m_lexerSettings.value(OPERATOR, SyntaxStandards::operatorColor()));
- boxes[8]->setColor(m_lexerSettings.value(UNCLOSED_STRING, SyntaxStandards::unclosedStringColor()));
- boxes[9]->setColor(m_lexerSettings.value(DOC_KEYWORD, SyntaxStandards::docKeywordColor()));
- boxes[10]->setColor(m_lexerSettings.value(DOC_KEYWORD_ERROR, SyntaxStandards::docKeywordErrorColor()));
-
- ui->ui_backgroundColorBox->setColor(backgroundColor);
- ui->ui_fontBox->setCurrentFont(font);
- ui->ui_fontSizeBox->setValue(fontSize);
+ readSettings();
+ setDefaults();
+ connect(ui->reset, SIGNAL(clicked()), SLOT(setDefaults()));
}
ThemeSettingsDialog::~ThemeSettingsDialog()
{
- for(int i = 0; i < ui->ui_table->rowCount(); ++i) delete boxes[i];
- delete boxes;
+ for(quint16 i = 0; i < ui->table->rowCount(); ++i) delete m_boxes[i];
+ delete m_boxes;
delete ui;
}
-QMap<QString, QColor> ThemeSettingsDialog::settings()
+int ThemeSettingsDialog::exec()
+{
+ readSettings();
+ if(!QDialog::exec()) return QDialog::Rejected;
+ writeSettings();
+ return QDialog::Accepted;
+}
+
+const QMap<QString, QColor>& ThemeSettingsDialog::settings() const
{
return m_lexerSettings;
}
-QColor ThemeSettingsDialog::backgroundColor()
+QColor ThemeSettingsDialog::backgroundColor() const
{
- return ui->ui_backgroundColorBox->color();
+ return ui->backgroundColorBox->color();
}
-QFont ThemeSettingsDialog::font()
+QFont ThemeSettingsDialog::font() const
{
- return ui->ui_fontBox->currentFont();
+ return ui->fontBox->currentFont();
}
-int ThemeSettingsDialog::fontSize()
+int ThemeSettingsDialog::fontSize() const
{
- return ui->ui_fontSizeBox->value();
+ return ui->fontSizeBox->value();
+}
+
+void ThemeSettingsDialog::readSettings()
+{
+ QSettings settings;
+
+ settings.beginGroup(EDITOR);
+ ui->backgroundColorBox->setColor(settings.value(BACKGROUND_COLOR, QColor(255, 255, 255)).value<QColor>());
+
+ // Figure out the font and set it
+#ifdef Q_OS_WIN32
+ QString fontString = settings.value(FONT, "Courier New").toString();
+#elif defined(Q_OS_MAC)
+ QString fontString = settings.value(FONT, "Monaco").toString();
+#else
+ QString fontString = settings.value(FONT, "Monospace").toString();
+#endif
+
+ ui->fontBox->setCurrentFont(QFont(fontString));
+
+ int fontSize = 0;
+#ifdef Q_OS_MAC
+ fontSize = settings.value(FONT_SIZE, 12).toInt();
+#else
+ fontSize = settings.value(FONT_SIZE, 10).toInt();
+#endif
+
+ // Figure out the font size and set the widget
+ ui->fontSizeBox->setValue(fontSize);
+
+ // Read the lexer settings
+ m_lexerSettings.clear();
+ settings.beginGroup(LEXER);
+ QStringList keys = settings.childKeys();
+ foreach(const QString& key, keys) m_lexerSettings.insert(key, settings.value(key).value<QColor>());
+
+ settings.endGroup();
+ settings.endGroup();
+
+ updateBoxes();
+}
+
+void ThemeSettingsDialog::writeSettings()
+{
+ QSettings settings;
+
+ settings.beginGroup(EDITOR);
+
+ settings.setValue(BACKGROUND_COLOR, backgroundColor());
+ settings.setValue(FONT, font());
+ settings.setValue(FONT_SIZE, fontSize());
+
+ settings.beginGroup(LEXER);
+ QMap<QString, QColor>::const_iterator i = m_lexerSettings.constBegin();
+ for(; i != m_lexerSettings.constEnd(); ++i) settings.setValue(i.key(), i.value());
+ Lexer::Settings::ref().setSettings(m_lexerSettings);
+ settings.endGroup();
+ settings.endGroup();
+}
+
+void ThemeSettingsDialog::setDefaults()
+{
+ m_lexerSettings[DEFAULT] = SyntaxStandards::defaultColor();
+ m_lexerSettings[COMMENT] = SyntaxStandards::commentColor();
+ m_lexerSettings[DOC_COMMENT] = SyntaxStandards::docColor();
+ m_lexerSettings[NUMBER] = SyntaxStandards::numberColor();
+ m_lexerSettings[KEYWORD] = SyntaxStandards::keywordColor();
+ m_lexerSettings[STRING] = SyntaxStandards::stringColor();
+ m_lexerSettings[PREPROCESSOR] = SyntaxStandards::preprocessorColor();
+ m_lexerSettings[OPERATOR] = SyntaxStandards::operatorColor();
+ m_lexerSettings[UNCLOSED_STRING] = SyntaxStandards::unclosedStringColor();
+ m_lexerSettings[DOC_KEYWORD] = SyntaxStandards::docKeywordColor();
+ m_lexerSettings[DOC_KEYWORD_ERROR] = SyntaxStandards::docKeywordErrorColor();
+ updateBoxes();
}
void ThemeSettingsDialog::settingChanged(QColor color)
{
ColorBox *box = (ColorBox *)sender();
- QString setting = ui->ui_table->item(box->property("row").toInt(), 0)->text();
+ QString setting = ui->table->item(box->property("row").toInt(), 0)->text();
m_lexerSettings.insert(setting, color);
}
+
+void ThemeSettingsDialog::updateBoxes()
+{
+ m_boxes[0]->setColor(m_lexerSettings.value(DEFAULT, SyntaxStandards::defaultColor()));
+ m_boxes[1]->setColor(m_lexerSettings.value(COMMENT, SyntaxStandards::commentColor()));
+ m_boxes[2]->setColor(m_lexerSettings.value(DOC_COMMENT, SyntaxStandards::docColor()));
+ m_boxes[3]->setColor(m_lexerSettings.value(NUMBER, SyntaxStandards::numberColor()));
+ m_boxes[4]->setColor(m_lexerSettings.value(KEYWORD, SyntaxStandards::keywordColor()));
+ m_boxes[5]->setColor(m_lexerSettings.value(STRING, SyntaxStandards::stringColor()));
+ m_boxes[6]->setColor(m_lexerSettings.value(PREPROCESSOR, SyntaxStandards::preprocessorColor()));
+ m_boxes[7]->setColor(m_lexerSettings.value(OPERATOR, SyntaxStandards::operatorColor()));
+ m_boxes[8]->setColor(m_lexerSettings.value(UNCLOSED_STRING, SyntaxStandards::unclosedStringColor()));
+ m_boxes[9]->setColor(m_lexerSettings.value(DOC_KEYWORD, SyntaxStandards::docKeywordColor()));
+ m_boxes[10]->setColor(m_lexerSettings.value(DOC_KEYWORD_ERROR, SyntaxStandards::docKeywordErrorColor()));
+}
View
1  src/menus/MainWindowMenu.cpp
@@ -46,6 +46,7 @@ MainWindowMenu::MainWindowMenu(MainWindow* mainWindow) : ConcreteMenuable(menuNa
m_edit.append(MenuNode::separator());
m_edit.append(node(activeAction("cog.png", "Settings", QKeySequence::Preferences, this, "settings")));
+ m_edit.append(node(activeAction("theme.png", "Editor Theme", QKeySequence::Preferences, this, "theme")));
QAction* about = activeAction("information", "About KISS IDE", QKeySequence::UnknownKey, this, "about");
m_help.append(node(about));
View
39 ui/ThemeSettingsDialog.ui
@@ -6,18 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
- <width>644</width>
+ <width>661</width>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
<string>Theme Settings</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QTableWidget" name="ui_table">
+ <widget class="QTableWidget" name="table">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@@ -175,7 +175,7 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="ColorBox" name="ui_backgroundColorBox"/>
+ <widget class="ColorBox" name="backgroundColorBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
@@ -185,7 +185,7 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QFontComboBox" name="ui_fontBox"/>
+ <widget class="QFontComboBox" name="fontBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
@@ -195,7 +195,7 @@
</widget>
</item>
<item row="2" column="1">
- <widget class="QSpinBox" name="ui_fontSizeBox">
+ <widget class="QSpinBox" name="fontSizeBox">
<property name="minimum">
<number>1</number>
</property>
@@ -224,14 +224,25 @@
</layout>
</item>
<item>
- <widget class="QDialogButtonBox" name="ui_buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="reset">
+ <property name="text">
+ <string>Reset Defaults</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="ui_buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
Please sign in to comment.
Something went wrong with that request. Please try again.