Commit 2f667bc4 authored by Victor Yacovlev's avatar Victor Yacovlev

Build fixes from upstream

parent 5678001d
This diff is collapsed.
......@@ -11,58 +11,13 @@
</rect>
</property>
<property name="windowTitle">
<string>Вертун</string>
<string>Isometric Robot</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>507</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menu">
<property name="title">
<string>Обстановка</string>
</property>
<addaction name="actionLoad"/>
<addaction name="separator"/>
<addaction name="actionPrev"/>
<addaction name="actionNext"/>
<addaction name="separator"/>
<addaction name="actionReset"/>
</widget>
<addaction name="menu"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionLoad"/>
<addaction name="separator"/>
<addaction name="actionPrev"/>
<addaction name="actionNext"/>
<addaction name="separator"/>
<addaction name="actionReset"/>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
<action name="actionLoad">
<property name="text">
<string>Загрузить...</string>
......
{
"name": { "ascii": "Robot", "ru_RU": "Робот" },
"methods": [
{ "name": {"ascii": "go up", "ru_RU": "вверх" }},
{ "name": {"ascii": "go down", "ru_RU": "вниз" } },
{ "name": {"ascii": "go left", "ru_RU": "влево" } },
{ "name": {"ascii": "go right", "ru_RU": "вправо" } },
{ "name": {"ascii": "go up", "ru_RU": "вверх" }, "async": true },
{ "name": {"ascii": "go down", "ru_RU": "вниз" }, "async": true },
{ "name": {"ascii": "go left", "ru_RU": "влево" }, "async": true },
{ "name": {"ascii": "go right", "ru_RU": "вправо"}, "async": true },
{ "name": {"ascii": "do paint", "ru_RU": "закрасить" }, "async": false },
{ "name": {"ascii": "do paint", "ru_RU": "закрасить" }, "async": true },
{
"name": {"ascii": "is wall at top", "ru_RU": "сверху стена"},
"returnType": "bool"
......
......@@ -1322,7 +1322,7 @@ namespace ActorRobot {
void RoboField::reverseColorCurrent()
{
reverseColor(robo_y,robo_x);
wasEdit=true;
if(mode!=NORMAL_MODE)wasEdit=true;
}
void RoboField::reverseMark(int row, int col)
......@@ -1432,7 +1432,7 @@ namespace ActorRobot {
wasEdit=false;
......@@ -1912,6 +1912,7 @@ namespace ActorRobot {
wasEdit=false;
......@@ -2534,7 +2535,7 @@ namespace ActorRobot {
// if (m_robot && !property("fromPult").toBool())
// m_robot->showHideWindow(true);
setProperty("fromPult", false);
// setProperty("fromPult", false);
if(getFieldItem(robo_y,robo_x)->canUp())
{
......@@ -2551,7 +2552,7 @@ namespace ActorRobot {
// if (m_robot && !property("fromPult").toBool())
// m_robot->showHideWindow(true);
setProperty("fromPult", false);
// setProperty("fromPult", false);
if(getFieldItem(robo_y,robo_x)->canDown())
{
......@@ -2565,7 +2566,7 @@ namespace ActorRobot {
{
// if (m_robot && !property("fromPult").toBool())
// m_robot->showHideWindow(true);
setProperty("fromPult", false);
// setProperty("fromPult", false);
if(getFieldItem(robo_y,robo_x)->canLeft())
{
......@@ -2580,7 +2581,7 @@ namespace ActorRobot {
{
// if (m_robot && !property("fromPult").toBool())
// m_robot->showHideWindow(true);
setProperty("fromPult", false);
// setProperty("fromPult", false);
if(getFieldItem(robo_y,robo_x)->canRight())
{
......@@ -2774,6 +2775,7 @@ namespace ActorRobot {
old_cell=QPair<int,int>(rowClicked, colClicked);
};
};
wasEdit=true;
// if(wasEdit)emit was_edit();
};
void RoboField::mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent )
......@@ -3364,6 +3366,7 @@ void RobotModule::copyFromPult(QString log)
// The source should be ready-to-read QIODevice like QBuffer or QFile
qDebug()<<"Load env";
if(field->loadFromDataStream(source)!=0)return ;
m_mainWidget->setWindowTitle(trUtf8("Робот - ")+source->objectName());
startField=field->Clone();
field->dropWasEdit();
// ajustWindowSize();//NEW ROBOT
......@@ -3860,6 +3863,42 @@ void RobotModule::createEmptyField(int rows,int cols)
mainWidget()->setWindowTitle(QString::fromUtf8("Робот - нет файла") );
field->dropWasEdit();
};
bool RobotModule::isSafeToQuit()
{
if(field->WasEdit())
{
QMessageBox::StandardButton r;
QMessageBox messageBox(
QMessageBox::Question,
trUtf8("Робот"),
trUtf8("Сохранить изменения?"),
QMessageBox::NoButton,mainWidget()
);
QPushButton * btnSave =
messageBox.addButton(trUtf8("Да"), QMessageBox::AcceptRole);
QPushButton * btnDiscard =
messageBox.addButton(trUtf8("Нет"), QMessageBox::DestructiveRole);
QPushButton * btnCancel =
messageBox.addButton(trUtf8("Отмена"), QMessageBox::RejectRole);
messageBox.setDefaultButton(btnSave);
messageBox.exec();
if (messageBox.clickedButton()==btnSave) {
r = QMessageBox::Save;
}
if (messageBox.clickedButton()==btnDiscard) {
r = QMessageBox::Discard;
}
if (messageBox.clickedButton()==btnCancel) {
r = QMessageBox::Cancel;
}
if (r==QMessageBox::Save) {saveEnv();};
if (r==QMessageBox::Cancel) {return false;};
}
return true;
}
void RobotModule::loadEnv()
{
if(field->WasEdit())
......@@ -4022,6 +4061,7 @@ void RobotModule::saveEnv()
SaveToFile(RobotFile);
RobotModule::robotSettings()->setValue("Robot/StartField/File",RobotFile);
updateLastFiles(RobotFile);
}
......
......@@ -502,6 +502,8 @@ namespace ActorRobot {
qreal runCellRad(const int row, const int col);
QChar runUpChar(const int row, const int col);
QChar runDownChar(const int row, const int col);
bool isSafeToQuit();
public:
// GUI access methods
QWidget* mainWidget() const;
......
......@@ -22,6 +22,9 @@ set(FORMS
dialog.ui
pult.ui
)
qt4_wrap_ui(UI_SOURCES ${FORMS})
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/vodoleymodulebase.cpp
......@@ -86,7 +89,7 @@ handleTranslation(ActorVodoley)
add_library(
ActorVodoley
SHARED
${MOC_SOURCES} ${SOURCES}
${MOC_SOURCES} ${SOURCES} ${UI_SOURCES}
${MOC_SOURCES_GENERATED} ${SOURCES_GENERATED}
)
......
This diff is collapsed.
#include "row.h"
#include "widgets/dockwindowplace.h"
#include <QDebug>
#include <QResizeEvent>
namespace CoreGUI {
Row::Row(QWidget *parent, const QString &settingsKey)
: QSplitter(Qt::Horizontal, parent)
, settingsKey_(settingsKey)
{
setHandleWidth(10);
setAutoFillBackground(true);
}
void Row::updateSettings(ExtensionSystem::SettingsPtr settings, const QStringList & keys)
{
// if (settings_) save();
settings_ = settings;
for (int i=0; i<count(); i++) {
QWidget * w = widget(i);
Widgets::DockWindowPlace * place =
qobject_cast<Widgets::DockWindowPlace*>(w);
if (place) {
place->updateSettings(settings);
}
}
QList<int> szs;
for (int i=0; i<10; i++) {
const QString key = settingsKey_+"/Size" + QString::number(i);
const QVariant value = settings_->value(key);
if (value.isValid())
szs.push_back(value.toInt());
else
break;
}
if (szs.size() > 0)
setSizes(szs);
}
void Row::addComponent(QWidget *widget, bool autoResizable)
{
addWidget(widget);
autoResizable_.push_back(autoResizable);
setCollapsible(count()-1, !autoResizable);
updateGeometry();
}
void Row::save()
{
if (!settings_) return;
for (int i=0; i<count(); i++) {
QWidget * w = widget(i);
Widgets::DockWindowPlace * place =
qobject_cast<Widgets::DockWindowPlace*>(w);
if (place) {
place->saveState();
}
}
QList<int> szs = sizes();
for (int i=0; i<szs.size(); i++) {
settings_->setValue(settingsKey_+"/Size" + QString::number(i), szs[i]);
}
}
void Row::restore()
{
if (!settings_) return;
for (int i=0; i<count(); i++) {
QWidget * w = widget(i);
Widgets::DockWindowPlace * place =
qobject_cast<Widgets::DockWindowPlace*>(w);
if (place) {
place->restoreState();
}
}
QList<int> szs;
for (int i=0; i<10; i++) {
const QString key = settingsKey_+"/Size" + QString::number(i);
const QVariant value = settings_->value(key);
if (value.isValid())
szs.push_back(value.toInt());
else
break;
}
if (szs.size() > 0)
setSizes(szs);
}
QSize Row::sizeHint() const
{
int w = (count() - 1) * handleWidth();
int h = 0;
for (int i=0; i<sizes().size(); i++) {
w += sizes().at(i);
h = qMax(h, widget(i)->height());
}
return QSize(w, h);
}
QSize Row::minimumSizeHint() const
{
int w = (count() - 1) * handleWidth();
int h = 0;
for (int i=0; i<count(); i++) {
const QSize sz = widget(i)->minimumSizeHint();
w += sz.width();
h = qMax(h, sz.height());
}
return QSize(w, h);
}
void Row::handleVisiblityRequest(bool visible, const QSize & size)
{
QWidget * component = qobject_cast<QWidget*>(sender());
if (visible)
ensureEnoughtSpaceForComponent(component, size);
else
releaseSpaceUsesByComponent(component);
if (visible) {
emit visiblityRequest();
}
}
void Row::ensureEnoughtSpaceForComponent(QWidget *component, const QSize &size)
{
int index = indexOf(component);
QList<int> szs = sizes();
int summ = 0;
for (int i=0; i<szs.size(); i++) {
summ += szs[i];
}
int w = size.isValid() ? size.width() : component->minimumSizeHint().width();
int diff = w - szs[index];
if (diff <= 0)
return;
// 1. Try to decrease width of auto-resizable component
int resizableIndex = autoResizable_.indexOf(true);
if (resizableIndex != -1 && resizableIndex != index) {
int minW = widget(resizableIndex)->minimumSizeHint().width();
int curW = szs[resizableIndex];
int space = curW - minW;
if (space > 0) {
int spaceToEat = qMin(space, diff);
szs[resizableIndex] = szs[resizableIndex] - spaceToEat;
diff -= spaceToEat;
}
}
// 2. Try to decrease all other component width
if (diff > 0) {
for (int i=0; i<szs.size(); i++) {
if (i!=resizableIndex && i!=index) {
int minW = widget(i)->minimumSizeHint().width();
int curW = szs[i];
int space = curW - minW;
if (space > 0) {
int spaceToEat = qMin(space, diff);
szs[i] = szs[i] - spaceToEat;
diff -= spaceToEat;
}
}
}
}
// 3. Try to decrease component
if (diff > 0 && w > component->minimumSizeHint().width()) {
int space = w - component->minimumSizeHint().width();
int spaceToEat = qMin(diff, space);
w -= spaceToEat;
diff -= spaceToEat;
}
szs[index] = w;
setSizes(szs);
}
void Row::releaseSpaceUsesByComponent(QWidget *component)
{
int index = indexOf(component);
QList<int> szs = sizes();
int freed = szs[index];
szs[index] = 0;
int resizableIndex = autoResizable_.indexOf(true);
if (resizableIndex != -1 && resizableIndex != index) {
szs[resizableIndex] = szs[resizableIndex] + freed + handleWidth();
}
setSizes(szs);
}
void Row::resizeEvent(QResizeEvent *event)
{
if (event->size().width() < minimumSizeHint().width() || event->size().height() < minimumSizeHint().height()) {
event->ignore();
return;
}
QList<int> szs = sizes();
QSplitter::resizeEvent(event);
if (event->size().width() > event->oldSize().width())
increaseSize(event->size().width() - event->oldSize().width(), szs);
else if (event->size().width() < event->oldSize().width())
decreaseSize(event->oldSize().width() - event->size().width(), szs);
}
void Row::increaseSize(int diff, QList<int> & szs)
{
int resizableIndex = autoResizable_.indexOf(true);
if (resizableIndex) {
QList<int> szs = sizes();
szs[resizableIndex] = szs[resizableIndex] + diff;
setSizes(szs);
}
}
void Row::decreaseSize(int diff, QList<int> & szs)
{
}
} // namespace CoreGUI
#ifndef COREGUI_ROW_H
#define COREGUI_ROW_H
#include "extensionsystem/settings.h"
#include <QtGlobal>
#include <QSplitter>
namespace CoreGUI {
class Row : public QSplitter
{
Q_OBJECT
public:
explicit Row(QWidget *parent,
const QString & settingsKey
);
void addComponent(QWidget * widget, bool autoResizable);
void updateSettings(ExtensionSystem::SettingsPtr settings, const QStringList & keys);
void save();
void restore();
QSize sizeHint() const;
QSize minimumSizeHint() const;
signals:
void visiblityRequest();
private slots:
void handleVisiblityRequest(bool visible, const QSize & size);
private /*methods*/:
void resizeEvent(QResizeEvent * event);
void ensureEnoughtSpaceForComponent(QWidget * component, const QSize & size);
void releaseSpaceUsesByComponent(QWidget * component);
void increaseSize(int diff, QList<int> & szs);
void decreaseSize(int diff, QList<int> & szs);
private /*fields*/:
ExtensionSystem::SettingsPtr settings_;
QString settingsKey_;
QList<bool> autoResizable_;
};
} // namespace CoreGUI
#endif // COREGUI_ROW_H
......@@ -71,13 +71,13 @@ void generator::renderData(ModelPtr data)
}
if (profile.startsWith("a4")) {
paper = "a4paper";
geometry = "tmargin=2cm,bmargin=2cm,imargin=2cm,omargin=3cm";
geometry = "tmargin=2cm,bmargin=2cm,%%LEFTMARGIN%%=2cm,%%RIGHTMARGIN%%=3cm";
lmargin = "2cm";
rmargin = "3cm";
}
else if (profile.startsWith("a5")) {
paper = "a5paper";
geometry = "tmargin=2cm,bmargin=2cm,imargin=2cm,omargin=3cm";
geometry = "tmargin=2cm,bmargin=2cm,%%LEFTMARGIN%%=2cm,%%RIGHTMARGIN%%=3cm";
lmargin = "2cm";
rmargin = "3cm";
}
......@@ -87,16 +87,20 @@ void generator::renderData(ModelPtr data)
}
else {
paper = "a5paper";
geometry = "tmargin=0.1cm,bmargin=0.1cm,imargin=0.5cm,omargin=0.5cm";
geometry = "tmargin=0.1cm,bmargin=0.1cm,%%LEFTMARGIN%%=0.5cm,%%RIGHTMARGIN%%=0.5cm";
allowRasterImages_ = true;
colorlinks = "true";
}
clazzparam = paper;
if (profile.endsWith("ts")) {
clazzparam += ",twoside";
clazzparam += ",twoside";
geometry = geometry.replace("%%LEFTMARGIN%%", "imargin");
geometry = geometry.replace("%%RIGHTMARGIN%%", "omargin");
}
else {
clazzparam += ",oneside";
clazzparam += ",oneside";
geometry = geometry.replace("%%LEFTMARGIN%%", "lmargin");
geometry = geometry.replace("%%RIGHTMARGIN%%", "rmargin");
}
clazz = root_ == DocBookModel::Book ? "book" : "article";
......
This diff is collapsed.
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