Пример #1
0
void View::onNewTab() {
  Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
  for(GList* l = fm_file_info_list_peek_head_link(menu->files()); l; l = l->next) {
    FmFileInfo* file = FM_FILE_INFO(l->data);
    Q_EMIT openDirRequested(fm_file_info_get_path(file), OpenInNewTab);
  }
}
Пример #2
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()));
    }
  }
}
Пример #3
0
void View::onOpenInTerminal() {
  Application* app = static_cast<Application*>(qApp);
  Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
  for(GList* l = fm_file_info_list_peek_head_link(menu->files()); l; l = l->next) {
    FmFileInfo* file = FM_FILE_INFO(l->data);
    app->openFolderInTerminal(fm_file_info_get_path(file));
  }
}
Пример #4
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;
    }
  }
}
Пример #5
0
void DesktopWindow::onStickToCurrentPos(bool toggled) {
  QAction* action = static_cast<QAction*>(sender());
  Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(action->parent());

  QModelIndexList indexes = listView_->selectionModel()->selectedIndexes();
  if(!indexes.isEmpty()) {
    FmFileInfo* file = menu->firstFile();
    QByteArray name = fm_file_info_get_name(file);
    QModelIndex index = indexes.first();
    if(toggled) { // remember to current custom position
      QRect itemRect = listView_->rectForIndex(index);
      customItemPos_[name] = itemRect.topLeft();
      saveItemPositions();
    }
    else { // cancel custom position and perform relayout
      QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name);
      if(it != customItemPos_.end()) {
        customItemPos_.erase(it);
        saveItemPositions();
        relayoutItems();
      }
    }
  }
}
Пример #6
0
void View::onNewWindow() {
  Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
  // FIXME: open the files in a new window
  Application* app = static_cast<Application*>(qApp);
  app->openFolders(menu->files());
}