diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf867f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +build*/ + +# Vim.gitignore +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist +*~ diff --git a/CMakeLists.txt b/CMakeLists.txt index 2241ded..d90c5e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(libfm-qt) set(LIBFM_QT_LIBRARY_NAME "fm-qt" CACHE STRING "fm-qt") set(LIBFM_QT_VERSION_MAJOR 0) -set(LIBFM_QT_VERSION_MINOR 10) +set(LIBFM_QT_VERSION_MINOR 11) set(LIBFM_QT_VERSION_PATCH 0) set(LIBFM_QT_VERSION ${LIBFM_QT_VERSION_MAJOR}.${LIBFM_QT_VERSION_MINOR}.${LIBFM_QT_VERSION_PATCH}) @@ -17,9 +17,9 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Actually, libtool uses different ways on different operating systems. So there is no # universal way to translate a libtool version-info to a cmake version. # We use "(current-age).age.revision" as the cmake version. -# current: 2, revision: 0, age: 0 => version: 2.0.0 -set(LIBFM_QT_LIB_VERSION "2.0.0") -set(LIBFM_QT_LIB_SOVERSION "2") +# current: 3, revision: 0, age: 0 => version: 3.0.0 +set(LIBFM_QT_LIB_VERSION "3.0.0") +set(LIBFM_QT_LIB_SOVERSION "3") set(REQUIRED_QT_VERSION "5.2") set(REQUIRED_LIBFM_VERSION "1.2.0") diff --git a/src/customaction_p.h b/src/customaction_p.h new file mode 100644 index 0000000..e3751f1 --- /dev/null +++ b/src/customaction_p.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 - 2015 Hong Jen Yee (PCMan) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef FM_CUSTOMACTION_P_H +#define FM_CUSTOMACTION_P_H + +namespace Fm { + +class CustomAction : public QAction { +public: + explicit CustomAction(FmFileActionItem* item, QObject* parent = NULL): + QAction(QString::fromUtf8(fm_file_action_item_get_name(item)), parent), + item_(reinterpret_cast(fm_file_action_item_ref(item))) { + const char* icon_name = fm_file_action_item_get_icon(item); + if(icon_name) + setIcon(QIcon::fromTheme(icon_name)); + } + + virtual ~CustomAction() { + fm_file_action_item_unref(item_); + } + + FmFileActionItem* item() { + return item_; + } + +private: + FmFileActionItem* item_; +}; + +} // namespace Fm + +#endif diff --git a/src/filemenu.cpp b/src/filemenu.cpp index f5692bd..2a1ff8d 100644 --- a/src/filemenu.cpp +++ b/src/filemenu.cpp @@ -28,6 +28,7 @@ #include "appchooserdialog.h" #ifdef CUSTOM_ACTIONS #include +#include "customaction_p.h" #endif #include #include @@ -184,6 +185,11 @@ void FileMenu::createMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd) GList* l; for(l=items; l; l=l->next) { FmFileActionItem* item = FM_FILE_ACTION_ITEM(l->data); + if(l == items && item + && !(fm_file_action_item_is_action(item) + && !(fm_file_action_item_get_target(item) & FM_FILE_ACTION_TARGET_CONTEXT))) { + addSeparator(); // before all custom actions + } addCustomActionItem(this, item); } } diff --git a/src/filemenu_p.h b/src/filemenu_p.h index 94376d8..73a6831 100644 --- a/src/filemenu_p.h +++ b/src/filemenu_p.h @@ -21,9 +21,6 @@ #define FM_FILEMENU_P_H #include "icontheme.h" -#ifdef CUSTOM_ACTIONS -#include -#endif #include namespace Fm { @@ -53,32 +50,6 @@ private: GAppInfo* appInfo_; }; -#ifdef CUSTOM_ACTIONS -class CustomAction : public QAction { - Q_OBJECT -public: - explicit CustomAction(FmFileActionItem* item, QObject* parent = NULL): - QAction(QString::fromUtf8(fm_file_action_item_get_name(item)), parent), - item_(reinterpret_cast(fm_file_action_item_ref(item))) { - const char* icon_name = fm_file_action_item_get_icon(item); - if(icon_name) - setIcon(QIcon::fromTheme(icon_name)); - } - - virtual ~CustomAction() { - fm_file_action_item_unref(item_); - } - - FmFileActionItem* item() { - return item_; - } - -private: - FmFileActionItem* item_; -}; - -#endif - } // namespace Fm #endif diff --git a/src/filesearch.ui b/src/filesearch.ui index 1cb466f..2919edb 100644 --- a/src/filesearch.ui +++ b/src/filesearch.ui @@ -261,22 +261,36 @@ - - - Larger than: - - - - - - + + + + + Smaller than: + + + + + + + false + + + + false - + + + + Larger than: + + + + false @@ -306,25 +320,7 @@ - - - - - - Smaller than: - - - - - - - - - false - - - - + false @@ -361,43 +357,50 @@ + + Qt::LeftToRight + Last Modified Time: - - - - Earlier than: - - - - - - Later than: - - - - - - - false - - - true - - - - - - - false - - - true - - + + + + + Earlier than: + + + + + + + Later than: + + + + + + + false + + + true + + + + + + + false + + + true + + + + diff --git a/src/filesearchdialog.cpp b/src/filesearchdialog.cpp index 022747e..4fc8699 100644 --- a/src/filesearchdialog.cpp +++ b/src/filesearchdialog.cpp @@ -41,6 +41,8 @@ FileSearchDialog::FileSearchDialog(QStringList paths, QWidget* parent, Qt::Windo connect(ui->addPath, &QPushButton::clicked, this, &FileSearchDialog::onAddPath); connect(ui->removePath, &QPushButton::clicked, this, &FileSearchDialog::onRemovePath); + + ui->namePatterns->setFocus(); } FileSearchDialog::~FileSearchDialog() { diff --git a/src/foldermenu.cpp b/src/foldermenu.cpp index bd1bb4a..fb74883 100644 --- a/src/foldermenu.cpp +++ b/src/foldermenu.cpp @@ -25,6 +25,10 @@ #include "folderview.h" #include "utilities.h" #include // for memset +#ifdef CUSTOM_ACTIONS +#include "customaction_p.h" +#include +#endif namespace Fm { @@ -68,6 +72,29 @@ FolderMenu::FolderMenu(FolderView* view, QWidget* parent): showHiddenAction_->setChecked(model->showHidden()); connect(showHiddenAction_, &QAction::triggered, this, &FolderMenu::onShowHiddenActionTriggered); +#ifdef CUSTOM_ACTIONS + FmFileInfo* folderInfo = view_->folderInfo(); + if(folderInfo) { + GList *single_list = NULL; + single_list = g_list_prepend(single_list, (GList*)folderInfo); + GList* items = fm_get_actions_for_files(single_list); + if(items) { + GList* l; + for(l=items; l; l=l->next) { + FmFileActionItem* item = FM_FILE_ACTION_ITEM(l->data); + if(l == items && item + && !(fm_file_action_item_is_action(item) + && !(fm_file_action_item_get_target(item) & FM_FILE_ACTION_TARGET_CONTEXT))) { + addSeparator(); // before all custom actions + } + addCustomActionItem(this, item); + } + } + g_list_foreach(items, (GFunc)fm_file_action_item_unref, NULL); + g_list_free(items); + } +#endif + separator4_ = addSeparator(); propertiesAction_ = new QAction(tr("Folder Pr&operties"), this); @@ -78,6 +105,46 @@ FolderMenu::FolderMenu(FolderView* view, QWidget* parent): FolderMenu::~FolderMenu() { } +#ifdef CUSTOM_ACTIONS +void FolderMenu::addCustomActionItem(QMenu* menu, FmFileActionItem* item) { + if(!item) return; + if(fm_file_action_item_is_action(item) && !(fm_file_action_item_get_target(item) & FM_FILE_ACTION_TARGET_CONTEXT)) + return; + + CustomAction* action = new CustomAction(item, menu); + menu->addAction(action); + if(fm_file_action_item_is_menu(item)) { + GList* subitems = fm_file_action_item_get_sub_items(item); + for(GList* l = subitems; l; l = l->next) { + FmFileActionItem* subitem = FM_FILE_ACTION_ITEM(l->data); + QMenu* submenu = new QMenu(menu); + addCustomActionItem(submenu, subitem); + action->setMenu(submenu); + } + } + else if(fm_file_action_item_is_action(item)) { + connect(action, &QAction::triggered, this, &FolderMenu::onCustomActionTrigerred); + } +} + +void FolderMenu::onCustomActionTrigerred() { + CustomAction* action = static_cast(sender()); + FmFileActionItem* item = action->item(); + + FmFileInfo* folderInfo = view_->folderInfo(); + if(folderInfo) { + GList *single_list = NULL; + single_list = g_list_prepend(single_list, (GList*)folderInfo); + char* output = NULL; + fm_file_action_item_launch(item, NULL, single_list, &output); + if(output) { + QMessageBox::information(this, tr("Output"), QString::fromUtf8(output)); + g_free(output); + } + } +} +#endif + void FolderMenu::addSortMenuItem(QString title, int id) { QAction* action = new QAction(title, this); sortMenu_->addAction(action); diff --git a/src/foldermenu.h b/src/foldermenu.h index fd2cbb4..8308153 100644 --- a/src/foldermenu.h +++ b/src/foldermenu.h @@ -25,6 +25,9 @@ #include #include #include "foldermodel.h" +#ifdef CUSTOM_ACTIONS +#include +#endif class QAction; @@ -87,6 +90,11 @@ public: return view_; } +protected: +#ifdef CUSTOM_ACTIONS + void addCustomActionItem(QMenu* menu, FmFileActionItem* item); +#endif + protected Q_SLOTS: void onPasteActionTriggered(); void onSelectAllActionTriggered(); @@ -97,6 +105,9 @@ protected Q_SLOTS: void onCaseSensitiveActionTriggered(bool checked); void onFolderFirstActionTriggered(bool checked); void onPropertiesActionTriggered(); +#ifdef CUSTOM_ACTIONS + void onCustomActionTrigerred(); +#endif private: void createSortMenu(); diff --git a/src/folderview.cpp b/src/folderview.cpp index 6814e49..e63a53f 100644 --- a/src/folderview.cpp +++ b/src/folderview.cpp @@ -473,6 +473,7 @@ void FolderView::setViewMode(ViewMode _mode) { if(mode == DetailedListMode) { FolderViewTreeView* treeView = new FolderViewTreeView(this); connect(treeView, &FolderViewTreeView::activatedFiltered, this, &FolderView::onItemActivated); + setFocusProxy(treeView); view = treeView; treeView->setItemsExpandable(false); @@ -492,6 +493,8 @@ void FolderView::setViewMode(ViewMode _mode) { connect(listView, &FolderViewListView::activatedFiltered, this, &FolderView::onItemActivated); view = listView; } + setFocusProxy(listView); + // set our own custom delegate FolderItemDelegate* delegate = new FolderItemDelegate(listView); listView->setItemDelegateForColumn(FolderModel::ColumnFileName, delegate);