[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/games/kolf-ng
From:       Huan Zeng <zh.issac () gmail ! com>
Date:       2009-08-17 8:39:10
Message-ID: 1250498350.859545.4103.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1012244 by hzeng:

remove "start blending" button, move it to the texture list widget, the previous \
mentioned crash still not fixed.


 M  +1 -1      editor/blender-blendthread.h  
 M  +6 -7      editor/blender-manager.cpp  
 M  +3 -2      editor/blender-manager.h  
 M  +14 -1     editor/blender-texturelistwidget.cpp  
 M  +1 -0      editor/blender-texturelistwidget.h  
 M  +0 -10     engine/game-editor.cpp  


--- trunk/playground/games/kolf-ng/editor/blender-blendthread.h #1012243:1012244
@@ -18,9 +18,9 @@
 
 #ifndef KOLF_BLENDER_BLENDTHREAD_H
 #define KOLF_BLENDER_BLENDTHREAD_H
+#include <QMutex>
 #include <QThread>
 #include <QWaitCondition>
-#include <QMutex>
 
 namespace Kolf
 {
--- trunk/playground/games/kolf-ng/editor/blender-manager.cpp #1012243:1012244
@@ -24,7 +24,6 @@
 #include "blender-manager.h"
 #include "blender-texture.h"
 #include "hmcreator-drawingboard.h"
-#include <KAction>
 #include <KStandardDirs>
 #include <QFileDialog>
 #include <QListView>
@@ -43,7 +42,6 @@
 	, m_isConfigurable(true)
 	, m_outputWidth(512)
 	, m_outputHeight(512)
-	, m_startBlendingAction(0)
 	, m_drawingBoard(0)
 	, m_texturesModified(false)
 {
@@ -64,6 +62,7 @@
 
 void Kolf::BlenderManager::addTextures()
 {	
+	QMutexLocker locker(&m_mutex);
 	if(!m_isConfigurable)
 		return;
 	m_isConfigurable = false;
@@ -73,18 +72,17 @@
      	tr("Open Image"), "./", tr("Image Files (*.png *.jpg *.bmp)"));
 	m_model->insertRows(fileNames, 0);
 
-	m_startBlendingAction->setEnabled(m_model->textureList().count() != 0 && \
!m_heightmap.isNull());  m_isConfigurable = true;
 
 }
 
 void Kolf::BlenderManager::addTextures(const QStringList& fileNames)
 {
+	QMutexLocker locker(&m_mutex);
 	if(!m_isConfigurable)
 		return;
 	m_isConfigurable = false;
 	m_model->insertRows(fileNames, 0);
-	m_startBlendingAction->setEnabled(m_model->textureList().count() != 0 && \
!m_heightmap.isNull());  m_isConfigurable = true;
 }
 
@@ -136,8 +134,8 @@
 void Kolf::BlenderManager::processBlending()
 {
 	bool heightmapModified = setHeightmap();
-	if(!m_isConfigurable || (!m_texturesModified && !heightmapModified)
-	   || !m_startBlendingAction->isEnabled())
+	QMutexLocker locker(&m_mutex);
+	if(!m_isConfigurable || (!m_texturesModified && !heightmapModified))
 		return;
 	m_isConfigurable = false;
 	m_blendResult = QImage(m_outputWidth, m_outputHeight, QImage::Format_ARGB32);
@@ -178,6 +176,7 @@
 
 bool Kolf::BlenderManager::setHeightmap()
 {
+	QMutexLocker locker(&m_mutex);
 	if(!m_isConfigurable)
 		return false;
 	if(!m_drawingBoard || m_drawingBoard->pixmap().isNull())
@@ -202,7 +201,6 @@
 			}
 		m_imageViewer->setLeftText(QString("Heightmap loaded\nHeight range: \
(%1,%2)").arg(min).arg(max));  }
-	m_startBlendingAction->setEnabled(m_model->textureList().count() != 0 && \
!m_heightmap.isNull());  m_isConfigurable = true;
 	return true;
 }
@@ -215,6 +213,7 @@
 
 void Kolf::BlenderManager::changeBrightness(int value)
 {
+	QMutexLocker locker(&m_mutex);
 	if(!m_isConfigurable || m_blendResult.isNull() )
 		return;
 	m_isConfigurable = false;
--- trunk/playground/games/kolf-ng/editor/blender-manager.h #1012243:1012244
@@ -19,6 +19,7 @@
 #ifndef KOLF_BLENDER_MANAGER_H 
 #define KOLF_BLENDER_MANAGER_H 
 #include "../elements/utils-heightmap.h"
+#include <QMutex>
 #include <QImage>
 #include <QObject>
 
@@ -45,8 +46,8 @@
 			const QImage& blendingResult() const {return m_brightEffect;}
 			QImage& blendingResult() {return m_brightEffect;}
 			void setImageViewer(ImageViewer* imageViewer) {m_imageViewer = imageViewer;}
-			void setStartBlendingAction(KAction* action) {m_startBlendingAction = action;}
 			void setDrawingBoard(DrawingBoard* board) {m_drawingBoard = board;}
+			QMutex& mutex() {return m_mutex;}
 
 		public Q_SLOTS:
 			bool setHeightmap();
@@ -79,10 +80,10 @@
 			bool m_isConfigurable;
 			int m_outputWidth;
 			int m_outputHeight;
-			KAction* m_startBlendingAction;
 			DrawingBoard* m_drawingBoard;
 			bool m_texturesModified;
 			BlendThread* m_blendThread;
+			QMutex m_mutex;
 	};
 }
 
--- trunk/playground/games/kolf-ng/editor/blender-texturelistwidget.cpp \
#1012243:1012244 @@ -20,6 +20,8 @@
 #include "blender-texturelistwidget.h"
 #include <KLocalizedString>
 #include <QListView>
+#include <QPushButton>
+#include <QVBoxLayout>
 
 Kolf::TextureListWidget::TextureListWidget(ImageViewer* imageViewer)
 	: GameUIDockWidget(i18n("Texture list"))
@@ -27,11 +29,22 @@
 {
 	setObjectName("TextureListWidget");
 	setPreferredArea(Qt::LeftDockWidgetArea);
-	setWidget(m_blenderManager->view());
+	setupUI();
 }
 
 Kolf::TextureListWidget::~TextureListWidget()
 {
 }
 
+void Kolf::TextureListWidget::setupUI()
+{
+	QWidget* wholeWidget = new QWidget;
+	QVBoxLayout* layout = new QVBoxLayout;
+	QPushButton* button = new QPushButton(i18n("Regenerate texture"));
+	layout->addWidget(m_blenderManager->view());
+	layout->addWidget(button);
+	wholeWidget->setLayout(layout);
+	setWidget(wholeWidget);
+	connect(button, SIGNAL(clicked()), m_blenderManager, SLOT(startBlending()));
+}
 #include "blender-texturelistwidget.moc"
--- trunk/playground/games/kolf-ng/editor/blender-texturelistwidget.h \
#1012243:1012244 @@ -32,6 +32,7 @@
 			~TextureListWidget();
 			BlenderManager* blenderManager() {return m_blenderManager;}
 		private:
+			void setupUI();
 			BlenderManager* m_blenderManager;
 	};
 }
--- trunk/playground/games/kolf-ng/engine/game-editor.cpp #1012243:1012244
@@ -95,16 +95,6 @@
 	actionCollection()->addAction("blender-delTexture", delTexAction);
 	connect(delTexAction, SIGNAL(triggered()), textureListWidget->blenderManager(), \
SLOT(delTextures()));  
- 	//Action: texture blender -- start blending
-	KAction* startAction = new KAction(KIcon("run-build"), i18n("Start &Blending"), \
                actionCollection());
-	startAction->setShortcut(i18n("Ctrl+B"));
-	startAction->setStatusTip(i18n("Start blending"));
-	startAction->setToolTip(i18n("start blending"));
-	startAction->setEnabled(false); //will become available when a heightmap and \
                textures are loaded
-	actionCollection()->addAction("blender-startBlending", startAction);
-	textureListWidget->blenderManager()->setStartBlendingAction(startAction);
-	connect(startAction, SIGNAL(triggered()), textureListWidget->blenderManager(), \
                SLOT(startBlending()));
-
  	//Action: texture blender -- save blending result
 	KAction* saveAction = new KAction(KIcon("document-save"), i18n("&Save"), \
actionCollection());  saveAction->setShortcut(i18n("Ctrl+S"));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic