Example #1
0
FileView::FileView(QWidget* parent)
    : QWidget(parent),
      ui_(new Ui_FileView),
      model_(nullptr),
      undo_stack_(new QUndoStack(this)),
      task_manager_(nullptr),
      storage_(new FilesystemMusicStorage("/")) {
  ui_->setupUi(this);

  // Icons
  ui_->back->setIcon(IconLoader::Load("go-previous", IconLoader::Base));
  ui_->forward->setIcon(IconLoader::Load("go-next", IconLoader::Base));
  ui_->home->setIcon(IconLoader::Load("go-home", IconLoader::Base));
  ui_->up->setIcon(IconLoader::Load("go-up", IconLoader::Base));

  connect(ui_->back, SIGNAL(clicked()), undo_stack_, SLOT(undo()));
  connect(ui_->forward, SIGNAL(clicked()), undo_stack_, SLOT(redo()));
  connect(ui_->home, SIGNAL(clicked()), SLOT(FileHome()));
  connect(ui_->up, SIGNAL(clicked()), SLOT(FileUp()));
  connect(ui_->path, SIGNAL(textChanged(QString)),
          SLOT(ChangeFilePath(QString)));

  connect(undo_stack_, SIGNAL(canUndoChanged(bool)), ui_->back,
          SLOT(setEnabled(bool)));
  connect(undo_stack_, SIGNAL(canRedoChanged(bool)), ui_->forward,
          SLOT(setEnabled(bool)));

  connect(ui_->list, SIGNAL(activated(QModelIndex)),
          SLOT(ItemActivated(QModelIndex)));
  connect(ui_->list, SIGNAL(doubleClicked(QModelIndex)),
          SLOT(ItemDoubleClick(QModelIndex)));
  connect(ui_->list, SIGNAL(AddToPlaylist(QMimeData*)),
          SIGNAL(AddToPlaylist(QMimeData*)));
  connect(ui_->list, SIGNAL(CopyToLibrary(QList<QUrl>)),
          SIGNAL(CopyToLibrary(QList<QUrl>)));
  connect(ui_->list, SIGNAL(MoveToLibrary(QList<QUrl>)),
          SIGNAL(MoveToLibrary(QList<QUrl>)));
  connect(ui_->list, SIGNAL(CopyToDevice(QList<QUrl>)),
          SIGNAL(CopyToDevice(QList<QUrl>)));
  connect(ui_->list, SIGNAL(Delete(QStringList)), SLOT(Delete(QStringList)));
  connect(ui_->list, SIGNAL(EditTags(QList<QUrl>)),
          SIGNAL(EditTags(QList<QUrl>)));

  QString filter(FileView::kFileFilter);
  filter_list_ << filter.split(" ");
}
Example #2
0
void FileViewList::EditTagsSlot() { emit EditTags(UrlListFromSelection()); }
Example #3
0
/* 
 * Run a command from the menus.
 */
void RunCommand (Menu_Item_Type *i) {
  char *command;
  int must_redraw=0;
  Conditional_String *cs=NULL;
  Window_List_Type *this_window=CurrentWindow;

  if (i->command[0] != '\0') { /* don't try to run a null command */

    if (i->edit_flag) { /* edit command on fly */
      cs=EditTags(i->command);
      if (cs->ignore) { /* user hit escape */
	free(cs->value);
	free(cs);
	return;
      }
      else { /* user hit enter */
	command=malloc(strlen(cs->value)+1);
	strcpy(command,cs->value);
	free(cs->value);
	free(cs);
      }
    }
    else { /* don't edit command on fly */
      command=malloc(strlen(i->command)+1);
      strcpy(command,i->command);
    }

#ifdef SETENV_FLAG_OK
    if (i->setenv_flag) { /* a setenv command */
      RunSetenv(command);
    }
    else
#endif
      if (i->makemenu_flag) { /* process command output as rc file */
	ReadRc(command,RC_PREPROC);
	SanityCheckMenus();
	/*
	 * make sure that all modified menus currently on screen
	 * get recalced.
	 */
	while (this_window) {
	  if (this_window->menu->recalc) {
	    CalcMenu(this_window->menu);
	    must_redraw=1;
	  }
	  this_window=this_window->last;
	}
	if (must_redraw)
	  DrawAll();
      }
      else if (i->truncate_flag) { /* display in a window and truncate */
	RunShow(i->text,command,1);
      }
      else if (i->display_flag) {	/* display in a window and wrap. */
	RunShow(i->text,command,0);
      }
      else { /* normal display */
	if (! i->noclear_flag) {
				/* clear screen */
	  SLsmg_cls();
	  SLsmg_normal_video();
	  Screen_Reset();
#ifdef GPM_SUPPORT
	  EndMouse(); /* return to normal GPM/selection mode */
#endif
	}

	/* 
	 * This is what the whole pdmenu program comes down to.
	 * The rest is fluff. ;-) 
	 */

	/*
	 * start: Steve Blott ([email protected])
	 *
	 * add capability to exec() (rather than system()) a command, thereby
	 * replacing the current process;  if the first word of command is
	 * "exec", then exec() it, otherwise system() it
	 */

	char *cp = command;

        while (isspace(cp[0]))
	   cp++;

	if ( strncmp(cp, "exec", 4) == 0 && isspace(cp[4]) )
	{
	   char *cv[4]; /* command vector */
	   cv[0] = "sh";
	   cv[1] = "-c";
	   cv[2] = cp;
	   cv[3] = 0;
	   execvp(cv[0],cv);
	   /* should not reach here; if the execvp fails, then pdmenu will
	    * continue to run, silently ignoring the failure; if the execvp
	    * succeeds but the subsequent exec fails, then pdmenu will silently
	    * disappear (its process no longer exists), and no feedback will be
	    * received */
	}
	else
	   system(command);

	if (! i->noclear_flag) { /* redraw screen */
	  Screen_Init();
			
	  if (i->pause_flag) { /* pause 1st */
	    printf("\n%s",_("Press Enter to return to Pdmenu."));
	    fflush(stdout); /* make sure above is displayed. */
	    /* Now wait for the keypress. */
	    while (1) {
		    int k;
		    k = SLang_getkey();
		    if (k == '\n' || k == '\r') {
			    break;
		    }
	    }
	    SLang_flush_input(); /* kill any buffered input */
	    printf("\n");
	  }

#ifdef GPM_SUPPORT
	  gpm_ok=InitMouse(); /* grab mouse pointer again. */
#endif

	  /* 
	   * we need to account for the screen size changing behind our backs
	   * while the program was running.
	   */
	  SetScreensize();
	  Resize_Screen();
	  DrawAll();
	}
      }
    free(command);
  }
}