Index: mythgame/mythgame/gametree.h
===================================================================
--- mythgame/mythgame/gametree.h	(revision 9935)
+++ mythgame/mythgame/gametree.h	(working copy)
@@ -102,6 +102,7 @@
   public slots:
     void handleTreeListSelection(int, IntVector*);
     void handleTreeListEntry(int, IntVector*);
+    void showImageTimeout(void);
 
   protected:
     void keyPressEvent(QKeyEvent *e);
@@ -125,6 +126,8 @@
     UITextType  *m_gameGenre;
     UITextType  *m_gameFavourite;
     UIImageType *m_gameImage;
+
+    QTimer      *timer;
 };
 
 #endif
Index: mythgame/mythgame/game_settings.xml
===================================================================
--- mythgame/mythgame/game_settings.xml	(revision 9935)
+++ mythgame/mythgame/game_settings.xml	(working copy)
@@ -21,8 +21,8 @@
       <text>Game Players</text>
       <text lang="IT">Impostazioni generali</text>
       <text lang="ES">Opciones Reproductores</text>
-      <text lang="CA">Opcions Generals</text>
-      <text lang="DE">Grundeinstellungen</text>
+      <text lang="CA"></text>
+      <text lang="DE">Spielestarter</text>
       <text lang="DK">Spil Systemer</text>
       <text lang="NL">Algemeen</text>
       <text lang="PT">Jogadores</text>
@@ -50,10 +50,10 @@
       <text>Clear Game Data</text>
       <text lang="IT">Impostazioni generali</text>
       <text lang="ES">Borrar Datos</text>
-      <text lang="CA">Opcions Generals</text>
-      <text lang="DE">Grundeinstellungen</text>
+      <text lang="CA"></text>
+      <text lang="DE">Loesche Spieleliste</text>
       <text lang="DK">Slet spil data</text>
-      <text lang="NL">Algemeen</text>
+      <text lang="NL"></text>
       <text lang="PT">Apagar Dados de Jogos</text>
       <text lang="SV">Generella inställningar</text>
       <text lang="SI">Splošne nastavitve</text>
@@ -61,5 +61,20 @@
       <action>CLEAR_GAME_DATA</action>
    </button>
 
+   <button>
+      <type>GAME_SETTINGS_GENERAL</type>
+      <text>Generate Screenshots</text>
+      <text lang="IT"></text>
+      <text lang="ES"></text>
+      <text lang="CA"></text>
+      <text lang="DE">Screenshots erzeugen</text>
+      <text lang="DK"></text>
+      <text lang="NL"></text>
+      <text lang="PT"></text>
+      <text lang="SV"></text>
+      <text lang="SI"></text>
+      <text lang="FI"></text>
+      <action>GENERATE_SCREENSHOTS</action>
+   </button>
 
 </mythmenu>
Index: mythgame/mythgame/gamehandler.cpp
===================================================================
--- mythgame/mythgame/gamehandler.cpp	(revision 9935)
+++ mythgame/mythgame/gamehandler.cpp	(working copy)
@@ -3,6 +3,9 @@
 #include "rom_metadata.h"
 
 #include <qobject.h>
+#include <qapplication.h>
+#include <qtimer.h>
+#include <qprocess.h>
 #include <qptrlist.h>
 #include <qstringlist.h>
 #include <iostream>
@@ -14,6 +17,9 @@
 #include <mythtv/mythdialogs.h>
 #include <mythtv/util.h>
 
+QProcess *process;
+QString screencmd;
+
 using namespace std;
 
 static QPtrList<GameHandler> *handlers = 0;
@@ -64,7 +70,7 @@
 void GameHandler::updateSettings(GameHandler *handler)
 {
     MSqlQuery query(MSqlQuery::InitCon());
-    query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks  FROM gameplayers WHERE playername = \"" + handler->SystemName() + "\";");
+    query.exec("SELECT rompath, workingpath, commandline, screenshots, gameplayerid, gametype, extensions, spandisks, screenshotenabled, screenshotcmd FROM gameplayers WHERE playername = \"" + handler->SystemName() + "\";");
 
     query.next();
     handler->rompath = query.value(0).toString();
@@ -75,6 +81,8 @@
     handler->gametype = query.value(5).toString();
     handler->validextensions = QStringList::split(",", query.value(6).toString().stripWhiteSpace().remove(" "));
     handler->spandisks = query.value(7).toInt();
+    handler->screenshotenabled = query.value(8).toInt();
+    handler->screenshotcmd = query.value(9).toInt();
 
 }
 
@@ -131,7 +139,6 @@
         cerr << "No romDB data read from database. Not imported?" << endl;
     else
         cerr << "Loaded " << romDB.count() << " items from romDB Database" << endl;
-
 }
 
 void GameHandler::GetMetadata(GameHandler *handler, QString rom, QString* Genre, QString* Year,
@@ -723,7 +730,7 @@
     else if (!(handler = GetHandler(romdata)))
     {
         // Couldn't get handler so abort.
-        return;
+        return ;
     }
     QString exec = handler->SystemCmdLine();
 
@@ -806,3 +813,176 @@
     handlers->append(handler);
 }
 
+void GameHandler::generateScreenshots(void)
+{
+    checkHandlers();
+
+    GameHandler *handler = handlers->first();
+
+    MSqlQuery query(MSqlQuery::InitCon());
+    while(handler)
+    {
+	updateSettings(handler);
+	if (handler->ScreenShotEnabled())
+	{
+
+	QString thequery;	
+	thequery = QString("SELECT romname, rompath, gamename, diskcount "
+		           "FROM gamemetadata WHERE system = '%1';")
+                           .arg(handler->SystemName());
+			   
+        query.exec(thequery);
+
+	if (query.isActive() && query.size() >0)
+	{
+	while (query.next())
+	{
+	    QString romname = query.value(0).toString();
+	    QString rompath = query.value(1).toString();
+	    int diskcount   = query.value(3).toInt();
+	    //Get the Extension via the RomInfo Class
+		RomInfo temp;
+		temp.setRomname(romname);
+	    QString extension = temp.getExtension();
+	    
+	    QString basename = romname.left(romname.length() - (extension.length() + 2));
+		
+	    QString exec = handler->SystemCmdLine();
+
+    	    if (handler->GameType() != "PC")
+    	    {
+    		QString arg = "\"" + rompath +
+                               "/" + romname + "\"";
+
+    		// If they specified a %s in the commandline place the romname
+    		// in that location, otherwise tack it on to the end of
+    		// the command.
+    		if (exec.contains("%s") || handler->SpanDisks())
+    		{
+        	    exec = exec.replace(QRegExp("%s"),arg);
+
+        	    if (handler->SpanDisks())
+        	    {
+            		QRegExp rxp = QRegExp( "%d[0-4]", TRUE, FALSE );
+
+            		if (exec.contains(rxp)) 
+            		{
+                	    if (diskcount > 1) 
+                	    {
+				// Chop off the extension, .  and last character of the name which we are assuming is the disk #
+                    		QString rom;
+                    		QString diskid[] = { "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6" };
+
+                    		for (int disk = 1; disk <= diskcount; disk++)
+                    		{
+                        	    rom = QString("\"%1/%2%3.%4\"")
+                                        	.arg(rompath)
+                                        	.arg(basename)
+                                        	.arg(disk)
+                                        	.arg(extension);
+                        	    exec = exec.replace(QRegExp(diskid[disk]),rom);
+                    		}
+                	    } 
+			    
+			    else
+                	    {   // If there is only one disk make sure we replace %d1 just like %s
+                    		exec = exec.replace(QRegExp("%d1"),arg);
+                	    }
+            		}
+        	    }
+    		}
+    		else
+    		{
+        	    exec = exec + " \"" + 
+                	    rompath + "/" +
+                	    romname + "\"";
+    		}
+	    }
+
+	    QString savedir = QDir::currentDirPath ();
+	    QDir d;
+	    if (handler->SystemWorkingPath()) {
+    		if (!d.cd(handler->SystemWorkingPath()))
+    		{
+        	cout << "Failed to change to specified Working Directory : " << handler->SystemWorkingPath() << endl;
+    		}
+	    }
+       
+	    if (handler->ScreenShotCmd().length() < 2)
+		screencmd = gContext->GetSetting("GameScreenshotCmd");
+	    else
+		screencmd = handler->ScreenShotCmd();
+	    
+	    if (screencmd.contains("%p"))
+		{
+	        QString reptxt = handler->SystemScreenShots() + "/" + basename;
+		screencmd = screencmd.replace(QRegExp("%p"),reptxt);	    
+		}
+
+	    if (screencmd.contains("%s"))
+		{
+	        QString reptxt = rompath + "/" + romname;
+		screencmd = screencmd.replace(QRegExp("%s"),reptxt);	    
+		}
+
+	    process = new QProcess();
+	    
+	    QStringList lst( QStringList::split( " ", exec ) );
+	    
+	    //Combine Parameters within "" to 1 Argument!
+	    QStringList s2;
+	    
+	    for(int i = 0; i < lst.count(); i++) 
+	    {
+		if(lst[i][0] == '"') 
+	        {
+	    	    if(lst[i][lst[i].length()-1] == '"') 
+		    {
+			s2.append(lst[i]);
+		    }
+		    else 
+		    {
+			QString s = lst[i];
+			s += " ";
+			
+			for(int j = i+1; j < lst.count(); j++) 
+			{
+			    s += lst[j];
+			    if (s[s.length()-1] == '"') 
+			    {
+				s2.append(s);
+				i=j;
+				break;
+			    }
+			    else
+			        s += " ";
+			}
+		    }
+		}
+		else
+		    s2.append(lst[i]);
+	    }
+	process->setArguments(s2);
+
+	    QString ShotTime = gContext->GetSetting("GameScreenshotTime");
+	    int myShotTime = ShotTime.toInt() * 1000;
+
+    	    QTimer::singleShot( myShotTime, this, SLOT( screenshotTimeout() ) );
+	    if (!process->start())
+		cout << "Error running Process:" << exec << endl;
+	    
+	    while (process->isRunning()){ qApp->processEvents(); }
+	    
+	
+	}
+	}
+	}
+        handler = handlers->next();
+	
+    }
+}
+void GameHandler::screenshotTimeout(void)
+{
+    myth_system(screencmd);
+    process->kill();
+}
Index: mythgame/mythgame/gamehandler.h
===================================================================
--- mythgame/mythgame/gamehandler.h	(revision 9935)
+++ mythgame/mythgame/gamehandler.h	(working copy)
@@ -53,8 +53,11 @@
 
 typedef QMap <QString, GameScan> GameScanMap;
 
-class GameHandler
-{
+class GameHandler : public QObject
+{  
+  
+  Q_OBJECT
+  
   public:
     GameHandler()
     {
@@ -78,6 +81,7 @@
     void VerifyGameDB(GameHandler *handler);
 
     static void clearAllGameData(void); 
+    void generateScreenshots(void); 
 
     static int buildFileCount(QString directory, GameHandler *handler);
     void buildFileList(QString directory, GameHandler *handler, 
@@ -96,6 +100,7 @@
 
     static RomInfo* create_rominfo(RomInfo* parent);
     int SpanDisks() const { return spandisks; }
+    int ScreenShotEnabled() const { return screenshotenabled; }
     QString SystemName() const { return systemname; }
     QString SystemCmdLine() const { return commandline; }
     QString SystemRomPath() const { return rompath; }
@@ -103,6 +108,10 @@
     QString SystemScreenShots() const { return screenshots; }
     uint GamePlayerID() const { return gameplayerid; }
     QString GameType() const { return gametype; }
+    QString ScreenShotCmd() const { return screenshotcmd; }
+    
+  public slots:
+    void screenshotTimeout(void);
 
   protected:
     static GameHandler* GetHandler(RomInfo *rominfo);
@@ -110,6 +119,7 @@
 
     bool rebuild;
     int spandisks;
+    int screenshotenabled;
     QString systemname;
     QString rompath;
     QString commandline;
@@ -117,6 +127,7 @@
     QString screenshots;
     uint gameplayerid;
     QString gametype;
+    QString screenshotcmd;
     QStringList validextensions;
 
     RomDBMap romDB;
Index: mythgame/mythgame/dbcheck.cpp
===================================================================
--- mythgame/mythgame/dbcheck.cpp	(revision 9935)
+++ mythgame/mythgame/dbcheck.cpp	(working copy)
@@ -10,7 +10,7 @@
 
 #include "gamesettings.h"
 
-const QString currentDatabaseVersion = "1012";
+const QString currentDatabaseVersion = "1013";
 
 static bool UpdateDBVersionNumber(const QString &newnumber)
 {
@@ -320,8 +320,21 @@
     }
 
 
+    if (dbver == "1012")
+    {
+        const QString updates[] = {
+"ALTER TABLE gameplayers ADD COLUMN screenshotcmd text NOT NULL default ''; ",
+"ALTER TABLE gameplayers ADD COLUMN screenshotenabled tinyint(1) NOT NULL default '0'; ",
+""
+};
 
+        if (!performActualUpdate(updates, "1013", dbver))
+            return false;
+    }
 
 
+
+
+
     return true;
 }
Index: mythgame/mythgame/main.cpp
===================================================================
--- mythgame/mythgame/main.cpp	(revision 9935)
+++ mythgame/mythgame/main.cpp	(working copy)
@@ -33,7 +33,7 @@
         settings.exec();
     }
 
-    if (sel == "game_players")
+    else if (sel == "game_players")
     {
 	MythGamePlayerEditor mgpe;
 	mgpe.exec();
@@ -42,11 +42,18 @@
     {
         GameHandler::processAllGames();
     }
-    if (sel == "clear_game_data")
+    
+    else if (sel == "clear_game_data")
     {
         GameHandler::clearAllGameData();
     }
 
+    else if (sel == "generate_screenshots")
+    {
+	GameHandler myHandler;
+        myHandler.generateScreenshots();
+    }
+
 }
 
 void runMenu(QString which_menu)
Index: mythgame/mythgame/gametree.cpp
===================================================================
--- mythgame/mythgame/gametree.cpp	(revision 9935)
+++ mythgame/mythgame/gametree.cpp	(working copy)
@@ -136,6 +136,9 @@
 
     m_gameTree = new GenericTree("game root", 0, false);
 
+    timer = new QTimer( this );
+    connect( timer, SIGNAL(timeout()),  SLOT(showImageTimeout()) );
+          
     wireUpTheme();
     //  create system filter to only select games where handlers are present
     QString systemFilter;
@@ -251,12 +254,16 @@
             if (romInfo->ImagePath()) 
             {
                 m_gameImage->SetImage(romInfo->ImagePath());
-                m_gameImage->LoadImage();
+		if ( timer->isActive() )
+		    timer->changeInterval(300);
+		else
+		    timer->start(300, true);
             }
         }
     }
     else 
     {   // Otherwise use some defaults.
+	timer->stop();
         m_gameImage->SetImage("");
         m_gameTitle->SetText("");
         m_gameSystem->SetText("Unknown");
@@ -267,6 +274,11 @@
 
 }
 
+void GameTree::showImageTimeout(void)
+{
+    m_gameImage->LoadImage();
+}
+
 QString getElement(QStringList list, int pos)
 {
     int curpos = 0;
Index: mythgame/mythgame/gamesettings.cpp
===================================================================
--- mythgame/mythgame/gamesettings.cpp	(revision 9935)
+++ mythgame/mythgame/gamesettings.cpp	(working copy)
@@ -76,7 +76,26 @@
     return gc;
 }   
 
+static HostLineEdit *GameScreenshotCmd()
+{
+    HostLineEdit *gc = new HostLineEdit("GameScreenshotCmd");
+    gc->setLabel(QObject::tr("Screenshot Command"));
+    gc->setValue("/usr/bin/scrot --quality 1 \"%p.png\"");
+    gc->setHelpText(QObject::tr("Programm wich generate Screenshots "
+                    "when the Rom ist started in Background "
+                    "use %s for romname and %p for the imagename without extension."));
+    return gc;
+}
 
+static HostLineEdit *GameScreenshotTime()
+{
+    HostLineEdit *gc = new HostLineEdit("GameScreenshotTime");
+    gc->setLabel(QObject::tr("Screenshot Timeout:"));
+    gc->setValue("10");
+    gc->setHelpText(QObject::tr("Enter Time (in seconds) after wich a Screenshot is taken"));
+    return gc;
+}
+
 MythGameGeneralSettings::MythGameGeneralSettings()
 {
     VerticalConfigurationGroup *general = new VerticalConfigurationGroup(false);
@@ -87,7 +106,13 @@
     general->addChild(GameRemovalPrompt());
     general->addChild(GameShowFileNames());
 
+    VerticalConfigurationGroup *screenshot = new VerticalConfigurationGroup(false);
+    screenshot->setLabel(QObject::tr("MythGame Settings -- Screenshots"));
+    screenshot->addChild(GameScreenshotCmd());
+    screenshot->addChild(GameScreenshotTime());
+
     addChild(general);
+    addChild(screenshot);
 
 }
 
@@ -183,6 +208,24 @@
     };
 };
 
+class GenerateScreenshots: virtual public MGSetting, virtual public CheckBoxSetting {
+public:
+    GenerateScreenshots(const MythGamePlayerSettings& parent):
+        MGSetting(parent, "screenshotenabled") {
+        setLabel(QObject::tr("Generation of SCreenshots Enabled"));
+        setHelpText(QObject::tr("This Setting means that this Gameplayer is included in the generation of Screenshots."));
+    };
+};
+
+class GenerateScreenshotsCmd: virtual public MGSetting, virtual public LineEditSetting {
+public:
+    GenerateScreenshotsCmd(const MythGamePlayerSettings& parent):
+        MGSetting(parent, "screenshotcmd") {
+        setLabel(QObject::tr("Screenshot Command"));
+        setHelpText(QObject::tr("If you want another Command then the global to Generate Screenshots, Enter it here!"));
+    };
+};
+
 MythGamePlayerSettings::MythGamePlayerSettings()
 {
     // must be first
@@ -198,6 +241,8 @@
     group->addChild(new WorkingDirPath(*this));
     group->addChild(new Extensions(*this));
     group->addChild(new AllowMultipleRoms(*this));
+    group->addChild(new GenerateScreenshots(*this));
+    group->addChild(new GenerateScreenshotsCmd(*this));
     addChild(group);
 };
 
