comparison src/colourset.cpp @ 370:b9c153e00e84

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