Rev 17895 | Rev 20186 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16546 | jghali | 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 | |||
9 | #include "propertiespalette_utils.h" |
||
10 | |||
11 | #include <QCloseEvent> |
||
12 | #include <QEvent> |
||
13 | #include <QFocusEvent> |
||
14 | #include <QHBoxLayout> |
||
15 | #include <QImage> |
||
16 | #include <QKeyEvent> |
||
17 | #include <QLabel> |
||
18 | #include <QListView> |
||
19 | #include <QMenu> |
||
20 | #include <QObject> |
||
21 | #include <QRegExp> |
||
22 | #include <QToolTip> |
||
23 | #include <QValidator> |
||
24 | #include <QWidget> |
||
25 | |||
17539 | jghali | 26 | #if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES) |
16546 | jghali | 27 | #define _USE_MATH_DEFINES |
28 | #endif |
||
29 | #include <cmath> |
||
30 | #include "commonstrings.h" |
||
31 | #include "sccolorengine.h" |
||
32 | #include "sccombobox.h" |
||
33 | #include "scraction.h" |
||
34 | #include "scribusdoc.h" |
||
35 | #include "selection.h" |
||
36 | #include "units.h" |
||
37 | #include "util.h" |
||
38 | #include "util_icon.h" |
||
39 | #include "util_math.h" |
||
40 | |||
41 | //using namespace std; |
||
42 | |||
43 | |||
44 | LineFormatValue::LineFormatValue() : m_Line(), m_doc(NULL), m_name() {}; |
||
45 | |||
46 | LineFormatValue::LineFormatValue( const multiLine& line, ScribusDoc* doc, const QString name ) : m_Line(line), m_doc(doc), m_name(name) {}; |
||
47 | |||
48 | LineFormatValue::LineFormatValue(const LineFormatValue& other) |
||
49 | { |
||
50 | m_name = other.m_name; |
||
51 | m_Line = other.m_Line; |
||
52 | m_doc = other.m_doc; |
||
53 | } |
||
54 | |||
55 | LineFormatValue& LineFormatValue::operator= (const LineFormatValue& other) |
||
56 | { |
||
57 | m_name = other.m_name; |
||
58 | m_Line = other.m_Line; |
||
59 | m_doc = other.m_doc; |
||
60 | return *this; |
||
61 | } |
||
62 | |||
63 | |||
64 | void LineFormatItemDelegate::redraw(const QVariant& data) const |
||
65 | { |
||
66 | const LineFormatValue& item(data.value<LineFormatValue>()); |
||
67 | QColor tmpf; |
||
68 | pmap->fill(Qt::white); |
||
69 | QPainter p; |
||
70 | p.begin(pmap.get()); |
||
71 | for (int its = item.m_Line.size()-1; its > -1; its--) |
||
72 | { |
||
73 | const ScColor& col = item.m_doc->PageColors[item.m_Line[its].Color]; |
||
74 | tmpf = ScColorEngine::getDisplayColor(col, item.m_doc, item.m_Line[its].Shade); |
||
75 | QPen pen; |
||
76 | QVector<double> m_array; |
||
77 | if (item.m_Line[its].Dash == 1) |
||
78 | pen.setStyle(Qt::SolidLine); |
||
79 | else |
||
80 | { |
||
81 | getDashArray(item.m_Line[its].Dash, 1, m_array); |
||
82 | pen.setDashPattern(m_array); |
||
83 | } |
||
84 | pen.setColor(tmpf); |
||
85 | pen.setWidth(qMax(static_cast<int>(item.m_Line[its].Width), 1)); |
||
86 | pen.setCapStyle(static_cast<Qt::PenCapStyle>(item.m_Line[its].LineEnd)); |
||
87 | pen.setJoinStyle(static_cast<Qt::PenJoinStyle>(item.m_Line[its].LineJoin)); |
||
88 | p.setPen(pen); |
||
89 | p.drawLine(0, 18, 37, 18); |
||
90 | } |
||
91 | p.end(); |
||
92 | } |
||
93 | |||
94 | QString LineFormatItemDelegate::text(const QVariant& data) const |
||
95 | { |
||
96 | return data.toString(); |
||
97 | } |
||
98 | |||
99 | NameWidget::NameWidget(QWidget* parent) : QLineEdit(parent) |
||
100 | { |
||
101 | setObjectName("namewidget"); |
||
17895 | fschmid | 102 | QRegExp rx( "[\\w()]+" ); |
16546 | jghali | 103 | QValidator* validator = new QRegExpValidator( rx, this ); |
104 | setValidator( validator ); |
||
105 | } |
||
106 | |||
107 | void NameWidget::focusOutEvent(QFocusEvent *e) |
||
108 | { |
||
109 | emit Leaved(); |
||
110 | QLineEdit::focusOutEvent(e); |
||
111 | } |
||
112 | |||
113 | UserActionSniffer::UserActionSniffer(QObject* parent) : QObject (parent) |
||
114 | { |
||
115 | |||
116 | } |
||
117 | |||
118 | bool UserActionSniffer::eventFilter(QObject*, QEvent *e) |
||
119 | { |
||
120 | if (e->type() == QEvent::MouseButtonPress) |
||
121 | emit actionStart(); |
||
122 | else if (e->type() == QEvent::MouseButtonRelease) |
||
123 | emit actionEnd(); |
||
124 | else if (e->type() == QEvent::KeyPress) |
||
125 | { |
||
126 | QKeyEvent *k = dynamic_cast<QKeyEvent*>(e); |
||
127 | if (k && !k->isAutoRepeat() && (k->key() == Qt::Key_Up || k->key() == Qt::Key_Down)) |
||
128 | emit actionStart(); |
||
129 | } |
||
130 | else if (e->type() == QEvent::KeyRelease) |
||
131 | { |
||
132 | QKeyEvent *k = dynamic_cast<QKeyEvent*>(e); |
||
133 | if (k && !k->isAutoRepeat() && (k->key() == Qt::Key_Up || k->key() == Qt::Key_Down)) |
||
134 | emit actionEnd(); |
||
135 | } |
||
136 | return false; |
||
137 | } |
||
138 | |||
139 |