annotate src/colourset.cpp @ 502:ba924fc4790a

Added tag easyhg_v1.0 for changeset 6bb2a1f3087c
author Chris Cannam
date Tue, 23 Aug 2011 12:05:48 +0100
parents a09d5ffe165c
children 533519ebc0cb
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@244 8 Copyright (c) 2011 Chris Cannam
Chris@244 9 Copyright (c) 2011 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@57 17
Chris@53 18
Chris@53 19 #include "colourset.h"
Chris@53 20
Chris@53 21 ColourSet
Chris@53 22 ColourSet::m_instance;
Chris@53 23
Chris@53 24 ColourSet::ColourSet() { }
Chris@53 25
Chris@53 26 ColourSet *
Chris@53 27 ColourSet::instance()
Chris@53 28 {
Chris@53 29 return &m_instance;
Chris@53 30 }
Chris@53 31
Chris@53 32 QColor
Chris@53 33 ColourSet::getColourFor(QString n)
Chris@53 34 {
Chris@53 35 if (m_defaultNames.contains(n)) return Qt::black;
Chris@53 36 if (m_colours.contains(n)) return m_colours[n];
Chris@53 37
Chris@53 38 QColor c;
Chris@53 39
Chris@53 40 if (m_colours.empty()) {
Chris@395 41 c = QColor::fromHsv(0, 200, 150);
Chris@53 42 } else {
Chris@395 43 int hue = m_lastColour.hue() - 130;
Chris@395 44 if (hue < 0) hue += 360;
Chris@395 45 c = QColor::fromHsv(hue, 200, 150);
Chris@53 46 }
Chris@53 47
Chris@53 48 m_colours[n] = c;
Chris@53 49 m_lastColour = c;
Chris@53 50 return c;
Chris@53 51 }
Chris@53 52
Chris@53 53
Chris@53 54