# # # add_file "src/view/ColorPicker.cpp" # content [4c497c2bffb4198c0bc2304830d6290f6eb16e0b] # # add_file "src/view/ColorPicker.h" # content [d2c27e940d644897abda48ac14cfe619e7c0b634] # # patch "guitone.pro" # from [b4ea319a62403a9ea00c7c7b36ceabf8ea257044] # to [3352f5d1507c2b8457752575d3e272374316ace7] # # patch "res/forms/preferences.ui" # from [d6c764259d715f6f92b86cb8da6a7191114fb62c] # to [182c4b2a6f2f3ae5c7b31a0de50b5ee97200ace9] # # patch "src/model/ContentDiff.cpp" # from [25b9c4272115c9105bc95a0e126731e098d76a06] # to [e0802384fee41ec12380d12008411f45647b0670] # # patch "src/model/GetFile.cpp" # from [71eb299484ec7ad15dea21b6f5604a947b58778b] # to [c6e55a8a637d916bd8b4482561197266faf2fd3c] # # patch "src/view/dialogs/Preferences.cpp" # from [36ea0bf13de6bbf6e5478a37d9bf75e243a0c1cd] # to [6da852bb8c13dcefc4495883dd4e066580a3b9d7] # ============================================================ --- src/view/ColorPicker.cpp 4c497c2bffb4198c0bc2304830d6290f6eb16e0b +++ src/view/ColorPicker.cpp 4c497c2bffb4198c0bc2304830d6290f6eb16e0b @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2008 by Thomas Keller * + * address@hidden * + * * + * This program 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program. If not, see . * + ***************************************************************************/ + +#include "ColorPicker.h" + +#include + +ColorPicker::ColorPicker(QWidget * parent) : QFrame(parent) +{ + setFrameShape(Panel); + setFrameShadow(Sunken); + setMinimumSize(60, 20); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + setSelectedColor(QColor("white")); +} + +ColorPicker::~ColorPicker() {} + +void ColorPicker::setSelectedColor(QColor color) +{ + if (!color.isValid()) return; + selectedColor = color; + setStyleSheet("background: " + color.name()); +} + +QColor ColorPicker::getSelectedColor() const +{ + return selectedColor; +} + +void ColorPicker::mousePressEvent(QMouseEvent * ev) +{ + Q_UNUSED(ev); + setSelectedColor(QColorDialog::getColor(selectedColor, this)); +} + ============================================================ --- src/view/ColorPicker.h d2c27e940d644897abda48ac14cfe619e7c0b634 +++ src/view/ColorPicker.h d2c27e940d644897abda48ac14cfe619e7c0b634 @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2008 by Thomas Keller * + * address@hidden * + * * + * This program 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program 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 this program. If not, see . * + ***************************************************************************/ + +#ifndef COLOR_PICKER_H +#define COLOR_PICKER_H + +#include + +class ColorPicker : public QFrame +{ + Q_OBJECT + +public: + ColorPicker(QWidget *); + ~ColorPicker(); + + void setSelectedColor(QColor); + QColor getSelectedColor() const; + +private: + void mousePressEvent(QMouseEvent *); + QColor selectedColor; +}; + +#endif ============================================================ --- guitone.pro b4ea319a62403a9ea00c7c7b36ceabf8ea257044 +++ guitone.pro 3352f5d1507c2b8457752575d3e272374316ace7 @@ -28,6 +28,7 @@ HEADERS = src/view/TreeView.h \ src/view/AttributesView.h \ src/view/DiffStatusView.h \ src/view/ChangeLogEdit.h \ + src/view/ColorPicker.h \ src/view/MenuBar.h \ src/view/DatabaseMenuBar.h \ src/view/WorkspaceMenuBar.h \ @@ -106,6 +107,7 @@ SOURCES += src/view/TreeView.cpp \ src/view/AttributesView.cpp \ src/view/DiffStatusView.cpp \ src/view/ChangeLogEdit.cpp \ + src/view/ColorPicker.cpp \ src/view/MenuBar.cpp \ src/view/DatabaseMenuBar.cpp \ src/view/WorkspaceMenuBar.cpp \ ============================================================ --- res/forms/preferences.ui d6c764259d715f6f92b86cb8da6a7191114fb62c +++ res/forms/preferences.ui 182c4b2a6f2f3ae5c7b31a0de50b5ee97200ace9 @@ -5,16 +5,10 @@ 0 0 - 446 - 481 + 458 + 340 - - - 0 - 0 - - Qt::NoContextMenu @@ -31,196 +25,361 @@ true - + - - - - - Path to monotone executable - - - - - - - - Qt::NoContextMenu - - - true - - - false - - + + + 0 + + + + + 0 + 0 + 428 + 245 + + + + General + + + + + + Path to monotone executable + + + + + + + + Qt::NoContextMenu + + + true + + + false + + + + + + + Browse + + + + - - + + - Browse + relaxed version check - - - - - relaxed version check - - - - - - - - - - Logging - - - - - - enable console logging - - - true - - - - - - - enable file logging (%1) - - - - - - - 6 - + + + + + + Logging + + - + - Log level + enable console logging + + true + - + + + enable file logging (%1) + + - - - Qt::Horizontal + + + 6 - - - 40 - 20 - - - + + + + Log level + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - - - - - - Miscellaneous - - - - - - check for updates on application launch - - - true - - - - - - - read workspace incrementally (faster for big directory trees) - - - false - - - - - - - disable auto-completion in commit dialog - - - false - - - - - - - ask before opening executable files and files with -the following extensions (comma-separated list): - - - true - - - - - - - - - - - + + + + + + + + 0 + 0 + 428 + 245 + + + + Colors + + - + + + + + background color of added lines in diffs + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 60 + 20 + + + + QFrame::Panel + + + QFrame::Sunken + + + + + + + + + + + background color of removed lines in diffs + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 60 + 20 + + + + QFrame::Panel + + + QFrame::Sunken + + + + + + + - Qt::Horizontal + Qt::Vertical - 0 - 0 + 20 + 146 + + + + + + 0 + 0 + 428 + 245 + + + + Miscellaneous + + - + - Cancel + check for updates on application launch + + true + - + - OK + read workspace incrementally (faster for big directory trees) - + + false + + + + + + + disable auto-completion in commit dialog + + + false + + + + + + + ask before opening executable files and files with +the following extensions (comma-separated list): + + true + + + + + + + Qt::Vertical + + + + 20 + 71 + + + + + + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + Cancel + + + + + + + OK + + + true + + + + + + ColorPicker + QFrame +
ColorPicker.h
+ 1 +
+
mtnExecutablePath selectMtnExecutable ============================================================ --- src/model/ContentDiff.cpp 25b9c4272115c9105bc95a0e126731e098d76a06 +++ src/model/ContentDiff.cpp e0802384fee41ec12380d12008411f45647b0670 @@ -18,6 +18,7 @@ #include "ContentDiff.h" #include "MonotoneUtil.h" +#include "Settings.h" #include #include @@ -230,12 +231,14 @@ QVariant ContentDiff::data(const QModelI if (line->lineMarker.startsWith("-")) { - return QVariant(QBrush(Qt::red)); + QColor added(Settings::getString("DiffColorAddedLines", "green")); + return QVariant(QBrush(added)); } if (line->lineMarker.startsWith("+")) { - return QVariant(QBrush(Qt::green)); + QColor removed(Settings::getString("DiffColorRemovedLines", "red")); + return QVariant(QBrush(removed)); } // unchanged lines ============================================================ --- src/model/GetFile.cpp 71eb299484ec7ad15dea21b6f5604a947b58778b +++ src/model/GetFile.cpp c6e55a8a637d916bd8b4482561197266faf2fd3c @@ -18,6 +18,7 @@ #include "GetFile.h" #include "MonotoneUtil.h" +#include "Settings.h" #include #include @@ -246,14 +247,17 @@ QVariant GetFile::data(const QModelIndex else if (role == Qt::BackgroundRole) { + QColor added(Settings::getString("DiffColorAddedLines", "green")); + QColor removed(Settings::getString("DiffColorRemovedLines", "red")); + switch (line->state) { case DiffLine::Added: case DiffLine::AddedMissingNewline: - return QVariant(QBrush(Qt::green)); - case DiffLine::Removed: + return QVariant(QBrush(added)); + case DiffLine::Removed: case DiffLine::RemovedMissingNewline: - return QVariant(QBrush(Qt::red)); + return QVariant(QBrush(removed)); default: return QVariant(); } } ============================================================ --- src/view/dialogs/Preferences.cpp 36ea0bf13de6bbf6e5478a37d9bf75e243a0c1cd +++ src/view/dialogs/Preferences.cpp 6da852bb8c13dcefc4495883dd4e066580a3b9d7 @@ -69,6 +69,14 @@ Preferences::Preferences(QWidget * paren Qt::Checked : Qt::Unchecked ); + colorPickerAddedLines->setSelectedColor( + QColor(Settings::getString("DiffColorAddedLines", "green")) + ); + + colorPickerRemovedLines->setSelectedColor( + QColor(Settings::getString("DiffColorRemovedLines", "red")) + ); + connect( selectMtnExecutable, SIGNAL(clicked()), this, SLOT(openFileBrowser()) @@ -154,6 +162,9 @@ void Preferences::accept() Settings::setBool("AskFileOpen", askFileOpen->isChecked()); Settings::setString("AskFileOpenExt", askFileOpenExtensions->text()); + Settings::setString("DiffColorAddedLines", colorPickerAddedLines->getSelectedColor().name()); + Settings::setString("DiffColorRemovedLines", colorPickerRemovedLines->getSelectedColor().name()); + if (Settings::getBool("ReadWorkspaceIncrementally", false) != readWorkspaceIncrementally->isChecked()) {