export bug fixed, UI updated
This commit is contained in:
		
							parent
							
								
									59b8ba8835
								
							
						
					
					
						commit
						330f0e3984
					
				
					 7 changed files with 211 additions and 159 deletions
				
			
		| 
						 | 
					@ -37,7 +37,7 @@ void ExportThread::run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (widget->isSelected())
 | 
					        if (widget->isSelected())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (profileMap[widget] == "SnapmaticWidget")
 | 
					            if (widget->getWidgetType() == "SnapmaticWidget")
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
 | 
					                SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
 | 
				
			||||||
                SnapmaticPicture *picture = picWidget->getPicture();
 | 
					                SnapmaticPicture *picture = picWidget->getPicture();
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,7 @@ void ExportThread::run()
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (profileMap[widget] == "SavegameWidget")
 | 
					            else if (widget->getWidgetType() == "SavegameWidget")
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                SavegameWidget *sgdWidget = (SavegameWidget*)widget;
 | 
					                SavegameWidget *sgdWidget = (SavegameWidget*)widget;
 | 
				
			||||||
                SavegameData *savegame = sgdWidget->getSavegame();
 | 
					                SavegameData *savegame = sgdWidget->getSavegame();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,8 +56,8 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Export menu
 | 
					    // Export menu
 | 
				
			||||||
    exportMenu = new QMenu(this);
 | 
					    exportMenu = new QMenu(this);
 | 
				
			||||||
    exportMenu->addAction(tr("Export as &picture...", "Export as picture"), this, SLOT(exportSnapmaticPicture()));
 | 
					    exportMenu->addAction(tr("Export as &JPG picture..."), this, SLOT(exportSnapmaticPicture()));
 | 
				
			||||||
    exportMenu->addAction(tr("Export for &import...", "Export for import"), this, SLOT(copySnapmaticPicture()));
 | 
					    exportMenu->addAction(tr("Export as >A Snapmatic..."), this, SLOT(copySnapmaticPicture()));
 | 
				
			||||||
    ui->cmdExport->setMenu(exportMenu);
 | 
					    ui->cmdExport->setMenu(exportMenu);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@
 | 
				
			||||||
     <property name="sizePolicy">
 | 
					     <property name="sizePolicy">
 | 
				
			||||||
      <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
 | 
					      <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
 | 
				
			||||||
       <horstretch>0</horstretch>
 | 
					       <horstretch>0</horstretch>
 | 
				
			||||||
       <verstretch>0</verstretch>
 | 
					       <verstretch>1</verstretch>
 | 
				
			||||||
      </sizepolicy>
 | 
					      </sizepolicy>
 | 
				
			||||||
     </property>
 | 
					     </property>
 | 
				
			||||||
     <property name="text">
 | 
					     <property name="text">
 | 
				
			||||||
| 
						 | 
					@ -86,24 +86,54 @@
 | 
				
			||||||
       </widget>
 | 
					       </widget>
 | 
				
			||||||
      </item>
 | 
					      </item>
 | 
				
			||||||
      <item>
 | 
					      <item>
 | 
				
			||||||
       <widget class="QPushButton" name="cmdExport">
 | 
					       <layout class="QVBoxLayout" name="vlButtons">
 | 
				
			||||||
        <property name="toolTip">
 | 
					        <property name="rightMargin">
 | 
				
			||||||
         <string>Export picture</string>
 | 
					         <number>5</number>
 | 
				
			||||||
        </property>
 | 
					        </property>
 | 
				
			||||||
        <property name="text">
 | 
					        <property name="bottomMargin">
 | 
				
			||||||
         <string>&Export</string>
 | 
					         <number>5</number>
 | 
				
			||||||
        </property>
 | 
					        </property>
 | 
				
			||||||
       </widget>
 | 
					        <item>
 | 
				
			||||||
      </item>
 | 
					         <spacer name="vsButtons">
 | 
				
			||||||
      <item>
 | 
					          <property name="orientation">
 | 
				
			||||||
       <widget class="QPushButton" name="cmdClose">
 | 
					           <enum>Qt::Vertical</enum>
 | 
				
			||||||
        <property name="toolTip">
 | 
					          </property>
 | 
				
			||||||
         <string>Close</string>
 | 
					          <property name="sizeType">
 | 
				
			||||||
        </property>
 | 
					           <enum>QSizePolicy::Expanding</enum>
 | 
				
			||||||
        <property name="text">
 | 
					          </property>
 | 
				
			||||||
         <string>&Close</string>
 | 
					          <property name="sizeHint" stdset="0">
 | 
				
			||||||
        </property>
 | 
					           <size>
 | 
				
			||||||
       </widget>
 | 
					            <width>0</width>
 | 
				
			||||||
 | 
					            <height>0</height>
 | 
				
			||||||
 | 
					           </size>
 | 
				
			||||||
 | 
					          </property>
 | 
				
			||||||
 | 
					         </spacer>
 | 
				
			||||||
 | 
					        </item>
 | 
				
			||||||
 | 
					        <item>
 | 
				
			||||||
 | 
					         <layout class="QHBoxLayout" name="hlButtons">
 | 
				
			||||||
 | 
					          <item>
 | 
				
			||||||
 | 
					           <widget class="QPushButton" name="cmdExport">
 | 
				
			||||||
 | 
					            <property name="toolTip">
 | 
				
			||||||
 | 
					             <string>Export picture</string>
 | 
				
			||||||
 | 
					            </property>
 | 
				
			||||||
 | 
					            <property name="text">
 | 
				
			||||||
 | 
					             <string>&Export</string>
 | 
				
			||||||
 | 
					            </property>
 | 
				
			||||||
 | 
					           </widget>
 | 
				
			||||||
 | 
					          </item>
 | 
				
			||||||
 | 
					          <item>
 | 
				
			||||||
 | 
					           <widget class="QPushButton" name="cmdClose">
 | 
				
			||||||
 | 
					            <property name="toolTip">
 | 
				
			||||||
 | 
					             <string>Close</string>
 | 
				
			||||||
 | 
					            </property>
 | 
				
			||||||
 | 
					            <property name="text">
 | 
				
			||||||
 | 
					             <string>&Close</string>
 | 
				
			||||||
 | 
					            </property>
 | 
				
			||||||
 | 
					           </widget>
 | 
				
			||||||
 | 
					          </item>
 | 
				
			||||||
 | 
					         </layout>
 | 
				
			||||||
 | 
					        </item>
 | 
				
			||||||
 | 
					       </layout>
 | 
				
			||||||
      </item>
 | 
					      </item>
 | 
				
			||||||
     </layout>
 | 
					     </layout>
 | 
				
			||||||
    </widget>
 | 
					    </widget>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -310,7 +310,7 @@ fileDialogPreOpen:
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        QMessageBox::warning(this, tr("Import copy"), tr("Failed to read Snapmatic picture"));
 | 
					                        QMessageBox::warning(this, tr("Import"), tr("Failed to read Snapmatic picture"));
 | 
				
			||||||
                        picture->deleteLater();
 | 
					                        picture->deleteLater();
 | 
				
			||||||
                        delete picture;
 | 
					                        delete picture;
 | 
				
			||||||
                        goto fileDialogPreOpen;
 | 
					                        goto fileDialogPreOpen;
 | 
				
			||||||
| 
						 | 
					@ -325,7 +325,7 @@ fileDialogPreOpen:
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        QMessageBox::warning(this, tr("Import copy"), tr("Failed to read Savegame file"));
 | 
					                        QMessageBox::warning(this, tr("Import"), tr("Failed to read Savegame file"));
 | 
				
			||||||
                        savegame->deleteLater();
 | 
					                        savegame->deleteLater();
 | 
				
			||||||
                        delete savegame;
 | 
					                        delete savegame;
 | 
				
			||||||
                        goto fileDialogPreOpen;
 | 
					                        goto fileDialogPreOpen;
 | 
				
			||||||
| 
						 | 
					@ -353,20 +353,20 @@ fileDialogPreOpen:
 | 
				
			||||||
                        picture->deleteLater();
 | 
					                        picture->deleteLater();
 | 
				
			||||||
                        delete savegame;
 | 
					                        delete savegame;
 | 
				
			||||||
                        delete picture;
 | 
					                        delete picture;
 | 
				
			||||||
                        QMessageBox::warning(this, tr("Import copy"), tr("Can't import %1 because of not valid file format").arg("\""+selectedFileName+"\""));
 | 
					                        QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because of not valid file format").arg("\""+selectedFileName+"\""));
 | 
				
			||||||
                        goto fileDialogPreOpen;
 | 
					                        goto fileDialogPreOpen;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                QMessageBox::warning(this, tr("Import copy"), tr("No valid file is selected"));
 | 
					                QMessageBox::warning(this, tr("Import"), tr("No valid file is selected"));
 | 
				
			||||||
                goto fileDialogPreOpen;
 | 
					                goto fileDialogPreOpen;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            QMessageBox::warning(this, tr("Import copy"), tr("No valid file is selected"));
 | 
					            QMessageBox::warning(this, tr("Import"), tr("No valid file is selected"));
 | 
				
			||||||
            goto fileDialogPreOpen;
 | 
					            goto fileDialogPreOpen;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -381,7 +381,7 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString
 | 
				
			||||||
    QString picFileName = picFileInfo.fileName();
 | 
					    QString picFileName = picFileInfo.fileName();
 | 
				
			||||||
    if (picFileName.left(4) != "PGTA")
 | 
					    if (picFileName.left(4) != "PGTA")
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Snapmatic picture because the file not begin with PGTA"));
 | 
					        QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, file not begin with PGTA"));
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (QFile::copy(picPath, profileFolder + "/" + picFileName))
 | 
					    else if (QFile::copy(picPath, profileFolder + "/" + picFileName))
 | 
				
			||||||
| 
						 | 
					@ -391,7 +391,7 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Snapmatic picture because the copy failed"));
 | 
					        QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, can't copy the file into profile"));
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -427,13 +427,13 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Savegame file because the copy failed"));
 | 
					            QMessageBox::warning(this, tr("Import"), tr("Failed to import the Savegame, can't copy the file into profile"));
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Savegame file because no free Savegame slot left"));
 | 
					        QMessageBox::warning(this, tr("Import"), tr("Failed to import the Savegame, no Savegame slot is left"));
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -482,163 +482,182 @@ void ProfileInterface::deselectAllWidgets()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ProfileInterface::exportSelected()
 | 
					void ProfileInterface::exportSelected()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int exportCount = 0;
 | 
					    if (selectedWidgts != 0)
 | 
				
			||||||
    int exportPictures = 0;
 | 
					 | 
				
			||||||
    int exportSavegames = 0;
 | 
					 | 
				
			||||||
    bool pictureCopyEnabled = false;
 | 
					 | 
				
			||||||
    bool pictureExportEnabled = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), profileFolder);
 | 
					 | 
				
			||||||
    if (exportDirectory != "")
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        foreach (ProfileWidget *widget, widgets.keys())
 | 
					        int exportCount = 0;
 | 
				
			||||||
 | 
					        int exportPictures = 0;
 | 
				
			||||||
 | 
					        int exportSavegames = 0;
 | 
				
			||||||
 | 
					        bool pictureCopyEnabled = false;
 | 
				
			||||||
 | 
					        bool pictureExportEnabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), profileFolder);
 | 
				
			||||||
 | 
					        if (exportDirectory != "")
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (widget->isSelected())
 | 
					            foreach (ProfileWidget *widget, widgets.keys())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (widget->getWidgetType() == "SnapmaticWidget")
 | 
					                if (widget->isSelected())
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    exportPictures++;
 | 
					                    if (widget->getWidgetType() == "SnapmaticWidget")
 | 
				
			||||||
                }
 | 
					                    {
 | 
				
			||||||
                else if (widget->getWidgetType() == "SavegameWidgets")
 | 
					                        exportPictures++;
 | 
				
			||||||
                {
 | 
					                    }
 | 
				
			||||||
                    exportSavegames++;
 | 
					                    else if (widget->getWidgetType() == "SavegameWidget")
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        exportSavegames++;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (exportPictures != 0)
 | 
					            if (exportPictures != 0)
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            QInputDialog inputDialog;
 | 
					 | 
				
			||||||
            QStringList inputDialogItems;
 | 
					 | 
				
			||||||
            inputDialogItems << tr("Export and Copy pictures");
 | 
					 | 
				
			||||||
            inputDialogItems << tr("Export pictures");
 | 
					 | 
				
			||||||
            inputDialogItems << tr("Copy pictures");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            bool itemSelected = false;
 | 
					 | 
				
			||||||
            QString selectedItem = inputDialog.getItem(this, tr("Export selected"), tr("How should we deal with the Snapmatic pictures?"), inputDialogItems, 0, false, &itemSelected, inputDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
 | 
					 | 
				
			||||||
            if (itemSelected)
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (selectedItem == tr("Export and Copy pictures"))
 | 
					                QInputDialog inputDialog;
 | 
				
			||||||
 | 
					                QStringList inputDialogItems;
 | 
				
			||||||
 | 
					                inputDialogItems << tr("JPG pictures and GTA Snapmatic");
 | 
				
			||||||
 | 
					                inputDialogItems << tr("JPG pictures only");
 | 
				
			||||||
 | 
					                inputDialogItems << tr("GTA Snapmatic only");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                bool itemSelected = false;
 | 
				
			||||||
 | 
					                QString selectedItem = inputDialog.getItem(this, tr("Export selected"), tr("Export Snapmatic pictures\n\nJPG pictures make it possible to open the picture with a Image Viewer\nGTA Snapmatic make it possible to import the picture into the game\n\nExport as:"), inputDialogItems, 0, false, &itemSelected, inputDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
 | 
				
			||||||
 | 
					                if (itemSelected)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (selectedItem == tr("JPG pictures and GTA Snapmatic"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        pictureExportEnabled = true;
 | 
				
			||||||
 | 
					                        pictureCopyEnabled = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (selectedItem == tr("JPG pictures only"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        pictureExportEnabled = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (selectedItem == tr("GTA Snapmatic only"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        pictureCopyEnabled = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        pictureExportEnabled = true;
 | 
				
			||||||
 | 
					                        pictureCopyEnabled = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    pictureExportEnabled = true;
 | 
					                    pictureExportEnabled = true;
 | 
				
			||||||
                    pictureCopyEnabled = true;
 | 
					                    pictureCopyEnabled = true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else if (selectedItem == tr("Export pictures"))
 | 
					            }
 | 
				
			||||||
                {
 | 
					
 | 
				
			||||||
                    pictureExportEnabled = true;
 | 
					            // Counting the exports together
 | 
				
			||||||
                }
 | 
					            exportCount = exportCount + exportSavegames;
 | 
				
			||||||
                else if (selectedItem == tr("Copy pictures"))
 | 
					            if (pictureExportEnabled && pictureCopyEnabled)
 | 
				
			||||||
                {
 | 
					            {
 | 
				
			||||||
                    pictureCopyEnabled = true;
 | 
					                int exportPictures2 = exportPictures * 2;
 | 
				
			||||||
                }
 | 
					                exportCount = exportCount + exportPictures2;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                pictureExportEnabled = true;
 | 
					                exportCount = exportCount + exportPictures;
 | 
				
			||||||
                pictureCopyEnabled = true;
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QProgressDialog pbDialog(this);
 | 
				
			||||||
 | 
					            pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
 | 
				
			||||||
 | 
					            pbDialog.setWindowTitle(tr("Export selected..."));
 | 
				
			||||||
 | 
					            pbDialog.setLabelText(tr("Initializing export..."));
 | 
				
			||||||
 | 
					            pbDialog.setRange(0, exportCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
 | 
				
			||||||
 | 
					            pbBtn.at(0)->setDisabled(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QList<QProgressBar*> pbBar = pbDialog.findChildren<QProgressBar*>();
 | 
				
			||||||
 | 
					            pbBar.at(0)->setTextVisible(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ExportThread *exportThread = new ExportThread(widgets, exportDirectory, pictureCopyEnabled, pictureExportEnabled, exportCount);
 | 
				
			||||||
 | 
					            QObject::connect(exportThread, SIGNAL(exportStringUpdate(QString)), &pbDialog, SLOT(setLabelText(QString)));
 | 
				
			||||||
 | 
					            QObject::connect(exportThread, SIGNAL(exportProgressUpdate(int)), &pbDialog, SLOT(setValue(int)));
 | 
				
			||||||
 | 
					            QObject::connect(exportThread, SIGNAL(exportFinished()), &pbDialog, SLOT(close()));
 | 
				
			||||||
 | 
					            exportThread->start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pbDialog.exec();
 | 
				
			||||||
 | 
					            QStringList getFailedSavegames = exportThread->getFailedSavegames();
 | 
				
			||||||
 | 
					            QStringList getFailedCopyPictures = exportThread->getFailedCopyPictures();
 | 
				
			||||||
 | 
					            QStringList getFailedExportPictures = exportThread->getFailedExportPictures();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QString errorStr;
 | 
				
			||||||
 | 
					            QStringList errorList;
 | 
				
			||||||
 | 
					            errorList << getFailedExportPictures;
 | 
				
			||||||
 | 
					            errorList << getFailedCopyPictures;
 | 
				
			||||||
 | 
					            errorList << getFailedSavegames;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach (const QString &curErrorStr, errorList)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                errorStr.append(", " + curErrorStr);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (errorStr != "")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                errorStr.remove(0, 2);
 | 
				
			||||||
 | 
					                QMessageBox::warning(this, tr("Export selected"), tr("Export failed with...\n\n%1").arg(errorStr));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (exportThread->isFinished())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                exportThread->deleteLater();
 | 
				
			||||||
 | 
					                delete exportThread;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                QEventLoop threadFinishLoop;
 | 
				
			||||||
 | 
					                QObject::connect(exportThread, SIGNAL(finished()), &threadFinishLoop, SLOT(quit()));
 | 
				
			||||||
 | 
					                threadFinishLoop.exec();
 | 
				
			||||||
 | 
					                exportThread->deleteLater();
 | 
				
			||||||
 | 
					                delete exportThread;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
        // Counting the exports together
 | 
					    else
 | 
				
			||||||
        exportCount = exportCount + exportSavegames;
 | 
					    {
 | 
				
			||||||
        if (pictureExportEnabled && pictureCopyEnabled)
 | 
					        QMessageBox::information(this, tr("Export selected"), tr("No Snapmatic pictures or Savegames files are selected"));
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int exportPictures2 = exportPictures * 2;
 | 
					 | 
				
			||||||
            exportCount = exportCount + exportPictures2;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            exportCount = exportCount + exportPictures;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QProgressDialog pbDialog(this);
 | 
					 | 
				
			||||||
        pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
 | 
					 | 
				
			||||||
        pbDialog.setWindowTitle(tr("Export selected..."));
 | 
					 | 
				
			||||||
        pbDialog.setLabelText(tr("Initializing export..."));
 | 
					 | 
				
			||||||
        pbDialog.setRange(0, exportCount);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
 | 
					 | 
				
			||||||
        pbBtn.at(0)->setDisabled(true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QList<QProgressBar*> pbBar = pbDialog.findChildren<QProgressBar*>();
 | 
					 | 
				
			||||||
        pbBar.at(0)->setTextVisible(false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ExportThread *exportThread = new ExportThread(widgets, exportDirectory, pictureCopyEnabled, pictureExportEnabled, exportCount);
 | 
					 | 
				
			||||||
        QObject::connect(exportThread, SIGNAL(exportStringUpdate(QString)), &pbDialog, SLOT(setLabelText(QString)));
 | 
					 | 
				
			||||||
        QObject::connect(exportThread, SIGNAL(exportProgressUpdate(int)), &pbDialog, SLOT(setValue(int)));
 | 
					 | 
				
			||||||
        QObject::connect(exportThread, SIGNAL(exportFinished()), &pbDialog, SLOT(close()));
 | 
					 | 
				
			||||||
        exportThread->start();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        pbDialog.exec();
 | 
					 | 
				
			||||||
        QStringList getFailedSavegames = exportThread->getFailedSavegames();
 | 
					 | 
				
			||||||
        QStringList getFailedCopyPictures = exportThread->getFailedCopyPictures();
 | 
					 | 
				
			||||||
        QStringList getFailedExportPictures = exportThread->getFailedExportPictures();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QString errorStr;
 | 
					 | 
				
			||||||
        QStringList errorList;
 | 
					 | 
				
			||||||
        errorList << getFailedExportPictures;
 | 
					 | 
				
			||||||
        errorList << getFailedCopyPictures;
 | 
					 | 
				
			||||||
        errorList << getFailedSavegames;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        foreach (const QString &curErrorStr, errorList)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            errorStr.append(", " + curErrorStr);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (errorStr != "")
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            errorStr.remove(0, 2);
 | 
					 | 
				
			||||||
            QMessageBox::warning(this, tr("Export selected"), tr("Export failed with...\n\n%1").arg(errorStr));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (exportThread->isFinished())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            exportThread->deleteLater();
 | 
					 | 
				
			||||||
            delete exportThread;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            QEventLoop threadFinishLoop;
 | 
					 | 
				
			||||||
            QObject::connect(exportThread, SIGNAL(finished()), &threadFinishLoop, SLOT(quit()));
 | 
					 | 
				
			||||||
            threadFinishLoop.exec();
 | 
					 | 
				
			||||||
            exportThread->deleteLater();
 | 
					 | 
				
			||||||
            delete exportThread;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ProfileInterface::deleteSelected()
 | 
					void ProfileInterface::deleteSelected()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (QMessageBox::Yes == QMessageBox::warning(this, tr("Delete selected"), tr("You really want delete the selected content?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
 | 
					    if (selectedWidgts != 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        foreach (ProfileWidget *widget, widgets.keys())
 | 
					        if (QMessageBox::Yes == QMessageBox::warning(this, tr("Remove selected"), tr("You really want remove the selected Snapmatic picutres and Savegame files?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (widget->isSelected())
 | 
					            foreach (ProfileWidget *widget, widgets.keys())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (widget->getWidgetType() == "SnapmaticWidget")
 | 
					                if (widget->isSelected())
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
 | 
					                    if (widget->getWidgetType() == "SnapmaticWidget")
 | 
				
			||||||
                    SnapmaticPicture *picture = picWidget->getPicture();
 | 
					 | 
				
			||||||
                    QString fileName = picture->getPictureFileName();
 | 
					 | 
				
			||||||
                    if (!QFile::exists(fileName) || QFile::remove(fileName))
 | 
					 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        pictureDeleted_f(picWidget);
 | 
					                        SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
 | 
				
			||||||
 | 
					                        SnapmaticPicture *picture = picWidget->getPicture();
 | 
				
			||||||
 | 
					                        QString fileName = picture->getPictureFileName();
 | 
				
			||||||
 | 
					                        if (!QFile::exists(fileName) || QFile::remove(fileName))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            pictureDeleted_f(picWidget);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                    else if (widget->getWidgetType() == "SavegameWidget")
 | 
				
			||||||
                else if (widget->getWidgetType() == "SavegameWidget")
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SavegameWidget *sgdWidget = (SavegameWidget*)widget;
 | 
					 | 
				
			||||||
                    SavegameData *savegame = sgdWidget->getSavegame();
 | 
					 | 
				
			||||||
                    QString fileName = savegame->getSavegameFileName();
 | 
					 | 
				
			||||||
                    if (!QFile::exists(fileName) || QFile::remove(fileName))
 | 
					 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        savegameDeleted_f(sgdWidget);
 | 
					                        SavegameWidget *sgdWidget = (SavegameWidget*)widget;
 | 
				
			||||||
 | 
					                        SavegameData *savegame = sgdWidget->getSavegame();
 | 
				
			||||||
 | 
					                        QString fileName = savegame->getSavegameFileName();
 | 
				
			||||||
 | 
					                        if (!QFile::exists(fileName) || QFile::remove(fileName))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            savegameDeleted_f(sgdWidget);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					            if (selectedWidgts != 0)
 | 
				
			||||||
        if (selectedWidgts != 0)
 | 
					            {
 | 
				
			||||||
        {
 | 
					                QMessageBox::warning(this, tr("Remove selected"), tr("Failed at remove the complete selected Snapmatic pictures and/or Savegame files"));
 | 
				
			||||||
            QMessageBox::warning(this, tr("Delete selected"), tr("Failed at delete all selected content"));
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        QMessageBox::information(this, tr("Remove selected"), tr("No Snapmatic pictures or Savegames files are selected"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,9 @@
 | 
				
			||||||
   <string>Profile Interface</string>
 | 
					   <string>Profile Interface</string>
 | 
				
			||||||
  </property>
 | 
					  </property>
 | 
				
			||||||
  <layout class="QVBoxLayout" name="vlProfileInterface">
 | 
					  <layout class="QVBoxLayout" name="vlProfileInterface">
 | 
				
			||||||
 | 
					   <property name="spacing">
 | 
				
			||||||
 | 
					    <number>0</number>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
   <property name="leftMargin">
 | 
					   <property name="leftMargin">
 | 
				
			||||||
    <number>0</number>
 | 
					    <number>0</number>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
| 
						 | 
					@ -106,7 +109,7 @@
 | 
				
			||||||
            <x>0</x>
 | 
					            <x>0</x>
 | 
				
			||||||
            <y>0</y>
 | 
					            <y>0</y>
 | 
				
			||||||
            <width>398</width>
 | 
					            <width>398</width>
 | 
				
			||||||
            <height>251</height>
 | 
					            <height>257</height>
 | 
				
			||||||
           </rect>
 | 
					           </rect>
 | 
				
			||||||
          </property>
 | 
					          </property>
 | 
				
			||||||
          <layout class="QVBoxLayout" name="vlProfile">
 | 
					          <layout class="QVBoxLayout" name="vlProfile">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -176,8 +176,8 @@ void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QMenu contextMenu(this);
 | 
					    QMenu contextMenu(this);
 | 
				
			||||||
    QMenu exportMenu(tr("&Export"), this);
 | 
					    QMenu exportMenu(tr("&Export"), this);
 | 
				
			||||||
    exportMenu.addAction(tr("Export as &picture...", "Export as picture"), this, SLOT(on_cmdExport_clicked()));
 | 
					    exportMenu.addAction(tr("Export as &JPG picture"), this, SLOT(on_cmdExport_clicked()));
 | 
				
			||||||
    exportMenu.addAction(tr("Export for &import...", "Export for import"), this, SLOT(on_cmdCopy_clicked()));
 | 
					    exportMenu.addAction(tr("Export as >A Snapmatic"), this, SLOT(on_cmdCopy_clicked()));
 | 
				
			||||||
    contextMenu.addAction(tr("&View"), this, SLOT(on_cmdView_clicked()));
 | 
					    contextMenu.addAction(tr("&View"), this, SLOT(on_cmdView_clicked()));
 | 
				
			||||||
    contextMenu.addMenu(&exportMenu);
 | 
					    contextMenu.addMenu(&exportMenu);
 | 
				
			||||||
    contextMenu.addAction(tr("&Remove"), this, SLOT(on_cmdDelete_clicked()));
 | 
					    contextMenu.addAction(tr("&Remove"), this, SLOT(on_cmdDelete_clicked()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -166,7 +166,7 @@
 | 
				
			||||||
  </action>
 | 
					  </action>
 | 
				
			||||||
  <action name="actionExport_selected">
 | 
					  <action name="actionExport_selected">
 | 
				
			||||||
   <property name="text">
 | 
					   <property name="text">
 | 
				
			||||||
    <string>&Export selected</string>
 | 
					    <string>&Export selected...</string>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
   <property name="shortcut">
 | 
					   <property name="shortcut">
 | 
				
			||||||
    <string>Ctrl+E</string>
 | 
					    <string>Ctrl+E</string>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue