void ImageManager::actionAddImage(){ bool ok; QString fileName, newName; #ifdef _OS_LINUX_ fileName = QFileDialog::getOpenFileName(this, tr("Open CD image file"), QDir::homePath(), tr("CD image files (*.iso *.nrg *.img *.bin *.mdf)")); #endif #ifdef _OS_FREEBSD_ fileName = QFileDialog::getOpenFileName(this, tr("Open ISO Image file"), QDir::homePath(), tr("iso files (*.iso)")); #endif if(!fileName.isEmpty()){ newName = fileName.split("/").last(); while (db_image.isExistsByName(newName)){ newName = QInputDialog::getText(this, tr("Sorry. It seems CD iamge already exists."), tr("Sorry. It seems CD image file already exists.<br>Please rename it, or cancel add image operation."), QLineEdit::Normal, fileName.split("/").last() , &ok); if (!ok){ return; } } if (!db_image.addImage(newName, fileName)) return; actionRefreshImageList(); } return; }
void ImageManager::loadThemeIcons(){ lblLogo->setPixmap(CoreLib->loadPixmap("data/iso_manager.png")); std::auto_ptr<QToolBar> managerToolBar (new QToolBar(tlbManager)); actionAdd.reset(managerToolBar->addAction (CoreLib->loadIcon("data/add.png"), tr("Add image"))); connect(actionAdd.get(), SIGNAL(triggered()), this, SLOT(actionAddImage())); actionRename.reset(managerToolBar->addAction (CoreLib->loadIcon("data/configure.png"), tr("Rename image"))); connect(actionRename.get(), SIGNAL(triggered()), this, SLOT(actionRenameImage())); managerToolBar->addSeparator (); actionRemove.reset(managerToolBar->addAction (CoreLib->loadIcon("data/remove.png"), tr("Remove image"))); connect(actionRemove.get(), SIGNAL(triggered()), this, SLOT(actionRemoveImage())); managerToolBar->addSeparator (); actionRefresh.reset(managerToolBar->addAction (CoreLib->loadIcon("data/reload.png"), tr("Refresh image list"))); connect(actionRefresh.get(), SIGNAL(triggered()), this, SLOT(actionRefreshImageList())); std::auto_ptr<QBoxLayout> layout (new QBoxLayout(QBoxLayout::TopToBottom)); layout->addWidget(managerToolBar.release()); layout->setMargin(0); layout->setSpacing(0); tlbManager->setLayout(layout.release()); return; }
void ImageManager::actionAddImage(){ bool ok; QString fileName, newName, fileFilter; #ifdef _OS_LINUX_ fileFilter = tr("Disc image files (*.iso *.ISO *.nrg *.NRG *.img *.IMG *.bin *.BIN *.mdf *.MDF);;All files (*)"); #endif #ifdef _OS_FREEBSD_ fileFilter = tr("ISO image files (*.iso *.ISO);;All files (*)"); #endif QFileDialog::Options options; if (CoreLib->getSetting("advanced", "useNativeFileDialog", false, 1)==0) options = QFileDialog::DontUseNativeDialog; fileName = QFileDialog::getOpenFileName(this, tr("Open ISO image file"), QDir::homePath(), fileFilter, 0, options); if(!fileName.isEmpty()){ newName = fileName.split("/").last(); while (db_image.isExistsByName(newName)){ newName = QInputDialog::getText(this, tr("Sorry. It seems that the CD image already exists."), tr("Sorry. It seems that the CD image file already exists.<br>Please rename it, or cancel add image operation."), QLineEdit::Normal, fileName.split("/").last() , &ok); if (!ok){ return; } } if (!db_image.addImage(newName, fileName)) return; actionRefreshImageList(); } return; }
void ImageManager::loadThemeIcons(){ std::unique_ptr<QToolBar> managerToolBar (new QToolBar(tlbManager)); actionAdd.reset(managerToolBar->addAction (CoreLib->loadIcon("document-new"), tr("Add image"))); connect(actionAdd.get(), SIGNAL(triggered()), this, SLOT(actionAddImage())); actionRename.reset(managerToolBar->addAction (CoreLib->loadIcon("document-properties"), tr("Rename image"))); connect(actionRename.get(), SIGNAL(triggered()), this, SLOT(actionRenameImage())); managerToolBar->addSeparator (); actionRemove.reset(managerToolBar->addAction (CoreLib->loadIcon("edit-delete"), tr("Remove image"))); connect(actionRemove.get(), SIGNAL(triggered()), this, SLOT(actionRemoveImage())); managerToolBar->addSeparator (); actionRefresh.reset(managerToolBar->addAction (CoreLib->loadIcon("view-refresh"), tr("Refresh image list"))); connect(actionRefresh.get(), SIGNAL(triggered()), this, SLOT(actionRefreshImageList())); std::unique_ptr<QBoxLayout> layout (new QBoxLayout(QBoxLayout::TopToBottom)); layout->addWidget(managerToolBar.release()); layout->setMargin(0); layout->setSpacing(0); tlbManager->setLayout(layout.release()); return; }
void ImageManager::actionRemoveImage(){ if (tableImage->currentRow()==-1) return; if (!db_image.delImage(tableImage->item(tableImage->currentRow(), 0)->text())) return; actionRefreshImageList(); return; }
void ImageManager::actionRenameImage(){ if (tableImage->currentRow()==-1) return; bool ok=false; QString newName = QInputDialog::getText(this, tr("Enter new name"), tr("Enter new name:"), QLineEdit::Normal, tableImage->item(tableImage->currentRow(), 0)->text(), &ok); while (db_image.isExistsByName(newName) or (newName.isEmpty())){ if (!ok){ return; } if (newName.isEmpty()){ newName = QInputDialog::getText(this, tr("Sorry. CD iamge name can not be empty."), tr("Sorry. CD iamge name can not be empty.<br>Please enter new name, or cancel rename image operation."), QLineEdit::Normal, newName, &ok); } else { newName = QInputDialog::getText(this, tr("Sorry. It seems CD iamge already exists."), tr("Sorry. It seems CD image file already exists.<br>Please rename it, or cancel rename image operation."), QLineEdit::Normal, newName, &ok); } } if (!db_image.renameImage(newName, tableImage->item(tableImage->currentRow(), 0)->text())) return; actionRefreshImageList(); return; }