Exemple #1
0
void FolderView::onFileClicked(int type, FmFileInfo* fileInfo) {
  if(type == ActivatedClick) {
    if(fileLauncher_) {
      GList* files = g_list_append(NULL, fileInfo);
      fileLauncher_->launchFiles(NULL, files);
      g_list_free(files);
    }
  }
  else if(type == ContextMenuClick) {
    FmPath* folderPath = path();
    QMenu* menu = NULL;
    if(fileInfo) {
      // show context menu
      if (FmFileInfoList* files = selectedFiles()) {
        Fm::FileMenu* fileMenu = new Fm::FileMenu(files, fileInfo, folderPath);
        fileMenu->setFileLauncher(fileLauncher_);
        prepareFileMenu(fileMenu);
        fm_file_info_list_unref(files);
        menu = fileMenu;
      }
    }
    else {
      FmFolder* _folder = folder();
      FmFileInfo* info = fm_folder_get_info(_folder);
      Fm::FolderMenu* folderMenu = new Fm::FolderMenu(this);
      prepareFolderMenu(folderMenu);
      menu = folderMenu;
    }
    if (menu) {
      menu->popup(QCursor::pos());
      connect(menu, SIGNAL(aboutToHide()), menu, SLOT(deleteLater()));
    }
  }
}
Exemple #2
0
void FolderView::onFileClicked(int type, FmFileInfo* fileInfo) {
  if(type == ActivatedClick) {
    if(fileLauncher_) {
      GList* files = g_list_append(nullptr, fileInfo);
      fileLauncher_->launchFiles(nullptr, files);
      g_list_free(files);
    }
  }
  else if(type == ContextMenuClick) {
    FmPath* folderPath = nullptr;
    FmFileInfoList* files = selectedFiles();
    if (files) {
      FmFileInfo* first = fm_file_info_list_peek_head(files);
      if (fm_file_info_list_get_length(files) == 1 && fm_file_info_is_dir(first))
        folderPath = fm_file_info_get_path(first);
    }
    if (!folderPath)
      folderPath = path();
    QMenu* menu = nullptr;
    if(fileInfo) {
      // show context menu
      if (FmFileInfoList* files = selectedFiles()) {
        Fm::FileMenu* fileMenu = new Fm::FileMenu(files, fileInfo, folderPath);
        fileMenu->setFileLauncher(fileLauncher_);
        prepareFileMenu(fileMenu);
        fm_file_info_list_unref(files);
        menu = fileMenu;
      }
    }
    else {
      Fm::FolderMenu* folderMenu = new Fm::FolderMenu(this);
      prepareFolderMenu(folderMenu);
      menu = folderMenu;
    }
    if (menu) {
      menu->exec(QCursor::pos());
      delete menu;
    }
  }
}