Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
e0bd63e9
Commit
e0bd63e9
authored
Sep 14, 2016
by
Denis Khachko
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://git.lpm.org.ru:7999/niisi/kumir2
parents
70123be0
d1a397d7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
17 deletions
+84
-17
scripts/gen_actor_source.py
scripts/gen_actor_source.py
+3
-0
src/actors/_colorer/_colorermodule.cpp
src/actors/_colorer/_colorermodule.cpp
+24
-15
src/actors/_colorer/_colorermodule.h
src/actors/_colorer/_colorermodule.h
+1
-0
src/actors/painter/paintermodule.cpp
src/actors/painter/paintermodule.cpp
+8
-1
src/actors/painter/paintertools.cpp
src/actors/painter/paintertools.cpp
+37
-0
src/actors/painter/paintertools.h
src/actors/painter/paintertools.h
+4
-0
src/actors/painter/painterwindow.cpp
src/actors/painter/painterwindow.cpp
+6
-1
src/actors/painter/painterwindow.h
src/actors/painter/painterwindow.h
+1
-0
No files found.
scripts/gen_actor_source.py
View file @
e0bd63e9
...
...
@@ -900,6 +900,9 @@ class MenuItem:
else
:
self
.
icon
=
None
def
__repr__
(
self
):
return
self
.
title
.
get_ascii_value
()
class
Gui
:
"""
...
...
src/actors/_colorer/_colorermodule.cpp
View file @
e0bd63e9
...
...
@@ -31,6 +31,28 @@ _ColorerModule::_ColorerModule(ExtensionSystem::KPlugin * parent)
return
QList
<
ExtensionSystem
::
CommandLineParameter
>
();
}
const
QStringList
&
_ColorerModule
::
standardRussianColorNames
()
{
static
QStringList
validValues
;
if
(
validValues
.
isEmpty
())
{
validValues
<<
QString
::
fromUtf8
(
"прозрачный"
);
validValues
<<
QString
::
fromUtf8
(
"белый"
);
validValues
<<
QString
::
fromUtf8
(
"черный"
);
validValues
<<
QString
::
fromUtf8
(
"чёрный"
);
validValues
<<
QString
::
fromUtf8
(
"серый"
);
validValues
<<
QString
::
fromUtf8
(
"фиолетовый"
);
validValues
<<
QString
::
fromUtf8
(
"синий"
);
validValues
<<
QString
::
fromUtf8
(
"голубой"
);
validValues
<<
QString
::
fromUtf8
(
"зелёный"
);
validValues
<<
QString
::
fromUtf8
(
"зеленый"
);
validValues
<<
QString
::
fromUtf8
(
"жёлтый"
);
validValues
<<
QString
::
fromUtf8
(
"желтый"
);
validValues
<<
QString
::
fromUtf8
(
"оранжевый"
);
validValues
<<
QString
::
fromUtf8
(
"красный"
);
}
return
validValues
;
}
/* public slot */
void
_ColorerModule
::
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
)
{
// Called when changed kumir state. The states are defined as enum ExtensionSystem::GlobalState:
...
...
@@ -163,21 +185,8 @@ static QColor parseColor(const QString &css)
/* public slot */
Color
_ColorerModule
::
runOperatorINPUT
(
const
QString
&
x
,
bool
&
ok
)
{
/* алг цвет ввод(лит x, рез лог ok) */
QStringList
validValues
;
validValues
<<
QString
::
fromUtf8
(
"прозрачный"
);
validValues
<<
QString
::
fromUtf8
(
"белый"
);
validValues
<<
QString
::
fromUtf8
(
"черный"
);
validValues
<<
QString
::
fromUtf8
(
"чёрный"
);
validValues
<<
QString
::
fromUtf8
(
"серый"
);
validValues
<<
QString
::
fromUtf8
(
"фиолетовый"
);
validValues
<<
QString
::
fromUtf8
(
"синий"
);
validValues
<<
QString
::
fromUtf8
(
"голубой"
);
validValues
<<
QString
::
fromUtf8
(
"зелёный"
);
validValues
<<
QString
::
fromUtf8
(
"зеленый"
);
validValues
<<
QString
::
fromUtf8
(
"жёлтый"
);
validValues
<<
QString
::
fromUtf8
(
"желтый"
);
validValues
<<
QString
::
fromUtf8
(
"оранжевый"
);
validValues
<<
QString
::
fromUtf8
(
"красный"
);
const
QStringList
&
validValues
=
standardRussianColorNames
();
ok
=
validValues
.
contains
(
x
.
trimmed
());
Color
result
;
result
.
r
=
result
.
g
=
result
.
b
=
result
.
a
=
0
;
if
(
ok
)
{
...
...
src/actors/_colorer/_colorermodule.h
View file @
e0bd63e9
...
...
@@ -29,6 +29,7 @@ class _ColorerModule
public
/* methods */
:
_ColorerModule
(
ExtensionSystem
::
KPlugin
*
parent
);
static
QList
<
ExtensionSystem
::
CommandLineParameter
>
acceptableCommandLineParameters
();
static
const
QStringList
&
standardRussianColorNames
();
public
slots
:
void
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
);
void
loadActorData
(
QIODevice
*
source
);
...
...
src/actors/painter/paintermodule.cpp
View file @
e0bd63e9
...
...
@@ -180,8 +180,10 @@ void PainterModule::runLoadPage(const QString& fileName)
setError
(
tr
(
"File not exists: %s"
).
arg
(
fileName
));
}
canvas
.
reset
(
new
QImage
(
fileName
));
if
(
m_window
)
if
(
m_window
)
{
m_window
->
setCanvasSize
(
canvas
->
size
());
m_window
->
setCanvasName
(
QFile
(
fileName
).
fileName
());
}
markViewDirty
();
}
...
...
@@ -287,6 +289,11 @@ void PainterModule::runNewPage(const int width, const int height, const Color& b
canvas
.
reset
(
new
QImage
(
width
,
height
,
QImage
::
Format_RGB32
));
canvas
->
fill
(
clr
.
rgb
());
m_window
->
setCanvasSize
(
canvas
->
size
());
QString
colorName
=
findColorName
(
backgroundColor
);
if
(
colorName
.
length
()
>
0
&&
!
colorName
.
contains
(
"("
)
)
{
colorName
[
0
]
=
colorName
[
0
].
toUpper
();
}
m_window
->
setCanvasName
(
QString
(
"%1 %2x%3"
).
arg
(
colorName
).
arg
(
width
).
arg
(
height
));
markViewDirty
();
}
...
...
src/actors/painter/paintertools.cpp
View file @
e0bd63e9
...
...
@@ -256,4 +256,41 @@ extern QString CSS_RGB_toString(const QString &cssRgb)
return
result
;
}
const
QStringList
&
standardRussianColorNames
()
{
static
QStringList
validValues
;
if
(
validValues
.
isEmpty
())
{
validValues
<<
QString
::
fromUtf8
(
"прозрачный"
);
validValues
<<
QString
::
fromUtf8
(
"белый"
);
validValues
<<
QString
::
fromUtf8
(
"черный"
);
validValues
<<
QString
::
fromUtf8
(
"чёрный"
);
validValues
<<
QString
::
fromUtf8
(
"серый"
);
validValues
<<
QString
::
fromUtf8
(
"фиолетовый"
);
validValues
<<
QString
::
fromUtf8
(
"синий"
);
validValues
<<
QString
::
fromUtf8
(
"голубой"
);
validValues
<<
QString
::
fromUtf8
(
"зелёный"
);
validValues
<<
QString
::
fromUtf8
(
"зеленый"
);
validValues
<<
QString
::
fromUtf8
(
"жёлтый"
);
validValues
<<
QString
::
fromUtf8
(
"желтый"
);
validValues
<<
QString
::
fromUtf8
(
"оранжевый"
);
validValues
<<
QString
::
fromUtf8
(
"красный"
);
}
return
validValues
;
}
QString
findColorName
(
const
Actor_Colorer
::
Color
&
color
)
{
const
QStringList
&
validValues
=
standardRussianColorNames
();
Q_FOREACH
(
const
QString
&
name
,
validValues
)
{
const
QColor
test
=
parseColor
(
name
).
toRgb
();
bool
r
=
test
.
red
()
==
color
.
r
;
bool
g
=
test
.
green
()
==
color
.
g
;
bool
b
=
test
.
blue
()
==
color
.
b
;
if
(
r
&&
g
&&
b
)
{
return
name
;
}
}
return
QString
(
"rgb(%1,%2,%3)"
).
arg
(
color
.
r
).
arg
(
color
.
g
).
arg
(
color
.
b
);
}
}
src/actors/painter/paintertools.h
View file @
e0bd63e9
...
...
@@ -8,10 +8,14 @@
#include <QtGui>
#endif
#include "../_colorer/typecolor.h"
namespace
ActorPainter
{
extern
QColor
parseColor
(
const
QString
&
css
);
extern
QString
CSS_RGB_toString
(
const
QString
&
cssRgb
);
extern
QString
findColorName
(
const
Actor_Colorer
::
Color
&
color
);
extern
const
QStringList
&
standardRussianColorNames
();
}
...
...
src/actors/painter/painterwindow.cpp
View file @
e0bd63e9
...
...
@@ -95,6 +95,11 @@ void PainterWindow::setCanvasSize(const QSize &size)
}
void
PainterWindow
::
setCanvasName
(
const
QString
&
name
)
{
setWindowTitle
(
tr
(
"Painter [%1]"
).
arg
(
name
));
}
PainterView
*
PainterWindow
::
view
()
{
return
ui
->
view
;
...
...
@@ -199,7 +204,7 @@ void PainterWindow::newImage()
s_templateName
=
m_newImageDialog
->
templateFileName
();
static
const
QString
resourcesRoot
=
m_module
->
myResourcesDir
().
absolutePath
();
if
(
m_newImageDialog
->
isTemplate
())
{
m_module
->
runLoadPage
(
resourcesRoot
+
s_templateName
);
m_module
->
runLoadPage
(
resourcesRoot
+
"/"
+
s_templateName
);
}
else
{
Color
c
=
colorFromCss
(
m_newImageDialog
->
color
());
...
...
src/actors/painter/painterwindow.h
View file @
e0bd63e9
...
...
@@ -26,6 +26,7 @@ class PainterWindow : public QWidget
public:
explicit
PainterWindow
(
PainterModule
*
module
,
QWidget
*
parent
=
0
);
void
setCanvasSize
(
const
QSize
&
size
);
void
setCanvasName
(
const
QString
&
name
);
inline
QSize
minimumSizeHint
()
const
{
return
QSize
(
360
,
300
);
}
PainterView
*
view
();
~
PainterWindow
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment