Integrated paint guis while removing remains of oldPaint/double-click system.

This commit is contained in:
Tats
2014-10-16 17:52:32 +00:00
parent fc89b4fb11
commit eef76173b6
3 changed files with 21 additions and 23 deletions
+15 -16
View File
@@ -216,6 +216,9 @@ void MainWindow::handlePaintChanged(Paint::ptr paint) {
uid paintId = mappingManager->getPaintId(paint);
if (paint->getType() == "media") {
std::tr1::shared_ptr<Media> media = std::tr1::static_pointer_cast<Media>(paint);
Q_CHECK_PTR(media);
updatePaintItem(paintId, QIcon(), strippedName(media->getUri()));
// QString fileName = QFileDialog::getOpenFileName(this,
// tr("Import media source file"), ".");
// // Restart video playback. XXX Hack
@@ -223,6 +226,9 @@ void MainWindow::handlePaintChanged(Paint::ptr paint) {
// importMediaFile(fileName, paint, false);
}
if (paint->getType() == "image") {
std::tr1::shared_ptr<Image> image = std::tr1::static_pointer_cast<Image>(paint);
Q_CHECK_PTR(image);
updatePaintItem(paintId, QIcon(), strippedName(image->getUri()));
// QString fileName = QFileDialog::getOpenFileName(this,
// tr("Import media source file"), ".");
// // Restart video playback. XXX Hack
@@ -351,7 +357,7 @@ void MainWindow::importVideo()
videoTimer->start();
if (!fileName.isEmpty())
importMediaFile(fileName, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), false);
importMediaFile(fileName, false);
}
void MainWindow::importImage()
@@ -368,7 +374,7 @@ void MainWindow::importImage()
videoTimer->start();
if (!fileName.isEmpty())
importMediaFile(fileName, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), true);
importMediaFile(fileName, true);
}
void MainWindow::addColor()
@@ -380,7 +386,7 @@ void MainWindow::addColor()
QColor initialColor;
QColor color = QColorDialog::getColor(initialColor, this);
if (color.isValid())
addColorPaint(color, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)));
addColorPaint(color);
// Restart video playback. XXX Hack
videoTimer->start();
@@ -617,7 +623,7 @@ bool MainWindow::clearProject()
return true;
}
uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, Paint::ptr oldPaint, bool isImage)
uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, bool isImage)
{
// Cannot create image with already existing id.
if (Paint::getUidAllocator().exists(paintId))
@@ -640,20 +646,13 @@ uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, Pai
// Add paint to model and return its uid.
uid id = mappingManager->addPaint(paint);
// If replacing existing paint, extra work needs to be done
if (oldPaint.get()) {
mappingManager->replacePaintMappings(oldPaint, paint);
deletePaint(oldPaint->getId(), true);
emit paintChanged();
}
// Add paint widget item.
addPaintItem(id, QIcon(uri), strippedName(uri));
return id;
}
}
uid MainWindow::createColorPaint(uid paintId, QColor color, Paint::ptr oldPaint)
uid MainWindow::createColorPaint(uid paintId, QColor color)
{
// Cannot create image with already existing id.
if (Paint::getUidAllocator().exists(paintId))
@@ -1465,7 +1464,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
// {
// }
bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint, bool isImage)
bool MainWindow::importMediaFile(const QString &fileName, bool isImage)
{
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
@@ -1479,7 +1478,7 @@ bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint, b
QApplication::setOverrideCursor(Qt::WaitCursor);
// Add media file to model.
uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, oldPaint, isImage);
uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, isImage);
// Initialize position (center).
std::tr1::shared_ptr<Media> media = std::tr1::static_pointer_cast<Media>(mappingManager->getPaintById(mediaId));
@@ -1500,12 +1499,12 @@ bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint, b
return true;
}
bool MainWindow::addColorPaint(const QColor& color, Paint::ptr oldPaint)
bool MainWindow::addColorPaint(const QColor& color)
{
QApplication::setOverrideCursor(Qt::WaitCursor);
// Add color to model.
uint colorId = createColorPaint(NULL_UID, color, oldPaint);
uint colorId = createColorPaint(NULL_UID, color);
// Initialize position (center).
std::tr1::shared_ptr<Color> colorPaint = std::tr1::static_pointer_cast<Color>(mappingManager->getPaintById(colorId));
+4 -4
View File
@@ -115,10 +115,10 @@ public slots:
bool clearProject();
/// Create or replace a media paint (or image).
uid createMediaPaint(uid paintId, QString uri, float x, float y, Paint::ptr oldPaint, bool isImage);
uid createMediaPaint(uid paintId, QString uri, float x, float y, bool isImage);
/// Create or replace a color paint.
uid createColorPaint(uid paintId, QColor color, Paint::ptr oldPaint);
uid createColorPaint(uid paintId, QColor color);
/// Creates a textured mesh.
uid createMeshTextureMapping(uid mappingId,
@@ -188,8 +188,8 @@ public:
bool loadFile(const QString &fileName);
bool saveFile(const QString &fileName);
void setCurrentFile(const QString &fileName);
bool importMediaFile(const QString &fileName, Paint::ptr oldPaint, bool isImage);
bool addColorPaint(const QColor& color, Paint::ptr oldPaint);
bool importMediaFile(const QString &fileName, bool isImage);
bool addColorPaint(const QColor& color);
void addMappingItem(uid mappingId);
void removeMappingItem(uid mappingId);
void addPaintItem(uid paintId, const QIcon& icon, const QString& name);
+2 -3
View File
@@ -96,8 +96,7 @@ void ProjectReader::parsePaint(const QDomElement& paint)
QString x = paint.firstChildElement("x").text();
QString y = paint.firstChildElement("y").text();
uid id = _window->createMediaPaint(paintAttrId.toInt(), uri, x.toFloat(), y.toFloat(),
std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), paintAttrType == "image");
uid id = _window->createMediaPaint(paintAttrId.toInt(), uri, x.toFloat(), y.toFloat(), paintAttrType == "image");
if (id == NULL_UID)
_xml.raiseError(QObject::tr("Cannot create media with uri %1.").arg(uri));
}
@@ -106,7 +105,7 @@ void ProjectReader::parsePaint(const QDomElement& paint)
QString rgb = paint.firstChildElement("rgb").text();
QColor color(rgb);
uid id = _window->createColorPaint(paintAttrId.toInt(), color, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)));
uid id = _window->createColorPaint(paintAttrId.toInt(), color);
if (id == NULL_UID)
_xml.raiseError(QObject::tr("Cannot create color with RGB hex code %1.").arg(rgb));