diff --git a/bin/app/data/ApplicationSettings_template.xml b/bin/app/data/ApplicationSettings_template.xml index 7a86c6df..b37a3891 100644 --- a/bin/app/data/ApplicationSettings_template.xml +++ b/bin/app/data/ApplicationSettings_template.xml @@ -29,6 +29,7 @@ + @@ -39,81 +40,4 @@ - - - - - #8FBC92 - #5EA071 - - - #FCA47E - #F97A4E - - - - #ededed - #ededed - - - #ededed - #ededed - - - #ededed - #ededed - - - #F4D07D - #F4BC3D - - - #F4D07D - #F4BC3D - - - #7BB5D4 - #42A1D4 - - - #7BB5D4 - #42A1D4 - - - #00000000 - #00000000 - - - #7BB5D4 - #42A1D4 - - - #F4D07D - #F4BC3D - - - #ededed - #ededed - - - #00000000 - #00000000 - - - #ededed - #ededed - - - #7BB5D4 - #42A1D4 - - - #ededed - #ededed - - - #88BAB3 - #6AA39B - - diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml new file mode 100644 index 00000000..914e9628 --- /dev/null +++ b/bin/app/data/color_schemes/bright.xml @@ -0,0 +1,248 @@ + + + + + white + + + + + black + #E0E0E0 + #B2B2B2 + + + + black + #A0A0A0 + white + #B2B2B2 + + + + + white + #F5F5F5 + + + #8FBC92 + #5EA071 + + + #FCA47E + #F97A4E + + + + + + white + + + #E0E0E0 + + + <text>black</text> + <normal>#E0E0E0</normal> + <hover>#B2B2B2</hover> + <press>#626262</press> + + + + + transparent + + + <text>#A0A0A0</text> + <background>transparent</background> + <hover>#F5F5F5</hover> + + + + black + transparent + + + + black + #1B8856 + #1B8856 + #C1492D + #A0A0A4 + #C1315E + #865F9E + #CC9533 + + + + + #90EBEBEB + #90B6D1DD + + + #60E4EEF2 + #90E4EEF2 + + + #80FF0000 + #FFFF0000 + + + + + + + black + white + #3C3C3C + + + + #ededed + #ededed + + + #ededed + #ededed + + + #ededed + #ededed + + + #ededed + #ededed + + + #ededed + #ededed + + + #ededed + #ededed + + + + #F4D07D + #F4BC3D + + + #F4D07D + #F4BC3D + + + #F4D07D + #F4BC3D + + + + #7BB5D4 + #42A1D4 + + + #7BB5D4 + #42A1D4 + + + #7BB5D4 + #42A1D4 + + + #7BB5D4 + #42A1D4 + + + + #CC8D91 + #CC8D91 + + + #CC8D91 + #CC8D91 + + + + #88BAB3 + #6AA39B + + + + + #878787 + #878787 + + + #878787 + #878787 + + + #878787 + #878787 + + + #878787 + #878787 + + + #878787 + #878787 + + + #878787 + #878787 + + + + #CC5E89 + #CC5E89 + + + + #F4BC3D + #F4BC3D + + + + #3190BA + #3190BA + + + + #C1305D + #C1305D + + + #C1305D + #C1305D + + + #C1305D + #C1305D + + + #C1305D + #C1305D + + + + #5DA399 + #5DA399 + + + + #EEE + #DDD + + + + + + black + #E0E0E0 + + diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml new file mode 100644 index 00000000..79ac5a37 --- /dev/null +++ b/bin/app/data/color_schemes/dark.xml @@ -0,0 +1,248 @@ + + + + + #272728 + + + + + #F7F7F7 + #777777 + #555555 + + + + #F7F7F7 + #A0A0A0 + #272728 + #555555 + + + + + #2F2F2F + black + + + #406D4D + #4E855E + + + #7D2724 + #8C2B29 + + + + + + #272728 + + + #777777 + + + <text>#F7F7F7</text> + <normal>#777777</normal> + <hover>#555555</hover> + <press>#444444</press> + + + + + transparent + + + <text>#A0A0A0</text> + <background>transparent</background> + <hover>#2F2F2F</hover> + + + + #F7F7F7 + transparent + + + + #F7F7F7 + #1F9C62 + #1F9C62 + #D95233 + #A0A0A4 + #CC3463 + #9368AD + #D69C36 + + + + + #20EBEBEB + #40B6D1DD + + + #10E4EEF2 + #18E4EEF2 + + + #A0FF0000 + #FFFF0000 + + + + + + + #F7F7F7 + #C3C3C3 + #272728 + + + + #4D4D4D + #4D4D4D + + + #4D4D4D + #4D4D4D + + + #4D4D4D + #4D4D4D + + + #4D4D4D + #4D4D4D + + + #4D4D4D + #4D4D4D + + + #4D4D4D + #4D4D4D + + + + #7A681F + #9C8528 + + + #7A681F + #9C8528 + + + #7A681F + #9C8528 + + + + #21516B + #2A6484 + + + #21516B + #2A6484 + + + #21516B + #2A6484 + + + #21516B + #2A6484 + + + + #78282D + #78282D + + + #78282D + #78282D + + + + #1B564E + #247368 + + + + + #797979 + #797979 + + + #797979 + #797979 + + + #797979 + #797979 + + + #797979 + #797979 + + + #797979 + #797979 + + + #797979 + #797979 + + + + #CC5E89 + #CC5E89 + + + + #9C8528 + #9C8528 + + + + #2A6484 + #2A6484 + + + + #C1305D + #C1305D + + + #C1305D + #C1305D + + + #C1305D + #C1305D + + + #C1305D + #C1305D + + + + #247368 + #247368 + + + + #5D5D5D + #6D6D6D + + + + + + #F7F7F7 + #777777 + + diff --git a/bin/app/data/gui/code_view/code_view.css b/bin/app/data/gui/code_view/code_view.css index 31ca6d17..5240c1c0 100644 --- a/bin/app/data/gui/code_view/code_view.css +++ b/bin/app/data/gui/code_view/code_view.css @@ -1,40 +1,48 @@ -#code_file_list { - background-color: white; +#code_file_list_base, #code_file_list { + background-color: ; +} + +* { + font-size: pt; } #code_file { - background-color: white; - border: 2px solid #E0E0E0; + background-color: ; + border: 2px solid ; border-radius: 14px; } #code_file #title_widget { - background-color: #E0E0E0; + background-color: ; border-top-left-radius: 10px; border-top-right-radius: 10px; - margin-bottom: 5px; padding-right: 5px; } #code_file #title_label { - background: none; + background-color: ; border: none; border-radius: 3px; + color: ; padding: 2px 4px; margin: 1px 8px 3px; } #code_file #title_label:hover { - background-color: #D0D0D0; + background-color: ; } -#code_file #title_label:disabled { - color: black; +#code_file #title_label:pressed { + background-color: ; } -#code_file #code_snippet{ - border-top: 2px solid #E0E0E0; - padding-top: 2px; +#code_file #code_snippet { + background-color: ; + border-top: 2px solid ; +} + +#code_file #code_snippet * { + font-family: ""; } #code_file #code_snippet[isFirst=true] { @@ -42,23 +50,45 @@ padding-top: 0px; } +#code_file #code_snippet[isLast=true] { + border-bottom-left-radius: 12px; + border-bottom-right-radius: 12px; +} + #code_file #code_snippet #scope_name, #code_file #code_snippet #dots { - background: none; - color: gray; + background-color: ; + color: ; border: none; } +#code_file #code_snippet #scope_name:hover { + background-color: ; +} + #code_file #code_snippet #dots { + background-color: ; padding-right: 13px; text-align: right; } #code_file #code_snippet #scope_name { padding-left: 4px; + text-align: left; +} + +#code_file #code_snippet #line_number_area { + background-color: ; + border: none; + color: ; +} + +#code_file #code_snippet[isLast=true] #line_number_area { + border-bottom-left-radius: 12px; } #code_area { background-color: transparent; + color: ; } #code_file #maximize_button, #code_file #snippet_button, #code_file #minimize_button { @@ -92,7 +122,7 @@ } QToolTip { - background-color: rgb(204, 204, 204); - border: 1px solid rgb(0, 0, 0); - color: rgb(0, 0, 0); + background-color: ; + color: ; + font-size: pt; } diff --git a/bin/app/data/gui/refresh_view/refresh_view.css b/bin/app/data/gui/refresh_view/refresh_view.css index 9210003c..e2fc78d7 100644 --- a/bin/app/data/gui/refresh_view/refresh_view.css +++ b/bin/app/data/gui/refresh_view/refresh_view.css @@ -1,20 +1,20 @@ #refresh_bar { - background: white; + background: transparent; } QPushButton { - background: #E0E0E0; + background: ; border: none; height: 30px; width: 30px; } QPushButton:hover, QPushButton:checked { - background: #B2B2B2; + background: ; } QPushButton:pressed { - background: #626262; + background: ; } #refresh_button { @@ -29,7 +29,7 @@ QPushButton:pressed { } QToolTip { - background-color: rgb(204, 204, 204); - border: 1px solid rgb(0, 0, 0); - color: rgb(0, 0, 0); + background-color: ; + color: ; + font-size: pt; } diff --git a/bin/app/data/gui/search_view/search_view.css b/bin/app/data/gui/search_view/search_view.css index a864f6c3..36f01e0d 100644 --- a/bin/app/data/gui/search_view/search_view.css +++ b/bin/app/data/gui/search_view/search_view.css @@ -1,9 +1,18 @@ +* { + font-size: pt; +} + +#search_box, #search_box * { + font-family: ""; + font-size: pt; +} + #search_bar { - background: white; + background-color: transparent; } QWidget#search_box_container { - background: #E0E0E0; + background: ; border: none; border-bottom-left-radius: 12px; border-top-left-radius: 12px; @@ -11,26 +20,29 @@ QWidget#search_box_container { } QLineEdit#search_box { - background: #E0E0E0; + background-color: transparent; border: none; - selection-background-color: #B2B2B2; + color: ; + selection-background-color: ; } QWidget#search_box_highlight { - background: #B2B2B2; + background-color: ; border: none; } QAbstractItemView#search_box_popup { - background-color: white; + background-color: ; border: none; + color: ; + font-family: ""; margin: 8px 0 0; min-height: 26px; - selection-background-color: #B2B2B2; + selection-background-color: ; } QPushButton#search_button { - background: #E0E0E0; + background: ; border: none; border-bottom-right-radius: 12px; border-top-right-radius: 12px; @@ -39,15 +51,15 @@ QPushButton#search_button { } #search_button:hover { - background: #B2B2B2; + background: ; } #search_button:pressed { - background: #626262; + background: ; } QToolTip { - background-color: rgb(204, 204, 204); - border: 1px solid rgb(0, 0, 0); - color: rgb(0, 0, 0); + background-color: ; + color: ; + font-size: pt; } diff --git a/bin/app/data/gui/undoredo_view/undoredo_view.css b/bin/app/data/gui/undoredo_view/undoredo_view.css index 6d853e58..4aa0d7c2 100644 --- a/bin/app/data/gui/undoredo_view/undoredo_view.css +++ b/bin/app/data/gui/undoredo_view/undoredo_view.css @@ -1,9 +1,9 @@ #undo_redo_bar { - background: white; + background: transparent; } QPushButton { - background: #E0E0E0; + background: ; border: none; background-position: 15px 5px; height: 30px; @@ -22,19 +22,19 @@ QPushButton { } QPushButton:disabled { - background: #F4F4F4; + background: ; } QPushButton:hover { - background: #B2B2B2; + background: ; } QPushButton:pressed { - background: #626262; + background: ; } QToolTip { - background-color: rgb(204, 204, 204); - border: 1px solid rgb(0, 0, 0); - color: rgb(0, 0, 0); + background-color: ; + color: ; + font-size: pt; } diff --git a/src/app/qt/element/QtAutocompletionList.cpp b/src/app/qt/element/QtAutocompletionList.cpp index 6421c070..51e244f9 100644 --- a/src/app/qt/element/QtAutocompletionList.cpp +++ b/src/app/qt/element/QtAutocompletionList.cpp @@ -4,6 +4,7 @@ #include #include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" QtAutocompletionModel::QtAutocompletionModel(QObject* parent) : QAbstractTableModel(parent) @@ -85,6 +86,8 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt { painter->save(); + ColorScheme* scheme = ColorScheme::getInstance().get(); + if (option.state & QStyle::State_Selected) { painter->fillRect(option.rect, option.palette.color(QPalette::Highlight)); @@ -101,17 +104,16 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt QColor color("#FFFFFF"); Node::NodeType nodeType = static_cast(index.sibling(index.row(), index.column() + 3).data().toInt()); - if(type.size() && nodeType) + if (type.size() && nodeType) { - color = QColor(ApplicationSettings::getInstance()->getNodeTypeColor(nodeType).c_str()); + color = QColor(scheme->getNodeTypeColor(nodeType).c_str()); } else { - color = QColor(ApplicationSettings::getInstance()->getQueryNodeTypeColor(QueryNode::QUERYNODETYPE_COMMAND).c_str()); + color = QColor(scheme->getQueryNodeTypeColor(QueryNode::QUERYNODETYPE_COMMAND).c_str()); } - QList indices = index.sibling(index.row(), index.column() + 2).data().toList(); if (indices.size()) { @@ -149,15 +151,11 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt painter->setFont(typeFont); } - QPen pen = painter->pen(); - QPen typePen = pen; - typePen.setColor(QColor("#878787")); + QPen typePen = painter->pen(); + typePen.setColor(scheme->getColor("search/popup/by_text").c_str()); painter->setPen(typePen); painter->drawText(option.rect.adjusted(0, 3, -charWidth, 0), Qt::AlignRight, type); - - painter->setFont(font); - painter->setPen(pen); } painter->restore(); diff --git a/src/app/qt/element/QtCodeArea.cpp b/src/app/qt/element/QtCodeArea.cpp index 6c2cd658..11eededf 100644 --- a/src/app/qt/element/QtCodeArea.cpp +++ b/src/app/qt/element/QtCodeArea.cpp @@ -18,6 +18,7 @@ #include "qt/element/QtCodeSnippet.h" #include "qt/utility/QtHighlighter.h" #include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" QtCodeArea::LineNumberArea::LineNumberArea(QtCodeArea *codeArea) : QWidget(codeArea) @@ -115,7 +116,6 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event) if (block.isVisible() && bottom >= event->rect().top()) { QString number = QString::number(blockNumber + m_startLineNumber); - painter.setPen(Qt::black); painter.drawText(0, top, m_lineNumberArea->width() - 13, fontMetrics().height(), Qt::AlignRight, number); } @@ -187,23 +187,17 @@ void QtCodeArea::paintEvent(QPaintEvent* event) int top = blockBoundingGeometry(block).translated(contentOffset()).top(); int blockHeight = blockBoundingRect(block).height(); - QColor qColor; + ColorScheme* scheme = ColorScheme::getInstance().get(); + + QColor scopeColor(scheme->getColor("code/snippet/highlight/scope/normal").c_str()); + QColor activeScopeColor(scheme->getColor("code/snippet/highlight/scope/hover").c_str()); for (const ScopeAnnotation& scope : m_scopeAnnotations) { - if (scope.isFocused || scope.startLine == scope.endLine) - { - qColor = QColor("#90E4EEF2"); - } - else - { - qColor = QColor("#60E4EEF2"); - } - painter.fillRect( 0, top + scope.startLine * blockHeight, width(), (scope.endLine - scope.startLine + 1) * blockHeight, - qColor + (scope.isFocused || scope.startLine == scope.endLine) ? activeScopeColor : scopeColor ); } @@ -387,7 +381,14 @@ void QtCodeArea::annotateText() std::vector scopeAnnotations; - QColor color; + ColorScheme* scheme = ColorScheme::getInstance().get(); + + QColor locationColor(scheme->getColor("code/snippet/highlight/location/normal").c_str()); + QColor activeLocationColor(scheme->getColor("code/snippet/highlight/location/hover").c_str()); + + QColor errorColor(scheme->getColor("code/snippet/highlight/error/normal").c_str()); + QColor activeErrorColor(scheme->getColor("code/snippet/highlight/error/hover").c_str()); + QList extraSelections; for (const Annotation& annotation: m_annotations) @@ -395,21 +396,22 @@ void QtCodeArea::annotateText() bool isActive = std::find(ids.begin(), ids.end(), annotation.tokenId) != ids.end(); bool isFocused = (annotation.tokenId == focusedTokenId); + QColor color; if (&annotation == m_hoveredAnnotation && errorMessages.size()) { - color.setNamedColor("#80FF0000"); + color = activeErrorColor; } else if (errorMessages.size()) { - color.setNamedColor("#FFFF0000"); + color = errorColor; } else if (isActive || isFocused) { - color.setNamedColor("#90B6D1DD"); + color = activeLocationColor; } else { - color.setNamedColor("#90EBEBEB"); + color = locationColor; } QTextEdit::ExtraSelection selection; diff --git a/src/app/qt/element/QtCodeFile.cpp b/src/app/qt/element/QtCodeFile.cpp index 29300785..7dd99aa1 100644 --- a/src/app/qt/element/QtCodeFile.cpp +++ b/src/app/qt/element/QtCodeFile.cpp @@ -74,6 +74,10 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent) connect(m_snippetButton, SIGNAL(clicked()), this, SLOT(clickedSnippetButton())); connect(m_maximizeButton, SIGNAL(clicked()), this, SLOT(clickedMaximizeButton())); + m_minimizePlaceholder = new QWidget(this); + m_minimizePlaceholder->setMinimumHeight(5); + layout->addWidget(m_minimizePlaceholder); + update(); } @@ -120,6 +124,7 @@ void QtCodeFile::addCodeSnippet( if (locationFile->isWholeCopy) { snippet->setProperty("isFirst", true); + snippet->setProperty("isLast", true); m_fileSnippet = snippet; clickedMaximizeButton(); return; @@ -135,6 +140,7 @@ void QtCodeFile::addCodeSnippet( int maxDigits = 1; for (std::shared_ptr snippet : m_snippets) { + snippet->setProperty("isLast", false); maxDigits = qMax(maxDigits, snippet->lineNumberDigits()); } @@ -143,6 +149,8 @@ void QtCodeFile::addCodeSnippet( snippet->updateLineNumberAreaWidthForDigits(maxDigits); } + snippet->setProperty("isLast", true); + clickedSnippetButton(); } @@ -195,6 +203,8 @@ void QtCodeFile::clickedMinimizeButton() m_snippetButton->setEnabled(true); } m_maximizeButton->setEnabled(true); + + m_minimizePlaceholder->show(); } void QtCodeFile::clickedSnippetButton() @@ -212,6 +222,8 @@ void QtCodeFile::clickedSnippetButton() m_minimizeButton->setEnabled(true); m_snippetButton->setEnabled(false); m_maximizeButton->setEnabled(true); + + m_minimizePlaceholder->hide(); } void QtCodeFile::clickedMaximizeButton() @@ -236,4 +248,6 @@ void QtCodeFile::clickedMaximizeButton() m_snippetButton->setEnabled(true); } m_maximizeButton->setEnabled(false); + + m_minimizePlaceholder->hide(); } diff --git a/src/app/qt/element/QtCodeFile.h b/src/app/qt/element/QtCodeFile.h index d0fe6e27..fb18d663 100644 --- a/src/app/qt/element/QtCodeFile.h +++ b/src/app/qt/element/QtCodeFile.h @@ -59,6 +59,7 @@ private: std::vector> m_snippets; std::shared_ptr m_fileSnippet; + QWidget* m_minimizePlaceholder; const FilePath m_filePath; }; diff --git a/src/app/qt/element/QtCodeFileList.cpp b/src/app/qt/element/QtCodeFileList.cpp index 7ae22c4b..0f23bae0 100644 --- a/src/app/qt/element/QtCodeFileList.cpp +++ b/src/app/qt/element/QtCodeFileList.cpp @@ -14,6 +14,8 @@ QtCodeFileList::QtCodeFileList(QWidget* parent) : QScrollArea(parent) , m_focusedTokenId(0) { + setObjectName("code_file_list_base"); + m_frame = std::make_shared(this); m_frame->setObjectName("code_file_list"); diff --git a/src/app/qt/element/QtCodeSnippet.cpp b/src/app/qt/element/QtCodeSnippet.cpp index 55c42cf2..56219dbb 100644 --- a/src/app/qt/element/QtCodeSnippet.cpp +++ b/src/app/qt/element/QtCodeSnippet.cpp @@ -42,7 +42,7 @@ QtCodeSnippet::QtCodeSnippet( m_title->setObjectName("scope_name"); m_title->minimumSizeHint(); // force font loading m_title->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - m_title->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed); + m_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); titleLayout->addWidget(m_title); } diff --git a/src/app/qt/element/QtMainWindow.cpp b/src/app/qt/element/QtMainWindow.cpp index 821a6712..f16776ba 100644 --- a/src/app/qt/element/QtMainWindow.cpp +++ b/src/app/qt/element/QtMainWindow.cpp @@ -19,6 +19,7 @@ #include "utility/messaging/type/MessageRedo.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageSaveProject.h" +#include "utility/messaging/type/MessageSwitchColorScheme.h" #include "utility/messaging/type/MessageUndo.h" #include "utility/messaging/type/MessageWindowFocus.h" #include "utility/messaging/type/MessageZoom.h" @@ -228,6 +229,16 @@ void QtMainWindow::zoomOut() MessageZoom(false).dispatch(); } +void QtMainWindow::switchColorScheme() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "./data/color_schemes", "XML Files (*.xml)"); + + if (!fileName.isEmpty()) + { + MessageSwitchColorScheme(fileName.toStdString()).dispatch(); + } +} + void QtMainWindow::handleEscapeShortcut() { m_startScreen->hide(); @@ -271,6 +282,8 @@ void QtMainWindow::setupViewMenu() menu->addAction(tr("Larger font"), this, SLOT(zoomIn()), QKeySequence::ZoomIn); menu->addAction(tr("Smaller font"), this, SLOT(zoomOut()), QKeySequence::ZoomOut); + + menu->addAction(tr("Switch Color Scheme..."), this, SLOT(switchColorScheme())); } void QtMainWindow::setupHelpMenu() diff --git a/src/app/qt/element/QtMainWindow.h b/src/app/qt/element/QtMainWindow.h index 23d71d36..ccf01a14 100644 --- a/src/app/qt/element/QtMainWindow.h +++ b/src/app/qt/element/QtMainWindow.h @@ -47,6 +47,7 @@ public slots: void redo(); void zoomIn(); void zoomOut(); + void switchColorScheme(); void handleEscapeShortcut(); diff --git a/src/app/qt/element/QtSmartSearchBox.cpp b/src/app/qt/element/QtSmartSearchBox.cpp index 90122a51..c7845d54 100644 --- a/src/app/qt/element/QtSmartSearchBox.cpp +++ b/src/app/qt/element/QtSmartSearchBox.cpp @@ -14,7 +14,7 @@ #include "data/query/QueryTree.h" #include "qt/element/QtAutocompletionList.h" -#include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" QtQueryElement::QtQueryElement(const QString& text, QWidget* parent) : QPushButton(text, parent) @@ -573,6 +573,10 @@ void QtSmartSearchBox::updateElements() { m_elements.clear(); + ColorScheme* scheme = ColorScheme::getInstance().get(); + + std::string textColor = scheme->getColor("search/field/text"); + for (const SearchMatch& token : m_tokens) { std::string name = token.fullName; @@ -582,28 +586,25 @@ void QtSmartSearchBox::updateElements() std::shared_ptr element = std::make_shared(QString::fromStdString(name), this); m_elements.push_back(element); - std::string color = "#000000"; - std::string hoverColor = "#000000"; + std::string color; + std::string hoverColor; if (token.queryNodeType == QueryNode::QUERYNODETYPE_TOKEN) { element->setObjectName(QString::fromStdString("search_element_" + token.getNodeTypeAsString())); - color = ApplicationSettings::getInstance()->getNodeTypeColor(token.nodeType); - hoverColor = ApplicationSettings::getInstance()->getNodeTypeColor(token.nodeType, "hover"); + color = scheme->getNodeTypeColor(token.nodeType); + hoverColor = scheme->getNodeTypeColor(token.nodeType, "hover"); } else { element->setObjectName(QString::fromStdString("search_element_" + QueryTree::getTokenTypeName(token.queryNodeType))); - color = ApplicationSettings::getInstance()->getQueryNodeTypeColor(token.queryNodeType); - hoverColor = ApplicationSettings::getInstance()->getQueryNodeTypeColor(token.queryNodeType, "hover"); + color = scheme->getQueryNodeTypeColor(token.queryNodeType); + hoverColor = scheme->getQueryNodeTypeColor(token.queryNodeType, "hover"); } std::stringstream css; - css << "QPushButton { border: none; padding: 0px 4px; background-color:"; - css << color; - css << ";} QPushButton:hover { background-color:"; - css << hoverColor; - css << ";}"; + css << "QPushButton {border: none; padding: 0px 4px; background-color:" << color << "; color:" << textColor << ";} "; + css << "QPushButton:hover { background-color:" << hoverColor << ";} "; element->setStyleSheet(css.str().c_str()); diff --git a/src/app/qt/graphics/QtStraightLineItem.cpp b/src/app/qt/graphics/QtStraightLineItem.cpp index 09d33453..edb6ef4f 100644 --- a/src/app/qt/graphics/QtStraightLineItem.cpp +++ b/src/app/qt/graphics/QtStraightLineItem.cpp @@ -8,15 +8,18 @@ #include "utility/utility.h" #include "qt/graphics/QtRoundedRectItem.h" +#include "settings/ColorScheme.h" QtStraightLineItem::QtStraightLineItem(QGraphicsItem* parent) : QGraphicsLineItem(parent) { this->setAcceptHoverEvents(true); + ColorScheme* scheme = ColorScheme::getInstance().get(); + m_circle = new QtRoundedRectItem(this); m_circle->setRadius(100); - m_circle->setBrush(QBrush(QColor("#FFF"))); + m_circle->setBrush(QBrush(scheme->getColor("graph/background").c_str())); m_circle->setAcceptHoverEvents(true); QFont font; @@ -26,6 +29,7 @@ QtStraightLineItem::QtStraightLineItem(QGraphicsItem* parent) m_number = new QGraphicsSimpleTextItem(this); m_number->setFont(font); + m_number->setBrush(QBrush(scheme->getColor("graph/text").c_str())); m_arrowLeft = new QGraphicsLineItem(this); m_arrowRight = new QGraphicsLineItem(this); @@ -101,9 +105,6 @@ void QtStraightLineItem::updateLine( arrowSide -= nUnit * 14; m_arrowLeft->setLine(arrow.x, arrow.y, arrowSide.x, arrowSide.y); - m_arrowLeft->setPen(QPen(QBrush(QColor("#E0E0E0")), 2, Qt::SolidLine, Qt::RoundCap)); - m_arrowRight->setPen(QPen(QBrush(QColor("#E0E0E0")), 2, Qt::SolidLine, Qt::RoundCap)); - m_arrowLeft->show(); m_arrowRight->show(); } @@ -114,15 +115,23 @@ void QtStraightLineItem::updateLine( } m_circle->setRect(mid.x - radius, mid.y - radius, 2 * radius, 2 * radius); - m_circle->setPen(QPen(QColor("#E0E0E0"), 2)); QString numberStr = QString::number(number); m_number->setText(numberStr); - m_number->setBrush(QBrush(QColor("#666"))); m_number->setPos( mid.x - QFontMetrics(m_number->font()).width(numberStr) / 2, mid.y - QFontMetrics(m_number->font()).height() / 2 ); - this->setPen(QPen(QBrush(style.color.c_str()), number + style.width, Qt::SolidLine, Qt::RoundCap)); + + QColor color(style.color.c_str()); + + this->setPen(QPen(QBrush(color), number + style.width, Qt::SolidLine, Qt::RoundCap)); + + color = color.darker(110); + + m_circle->setPen(QPen(color, 2)); + + m_arrowLeft->setPen(QPen(QBrush(color), 2, Qt::SolidLine, Qt::RoundCap)); + m_arrowRight->setPen(QPen(QBrush(color), 2, Qt::SolidLine, Qt::RoundCap)); } diff --git a/src/app/qt/utility/QtHighlighter.cpp b/src/app/qt/utility/QtHighlighter.cpp index 05ab7802..626e4fde 100644 --- a/src/app/qt/utility/QtHighlighter.cpp +++ b/src/app/qt/utility/QtHighlighter.cpp @@ -3,6 +3,8 @@ #include #include +#include "settings/ColorScheme.h" + QtHighlighter::QtHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { @@ -29,13 +31,15 @@ QtHighlighter::QtHighlighter(QTextDocument *parent) QRegExp numberRegExp = QRegExp("\\b[0-9]+\\b"); QRegExp functionRegExp = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); - QColor directiveColor = QColor(27,136,86); - QColor keywordColor = QColor(27,136,86); - QColor typeColor = QColor("#C1492D"); - QColor commentColor = Qt::gray; - QColor numberColor = QColor("#C1315E"); - QColor quotationColor = QColor("#865F9E"); - QColor functionColor = QColor("#CC9533"); + ColorScheme* scheme = ColorScheme::getInstance().get(); + + QColor directiveColor(scheme->getSyntaxColor("directive").c_str()); + QColor keywordColor(scheme->getSyntaxColor("keyword").c_str()); + QColor typeColor(scheme->getSyntaxColor("type").c_str()); + QColor commentColor(scheme->getSyntaxColor("comment").c_str()); + QColor numberColor(scheme->getSyntaxColor("number").c_str()); + QColor quotationColor(scheme->getSyntaxColor("quotation").c_str()); + QColor functionColor(scheme->getSyntaxColor("function").c_str()); foreach (const QString &pattern, keywordPatterns) { diff --git a/src/app/qt/utility/utilityQt.cpp b/src/app/qt/utility/utilityQt.cpp index 23811d5b..548186ec 100644 --- a/src/app/qt/utility/utilityQt.cpp +++ b/src/app/qt/utility/utilityQt.cpp @@ -7,13 +7,18 @@ #include "utility/file/FileSystem.h" #include "utility/logging/logging.h" +#include "utility/utilityString.h" +#include "utility/text/TextAccess.h" + +#include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" namespace utility { - void setWidgetBackgroundColor(QWidget* widget, const Colori& color) + void setWidgetBackgroundColor(QWidget* widget, const std::string& color) { QPalette palette = widget->palette(); - palette.setColor(widget->backgroundRole(), QColor(color.r, color.g, color.b, color.a)); + palette.setColor(widget->backgroundRole(), QColor(color.c_str())); widget->setPalette(palette); widget->setAutoFillBackground(true); } @@ -47,4 +52,67 @@ namespace utility } } } + + std::string getStyleSheet(const std::string& path) + { + std::string css = TextAccess::createFromFile(path)->getText(); + + size_t pos = 0; + + while (pos != std::string::npos) + { + size_t posA = css.find('<', pos); + size_t posB = css.find('>', pos); + + if (posA == std::string::npos || posB == std::string::npos) + { + break; + } + + std::deque seq = utility::split(css.substr(posA + 1, posB - posA - 1), ':'); + if (seq.size() != 2) + { + LOG_ERROR("Syntax error in file: " + path); + return ""; + } + + std::string key = seq.front(); + std::string val = seq.back(); + + if (key == "setting") + { + if (val == "font_size") + { + val = std::to_string(ApplicationSettings::getInstance()->getFontSize()); + } + else if (val == "font_size+2") + { + val = std::to_string(ApplicationSettings::getInstance()->getFontSize() + 2); + } + else if (val == "font_name") + { + val = ApplicationSettings::getInstance()->getFontName(); + } + else + { + LOG_ERROR("Syntax error in file: " + path); + return ""; + } + } + else if (key == "color") + { + val = ColorScheme::getInstance()->getColor(val); + } + else + { + LOG_ERROR("Syntax error in file: " + path); + return ""; + } + + css.replace(posA, posB - posA + 1, val); + pos = posA + val.size(); + } + + return css; + } } diff --git a/src/app/qt/utility/utilityQt.h b/src/app/qt/utility/utilityQt.h index bb2f93e4..61833191 100644 --- a/src/app/qt/utility/utilityQt.h +++ b/src/app/qt/utility/utilityQt.h @@ -4,12 +4,12 @@ #include #include -#include "utility/math/Color.h" - namespace utility { - void setWidgetBackgroundColor(QWidget* widget, const Colori& color); + void setWidgetBackgroundColor(QWidget* widget, const std::string& color); void loadFontsFromDirectory(const std::string& path, const std::string& extension = ".otf"); + + std::string getStyleSheet(const std::string& path); } # endif // UTILITY_QT_H diff --git a/src/app/qt/view/QtCodeView.cpp b/src/app/qt/view/QtCodeView.cpp index 75febb93..3da3ed1e 100644 --- a/src/app/qt/view/QtCodeView.cpp +++ b/src/app/qt/view/QtCodeView.cpp @@ -1,13 +1,11 @@ #include "qt/view/QtCodeView.h" -#include - #include "utility/file/FileSystem.h" -#include "utility/text/TextAccess.h" +#include "qt/utility/utilityQt.h" #include "qt/element/QtCodeFileList.h" #include "qt/view/QtViewWidgetWrapper.h" -#include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" QtCodeView::QtCodeView(ViewLayout* viewLayout) : CodeView(viewLayout) @@ -19,7 +17,7 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout) , m_defocusTokenFunctor(std::bind(&QtCodeView::doDefocusToken, this)) { m_widget = new QtCodeFileList(); - setStyleSheet(m_widget); + setStyleSheet(); } QtCodeView::~QtCodeView() @@ -77,7 +75,7 @@ void QtCodeView::defocusToken() void QtCodeView::doRefreshView() { - setStyleSheet(m_widget); + setStyleSheet(); m_widget->clearCodeSnippets(); } @@ -92,6 +90,8 @@ void QtCodeView::doShowCodeSnippets(const std::vector& snippe { m_widget->addCodeSnippet(params.startLineNumber, params.title, params.code, params.locationFile); } + + setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly } void QtCodeView::doShowCodeFile(const CodeSnippetParams& params) @@ -115,12 +115,9 @@ void QtCodeView::doDefocusToken() m_widget->defocusToken(); } -void QtCodeView::setStyleSheet(QWidget* widget) const +void QtCodeView::setStyleSheet() const { - std::stringstream css; - css << TextAccess::createFromFile("data/gui/code_view/code_view.css")->getText(); - css << "* { font-size: " << ApplicationSettings::getInstance()->getFontSize() << "pt; }"; - css << "#code_file #code_snippet * { font-family: " << ApplicationSettings::getInstance()->getFontName() << "; }"; + utility::setWidgetBackgroundColor(m_widget, ColorScheme::getInstance()->getColor("code/background")); - widget->setStyleSheet(css.str().c_str()); + m_widget->setStyleSheet(utility::getStyleSheet("data/gui/code_view/code_view.css").c_str()); } diff --git a/src/app/qt/view/QtCodeView.h b/src/app/qt/view/QtCodeView.h index 4c25d50c..75284066 100644 --- a/src/app/qt/view/QtCodeView.h +++ b/src/app/qt/view/QtCodeView.h @@ -48,7 +48,7 @@ private: void doFocusToken(const Id tokenId); void doDefocusToken(); - void setStyleSheet(QWidget* widget) const; + void setStyleSheet() const; QtThreadedFunctor<> m_refreshViewFunctor; QtThreadedFunctor&> m_showCodeSnippetsFunctor; diff --git a/src/app/qt/view/QtCompositeView.cpp b/src/app/qt/view/QtCompositeView.cpp index 239a821b..f6afb06a 100644 --- a/src/app/qt/view/QtCompositeView.cpp +++ b/src/app/qt/view/QtCompositeView.cpp @@ -4,6 +4,7 @@ #include "qt/utility/utilityQt.h" #include "qt/view/QtViewWidgetWrapper.h" +#include "settings/ColorScheme.h" QtCompositeView::QtCompositeView(ViewLayout* viewLayout, CompositeDirection direction) : CompositeView(viewLayout, direction) @@ -24,7 +25,8 @@ QtCompositeView::QtCompositeView(ViewLayout* viewLayout, CompositeDirection dire m_widget = new QWidget(); m_widget->setLayout(layout); - utility::setWidgetBackgroundColor(m_widget, Colori(255, 255, 255, 255)); + + refreshView(); } QtCompositeView::~QtCompositeView() @@ -43,7 +45,7 @@ void QtCompositeView::initView() void QtCompositeView::refreshView() { - + utility::setWidgetBackgroundColor(m_widget, ColorScheme::getInstance()->getColor("search/background")); } void QtCompositeView::addViewWidget(View* view) diff --git a/src/app/qt/view/QtGraphView.cpp b/src/app/qt/view/QtGraphView.cpp index fd469bc5..56fb6604 100644 --- a/src/app/qt/view/QtGraphView.cpp +++ b/src/app/qt/view/QtGraphView.cpp @@ -23,6 +23,7 @@ #include "qt/view/graphElements/QtGraphNodeBundle.h" #include "qt/view/graphElements/QtGraphNodeData.h" #include "qt/view/graphElements/QtGraphNodeExpandToggle.h" +#include "settings/ColorScheme.h" QtGraphView::QtGraphView(ViewLayout* viewLayout) : GraphView(viewLayout) @@ -47,7 +48,6 @@ void QtGraphView::createWidgetWrapper() void QtGraphView::initView() { QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this); - utility::setWidgetBackgroundColor(widget, Colori(255, 255, 255, 255)); QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom); layout->setContentsMargins(0, 0, 0, 0); @@ -61,12 +61,19 @@ void QtGraphView::initView() view->setRenderHints(QPainter::Antialiasing); widget->layout()->addWidget(view); + + refreshView(); } void QtGraphView::refreshView() { clear(); resizeView(); + + std::string backgroundColor = ColorScheme::getInstance()->getColor("graph/background"); + + utility::setWidgetBackgroundColor(QtViewWidgetWrapper::getWidgetOfView(this), backgroundColor); + utility::setWidgetBackgroundColor(getView(), backgroundColor); } void QtGraphView::rebuildGraph( diff --git a/src/app/qt/view/QtRefreshView.cpp b/src/app/qt/view/QtRefreshView.cpp index b0bc960b..aab3999c 100644 --- a/src/app/qt/view/QtRefreshView.cpp +++ b/src/app/qt/view/QtRefreshView.cpp @@ -1,12 +1,9 @@ #include "qt/view/QtRefreshView.h" -#include - -#include "utility/text/TextAccess.h" +#include "qt/utility/utilityQt.h" #include "component/controller/RefreshController.h" #include "qt/view/QtViewWidgetWrapper.h" -#include "settings/ApplicationSettings.h" QtRefreshView::QtRefreshView(ViewLayout* viewLayout) : RefreshView(viewLayout) @@ -42,9 +39,5 @@ void QtRefreshView::doRefreshView() void QtRefreshView::setStyleSheet() { - std::stringstream css; - css << TextAccess::createFromFile("data/gui/refresh_view/refresh_view.css")->getText(); - css << "* { font-size: " << ApplicationSettings::getInstance()->getFontSize() << "pt; }"; - - m_widget->setStyleSheet(css.str().c_str()); + m_widget->setStyleSheet(utility::getStyleSheet("data/gui/refresh_view/refresh_view.css").c_str()); } diff --git a/src/app/qt/view/QtSearchView.cpp b/src/app/qt/view/QtSearchView.cpp index dae0b3ad..4fc1901f 100644 --- a/src/app/qt/view/QtSearchView.cpp +++ b/src/app/qt/view/QtSearchView.cpp @@ -1,12 +1,9 @@ #include "qt/view/QtSearchView.h" -#include - -#include "utility/text/TextAccess.h" +#include "qt/utility/utilityQt.h" #include "component/controller/SearchController.h" #include "qt/view/QtViewWidgetWrapper.h" -#include "settings/ApplicationSettings.h" QtSearchView::QtSearchView(ViewLayout* viewLayout) : SearchView(viewLayout) @@ -78,16 +75,12 @@ void QtSearchView::doSetAutocompletionList(const std::vector& autoc void QtSearchView::setStyleSheet() { - std::stringstream css; - css << TextAccess::createFromFile("data/gui/search_view/search_view.css")->getText(); - css << "* { font-size: " << ApplicationSettings::getInstance()->getFontSize() << "pt; }"; - css << "#search_box, #search_box *, #search_box_popup { font-family: " << ApplicationSettings::getInstance()->getFontName() << "; }"; - css << "#search_box, #search_box * { font-size: " << ApplicationSettings::getInstance()->getFontSize() + 2 << "pt; }"; + std::string css = utility::getStyleSheet("data/gui/search_view/search_view.css"); - m_widget->setStyleSheet(css.str().c_str()); + m_widget->setStyleSheet(css.c_str()); if (m_widget->getCompleterPopup()) { - m_widget->getCompleterPopup()->setStyleSheet(css.str().c_str()); + m_widget->getCompleterPopup()->setStyleSheet(css.c_str()); } } diff --git a/src/app/qt/view/QtUndoRedoView.cpp b/src/app/qt/view/QtUndoRedoView.cpp index ef70e869..bad3c708 100644 --- a/src/app/qt/view/QtUndoRedoView.cpp +++ b/src/app/qt/view/QtUndoRedoView.cpp @@ -1,12 +1,9 @@ #include "qt/view/QtUndoRedoView.h" -#include - -#include "utility/text/TextAccess.h" +#include "qt/utility/utilityQt.h" #include "qt/view/QtMainView.h" #include "qt/view/QtViewWidgetWrapper.h" -#include "settings/ApplicationSettings.h" QtUndoRedoView::QtUndoRedoView(ViewLayout* viewLayout) : UndoRedoView(viewLayout) @@ -38,11 +35,7 @@ void QtUndoRedoView::refreshView() void QtUndoRedoView::setStyleSheet() { - std::stringstream css; - css << TextAccess::createFromFile("data/gui/undoredo_view/undoredo_view.css")->getText(); - css << "* { font-size: " << ApplicationSettings::getInstance()->getFontSize() << "pt; }"; - - m_widget->setStyleSheet(css.str().c_str()); + m_widget->setStyleSheet(utility::getStyleSheet("data/gui/undoredo_view/undoredo_view.css").c_str()); } void QtUndoRedoView::doSetRedoButtonEnabled(bool enabled) diff --git a/src/app/qt/view/graphElements/QtGraphNode.cpp b/src/app/qt/view/graphElements/QtGraphNode.cpp index e98aa209..5f85bd42 100644 --- a/src/app/qt/view/graphElements/QtGraphNode.cpp +++ b/src/app/qt/view/graphElements/QtGraphNode.cpp @@ -392,5 +392,6 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) } m_text->setFont(font); + m_text->setBrush(QBrush(style.textColor.c_str())); m_text->setPos(style.textOffset.x, style.textOffset.y); } diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index c175ab5d..2548da72 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -11,6 +11,7 @@ #include "component/view/ViewFactory.h" #include "data/StorageCache.h" #include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" std::shared_ptr Application::create(ViewFactory* viewFactory) { @@ -32,6 +33,8 @@ std::shared_ptr Application::create(ViewFactory* viewFactory) void Application::loadSettings() { ApplicationSettings::getInstance()->load("data/ApplicationSettings.xml"); + ColorScheme::getInstance()->load(ApplicationSettings::getInstance()->getColorSchemePath()); + GraphViewStyle::loadStyleSettings(); } diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 3813b9e1..ee7ef9fe 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -211,6 +211,8 @@ add_files( settings/ApplicationSettings.cpp settings/ApplicationSettings.h + settings/ColorScheme.cpp + settings/ColorScheme.h settings/CommonSettings.cpp settings/CommonSettings.h settings/ProjectSettings.cpp @@ -274,6 +276,7 @@ add_files( utility/messaging/type/MessageSearchAutocomplete.h utility/messaging/type/MessageShowFile.h utility/messaging/type/MessageStatus.h + utility/messaging/type/MessageSwitchColorScheme.h utility/messaging/type/MessageUndo.h utility/messaging/type/MessageWindowFocus.h utility/messaging/type/MessageZoom.h diff --git a/src/lib/component/ComponentManager.cpp b/src/lib/component/ComponentManager.cpp index 29a5d84e..cf89ae83 100644 --- a/src/lib/component/ComponentManager.cpp +++ b/src/lib/component/ComponentManager.cpp @@ -60,6 +60,11 @@ void ComponentManager::refreshViews() view->refreshView(); } } + + for (std::shared_ptr view : m_compositeViews) + { + view->refreshView(); + } } ComponentManager::ComponentManager() diff --git a/src/lib/component/controller/FeatureController.cpp b/src/lib/component/controller/FeatureController.cpp index e137e25e..03c40ec8 100644 --- a/src/lib/component/controller/FeatureController.cpp +++ b/src/lib/component/controller/FeatureController.cpp @@ -88,6 +88,15 @@ void FeatureController::handleMessage(MessageSearch* message) m.dispatchImmediately(); } +void FeatureController::handleMessage(MessageSwitchColorScheme* message) +{ + ApplicationSettings* settings = ApplicationSettings::getInstance().get(); + settings->setColorSchemePath(message->colorSchemeFilePath); + settings->save(); + + MessageRefresh(true).dispatch(); +} + void FeatureController::handleMessage(MessageZoom* message) { ApplicationSettings* settings = ApplicationSettings::getInstance().get(); diff --git a/src/lib/component/controller/FeatureController.h b/src/lib/component/controller/FeatureController.h index 2d6bc2b5..a7d782ba 100644 --- a/src/lib/component/controller/FeatureController.h +++ b/src/lib/component/controller/FeatureController.h @@ -7,6 +7,7 @@ #include "utility/messaging/type/MessageActivateNode.h" #include "utility/messaging/type/MessageActivateTokenLocation.h" #include "utility/messaging/type/MessageSearch.h" +#include "utility/messaging/type/MessageSwitchColorScheme.h" #include "utility/messaging/type/MessageZoom.h" #include "component/controller/Controller.h" @@ -20,6 +21,7 @@ class FeatureController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener { public: @@ -32,6 +34,7 @@ private: virtual void handleMessage(MessageActivateNode* message); virtual void handleMessage(MessageActivateTokenLocation* message); virtual void handleMessage(MessageSearch* message); + virtual void handleMessage(MessageSwitchColorScheme* message); virtual void handleMessage(MessageZoom* message); StorageAccess* m_storageAccess; diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index bd7c5cf8..3e053e0f 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -213,10 +213,13 @@ void UndoRedoController::processNormalCommand(const Command& command) void UndoRedoController::processRedoCommand(const Command& command) { - m_undo.push_back(m_lastCommand); - m_lastCommand = command; + if (m_lastCommand.message) + { + m_undo.push_back(m_lastCommand); + getView()->setUndoButtonEnabled(true); + } - getView()->setUndoButtonEnabled(true); + m_lastCommand = command; if (m_redo.empty()) { @@ -226,10 +229,13 @@ void UndoRedoController::processRedoCommand(const Command& command) void UndoRedoController::processUndoCommand(const Command& command) { - m_redo.push_back(m_lastCommand); - m_lastCommand = command; + if (m_lastCommand.message) + { + m_redo.push_back(m_lastCommand); + getView()->setRedoButtonEnabled(true); + } - getView()->setRedoButtonEnabled(true); + m_lastCommand = command; if (m_undo.empty()) { diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index 7e5c4218..cb4064d7 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -4,6 +4,7 @@ #include "component/view/GraphViewStyleImpl.h" #include "settings/ApplicationSettings.h" +#include "settings/ColorScheme.h" GraphViewStyle::NodeMargins::NodeMargins() : left(0) @@ -248,33 +249,31 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( ){ NodeStyle style; - style.color = "#D3D3D3"; - style.borderColor = "#00000000"; - - style.fontName = getFontNameForNodeType(type); - style.fontSize = getFontSizeForNodeType(type); - - if (isActive) - { - style.borderColor = "#3c3c3c"; - } + ColorScheme* scheme = ColorScheme::getInstance().get(); if (isActive || isFocused) { - style.color = ApplicationSettings::getInstance()->getNodeTypeColor(type, "hover"); + style.color = scheme->getNodeTypeColor(type, "hover"); } else { - style.color = ApplicationSettings::getInstance()->getNodeTypeColor(type); + style.color = scheme->getNodeTypeColor(type); } + style.textColor = scheme->getColor("graph/text"); + style.borderColor = isActive ? scheme->getColor("graph/border") : "#00000000"; + + style.fontName = getFontNameForNodeType(type); + style.fontSize = getFontSizeForNodeType(type); + switch (type) { case Node::NODE_UNDEFINED: style.borderDashed = true; case Node::NODE_NAMESPACE: - style.borderColor = "#cc8d91"; + style.borderColor = style.color; + style.color = "#00000000"; style.borderWidth = 1; style.cornerRadius = 20; @@ -296,13 +295,14 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( style.fontBold = true; } + style.shadowColor = scheme->getColor("graph/border"); if (isFocused) { - style.shadowColor = "#FF000000"; + style.shadowColor.insert(1, "FF"); } else { - style.shadowColor = "#80000000"; + style.shadowColor.insert(1, "80"); } style.shadowBlurRadius = 5; @@ -363,7 +363,10 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfAccessNode() { NodeStyle style; - style.color = "#FFFFFF"; + ColorScheme* scheme = ColorScheme::getInstance().get(); + + style.color = scheme->getColor("graph/background"); + style.textColor = scheme->getColor("graph/text"); style.borderColor = "#00000000"; style.cornerRadius = 12; @@ -382,7 +385,10 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode() { NodeStyle style; - style.color = "#FFFFFF"; + ColorScheme* scheme = ColorScheme::getInstance().get(); + + style.color = scheme->getColor("graph/background"); + style.textColor = scheme->getColor("graph/text"); style.borderColor = "#00000000"; style.cornerRadius = 100; @@ -397,8 +403,10 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused) { NodeStyle style = getStyleForNodeType(Node::NODE_CLASS, false, isFocused, false); + ColorScheme* scheme = ColorScheme::getInstance().get(); + style.shadowColor = ""; - style.borderColor = "#3c3c3c"; + style.borderColor = scheme->getColor("graph/border"); style.borderWidth = isFocused ? 2 : 1; return style; @@ -423,23 +431,28 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ style.originOffset.y = -1; style.targetOffset.y = 1; + if (isActive) + { + style.color = ColorScheme::getInstance()->getEdgeTypeColor(type, "hover"); + } + else + { + style.color = ColorScheme::getInstance()->getEdgeTypeColor(type); + } + switch (type) { case Edge::EDGE_AGGREGATION: style.isStraight = true; - style.color = isActive ? "#DDD" : "#EEE"; style.width = 1; style.zValue = isActive ? -2 : -5; break; - case Edge::EDGE_CALL: - style.color = "#F4BC3D"; style.originOffset.y = 1; style.targetOffset.y = -1; style.verticalOffset = 4; break; case Edge::EDGE_USAGE: - style.color = "#3190BA"; style.originOffset.y = 3; style.targetOffset.y = -3; style.verticalOffset = 6; @@ -449,22 +462,8 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ style.arrowWidth = 14; style.arrowClosed = true; style.targetOffset.x = 34; - style.color = "#878787"; - break; - case Edge::EDGE_OVERRIDE: - style.color = "#CC5E89"; - break; - case Edge::EDGE_INCLUDE: - style.color = "#5DA399"; - break; - case Edge::EDGE_TEMPLATE_PARAMETER_OF: - case Edge::EDGE_TEMPLATE_ARGUMENT_OF: - case Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF: - case Edge::EDGE_TEMPLATE_SPECIALIZATION_OF: - style.color = "#C1305D"; break; default: - style.color = "#878787"; break; } diff --git a/src/lib/component/view/GraphViewStyle.h b/src/lib/component/view/GraphViewStyle.h index 63e80417..2b62616b 100644 --- a/src/lib/component/view/GraphViewStyle.h +++ b/src/lib/component/view/GraphViewStyle.h @@ -39,6 +39,7 @@ public: NodeStyle(); std::string color; + std::string textColor; std::string shadowColor; int shadowBlurRadius; diff --git a/src/lib/data/graph/Edge.cpp b/src/lib/data/graph/Edge.cpp index 90328724..41943d4a 100644 --- a/src/lib/data/graph/Edge.cpp +++ b/src/lib/data/graph/Edge.cpp @@ -154,13 +154,13 @@ std::string Edge::getTypeString(EdgeType type) case EDGE_TYPEDEF_OF: return "typedef"; case EDGE_TEMPLATE_PARAMETER_OF: - return "template parameter"; + return "template_parameter"; case EDGE_TEMPLATE_ARGUMENT_OF: - return "template argument"; + return "template_argument"; case EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF: - return "template default argument"; + return "template_default_argument"; case EDGE_TEMPLATE_SPECIALIZATION_OF: - return "template specialization"; + return "template_specialization"; case EDGE_INCLUDE: return "include"; case EDGE_AGGREGATION: diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 952a26a5..0d60b948 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -46,6 +46,16 @@ void ApplicationSettings::setFontSize(int fontSize) setValue("application/font_size", fontSize); } +std::string ApplicationSettings::getColorSchemePath() const +{ + return getValue("application/color_scheme", "./data/color_schemes/bright.xml"); +} + +void ApplicationSettings::setColorSchemePath(const std::string& colorSchemePath) +{ + setValue("application/color_scheme", colorSchemePath); +} + int ApplicationSettings::getCodeTabWidth() const { return getValue("code/TabWidth", 4); @@ -76,31 +86,6 @@ void ApplicationSettings::setCodeSnippetExpandRange(int range) setValue("code/snippet/expand_range", range); } -std::string ApplicationSettings::getNodeTypeColor(Node::NodeType type, const std::string& state) const -{ - std::string path = "colors/" + Node::getTypeString(type) + "/" + state; - return getValue(path, "#FFFFFF"); -} - -void ApplicationSettings::setNodeTypeColor(Node::NodeType type, const std::string& color, const std::string& state) -{ - std::string path = "colors/" + Node::getTypeString(type) + "/" + state; - setValue(path, color); -} - -std::string ApplicationSettings::getQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& state) const -{ - std::string path = "colors/" + QueryNode::queryNodeTypeToString(type) + "/" + state; - return getValue(path, "#FFFFFF"); -} - -void ApplicationSettings::setQueryNodeTypeColor(QueryNode::QueryNodeType type, - const std::string& color, const std::string& state) -{ - std::string path = "colors/" + QueryNode::queryNodeTypeToString(type) + "/" + state; - setValue(path, color); -} - ApplicationSettings::ApplicationSettings() { } diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index a3254e7f..75fa0c8d 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -3,10 +3,6 @@ #include -#include "utility/math/Color.h" - -#include "data/graph/Node.h" -#include "data/query/QueryNode.h" #include "settings/CommonSettings.h" class ApplicationSettings @@ -26,6 +22,9 @@ public: int getFontSize() const; void setFontSize(int fontSize); + std::string getColorSchemePath() const; + void setColorSchemePath(const std::string& colorSchemePath); + // code int getCodeTabWidth() const; void setCodeTabWidth(int codeTabWidth); @@ -36,13 +35,6 @@ public: int getCodeSnippetExpandRange() const; void setCodeSnippetExpandRange(int range); - // colors - std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const; - void setNodeTypeColor(Node::NodeType type, const std::string& color, const std::string& state = "normal"); - - std::string getQueryNodeTypeColor(QueryNode::QueryNodeType type , const std::string& state = "normal") const; - void setQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& color, const std::string& state = "normal"); - private: ApplicationSettings(); ApplicationSettings(const ApplicationSettings&); diff --git a/src/lib/settings/ColorScheme.cpp b/src/lib/settings/ColorScheme.cpp new file mode 100644 index 00000000..c2d6ca1b --- /dev/null +++ b/src/lib/settings/ColorScheme.cpp @@ -0,0 +1,49 @@ +#include "settings/ColorScheme.h" + +std::shared_ptr ColorScheme::s_instance; + +std::shared_ptr ColorScheme::getInstance() +{ + if (!s_instance) + { + s_instance = std::shared_ptr(new ColorScheme()); + } + + return s_instance; +} + +ColorScheme::~ColorScheme() +{ +} + +std::string ColorScheme::getColor(const std::string& key) const +{ + return getValue(key, "#FFFFFF"); +} + +std::string ColorScheme::getNodeTypeColor(Node::NodeType type, const std::string& state) const +{ + std::string path = "graph/node/" + Node::getTypeString(type) + "/" + state; + return getValue(path, "#FFFFFF"); +} + +std::string ColorScheme::getEdgeTypeColor(Edge::EdgeType type, const std::string& state) const +{ + std::string path = "graph/edge/" + Edge::getTypeString(type) + "/" + state; + return getValue(path, "#FFFFFF"); +} + +std::string ColorScheme::getQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& state) const +{ + std::string path = "search/query/" + QueryNode::queryNodeTypeToString(type) + "/" + state; + return getValue(path, "#FFFFFF"); +} + +std::string ColorScheme::getSyntaxColor(const std::string& key) const +{ + return getValue("code/snippet/syntax/" + key, "#FFFFFF"); +} + +ColorScheme::ColorScheme() +{ +} diff --git a/src/lib/settings/ColorScheme.h b/src/lib/settings/ColorScheme.h new file mode 100644 index 00000000..5783d1d7 --- /dev/null +++ b/src/lib/settings/ColorScheme.h @@ -0,0 +1,31 @@ +#ifndef COLOR_SCHEME_H +#define COLOR_SCHEME_H + +#include "data/graph/Node.h" +#include "data/graph/Edge.h" +#include "data/query/QueryNode.h" +#include "settings/Settings.h" + +class ColorScheme + : public Settings +{ +public: + static std::shared_ptr getInstance(); + virtual ~ColorScheme(); + + std::string getColor(const std::string& key) const; + + std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const; + std::string getEdgeTypeColor(Edge::EdgeType type, const std::string& state = "normal") const; + std::string getQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& state = "normal") const; + std::string getSyntaxColor(const std::string& key) const; + +protected: + ColorScheme(); + ColorScheme(const ColorScheme&); + void operator=(const ColorScheme&); + + static std::shared_ptr s_instance; +}; + +#endif // COLOR_SCHEME_H diff --git a/src/lib/utility/messaging/type/MessageSwitchColorScheme.h b/src/lib/utility/messaging/type/MessageSwitchColorScheme.h new file mode 100644 index 00000000..0b7f7dc6 --- /dev/null +++ b/src/lib/utility/messaging/type/MessageSwitchColorScheme.h @@ -0,0 +1,23 @@ +#ifndef MESSAGE_SWITCH_COLOR_SCHEME_H +#define MESSAGE_SWITCH_COLOR_SCHEME_H + +#include "utility/messaging/Message.h" + +class MessageSwitchColorScheme + : public Message +{ +public: + MessageSwitchColorScheme(const std::string& filePath) + : colorSchemeFilePath(filePath) + { + } + + static const std::string getStaticType() + { + return "MessageSwitchColorScheme"; + } + + const std::string colorSchemeFilePath; +}; + +#endif // MESSAGE_SWITCH_COLOR_SCHEME_H