~ubuntu-branches/ubuntu/trusty/scribus-ng/trusty

« back to all changes in this revision

Viewing changes to scribus/smcolorcombo.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-15 15:57:12 UTC
  • mfrom: (4.2.10 sid)
  • Revision ID: package-import@ubuntu.com-20120215155712-biimoc8o875jht80
Tags: 1.4.0.dfsg+r17300-1
* Prepare a dummy transitional package to converge on the 1.4.0 release.
* debian/NEWS: update the news.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 
to the COPYING file provided with the program. Following this notice may exist
4
 
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 
for which a new license (GPL+exception) is in place.
6
 
*/
7
 
 
8
 
#include "smcolorcombo.h"
9
 
#include "util.h"
10
 
 
11
 
 
12
 
SMColorCombo::SMColorCombo(QWidget *parent)
13
 
: ColorCombo(parent),
14
 
  hasParent_(false),
15
 
  useParentValue_(false),
16
 
  pItem_(0)
17
 
{
18
 
        
19
 
}
20
 
 
21
 
SMColorCombo::SMColorCombo(bool rw, QWidget* parent)
22
 
: ColorCombo(rw, parent),
23
 
  hasParent_(false),
24
 
  useParentValue_(false),
25
 
  pItem_(0),
26
 
  pText_(QString::null)
27
 
{
28
 
        
29
 
}
30
 
 
31
 
void SMColorCombo::setCurrentItem(int i)
32
 
{
33
 
        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
34
 
        setFont(false);
35
 
        hasParent_ = false;
36
 
        pItem_ = 0;
37
 
        pText_ = QString::null;
38
 
        ColorCombo::setCurrentIndex(i);
39
 
}
40
 
 
41
 
void SMColorCombo::setCurrentItem(int i, bool isParentValue)
42
 
{
43
 
        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
44
 
        hasParent_ = true;
45
 
        pItem_ = i;
46
 
        pText_ = QString::null;
47
 
        ColorCombo::setCurrentIndex(i);
48
 
        setFont(!isParentValue);
49
 
        connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
50
 
}
51
 
 
52
 
void SMColorCombo::setCurrentText(const QString &s)
53
 
{
54
 
        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
55
 
        setFont(false);
56
 
        hasParent_ = false;
57
 
        pItem_ = -1;
58
 
        pText_ = s;
59
 
        setCurrentComboItem(this, s);
60
 
        connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
61
 
}
62
 
 
63
 
void SMColorCombo::setCurrentText(const QString &s, bool isParentValue)
64
 
{
65
 
        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
66
 
        hasParent_ = true;
67
 
        pItem_ = -1;
68
 
        pText_ = s;
69
 
        setCurrentComboItem(this, s);
70
 
        setFont(!isParentValue);
71
 
        connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
72
 
}
73
 
 
74
 
void SMColorCombo::setParentItem(int i)
75
 
{
76
 
        hasParent_ = true;
77
 
        pItem_ = i;
78
 
        pText_ = QString::null;
79
 
}
80
 
 
81
 
void SMColorCombo::setParentText(const QString &s)
82
 
{
83
 
        hasParent_ = true;
84
 
        pText_ = s;
85
 
}
86
 
 
87
 
bool SMColorCombo::useParentValue()
88
 
{
89
 
        bool ret = false;
90
 
 
91
 
        if (useParentValue_ && hasParent_)
92
 
        {
93
 
                ret = currentIndex() == (count() - 1);
94
 
                if (ret)
95
 
                {
96
 
                        removeItem(count() - 1);
97
 
                        setFont(false);
98
 
                        if (!pText_.isNull())
99
 
                                setCurrentText(pText_, true);
100
 
                        else
101
 
                                setCurrentItem(pItem_, true);
102
 
                        useParentValue_ = false;
103
 
                }
104
 
        }
105
 
 
106
 
        return ret;
107
 
}
108
 
 
109
 
void SMColorCombo::setFont(bool wantBold)
110
 
{
111
 
        QFont f(font());
112
 
        f.setBold(wantBold);
113
 
        ColorCombo::setFont(f);
114
 
}
115
 
 
116
 
void SMColorCombo::currentChanged()
117
 
{
118
 
        if (hasParent_ && !useParentValue_)
119
 
        {
120
 
                setFont(true);
121
 
                addItem( tr("Use Parent Value"));
122
 
                useParentValue_ = true;
123
 
        }
124
 
}