Commit 1342a5a5 authored by Victor Yacovlev's avatar Victor Yacovlev

Painter: title update on new page command

parent 522fa138
......@@ -900,6 +900,9 @@ class MenuItem:
else:
self.icon = None
def __repr__(self):
return self.title.get_ascii_value()
class Gui:
"""
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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();
}
......
......@@ -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);
}
}
......@@ -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();
}
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment