//static FileOperation* FileOperation::trashFiles(FmPathList* srcFiles, bool prompt, QWidget* parent) { if(prompt) { int result = QMessageBox::warning(parent, tr("Confirm"), tr("Do you want to move the selected files to trash can?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No); if(result != QMessageBox::Yes) return NULL; } FileOperation* op = new FileOperation(FileOperation::Trash, srcFiles); op->run(); return op; }
void FilePropsDialog::accept() { // applications if(mimeType && ui->openWith->isChanged()) { GAppInfo* currentApp = ui->openWith->selectedApp(); g_app_info_set_as_default_for_type(currentApp, fm_mime_type_get_type(mimeType), NULL); } // check if chown or chmod is needed guint32 newUid = uidFromName(ui->owner->text()); guint32 newGid = gidFromName(ui->ownerGroup->text()); bool needChown = (newUid != -1 && newUid != uid) || (newGid != -1 && newGid != gid); int newOwnerPermSel = ui->ownerPerm->currentIndex(); int newGroupPermSel = ui->groupPerm->currentIndex(); int newOtherPermSel = ui->otherPerm->currentIndex(); Qt::CheckState newExecCheckState = ui->executable->checkState(); bool needChmod = ((newOwnerPermSel != ownerPermSel) || (newGroupPermSel != groupPermSel) || (newOtherPermSel != otherPermSel) || (newExecCheckState != execCheckState)); if(needChmod || needChown) { FmPathList* paths = fm_path_list_new_from_file_info_list(fileInfos_); FileOperation* op = new FileOperation(FileOperation::ChangeAttr, paths); fm_path_list_unref(paths); if(needChown) { // don't do chown if new uid/gid and the original ones are actually the same. if(newUid == uid) newUid = -1; if(newGid == gid) newGid = -1; op->setChown(newUid, newGid); } if(needChmod) { mode_t newMode = 0; mode_t newModeMask = 0; // FIXME: we need to make sure that folders with "r" permission also have "x" // at the same time. Otherwise, it's not able to browse the folder later. if(newOwnerPermSel != ownerPermSel && newOwnerPermSel != ACCESS_NO_CHANGE) { // owner permission changed newModeMask |= (S_IRUSR|S_IWUSR); // affect user bits if(newOwnerPermSel == ACCESS_READ_ONLY) newMode |= S_IRUSR; else if(newOwnerPermSel == ACCESS_READ_WRITE) newMode |= (S_IRUSR|S_IWUSR); } if(newGroupPermSel != groupPermSel && newGroupPermSel != ACCESS_NO_CHANGE) { qDebug("newGroupPermSel: %d", newGroupPermSel); // group permission changed newModeMask |= (S_IRGRP|S_IWGRP); // affect group bits if(newGroupPermSel == ACCESS_READ_ONLY) newMode |= S_IRGRP; else if(newGroupPermSel == ACCESS_READ_WRITE) newMode |= (S_IRGRP|S_IWGRP); } if(newOtherPermSel != otherPermSel && newOtherPermSel != ACCESS_NO_CHANGE) { // other permission changed newModeMask |= (S_IROTH|S_IWOTH); // affect other bits if(newOtherPermSel == ACCESS_READ_ONLY) newMode |= S_IROTH; else if(newOtherPermSel == ACCESS_READ_WRITE) newMode |= (S_IROTH|S_IWOTH); } if(newExecCheckState != execCheckState && newExecCheckState != Qt::PartiallyChecked) { // executable state changed newModeMask |= (S_IXUSR|S_IXGRP|S_IXOTH); if(newExecCheckState == Qt::Checked) newMode |= (S_IXUSR|S_IXGRP|S_IXOTH); } op->setChmod(newMode, newModeMask); if(hasDir) { // if there are some dirs in our selected files QMessageBox::StandardButton r = QMessageBox::question(this, tr("Apply changes"), tr("Do you want to recursively apply these changes to all files and sub-folders?"), QMessageBox::Yes|QMessageBox::No); if(r == QMessageBox::Yes) op->setRecursiveChattr(true); } } op->setAutoDestroy(true); op->run(); } QDialog::accept(); }
// static FileOperation* FileOperation::changeAttrFiles(FmPathList* srcFiles, QWidget* parent) { //TODO FileOperation* op = new FileOperation(FileOperation::ChangeAttr, srcFiles); op->run(); return op; }
//static FileOperation* FileOperation::unTrashFiles(FmPathList* srcFiles, QWidget* parent) { FileOperation* op = new FileOperation(FileOperation::UnTrash, srcFiles); op->run(); return op; }
//static FileOperation* FileOperation::symlinkFiles(FmPathList* srcFiles, FmPath* dest, QWidget* parent) { FileOperation* op = new FileOperation(FileOperation::Link, srcFiles); op->setDestination(dest); op->run(); return op; }