From 4591188e01fb3c760f7a773ede30fa7bb7d53964 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Sat, 24 Sep 2016 12:14:45 +0200 Subject: [PATCH] Adding upstream version 0.11.1. --- .gitignore | 10 + CHANGELOG | 344 ++++++++++++++++++ CMakeLists.txt | 27 +- README.md | 30 +- cmake/FindXCB.cmake | 53 +++ src/CMakeLists.txt | 3 +- src/appchoosercombobox.cpp | 4 +- src/appchooserdialog.cpp | 4 +- src/appinfo.h | 0 src/appmenuview.cpp | 4 +- src/archiver.h | 143 ++++++++ src/bookmarks.h | 163 +++++++++ src/config.h | 152 ++++++++ src/deepcountjob.h | 128 +++++++ src/dirlistjob.h | 148 ++++++++ src/dirtreemodelitem.cpp | 16 +- src/dirtreeview.cpp | 6 +- src/dnddest.cpp | 6 +- src/dummymonitor.h | 35 ++ src/execfiledialog.cpp | 4 +- src/file.h | 153 ++++++++ src/fileinfo.h | 511 +++++++++++++++++++++++++++ src/fileinfojob.h | 138 ++++++++ src/filemenu.cpp | 12 +- src/fileoperation.cpp | 4 +- src/fileopsjob.h | 193 ++++++++++ src/fileopsjobchangeattr.h | 0 src/fileopsjobdelete.h | 0 src/fileopsjobxfer.h | 0 src/filepropsdialog.cpp | 4 +- src/filesearchdialog.cpp | 8 +- src/folder.h | 228 ++++++++++++ src/folderconfig.h | 198 +++++++++++ src/folderitemdelegate.cpp | 48 +-- src/folderitemdelegate.h | 2 +- src/foldermenu.cpp | 8 +- src/folderview.cpp | 41 +-- src/folderview.h | 6 +- src/icon.h | 168 +++++++++ src/job.h | 225 ++++++++++++ src/list.h | 153 ++++++++ src/mimetype.h | 163 +++++++++ src/monitor.h | 0 src/mountoperation.cpp | 4 +- src/mountoperationpassworddialog.cpp | 8 +- src/navhistory.h | 192 ++++++++++ src/path.h | 430 +++++++++++++++------- src/pathedit.cpp | 4 +- src/placesmodelitem.cpp | 16 +- src/proxyfoldermodel.cpp | 4 +- src/sidepane.cpp | 8 +- src/simplejob.h | 0 src/templates.h | 158 +++++++++ src/terminal.h | 143 ++++++++ src/thumbnailer.h | 158 +++++++++ src/thumbnailloader.cpp | 4 +- src/utilities.cpp | 4 +- src/{path.cpp => utils.h} | 19 +- src/xdndworkaround.cpp | 4 +- 59 files changed, 4432 insertions(+), 267 deletions(-) create mode 100644 .gitignore create mode 100644 CHANGELOG create mode 100644 cmake/FindXCB.cmake create mode 100644 src/appinfo.h create mode 100644 src/archiver.h create mode 100644 src/bookmarks.h create mode 100644 src/config.h create mode 100644 src/deepcountjob.h create mode 100644 src/dirlistjob.h create mode 100644 src/dummymonitor.h create mode 100644 src/file.h create mode 100644 src/fileinfo.h create mode 100644 src/fileinfojob.h create mode 100644 src/fileopsjob.h create mode 100644 src/fileopsjobchangeattr.h create mode 100644 src/fileopsjobdelete.h create mode 100644 src/fileopsjobxfer.h create mode 100644 src/folder.h create mode 100644 src/folderconfig.h create mode 100644 src/icon.h create mode 100644 src/job.h create mode 100644 src/list.h create mode 100644 src/mimetype.h create mode 100644 src/monitor.h create mode 100644 src/navhistory.h create mode 100644 src/simplejob.h create mode 100644 src/templates.h create mode 100644 src/terminal.h create mode 100644 src/thumbnailer.h rename src/{path.cpp => utils.h} (73%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f16c9c --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +build*/ +src/translations/libfm-qt + +# Vim.gitignore +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist +*~ diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..e9861f0 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,344 @@ + +libfm-qt-0.11.1 / 2016-09-24 +============================ + + * Bump version to 0.11.1 (#39) + * Fix Custom Actions Submenu (#38) + * Extend README.md + * Add C++ wrappers for libfm C APIs. + * Correct positioning of small icons in icon/thumbnail mode (#32) + * Silence new compiler warnings (#36) + * Adapt to QT_USE_QSTRINGBUILDER macro + * Fixes xcb linking error + * Use LXQtCompilerSettings cmake module + * Replaces deprecated QStyleOptionViewItemV4 + * Fix item text direction with RTL layout (#33) + * Set tabstops for mount operation password dialog (#31) + * Fix memory leak in file open menu (#29) + * Fixes https://github.com/lxde/pcmanfm-qt/issues/351. (#27) + * build: Use external translations + * ts-file removal (#26) + * Fix memory leaks in file menu (#25) + * Merge pull request #24 from philippwiesemann/fix-folder-menu-leak + * translations: fix four typos in messages (#23) + * Fix memory leak if restoring files from trash + * Fix rename dialog displaying source info twice + * Enable renaming in Properties dialog Fixes https://github.com/lxde/pcmanfm-qt/issues/324. + * Cancel indexing job when closing filepropsdialog + * Bump year + +0.11.0 / 2016-02-27 +=================== + + * Bump version number and ABI version and preparing for the initial release. + * Redirect focus operation on the folderview to the actual widget + * Use grid layout to have proper properties alignment + * Focus automatically on the first field of the filesearch dialog + * Add (folder) custom actions to foldermenu. + * Update czech translation (by Petr Balíček ) + * Fix compiling with Qt < 5.4 + * Add supports for freedesktop Xdnd direct save (XDS) protocol (closes #pcmanfm-qt/298). * Move Xdnd workarounds from pcmanfm-qt to libfm-qt. + * Protected FolderView methods for getting and setting item delegate margins + * Perform auto-completion for the path bar when the user press Tab key. This closes pcmanfm-qt/#201. + * Disable unused options in file search dialog + * Let the style engine draw the text selection rectangle. + * Fix file search with smaller than option + * Fix target language in Lithuanian translation file + * Fix memory leak if reading stream for image failed + * Update German translation + * Polish translation updated + * Polish translation updated + * Add a missing type casting to fix a compiler warning. + * Relicense libfm-qt to LGPL v.2.1. + * Avoid using blocking calls when initializing the trash can to speed up startup. + * Updated Russian translation Removed ru_RU file + * Create DnD menu with supported actions only + * make createAction public so can be hidden from view + * Adds Runtime and Devel install COMPONENT + * Quote everything that could break due to whitespaces + * Use CMake GenerateExportHeader to generate ABI header file + * Use no exceptions also with Clang + * Uses CMAKE_VISIBILITY and CMAKE_CXX_VISIBILITY flags + * Use QString() instead of "" + * Fix duplicated mtp mounts in the side pane by adding workarounds for potential bugs of gvfs. + * Replace g_io_scheduler which is deprecated with QThread in Fm::PathEdit. * Fix compiler warnings. + * Adds .gitignore + * Makes Release the default BUILD_TYPE + * Adds INSTALL package configuration file + * Removes XCB from the dependencies + * Adds target_include_directories() for the INSTALL_INTERFACE. + * Removes CMAKE_CURRENT_BINARY_DIR usage + * Removes QTX_INCLUDE_DIRS + * Removes Qt Creator .user file + * Updates libraries dependencies + * Adds REQUIRED_PACKAGE_VERSION variables + * Adds generation of TARGETS CMake file + * Creates and installs an package version file + * Renames and moves LIBRARY_NAME variable to the top CMakeLists + * Removes sub-project + * Rename the library to libfm-qt and fix installed header files. + * Split pcmanfm-qt into two parts and move libfm-qt to its own repository. + * Update French translation + * Italian translation updates + * Fix a crash triggered when unmounting a volume from the side pane. + * Avoid duplicated volumes and mounts in the side panel. (This fixes the mtp:// problem.) + * Fix missing null pointer check in Fm::Path::parent() and use nullptr instead of NULL in path.h. + * Code cleanup, «using» directive only if necessary + * Upgrade of pcmanfm-qt to C++11 + * hu translations updated + * Fixed several problems with item selection and alignment + * Remove unnecessary qDebug traces + * Update translations. + * The signal QAbstractItemView::iconSizeChanged is only available after Qt 5.5. Add workarounds for older Qt versions. + * Add more null pointer checks in the thumbnail loader to avoid crashes caused by older versions of libfm. + * Update translations + * Avoid the column resizing tricks for the detailed list view when the view contains no columns. + * Improve the column width computation for the detailed view + * PlacesView: activate on click on the second column + * SidePane: reduce size of button's column width + * Added a filterbar + Handle virtually hidden files + * Russian translation update + * Update cs_CZ translation with the strings provided by petrbal in pull request #218. + * Allow adding or removing paths in the file search dialog. Fix bugs in searching for documents. + * Try to implement file searching by using the new Fm::FileSearchDialog class. + * Fix a incorrecy free() in fm_search_free() API. + * Add Fm::Path::take() API to take the ownership of a raw FmPath pointer. + * Add class Fm::FileSearchDialog used to show a dialog for searching files. + * Add FmSearch API which is used to build a search:// URI. (implemented in C and might become part of libfm later). + * Fix #195 - Crash when rightclick on item in trash. + * Add a null check for FmFileInfo in Fm::ProxyFolderModel::lessThan(). This closes #205. + * Fix (workaround) for right-click crash in placesview. + * Russian translation: update + * Italian translation: add desktop entry files, adjust TS files + * placesview: middle-click correct item to activate (fix of segfault) + * Check for null pointers. + * Select the folder from where we have gone up. + * Paste into folder from its context menu. + * libfm-qt: updated german translation + * libfm-qt: lupdated translation files + * Add Greek (el) translation + * added support for mouse back/forward buttons + * Update German translation + * Add new signal prepareFileMenu() to Fm::SidePane and Fm::DirTree so there's a chance to customize the file menu before its shown. + * Port some missing config options from the gtk+ version of pcmanfm. + * Also show hidden dirs in the directory tree when the "Show Hidden" option in the menu is turned on. + * Fix #190 - Column layout is not always updated. + * Create New menu actions, context menu in tree side pane, #163. + * Store side pane mode setting, #157. + * Fixes an translation regression + * Updates translations + * Uses LXQt lxqt_translate_ts() to handle translations + * Fix lxde/lxqt#447 - missing actions in Places' context menus + * Remove trailing whitespaces + * polishing German translation + * Add menu items and shortcuts for new folder and blank file, fixes #163. + * Display folders first when active and sort order descending, fixes #179. + * Avoid space wasted by incorrect decoration in detailed view columns, fixes #177. + * Avoid flickering column header while resizing manually, fixes #176. + * Hungarian translation + * Fix #627 - long startup time. (This blocking is caused by checking the availability of "network:///".) + * Enable text selection in file properties dialog + * Fix some memory leaks reported by valgrind. + * Fix warnings reported by cppcheck. + * Fix warnings reported by scan-build. + * Sort indicators in detailed view, store column and order in settings, fixes #109. + * Fix lxde/lxqt#512 - pcmanfm-qt: cannot delete to trash. + * Polish translations added + * Use 'user-trash' icon for 'Move to Trash' + * The "Custom" option in the application chooser combo box inside file properties dialog is broken. Fix by preventing recursive signal handler invocation. + * The file property dialog does not show correct default applications. Fix a bug in AppChooserComboBox::setMimeType() that does incorrect app comparison. + * When converting an UID or GID to its name, show the number as string when the user or group does not exists. + * Add more null checks. + * Portuguese update + * Add very basic "remaining time" display to the progress dialog. Fix lxde/lxqt#463 - Progress dialog of pcmanfm-qt does not show remaining time. + * Fix lxde/pcmanfm-qt#120 - Foucs "Rename" button when file name changed. + * Remove unnecessary '\n' charactor from the translated strings. + * Fix translations (the newly added string comes from the translation of libfm). + * Improve trash can handling: provide an option to delete the files if moving to trashcan fails. + * Fix broken filenames of translation files. + * More migration to Qt5 new signal/slot syntax for better type safety & speed. + * Migrade to new Qt5 signal/slot syntax for better type safety and speed. + * Fix the broken sorting option. + * Fix lxde/lxqt#448 - PCmanFM-QT renaming place bookmarks does nothing. + * Support linguistic sorting of file names. This fixes #105. + * Update the folder model & view after files are changed. + * Open folders in new tabs by middle clicking on items in the side pane. + * Portuguese update + * Fix a crash of the context menu of places view caused by change of items. + * Save the result of "Edit bookmarks" to gtk+3 bookmarks file instead of the deprecated ~/.gtkbookmarks file. This fixes bug #112 partially. + * Add spanish translations + * Update Japanese translation + * Add German translation + * add Japanese translation + * Implement "UnTrash" for files in trash:/// and close lxde/lxqt#136. + * Add Russian translation + * Drop Qt4 support in code + * Clean up CMakeLists.txt and drop Qt4 support + * New files added from LXDE Pootle server based on templates + * Commit from LXDE Pootle server by user Julius22.: 1007 of 1008 strings translated (2 need review). + * Commit from LXDE Pootle server by user Julius22.: 709 of 1008 strings translated (2 need review). + * Commit from LXDE Pootle server by user mbouzada.: 364 of 364 strings translated (0 need review). + * New files added from LXDE Pootle server based on templates + * Add cs_CZ translation for libfm-qt. + * Commit from LXDE Pootle server by user dforsi.: 364 of 364 strings translated (0 need review). + * Commit from LXDE Pootle server by user dforsi.: 358 of 364 strings translated (0 need review). + * Bump package version number and library soversion to prepare for 0.2 release. + * Fix #85 - Scrolling doesn't work in compact view. + * Hide UI elements that are not usable and disable trash can when gvfs is not available. * Add new API Fm::isUriSchemeSupported(). + * Avoid showing the popup menu when moving desktop items. + * Improve handling of file selection and fixing FolderView::selectAll(), which is reported in #45. Delay the handling of selectionChanged() signal to avoid too frequent UI updates. + * Little adjustment for the grid of the folder view to decrease unnecessary margins. + * Use a new way to optimize the size of filename display based on current view mode and font size. This also fixes lxde/lxde-qt #198 - PCmanFM-qt incorrectly displays 256x256 Thumbnails. + * Fully support single click activation and auto-selection with associated options added to the preference dialog. + * Add single click and auto-selection on hover support to Fm::FolderView. + * New files added from LXDE Pootle server based on templates + * New files added from LXDE Pootle server based on templates + * Improve update of translations to avoid unnecessary regeneration of ts files. + * Improve handling of fallback icons. This closes bug #57. + * Translations are lost accidentally in a previous commit. Restore them all. + * Fix a crash in Fm::PlacesModel when gvfs is not available. This closes bug #35 - Ctrl+W closes all windows. + * Do not detect filename extension and select the whole filename by default while renaming directories. This closes bug #71 - Don't try to detect extensions on directories. * API changed: Fm::renameFile() now accepect FmFileInfo as its first parameter. + * Fix bug #80 - make execute in context menu doesn't do change permissions. + * Revert "fixed selection issue #45" This patch breaks copying files by DND in icon view mode and moving desktop icons. + * Use qss instead of QPalette to set the background color of ColorButton. This fixed bug #192 of lxde-qt. + * Rename the library from libfm-qt to libfm-qt5 when built with Qt5. + * fixed selection issue #45 + * Fix middle click position calculation in detailed view mode + * Fix crash when context menu is requested but selection is empty + * Activate view items only if clicked with left mouse button + * Do not emit activated signal when keyboard modifiers are on. + * Splits the checks for needed libraries + * Removes duplicated include_directories() entry + * Make sure clang compiler does not complain + * Install pkgconfig file of libfm-qt to correct location in FreeBSD + * Fix missing return values in several methods. + * Avoid endless popups of error dialogs when there are errors launching files. + * Save thumbnails as png files correctly. + * Remember custom positions for desktop icons and fix #29. + * Add template support to the folder context menus and fix #39. + * Show "owner" in the detailed list view mode. * Fix a crash when switching to detailed list mode in qt5. + * Use xcb to set EWMH window type hint to the desktop window in Qt5. * Some more cleanup for the CMakeList.txt files + * Add initial support for Qt5. + * Try to fix #36 again. + * Fix a seg fault caused by the widget being deleted during glib signal handling. + * Code cleanup, removing unnecessary header inclusion to speed up compilation. + * Avoid further handling of MountOperation in the gio finished callback if the object is deleted. + * Use modeless dialogs for app chooser and error reporting in Fm::FileLauncher and Fm::FileMenu. + * Add an small emblem for symlinks (using icon name "emblem-symbolic-link"). Fix bug #27. + * Add missing file to git. + * Move internal implementation details to private headers which are not installed to the system. + * Implement Fm::AppChooserDialog and Fm::AppMenuView classes. * Add / menu item to Fm::FileMenu. * Add custom app to Fm::AppChooserComboBox. + * Add Fm::AppChooserComboBox and use it in Fm::FilePropsDialog. + * Redesign Fm::FileLauncher APIs to make it more usable. * Add Fm::FileMenu::setFileLauncher() and Fm::FolderView::setFileLauncher() APIs. * Move PCManFM::View::onFileClick() and other popup menu handling to Fm::FolderView. + * Improve Fm::FileLaucher to make it easy to derive subclasses. * Implement a special dialog for opening executable files (Fix bug #13 - it does not launch executables) + * Fix bug #28 - Tash can icon does not refresh when the trash can changes its empty/full status + * Load autocompletion list for Fm::PathEdit only when the widget has the keyboard focus to avoid unnecessary I/O. + * Add proper popup menu items for selected folders and fix #20 and #19. * Some code refactors, adding openFolders() and openFolderInTerminal() to Application class. + * Fix #25 - Amount of items in the folder is not refreshed when the folder content changes. * Update status bar text properly on switching tab pages, selection changes, and folder content changes. + * Fix the broken compiler definitions caused by previous commit. + * Fix bug #22 - Do not select file extension by default on file rename. * Avoid installing private headers (*_p.h files) + * Setup pcmanfm-qt to support optional Custom Actions Menubar detects if libfm was built with vala or not if so a fm-actions.h will exist and support will be compiled in if not, will still compile with no actions menu + * Allow installation path configuration with standard CMake X_INSTALL_DIR + * Support reordering bookmark items in the places view with DND. + * Support adding bookmarks to the places view using drag and drop + * Preparing for implementing dnd for places view. + * Improve the usability of icon view mode, fixing github bug #24. + * Fix crashes caused by invalid pointer access. + * Switch current dir of the folder view correctly with dir tree view in the side pane. + * Finish chdir operation for Fm::DirTreeView. + * Support hiding hidden folders from DirTreeModel. + * Move some methods from DirTreeModel to DirTreeModelItem and fix some row updating problems. + * Implement dynamic folder loading/unloading when expanding or collapsing dir tree nodes. * Enable horizontal scrollbar of dir tree view. + * Move some code from Fm::DirTreeModel to Fm::DirTreeModelItem. + * Partially implement Fm::DirTreeView and Fm::DirTreeModel. (not finished yet) + * Fix an invalid pointer + * Implment different modes for Fm::SidePane, matching libfm-qtk design. * Add basic skeleton for dir tree view/model. + * Fix the cosmetic defect introduced by the eject buttons in the places view. + * Add eject buttons to mounted volumes in the places side pane. + * Add a wrapper class Fm::Path for FmPath C struct. + * Initialize icon_ member of PlacesModelItem correctly. + * Fix fallback icon when a platform plugin is abscent. * Make Fm::IconTheme::checkUpdate() a static function. + * Remove xsettings support. Use a cleaner way to detect config changes by monitor StyleChange events. * Add Fm::IconTheme::changed() signal which is emitted when the icon theme name is changed. * Replace nested Fm::PlacesModel::Item and related classes with their own separate toplevel classes. + * Fix the icon for files of unknown mime types, again. + * Fix the icon for files of unknown mime types. + * Add DES-EMA custom actions to the popup menus. + * Make it safe to create multiple Fm::LibFmQt objects and only initialize libfm once. + * Fix incorrect export symbols and use GNUInstallDirs for installation destination + * Use the latest libfm thumbnailer APIs. + * Fix #3614873 - Thumbnails in icon view shown upside down for some jpegs. + * Adopt recent changes of libfm. FmIcon is essentially identical to GIcon now. + * Add a UI file for application chooser dialog. + * Correctly handle display names of folders in path entry auto-completion. + * Add a global header and add proper definition for LIBFM_QT_API macro. + * Add "Empty trash" and fix a memory leak. + * Fix memory leaks for bookmarks. Fix the broken "Network" item in places. + * Reduce memory usage: Paint the folder items with our own code instead of using a dirty hacks duplicating pixmaps. + * Reduce of size of QPixmapCache in the hope of decreasing memory usage. + * Add fallback icons for places item "applications" and "network". + * Add class Fm::CachedFolderModel, a convinient way to share Fm::FolderModel objects and reduce memory usage. + * Resize the columns of detailed list view when items are inserted or removed. + * Optimize column widths in detailed list mode when the view is resized. + * Only show thumbnails for the first column in detailed list mode. + * Use new "automoc" feature of cmake 2.8.6 and remove cumbersome #include "*.moc" code. + * Trivial fix. + * Add additional custom filter support to ProxyFolderModel. + * Fix some memory leaks. + * Fix some compiler errors and update translations. + * Support the latest libfm trunk. Remove -fpermissive compiler flag and fix compiler errors/warnings. + * Adopt new libfm thumbnail APIs. + * Add soname 0.0.0 for libfm-qt, preparing for 0.1 release. + * Fix crashes caused by incorrect deletion of dialog objects. + * Enable thumbnail related settings. + * Update zh_TW translations and translation templates. + * Add Portuguese translation (pt). + * Add Lithuanian translation (lt_LT). + * Adopt the latest thumbnail API in libfm (thumbnail branch) to speed up loading. + * Workardound incorrect thumbnail painting caused by bug of QStyledItemDelegate. :-( + * Fix a crash caused by accessing data for invalid model index. + * Fix a crash caused by accessing data for invalid model index. + * Add basic thumbnail support (need the latest thumbnail branch of libfm). + * Add archiver integration for file context menus. + * Add archiver integration to file context menus. + * Add mnemonics for menu items. Make confirm dialog before delete and trash can optional. + * Update side pane according to current dir. Little fix. + * Implement "Open in Terminal" and "Open as Root". + * Implement "Auto Run" for newly inserted removable devices. + * Add "Edit Bookmarks" dialog. + * Implement "Invert Selection". Little fix of UI, add a Tool menu to main window. + * Implement "Create New" menu in the folder popup menu. + * Modify make rules for translations. Avoid deleting generated ts files when "make clean". Fix a small error in zh_TW translation. + * Add auto-completion to path entry bar. + * Rename Fm::Application to Fm::LibFmQt to decrease confusion. Set required Qt version to 4.6. + * Load translation files correctly for pcmanfm-qt and libfm-qt. + * Add basic skeleton for i18n (using Qt QTranslator & Qt Linguist). + * Add separate CMakeLists.txt files for pcmanfm and libfm-qt. Hide more implementation details from libfm-qt headers. + * Fix copyright notice in all source files. + * Install a pkgconfig file for libfm-qt for use in other projects. + * Fix a memory error caused by incorrect array size. Fix incorrect spacing of icons. + * Finish chown and chmod supports. + * Try to add file opermission settings UI. + * Implement very basic drag and drop support. + * Supress the incorrect default dnd handling of QListView. + * Try to implement Dnd. + * Finish desktop preferences. + * Improve desktop preferences and apply settings (partially done). + * Add desktop preferences dialog. + * Apply side pane icon size correctly. Add basic skeleton for archiver integration. + * Set shortcuts for frequently used menu options. Implement "rename file" support. Hide tabs when there is only one tab left (optional). + * Delete windows properly when they're closed with setAttribute(Qt::WA_DeleteOnClose); Apply settings to windows after clicking OK in the preference dialog. + * Improve preferences dialog. Change base class of SidePane to QWidget. + * Sync the state of folder popup menu and main menu bar. + * Implement sort options for main window. + * Fix file sorting options for Fm::FolderMenu. + * Correctly implement browse history and fix crashes. + * Add very simple browse history (back/forward) handling. + * Apply gcc visiblility attributes to export less symbols. + * Correctly handle file rename/overwrite during file operations. + * Exclude unnecessary files from CPack. + * Improve folder popup menu. + * Add folder popup menu. Some UI polishing. + * Fix a little crash. + * Fix crashes when turning off desktop manager. + * Show popup menu for blank area of folders. + * Do some refactor to make Fm::FolderView cleaner. Add PCManFM::View to do file manager-specific operations. + * Move files for libfm-qt and pcmanfm-qt to separate subdirs. diff --git a/CMakeLists.txt b/CMakeLists.txt index 886e811..8ba59ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(LIBFM_QT_LIBRARY_NAME "fm-qt" CACHE STRING "fm-qt") set(LIBFM_QT_VERSION_MAJOR 0) set(LIBFM_QT_VERSION_MINOR 11) -set(LIBFM_QT_VERSION_PATCH 0) +set(LIBFM_QT_VERSION_PATCH 1) set(LIBFM_QT_VERSION ${LIBFM_QT_VERSION_MAJOR}.${LIBFM_QT_VERSION_MINOR}.${LIBFM_QT_VERSION_PATCH}) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -32,6 +32,8 @@ endif() find_package(Qt5Widgets "${REQUIRED_QT_VERSION}" REQUIRED) find_package(Qt5LinguistTools "${REQUIRED_QT_VERSION}" REQUIRED) find_package(Qt5X11Extras "${REQUIRED_QT_VERSION}" REQUIRED) +find_package(XCB REQUIRED) + #Note: no run-time dependency on liblxqt, just a build dependency for lxqt_translate_ts/desktop find_package(lxqt REQUIRED) @@ -40,7 +42,6 @@ pkg_check_modules(SYSTEM_LIBS REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 - xcb ) pkg_check_modules(LIBFM REQUIRED libfm>="${REQUIRED_LIBFM_VERSION}") @@ -52,6 +53,7 @@ include(GenerateExportHeader) include(CMakePackageConfigHelpers) include(LXQtTranslateTs) include(LXQtTranslateDesktop) +include(LXQtCompilerSettings NO_POLICY_SCOPE) add_definitions(-DQT_NO_KEYWORDS) @@ -59,27 +61,6 @@ add_definitions(-DQT_NO_KEYWORDS) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -if (CMAKE_VERSION VERSION_LESS "3.1") - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - else() - CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) - # -std=c++0x is deprecated but some tools e.g. qmake or older gcc are still using it - if(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - else() - message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} does not support c++11/c++0x") - endif() - endif() -else() - set(CMAKE_CXX_STANDARD 11) -endif() - -if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}") -endif() set(CMAKE_AUTOMOC TRUE) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/README.md b/README.md index 4340134..2db18f9 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,27 @@ # libfm-qt -Includes libfm-qt, the Qt port of the libfm - a library providing components to -build desktop file managers. +## Overview -Issue tracker: - https://github.com/lxde/pcmanfm-qt/issues +libfm-qt is the Qt port of libfm, a library providing components to build desktop file managers which belongs to [LXDE](http://lxde.org). -LXQt website: - http://lxqt.org +libfm-qt is licensed under the terms of the [LGPLv2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) or any later version. See file LICENSE for its full text. -LXDE website: - http://lxde.org +## Installation +### Compiling source code -# License +Runtime dependencies are qtx11extras and libfm ≥ 1,2 (not all features are provided by libfm-qt yet). +Additional build dependencies are CMake and optionally Git to pull latest VCS checkouts. The localization files were outsourced to repository [lxqt-l10n](https://github.com/lxde/lxqt-l10n) so the corresponding dependencies are needed, too. Please refer to this repository's `README.md` for further information. -libfm-qt is licensed under the terms of the -[LGPLv2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) or any later version. +Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` has to be set to `/usr` on most operating systems, depending on the way library paths are dealt with on 64bit systems variables like `CMAKE_INSTALL_LIBDIR` may have to be set as well. -See the LICENSE file for the full text of the license. +To build run `make`, to install `make install` which accepts variable `DESTDIR` as usual. + +### Binary packages + +Official binary packages are available in Arch Linux, Debian (as of Debian stretch) and openSUSE (Leap 42.1 and Tumbleweed). +The library is still missing in Fedora which is providing version 0.10.0 of PCManFM-Qt only so far. This version was still including the code outsourced into libfm-qt later so libfm-qt will have to be provided by Fedora, too, as soon as the distribution upgrades to PCManFM-Qt ≥ 0.10.1. + +## Development + +Issues should go to the tracker of PCManFM-Qt at https://github.com/lxde/pcmanfm-qt/issues. diff --git a/cmake/FindXCB.cmake b/cmake/FindXCB.cmake new file mode 100644 index 0000000..98445bc --- /dev/null +++ b/cmake/FindXCB.cmake @@ -0,0 +1,53 @@ +#.rst: +# FindXCB +# ------- +# +# Find XCB libraries +# +# Tries to find xcb libraries on unix systems. +# +# - Be sure to set the COMPONENTS to the components you want to link to +# - The XCB_LIBRARIES variable is set ONLY to your COMPONENTS list +# - To use only a specific component check the XCB_LIBRARIES_${COMPONENT} variable +# +# The following values are defined +# +# :: +# +# XCB_FOUND - True if xcb is available +# XCB_INCLUDE_DIRS - Include directories for xcb +# XCB_LIBRARIES - List of libraries for xcb +# XCB_DEFINITIONS - List of definitions for xcb +# +#============================================================================= +# Copyright (c) 2015 Jari Vetoniemi +# +# Distributed under the OSI-approved BSD License (the "License"); +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +include(FeatureSummary) +set_package_properties(XCB PROPERTIES + URL "http://xcb.freedesktop.org/" + DESCRIPTION "X protocol C-language Binding") + +find_package(PkgConfig) +pkg_check_modules(PC_XCB QUIET xcb ${XCB_FIND_COMPONENTS}) + +find_library(XCB_LIBRARIES xcb HINTS ${PC_XCB_LIBRARY_DIRS}) +find_path(XCB_INCLUDE_DIRS xcb/xcb.h PATH_SUFFIXES xcb HINTS ${PC_XCB_INCLUDE_DIRS}) + +foreach(COMPONENT ${XCB_FIND_COMPONENTS}) + find_library(XCB_LIBRARIES_${COMPONENT} ${COMPONENT} HINTS ${PC_XCB_LIBRARY_DIRS}) + list(APPEND XCB_LIBRARIES ${XCB_LIBRARIES_${COMPONENT}}) + mark_as_advanced(XCB_LIBRARIES_${COMPONENT}) +endforeach(COMPONENT ${XCB_FIND_COMPONENTS}) + +set(XCB_DEFINITIONS ${PC_XCB_CFLAGS_OTHER}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(XCB DEFAULT_MSG XCB_LIBRARIES XCB_INCLUDE_DIRS) +mark_as_advanced(XCB_INCLUDE_DIRS XCB_LIBRARIES XCB_DEFINITIONS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e4a056..f6ceea0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ include_directories( "${LIBFM_INCLUDEDIR}/libfm" # to workaround incorrect #include in fm-actions. "${LIBMENUCACHE_INCLUDE_DIRS}" "${SYSTEM_LIBS_INCLUDE_DIRS}" + "${XCB_INCLUDE_DIRS}" ) link_directories( @@ -49,7 +50,6 @@ set(libfm_SRCS dndactionmenu.cpp editbookmarksdialog.cpp thumbnailloader.cpp - path.cpp execfiledialog.cpp appchoosercombobox.cpp appmenuview.cpp @@ -112,6 +112,7 @@ target_link_libraries(${LIBFM_QT_LIBRARY_NAME} ${LIBFM_LIBRARIES} ${LIBMENUCACHE_LIBRARIES} ${SYSTEM_LIBS_LIBRARIES} + ${XCB_LIBRARIES} ) # set libtool soname diff --git a/src/appchoosercombobox.cpp b/src/appchoosercombobox.cpp index 5420930..bdd6cfe 100644 --- a/src/appchoosercombobox.cpp +++ b/src/appchoosercombobox.cpp @@ -26,11 +26,11 @@ namespace Fm { AppChooserComboBox::AppChooserComboBox(QWidget* parent): QComboBox(parent), - defaultApp_(NULL), + mimeType_(NULL), appInfos_(NULL), + defaultApp_(NULL), defaultAppIndex_(-1), prevIndex_(0), - mimeType_(NULL), blockOnCurrentIndexChanged_(false) { // the new Qt5 signal/slot syntax cannot handle overloaded methods by default diff --git a/src/appchooserdialog.cpp b/src/appchooserdialog.cpp index 0a2b19d..c331c7e 100644 --- a/src/appchooserdialog.cpp +++ b/src/appchooserdialog.cpp @@ -27,10 +27,10 @@ namespace Fm { AppChooserDialog::AppChooserDialog(FmMimeType* mimeType, QWidget* parent, Qt::WindowFlags f): QDialog(parent, f), + ui(new Ui::AppChooserDialog()), mimeType_(NULL), - selectedApp_(NULL), canSetDefault_(true), - ui(new Ui::AppChooserDialog()) { + selectedApp_(NULL) { ui->setupUi(this); connect(ui->appMenuView, &AppMenuView::selectionChanged, this, &AppChooserDialog::onSelectionChanged); diff --git a/src/appinfo.h b/src/appinfo.h new file mode 100644 index 0000000..e69de29 diff --git a/src/appmenuview.cpp b/src/appmenuview.cpp index 6804120..c66dc86 100644 --- a/src/appmenuview.cpp +++ b/src/appmenuview.cpp @@ -26,10 +26,10 @@ namespace Fm { AppMenuView::AppMenuView(QWidget* parent): + QTreeView(parent), model_(new QStandardItemModel()), menu_cache(NULL), - menu_cache_reload_notify(NULL), - QTreeView(parent) { + menu_cache_reload_notify(NULL) { setHeaderHidden(true); setSelectionMode(SingleSelection); diff --git a/src/archiver.h b/src/archiver.h new file mode 100644 index 0000000..9688327 --- /dev/null +++ b/src/archiver.h @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_ARCHIVER_H__ +#define __LIBFM_QT_FM_ARCHIVER_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Archiver { +public: + + + // default constructor + Archiver() { + dataPtr_ = nullptr; + } + + + // move constructor + Archiver(Archiver&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~Archiver() { + if(dataPtr_ != nullptr) { + (dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Archiver wrapPtr(FmArchiver* dataPtr) { + Archiver obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmArchiver* takeDataPtr() { + FmArchiver* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmArchiver* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmArchiver*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + + // move assignment + Archiver& operator=(Archiver&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void setDefault(void) { + fm_archiver_set_default(dataPtr()); + } + + + static Archiver getDefault( ) { + return wrapPtr(fm_archiver_get_default()); + } + + + bool extractArchivesTo(GAppLaunchContext* ctx, FmPathList* files, FmPath* dest_dir) { + return fm_archiver_extract_archives_to(dataPtr(), ctx, files, dest_dir); + } + + + bool extractArchives(GAppLaunchContext* ctx, FmPathList* files) { + return fm_archiver_extract_archives(dataPtr(), ctx, files); + } + + + bool createArchive(GAppLaunchContext* ctx, FmPathList* files) { + return fm_archiver_create_archive(dataPtr(), ctx, files); + } + + + bool isMimeTypeSupported(const char* type) { + return fm_archiver_is_mime_type_supported(dataPtr(), type); + } + + +// the wrapped object cannot be copied. +private: + Archiver(const Archiver& other) = delete; + Archiver& operator=(const Archiver& other) = delete; + + +private: + FmArchiver* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_ARCHIVER_H__ diff --git a/src/bookmarks.h b/src/bookmarks.h new file mode 100644 index 0000000..0545189 --- /dev/null +++ b/src/bookmarks.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_BOOKMARKS_H__ +#define __LIBFM_QT_FM_BOOKMARKS_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Bookmarks { +public: + + + // default constructor + Bookmarks() { + dataPtr_ = nullptr; + } + + + Bookmarks(FmBookmarks* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Bookmarks(const Bookmarks& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Bookmarks(Bookmarks&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~Bookmarks() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Bookmarks wrapPtr(FmBookmarks* dataPtr) { + Bookmarks obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmBookmarks* takeDataPtr() { + FmBookmarks* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmBookmarks* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmBookmarks*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Bookmarks& operator=(const Bookmarks& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Bookmarks& operator=(Bookmarks&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + GList* getAll(void) { + return fm_bookmarks_get_all(dataPtr()); + } + + + void rename(FmBookmarkItem* item, const char* new_name) { + fm_bookmarks_rename(dataPtr(), item, new_name); + } + + + void reorder(FmBookmarkItem* item, int pos) { + fm_bookmarks_reorder(dataPtr(), item, pos); + } + + + void remove(FmBookmarkItem* item) { + fm_bookmarks_remove(dataPtr(), item); + } + + + FmBookmarkItem* insert(FmPath* path, const char* name, int pos) { + return fm_bookmarks_insert(dataPtr(), path, name, pos); + } + + + static Bookmarks dup(void ) { + return Bookmarks::wrapPtr(fm_bookmarks_dup()); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_BOOKMARKS_H__ diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..d1cffd9 --- /dev/null +++ b/src/config.h @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_CONFIG_H__ +#define __LIBFM_QT_FM_CONFIG_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Config { +public: + + + Config(void ) { + dataPtr_ = reinterpret_cast(fm_config_new()); + } + + + Config(FmConfig* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Config(const Config& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Config(Config&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~Config() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Config wrapPtr(FmConfig* dataPtr) { + Config obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmConfig* takeDataPtr() { + FmConfig* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmConfig* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmConfig*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Config& operator=(const Config& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Config& operator=(Config&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void emitChanged(const char* changed_key) { + fm_config_emit_changed(dataPtr(), changed_key); + } + + + void save(const char* name) { + fm_config_save(dataPtr(), name); + } + + + void loadFromKeyFile(GKeyFile* kf) { + fm_config_load_from_key_file(dataPtr(), kf); + } + + + void loadFromFile(const char* name) { + fm_config_load_from_file(dataPtr(), name); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_CONFIG_H__ diff --git a/src/deepcountjob.h b/src/deepcountjob.h new file mode 100644 index 0000000..1eda2fe --- /dev/null +++ b/src/deepcountjob.h @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_DEEP_COUNT_JOB_H__ +#define __LIBFM_QT_FM_DEEP_COUNT_JOB_H__ + +#include +#include +#include +#include "libfmqtglobals.h" +#include "job.h" + +namespace Fm { + + +class LIBFM_QT_API DeepCountJob: public Job { +public: + + + DeepCountJob(FmPathList* paths, FmDeepCountJobFlags flags) { + dataPtr_ = reinterpret_cast(fm_deep_count_job_new(paths, flags)); + } + + + // default constructor + DeepCountJob() { + dataPtr_ = nullptr; + } + + + DeepCountJob(FmDeepCountJob* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + DeepCountJob(const DeepCountJob& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + DeepCountJob(DeepCountJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + + // create a wrapper for the data pointer without increasing the reference count + static DeepCountJob wrapPtr(FmDeepCountJob* dataPtr) { + DeepCountJob obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmDeepCountJob* takeDataPtr() { + FmDeepCountJob* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmDeepCountJob* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmDeepCountJob*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + DeepCountJob& operator=(const DeepCountJob& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + DeepCountJob& operator=(DeepCountJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void setDest(dev_t dev, const char* fs_id) { + fm_deep_count_job_set_dest(dataPtr(), dev, fs_id); + } + + + +}; + + +} + +#endif // __LIBFM_QT_FM_DEEP_COUNT_JOB_H__ diff --git a/src/dirlistjob.h b/src/dirlistjob.h new file mode 100644 index 0000000..0c509a8 --- /dev/null +++ b/src/dirlistjob.h @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_DIR_LIST_JOB_H__ +#define __LIBFM_QT_FM_DIR_LIST_JOB_H__ + +#include +#include +#include +#include "libfmqtglobals.h" +#include "job.h" + +namespace Fm { + + +class LIBFM_QT_API DirListJob: public Job { +public: + + + DirListJob(FmPath* path, gboolean dir_only) { + dataPtr_ = reinterpret_cast(fm_dir_list_job_new(path, dir_only)); + } + + + // default constructor + DirListJob() { + dataPtr_ = nullptr; + } + + + DirListJob(FmDirListJob* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + DirListJob(const DirListJob& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + DirListJob(DirListJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + + // create a wrapper for the data pointer without increasing the reference count + static DirListJob wrapPtr(FmDirListJob* dataPtr) { + DirListJob obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmDirListJob* takeDataPtr() { + FmDirListJob* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmDirListJob* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmDirListJob*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + DirListJob& operator=(const DirListJob& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + DirListJob& operator=(DirListJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void addFoundFile(FmFileInfo* file) { + fm_dir_list_job_add_found_file(dataPtr(), file); + } + + + void setIncremental(gboolean set) { + fm_dir_list_job_set_incremental(dataPtr(), set); + } + + + FmFileInfoList* getFiles(void) { + return fm_dir_list_job_get_files(dataPtr()); + } + + + static DirListJob newForGfile(GFile* gf) { + return DirListJob::wrapPtr(fm_dir_list_job_new_for_gfile(gf)); + } + + + static DirListJob new2(FmPath* path, FmDirListJobFlags flags) { + return DirListJob::wrapPtr(fm_dir_list_job_new2(path, flags)); + } + + + +}; + + +} + +#endif // __LIBFM_QT_FM_DIR_LIST_JOB_H__ diff --git a/src/dirtreemodelitem.cpp b/src/dirtreemodelitem.cpp index 05b6486..602ff3d 100644 --- a/src/dirtreemodelitem.cpp +++ b/src/dirtreemodelitem.cpp @@ -25,25 +25,25 @@ namespace Fm { DirTreeModelItem::DirTreeModelItem(): - model_(nullptr), + fileInfo_(nullptr), folder_(nullptr), expanded_(false), loaded_(false), - fileInfo_(nullptr), + parent_(nullptr), placeHolderChild_(nullptr), - parent_(nullptr) { + model_(nullptr) { } DirTreeModelItem::DirTreeModelItem(FmFileInfo* info, DirTreeModel* model, DirTreeModelItem* parent): - model_(model), - folder_(nullptr), - expanded_(false), - loaded_(false), fileInfo_(fm_file_info_ref(info)), + folder_(nullptr), displayName_(QString::fromUtf8(fm_file_info_get_disp_name(info))), icon_(IconTheme::icon(fm_file_info_get_icon(info))), + expanded_(false), + loaded_(false), + parent_(parent), placeHolderChild_(nullptr), - parent_(parent) { + model_(model) { if(info) addPlaceHolderChild(); diff --git a/src/dirtreeview.cpp b/src/dirtreeview.cpp index de7e589..8b58374 100644 --- a/src/dirtreeview.cpp +++ b/src/dirtreeview.cpp @@ -30,8 +30,8 @@ namespace Fm { DirTreeView::DirTreeView(QWidget* parent): - currentExpandingItem_(NULL), - currentPath_(NULL) { + currentPath_(NULL), + currentExpandingItem_(NULL) { setSelectionMode(QAbstractItemView::SingleSelection); setHeaderHidden(true); @@ -66,7 +66,7 @@ void DirTreeView::expandPendingPath() { if(pathsToExpand_.isEmpty()) return; - FmPath* path = pathsToExpand_.first().data(); + FmPath* path = pathsToExpand_.first(); // qDebug() << "expanding: " << Path(path).displayBasename(); DirTreeModel* _model = static_cast(model()); DirTreeModelItem* item = _model->itemFromPath(path); diff --git a/src/dnddest.cpp b/src/dnddest.cpp index 71cabb3..daf22f2 100644 --- a/src/dnddest.cpp +++ b/src/dnddest.cpp @@ -44,13 +44,13 @@ bool DndDest::dropMimeData(const QMimeData* data, Qt::DropAction action) { FmPathList* srcPaths = pathListFromQUrls(data->urls()); switch(action) { case Qt::CopyAction: - FileOperation::copyFiles(srcPaths, destPath_.data()); + FileOperation::copyFiles(srcPaths, destPath_); break; case Qt::MoveAction: - FileOperation::moveFiles(srcPaths, destPath_.data()); + FileOperation::moveFiles(srcPaths, destPath_); break; case Qt::LinkAction: - FileOperation::symlinkFiles(srcPaths, destPath_.data()); + FileOperation::symlinkFiles(srcPaths, destPath_); default: fm_path_list_unref(srcPaths); return false; diff --git a/src/dummymonitor.h b/src/dummymonitor.h new file mode 100644 index 0000000..1570250 --- /dev/null +++ b/src/dummymonitor.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_DUMMY_MONITOR_H__ +#define __LIBFM_QT_FM_DUMMY_MONITOR_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + + +} + +#endif // __LIBFM_QT_FM_DUMMY_MONITOR_H__ diff --git a/src/execfiledialog.cpp b/src/execfiledialog.cpp index dcf420a..3759d0b 100644 --- a/src/execfiledialog.cpp +++ b/src/execfiledialog.cpp @@ -25,9 +25,9 @@ namespace Fm { ExecFileDialog::ExecFileDialog(FmFileInfo* file, QWidget* parent, Qt::WindowFlags f): QDialog (parent, f), + ui(new Ui::ExecFileDialog()), fileInfo_(fm_file_info_ref(file)), - result_(FM_FILE_LAUNCHER_EXEC_CANCEL), - ui(new Ui::ExecFileDialog()) { + result_(FM_FILE_LAUNCHER_EXEC_CANCEL) { ui->setupUi(this); // show file icon diff --git a/src/file.h b/src/file.h new file mode 100644 index 0000000..8902cda --- /dev/null +++ b/src/file.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_FILE_H__ +#define __LIBFM_QT_FM_FILE_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API File { +public: + + + // default constructor + File() { + dataPtr_ = nullptr; + } + + + File(FmFile* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + File(const File& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + File(File&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~File() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static File wrapPtr(FmFile* dataPtr) { + File obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFile* takeDataPtr() { + FmFile* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFile* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFile*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + File& operator=(const File& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + File& operator=(File&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + static GFile* newForCommandlineArg(const char* arg) { + return fm_file_new_for_commandline_arg(arg); + } + + + static GFile* newForUri(const char* uri) { + return fm_file_new_for_uri(uri); + } + + + static bool wantsIncremental(GFile* file) { + return fm_file_wants_incremental(file); + } + + + static void addVfs(const char* name, FmFileInitTable* init) { + fm_file_add_vfs(name, init); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_FILE_H__ diff --git a/src/fileinfo.h b/src/fileinfo.h new file mode 100644 index 0000000..3322cbd --- /dev/null +++ b/src/fileinfo.h @@ -0,0 +1,511 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_FILE_INFO_H__ +#define __LIBFM_QT_FM_FILE_INFO_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API FileInfoList { +public: + + + FileInfoList( ) { + dataPtr_ = reinterpret_cast(fm_file_info_list_new()); + } + + + FileInfoList(FmFileInfoList* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_list_ref(FM_LIST(dataPtr))) : nullptr; + } + + + // copy constructor + FileInfoList(const FileInfoList& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_list_ref(FM_LIST(other.dataPtr_))) : nullptr; + } + + + // move constructor + FileInfoList(FileInfoList&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~FileInfoList() { + if(dataPtr_ != nullptr) { + fm_list_unref(FM_LIST(dataPtr_)); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static FileInfoList wrapPtr(FmFileInfoList* dataPtr) { + FileInfoList obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFileInfoList* takeDataPtr() { + FmFileInfoList* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFileInfoList* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFileInfoList*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + FileInfoList& operator=(const FileInfoList& other) { + if(dataPtr_ != nullptr) { + fm_list_unref(FM_LIST(dataPtr_)); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_list_ref(FM_LIST(other.dataPtr_))) : nullptr; + return *this; + } + + + // move assignment + FileInfoList& operator=(FileInfoList&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + bool isSameFs(void) { + return fm_file_info_list_is_same_fs(dataPtr()); + } + + + bool isSameType(void) { + return fm_file_info_list_is_same_type(dataPtr()); + } + + + bool isEmpty() { + return fm_file_info_list_is_empty(dataPtr()); + } + + unsigned int getLength() { + return fm_file_info_list_get_length(dataPtr()); + } + + FmFileInfo* peekHead() { + return fm_file_info_list_peek_head(dataPtr()); + } + + GList* peekHeadLink() { + return fm_file_info_list_peek_head_link(dataPtr()); + } + + void pushTail(FmFileInfo* d) { + fm_file_info_list_push_tail(dataPtr(), d); + } + + void pushTailLink(GList* d) { + fm_file_info_list_push_tail_link(dataPtr(), d); + } + + FmFileInfo* popHead(){ + return fm_file_info_list_pop_head(dataPtr()); + } + + void deleteLink(GList* _l) { + fm_file_info_list_delete_link(dataPtr(), _l); + } + + void clear() { + fm_file_info_list_clear(dataPtr()); + } + + +private: + FmFileInfoList* dataPtr_; // data pointer for the underlying C struct + +}; + + + +class LIBFM_QT_API FileInfo { +public: + + + FileInfo( ) { + dataPtr_ = reinterpret_cast(fm_file_info_new()); + } + + + FileInfo(FmFileInfo* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_file_info_ref(dataPtr)) : nullptr; + } + + + // copy constructor + FileInfo(const FileInfo& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_file_info_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + FileInfo(FileInfo&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~FileInfo() { + if(dataPtr_ != nullptr) { + fm_file_info_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static FileInfo wrapPtr(FmFileInfo* dataPtr) { + FileInfo obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFileInfo* takeDataPtr() { + FmFileInfo* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFileInfo* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFileInfo*() { + return dataPtr(); + } + + + // copy assignment + FileInfo& operator=(const FileInfo& other) { + if(dataPtr_ != nullptr) { + fm_file_info_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_file_info_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + FileInfo& operator=(FileInfo&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + bool canSetHidden(void) { + return fm_file_info_can_set_hidden(dataPtr()); + } + + + bool canSetIcon(void) { + return fm_file_info_can_set_icon(dataPtr()); + } + + + bool canSetName(void) { + return fm_file_info_can_set_name(dataPtr()); + } + + + bool canThumbnail(void) { + return fm_file_info_can_thumbnail(dataPtr()); + } + + + dev_t getDev(void) { + return fm_file_info_get_dev(dataPtr()); + } + + + gid_t getGid(void) { + return fm_file_info_get_gid(dataPtr()); + } + + + uid_t getUid(void) { + return fm_file_info_get_uid(dataPtr()); + } + + const char* getDispGroup() { + return fm_file_info_get_disp_group(dataPtr()); + } + + const char* getFsId() { + return fm_file_info_get_fs_id(dataPtr()); + } + + FmIcon* getIcon(void) { + return fm_file_info_get_icon(dataPtr()); + } + + + time_t getCtime(void) { + return fm_file_info_get_ctime(dataPtr()); + } + + + time_t getAtime(void) { + return fm_file_info_get_atime(dataPtr()); + } + + + time_t getMtime(void) { + return fm_file_info_get_mtime(dataPtr()); + } + + + const char* getTarget() { + return fm_file_info_get_target(dataPtr()); + } + + const char* getCollateKey() { + return fm_file_info_get_collate_key(dataPtr()); + } + + const char* getCollateKeyNoCaseFold() { + return fm_file_info_get_collate_key_nocasefold(dataPtr()); + } + + const char* getDesc() { + return fm_file_info_get_desc(dataPtr()); + } + + const char* getDispMtime() { + return fm_file_info_get_disp_mtime(dataPtr()); + } + + bool isWritableDirectory(void) { + return fm_file_info_is_writable_directory(dataPtr()); + } + + + bool isAccessible(void) { + return fm_file_info_is_accessible(dataPtr()); + } + + + bool isExecutableType(void) { + return fm_file_info_is_executable_type(dataPtr()); + } + + + bool isBackup(void) { + return fm_file_info_is_backup(dataPtr()); + } + + + bool isHidden(void) { + return fm_file_info_is_hidden(dataPtr()); + } + + + bool isUnknownType(void) { + return fm_file_info_is_unknown_type(dataPtr()); + } + + + bool isDesktopEntry(void) { + return fm_file_info_is_desktop_entry(dataPtr()); + } + + + bool isText(void) { + return fm_file_info_is_text(dataPtr()); + } + + + bool isImage(void) { + return fm_file_info_is_image(dataPtr()); + } + + + bool isMountable(void) { + return fm_file_info_is_mountable(dataPtr()); + } + + + bool isShortcut(void) { + return fm_file_info_is_shortcut(dataPtr()); + } + + + bool isSymlink(void) { + return fm_file_info_is_symlink(dataPtr()); + } + + + bool isDir(void) { + return fm_file_info_is_dir(dataPtr()); + } + + + FmMimeType* getMimeType(void) { + return fm_file_info_get_mime_type(dataPtr()); + } + + + bool isNative(void) { + return fm_file_info_is_native(dataPtr()); + } + + + mode_t getMode(void) { + return fm_file_info_get_mode(dataPtr()); + } + + + goffset getBlocks(void) { + return fm_file_info_get_blocks(dataPtr()); + } + + + goffset getSize(void) { + return fm_file_info_get_size(dataPtr()); + } + + const char* getDispSize() { + return fm_file_info_get_disp_size(dataPtr()); + } + + void setIcon(GIcon* icon) { + fm_file_info_set_icon(dataPtr(), icon); + } + + + void setDispName(const char* name) { + fm_file_info_set_disp_name(dataPtr(), name); + } + + + void setPath(FmPath* path) { + fm_file_info_set_path(dataPtr(), path); + } + + + const char* getName() { + return fm_file_info_get_name(dataPtr()); + } + + + const char* getDispName() { + return fm_file_info_get_disp_name(dataPtr()); + } + + + FmPath* getPath(void) { + return fm_file_info_get_path(dataPtr()); + } + + + void update(FmFileInfo* src) { + fm_file_info_update(dataPtr(), src); + } + + + static FileInfo newFromNativeFile(FmPath* path, const char* path_str, GError** err) { + return FileInfo::wrapPtr(fm_file_info_new_from_native_file(path, path_str, err)); + } + + + bool setFromNativeFile(const char* path, GError** err) { + return fm_file_info_set_from_native_file(dataPtr(), path, err); + } + + + void setFromMenuCacheItem(struct _MenuCacheItem* item) { + fm_file_info_set_from_menu_cache_item(dataPtr(), item); + } + + + static FileInfo newFromMenuCacheItem(FmPath* path, struct _MenuCacheItem* item) { + return FileInfo::wrapPtr(fm_file_info_new_from_menu_cache_item(path, item)); + } + + + void setFromGFileData(GFile* gf, GFileInfo* inf) { + fm_file_info_set_from_g_file_data(dataPtr(), gf, inf); + } + + + static FileInfo newFromGFileData(GFile* gf, GFileInfo* inf, FmPath* path) { + return FileInfo::wrapPtr(fm_file_info_new_from_g_file_data(gf, inf, path)); + } + + + void setFromGfileinfo(GFileInfo* inf) { + fm_file_info_set_from_gfileinfo(dataPtr(), inf); + } + + + static FileInfo newFromGfileinfo(FmPath* path, GFileInfo* inf) { + return FileInfo::wrapPtr(fm_file_info_new_from_gfileinfo(path, inf)); + } + + +private: + FmFileInfo* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_FILE_INFO_H__ diff --git a/src/fileinfojob.h b/src/fileinfojob.h new file mode 100644 index 0000000..396b254 --- /dev/null +++ b/src/fileinfojob.h @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_FILE_INFO_JOB_H__ +#define __LIBFM_QT_FM_FILE_INFO_JOB_H__ + +#include +#include +#include +#include "libfmqtglobals.h" +#include "job.h" + +namespace Fm { + + +class LIBFM_QT_API FileInfoJob: public Job { +public: + + + FileInfoJob(FmPathList* files_to_query, FmFileInfoJobFlags flags) { + dataPtr_ = reinterpret_cast(fm_file_info_job_new(files_to_query, flags)); + } + + + // default constructor + FileInfoJob() { + dataPtr_ = nullptr; + } + + + FileInfoJob(FmFileInfoJob* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + FileInfoJob(const FileInfoJob& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + FileInfoJob(FileInfoJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + + // create a wrapper for the data pointer without increasing the reference count + static FileInfoJob wrapPtr(FmFileInfoJob* dataPtr) { + FileInfoJob obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFileInfoJob* takeDataPtr() { + FmFileInfoJob* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFileInfoJob* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFileInfoJob*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + FileInfoJob& operator=(const FileInfoJob& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + FileInfoJob& operator=(FileInfoJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + FmPath* getCurrent(void) { + return fm_file_info_job_get_current(dataPtr()); + } + + + void addGfile(GFile* gf) { + fm_file_info_job_add_gfile(dataPtr(), gf); + } + + + void add(FmPath* path) { + fm_file_info_job_add(dataPtr(), path); + } + + + +}; + + +} + +#endif // __LIBFM_QT_FM_FILE_INFO_JOB_H__ diff --git a/src/filemenu.cpp b/src/filemenu.cpp index c6eaf09..49bc6e2 100644 --- a/src/filemenu.cpp +++ b/src/filemenu.cpp @@ -44,8 +44,8 @@ FileMenu::FileMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd, QWidget FileMenu::FileMenu(FmFileInfoList* files, FmFileInfo* info, FmPath* cwd, const QString& title, QWidget* parent): QMenu(title, parent), - fileLauncher_(NULL), - unTrashAction_(NULL) { + unTrashAction_(NULL), + fileLauncher_(NULL) { createMenu(files, info, cwd); } @@ -247,10 +247,12 @@ void FileMenu::addCustomActionItem(QMenu* menu, FmFileActionItem* item) { 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); + if (subitems != NULL) { QMenu* submenu = new QMenu(menu); - addCustomActionItem(submenu, subitem); + for(GList* l = subitems; l; l = l->next) { + FmFileActionItem* subitem = FM_FILE_ACTION_ITEM(l->data); + addCustomActionItem(submenu, subitem); + } action->setMenu(submenu); } } diff --git a/src/fileoperation.cpp b/src/fileoperation.cpp index 8026b8f..0d63772 100644 --- a/src/fileoperation.cpp +++ b/src/fileoperation.cpp @@ -31,6 +31,7 @@ namespace Fm { FileOperation::FileOperation(Type type, FmPathList* srcFiles, QObject* parent): QObject(parent), + job_(fm_file_ops_job_new((FmFileOpType)type, srcFiles)), dlg(NULL), destPath(NULL), srcPaths(fm_path_list_ref(srcFiles)), @@ -38,8 +39,7 @@ FileOperation::FileOperation(Type type, FmPathList* srcFiles, QObject* parent): elapsedTimer_(NULL), lastElapsed_(0), updateRemainingTime_(true), - autoDestroy_(true), - job_(fm_file_ops_job_new((FmFileOpType)type, srcFiles)) { + autoDestroy_(true) { g_signal_connect(job_, "ask", G_CALLBACK(onFileOpsJobAsk), this); g_signal_connect(job_, "ask-rename", G_CALLBACK(onFileOpsJobAskRename), this); diff --git a/src/fileopsjob.h b/src/fileopsjob.h new file mode 100644 index 0000000..e2bbe71 --- /dev/null +++ b/src/fileopsjob.h @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_FILE_OPS_JOB_H__ +#define __LIBFM_QT_FM_FILE_OPS_JOB_H__ + +#include +#include +#include +#include "libfmqtglobals.h" +#include "job.h" + +namespace Fm { + + +class LIBFM_QT_API FileOpsJob: public Job { +public: + + + FileOpsJob(FmFileOpType type, FmPathList* files) { + dataPtr_ = reinterpret_cast(fm_file_ops_job_new(type, files)); + } + + + // default constructor + FileOpsJob() { + dataPtr_ = nullptr; + } + + + FileOpsJob(FmFileOpsJob* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + FileOpsJob(const FileOpsJob& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + FileOpsJob(FileOpsJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + + // create a wrapper for the data pointer without increasing the reference count + static FileOpsJob wrapPtr(FmFileOpsJob* dataPtr) { + FileOpsJob obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFileOpsJob* takeDataPtr() { + FmFileOpsJob* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFileOpsJob* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFileOpsJob*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + FileOpsJob& operator=(const FileOpsJob& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + FileOpsJob& operator=(FileOpsJob&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + FmFileOpOption getOptions(void) { + return fm_file_ops_job_get_options(dataPtr()); + } + + + FmFileOpOption askRename(GFile* src, GFileInfo* src_inf, GFile* dest, GFile** new_dest) { + return fm_file_ops_job_ask_rename(dataPtr(), src, src_inf, dest, new_dest); + } + + + void emitPercent(void) { + fm_file_ops_job_emit_percent(dataPtr()); + } + + + void emitCurFile(const char* cur_file) { + fm_file_ops_job_emit_cur_file(dataPtr(), cur_file); + } + + + void emitPrepared(void) { + fm_file_ops_job_emit_prepared(dataPtr()); + } + + + void setTarget(const char* url) { + fm_file_ops_job_set_target(dataPtr(), url); + } + + + void setHidden(gboolean hidden) { + fm_file_ops_job_set_hidden(dataPtr(), hidden); + } + + + void setIcon(GIcon* icon) { + fm_file_ops_job_set_icon(dataPtr(), icon); + } + + + void setDisplayName(const char* name) { + fm_file_ops_job_set_display_name(dataPtr(), name); + } + + + void setChown(gint uid, gint gid) { + fm_file_ops_job_set_chown(dataPtr(), uid, gid); + } + + + void setChmod(mode_t new_mode, mode_t new_mode_mask) { + fm_file_ops_job_set_chmod(dataPtr(), new_mode, new_mode_mask); + } + + + void setRecursive(gboolean recursive) { + fm_file_ops_job_set_recursive(dataPtr(), recursive); + } + + + FmPath* getDest(void) { + return fm_file_ops_job_get_dest(dataPtr()); + } + + + void setDest(FmPath* dest) { + fm_file_ops_job_set_dest(dataPtr(), dest); + } + + + +}; + + +} + +#endif // __LIBFM_QT_FM_FILE_OPS_JOB_H__ diff --git a/src/fileopsjobchangeattr.h b/src/fileopsjobchangeattr.h new file mode 100644 index 0000000..e69de29 diff --git a/src/fileopsjobdelete.h b/src/fileopsjobdelete.h new file mode 100644 index 0000000..e69de29 diff --git a/src/fileopsjobxfer.h b/src/fileopsjobxfer.h new file mode 100644 index 0000000..e69de29 diff --git a/src/filepropsdialog.cpp b/src/filepropsdialog.cpp index 88611ae..398373f 100644 --- a/src/filepropsdialog.cpp +++ b/src/filepropsdialog.cpp @@ -46,9 +46,9 @@ enum { FilePropsDialog::FilePropsDialog(FmFileInfoList* files, QWidget* parent, Qt::WindowFlags f): QDialog(parent, f), fileInfos_(fm_file_info_list_ref(files)), + fileInfo(fm_file_info_list_peek_head(files)), singleType(fm_file_info_list_is_same_type(files)), singleFile(fm_file_info_list_get_length(files) == 1 ? true:false), - fileInfo(fm_file_info_list_peek_head(files)), mimeType(NULL) { setAttribute(Qt::WA_DeleteOnClose); @@ -304,7 +304,7 @@ void FilePropsDialog::initGeneralPage() { connect(fileSizeTimer, &QTimer::timeout, this, &FilePropsDialog::onFileSizeTimerTimeout); fileSizeTimer->start(600); g_signal_connect(deepCountJob, "finished", G_CALLBACK(onDeepCountJobFinished), this); - gboolean ret = fm_job_run_async(FM_JOB(deepCountJob)); + fm_job_run_async(FM_JOB(deepCountJob)); } /*static */ void FilePropsDialog::onDeepCountJobFinished(FmDeepCountJob* job, FilePropsDialog* pThis) { diff --git a/src/filesearchdialog.cpp b/src/filesearchdialog.cpp index 13ce21e..512aca2 100644 --- a/src/filesearchdialog.cpp +++ b/src/filesearchdialog.cpp @@ -23,6 +23,7 @@ #include "ui_filesearch.h" #include #include +#include namespace Fm { @@ -54,8 +55,7 @@ void FileSearchDialog::accept() { int n = ui->listView->count(); if(n > 0) { FmSearch* search = fm_search_new(); - int i; - for(i = 0; i < n; ++i) { // add directories + for(int i = 0; i < n; ++i) { // add directories QListWidgetItem* item = ui->listView->item(i); fm_search_add_dir(search, item->text().toLocal8Bit().constData()); } @@ -90,7 +90,7 @@ void FileSearchDialog::accept() { "application/msword;application/vnd.ms-word", "application/msexcel;application/vnd.ms-excel" }; - for(i = 0; i < sizeof(doc_types)/sizeof(char*); ++i) + for(unsigned int i = 0; i < sizeof(doc_types)/sizeof(char*); ++i) fm_search_add_mime_type(search, doc_types[i]); } @@ -114,7 +114,7 @@ void FileSearchDialog::accept() { fm_search_set_min_mtime(search, ui->minTime->date().toString(QStringLiteral("yyyy-MM-dd")).toUtf8().constData()); } - searchUri_.take(fm_search_dup_path(search)); + searchUri_ = std::move(Path::wrapPtr(fm_search_dup_path(search))); fm_search_free(search); } diff --git a/src/folder.h b/src/folder.h new file mode 100644 index 0000000..355b6d7 --- /dev/null +++ b/src/folder.h @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_FOLDER_H__ +#define __LIBFM_QT_FM_FOLDER_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Folder { +public: + + + // default constructor + Folder() { + dataPtr_ = nullptr; + } + + + Folder(FmFolder* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Folder(const Folder& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Folder(Folder&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~Folder() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Folder wrapPtr(FmFolder* dataPtr) { + Folder obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFolder* takeDataPtr() { + FmFolder* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFolder* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFolder*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Folder& operator=(const Folder& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Folder& operator=(Folder&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + bool makeDirectory(const char* name, GError** error) { + return fm_folder_make_directory(dataPtr(), name, error); + } + + + void queryFilesystemInfo(void) { + fm_folder_query_filesystem_info(dataPtr()); + } + + + bool getFilesystemInfo(guint64* total_size, guint64* free_size) { + return fm_folder_get_filesystem_info(dataPtr(), total_size, free_size); + } + + + void reload(void) { + fm_folder_reload(dataPtr()); + } + + + bool isIncremental(void) { + return fm_folder_is_incremental(dataPtr()); + } + + + bool isValid(void) { + return fm_folder_is_valid(dataPtr()); + } + + + bool isLoaded(void) { + return fm_folder_is_loaded(dataPtr()); + } + + + FmFileInfo* getFileByName(const char* name) { + return fm_folder_get_file_by_name(dataPtr(), name); + } + + + bool isEmpty(void) { + return fm_folder_is_empty(dataPtr()); + } + + + FmFileInfoList* getFiles(void) { + return fm_folder_get_files(dataPtr()); + } + + + FmPath* getPath(void) { + return fm_folder_get_path(dataPtr()); + } + + + FmFileInfo* getInfo(void) { + return fm_folder_get_info(dataPtr()); + } + + + void unblockUpdates(void) { + fm_folder_unblock_updates(dataPtr()); + } + + + void blockUpdates(void) { + fm_folder_block_updates(dataPtr()); + } + + + static Folder findByPath(FmPath* path) { + return Folder::wrapPtr(fm_folder_find_by_path(path)); + } + + + static Folder fromUri(const char* uri) { + return Folder::wrapPtr(fm_folder_from_uri(uri)); + } + + + static Folder fromPathName(const char* path) { + return Folder::wrapPtr(fm_folder_from_path_name(path)); + } + + + static Folder fromGfile(GFile* gf) { + return Folder::wrapPtr(fm_folder_from_gfile(gf)); + } + + + static Folder fromPath(FmPath* path) { + return Folder::wrapPtr(fm_folder_from_path(path)); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_FOLDER_H__ diff --git a/src/folderconfig.h b/src/folderconfig.h new file mode 100644 index 0000000..61ebb40 --- /dev/null +++ b/src/folderconfig.h @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_FOLDER_CONFIG_H__ +#define __LIBFM_QT_FM_FOLDER_CONFIG_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API FolderConfig { +public: + + + FolderConfig(FmPath* path) { + dataPtr_ = reinterpret_cast(fm_folder_config_open(path)); + } + + + // default constructor + FolderConfig() { + dataPtr_ = nullptr; + } + + + // move constructor + FolderConfig(FolderConfig&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~FolderConfig() { + if(dataPtr_ != nullptr) { + fm_folder_config_close(dataPtr_, nullptr); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static FolderConfig wrapPtr(FmFolderConfig* dataPtr) { + FolderConfig obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmFolderConfig* takeDataPtr() { + FmFolderConfig* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmFolderConfig* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmFolderConfig*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + + // move assignment + FolderConfig& operator=(FolderConfig&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + static void saveCache(void ) { + fm_folder_config_save_cache(); + } + + + void purge(void) { + fm_folder_config_purge(dataPtr()); + } + + + void removeKey(const char* key) { + fm_folder_config_remove_key(dataPtr(), key); + } + + + void setStringList(const char* key, const gchar * const list[], gsize length) { + fm_folder_config_set_string_list(dataPtr(), key, list, length); + } + + + void setString(const char* key, const char* string) { + fm_folder_config_set_string(dataPtr(), key, string); + } + + + void setBoolean(const char* key, gboolean val) { + fm_folder_config_set_boolean(dataPtr(), key, val); + } + + + void setDouble(const char* key, gdouble val) { + fm_folder_config_set_double(dataPtr(), key, val); + } + + + void setUint64(const char* key, guint64 val) { + fm_folder_config_set_uint64(dataPtr(), key, val); + } + + + void setInteger(const char* key, gint val) { + fm_folder_config_set_integer(dataPtr(), key, val); + } + + + char** getStringList(const char* key, gsize* length) { + return fm_folder_config_get_string_list(dataPtr(), key, length); + } + + + char* getString(const char* key) { + return fm_folder_config_get_string(dataPtr(), key); + } + + + bool getBoolean(const char* key, gboolean* val) { + return fm_folder_config_get_boolean(dataPtr(), key, val); + } + + + bool getDouble(const char* key, gdouble* val) { + return fm_folder_config_get_double(dataPtr(), key, val); + } + + + bool getUint64(const char* key, guint64* val) { + return fm_folder_config_get_uint64(dataPtr(), key, val); + } + + + bool getInteger(const char* key, gint* val) { + return fm_folder_config_get_integer(dataPtr(), key, val); + } + + + bool isEmpty(void) { + return fm_folder_config_is_empty(dataPtr()); + } + + +// the wrapped object cannot be copied. +private: + FolderConfig(const FolderConfig& other) = delete; + FolderConfig& operator=(const FolderConfig& other) = delete; + + +private: + FmFolderConfig* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_FOLDER_CONFIG_H__ diff --git a/src/folderitemdelegate.cpp b/src/folderitemdelegate.cpp index 078345c..973f0e0 100644 --- a/src/folderitemdelegate.cpp +++ b/src/folderitemdelegate.cpp @@ -22,7 +22,7 @@ #include "foldermodel.h" #include #include -#include +#include #include #include #include @@ -34,8 +34,8 @@ namespace Fm { FolderItemDelegate::FolderItemDelegate(QAbstractItemView* view, QObject* parent): QStyledItemDelegate(parent ? parent : view), - symlinkIcon_(QIcon::fromTheme("emblem-symbolic-link")), - view_(view) { + view_(view), + symlinkIcon_(QIcon::fromTheme("emblem-symbolic-link")) { } FolderItemDelegate::~FolderItemDelegate() { @@ -49,16 +49,19 @@ QSize FolderItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo if(option.decorationPosition == QStyleOptionViewItem::Top || option.decorationPosition == QStyleOptionViewItem::Bottom) { - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); opt.decorationAlignment = Qt::AlignHCenter|Qt::AlignTop; opt.displayAlignment = Qt::AlignTop|Qt::AlignHCenter; + // "opt.decorationSize" may be smaller than the requested size because + // "QStyledItemDelegate::initStyleOption()" uses "QIcon::actualSize()" to set it + // (see Qt -> qstyleditemdelegate.cpp). So, we always get decorationSize from "option". Q_ASSERT(gridSize_ != QSize()); - QRectF textRect(0, 0, gridSize_.width(), gridSize_.height() - opt.decorationSize.height()); + QRectF textRect(0, 0, gridSize_.width(), gridSize_.height() - option.decorationSize.height()); drawText(nullptr, opt, textRect); // passing NULL for painter will calculate the bounding rect only. - int width = qMax((int)textRect.width(), opt.decorationSize.width()); - int height = opt.decorationSize.height() + textRect.height(); + int width = qMax((int)textRect.width(), option.decorationSize.width()); + int height = option.decorationSize.height() + textRect.height(); return QSize(width, height); } return QStyledItemDelegate::sizeHint(option, index); @@ -83,28 +86,30 @@ void FolderItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& op painter->save(); painter->setClipRect(option.rect); - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); opt.decorationAlignment = Qt::AlignHCenter|Qt::AlignTop; opt.displayAlignment = Qt::AlignTop|Qt::AlignHCenter; // draw the icon QIcon::Mode iconMode = iconModeFromState(opt.state); - QPoint iconPos(opt.rect.x() + (opt.rect.width() - opt.decorationSize.width()) / 2, opt.rect.y()); - QPixmap pixmap = opt.icon.pixmap(opt.decorationSize, iconMode); - painter->drawPixmap(iconPos, pixmap); + QPoint iconPos(opt.rect.x() + (opt.rect.width() - option.decorationSize.width()) / 2, opt.rect.y()); + QPixmap pixmap = opt.icon.pixmap(option.decorationSize, iconMode); + // in case the pixmap is smaller than the requested size + QSize margin = ((option.decorationSize - pixmap.size()) / 2).expandedTo(QSize(0, 0)); + painter->drawPixmap(iconPos + QPoint(margin.width(), margin.height()), pixmap); // draw some emblems for the item if needed // we only support symlink emblem at the moment if(isSymlink) - painter->drawPixmap(iconPos, symlinkIcon_.pixmap(opt.decorationSize / 2, iconMode)); + painter->drawPixmap(iconPos, symlinkIcon_.pixmap(option.decorationSize / 2, iconMode)); // draw the text // The text rect dimensions should be exactly as they were in sizeHint() QRectF textRect(opt.rect.x() - (gridSize_.width() - opt.rect.width()) / 2, - opt.rect.y() + opt.decorationSize.height(), + opt.rect.y() + option.decorationSize.height(), gridSize_.width(), - gridSize_.height() - opt.decorationSize.height()); + gridSize_.height() - option.decorationSize.height()); drawText(painter, opt, textRect); painter->restore(); } @@ -114,24 +119,27 @@ void FolderItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& op // draw emblems if needed if(isSymlink) { - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); QIcon::Mode iconMode = iconModeFromState(opt.state); - QPoint iconPos(opt.rect.x(), opt.rect.y() + (opt.rect.height() - opt.decorationSize.height()) / 2); + QPoint iconPos(opt.rect.x(), opt.rect.y() + (opt.rect.height() - option.decorationSize.height()) / 2); // draw some emblems for the item if needed // we only support symlink emblem at the moment - painter->drawPixmap(iconPos, symlinkIcon_.pixmap(opt.decorationSize / 2, iconMode)); + painter->drawPixmap(iconPos, symlinkIcon_.pixmap(option.decorationSize / 2, iconMode)); } } } // if painter is nullptr, the method calculate the bounding rectangle of the text and save it to textRect -void FolderItemDelegate::drawText(QPainter* painter, QStyleOptionViewItemV4& opt, QRectF& textRect) const { +void FolderItemDelegate::drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const { QTextLayout layout(opt.text, opt.font); QTextOption textOption; textOption.setAlignment(opt.displayAlignment); textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - textOption.setTextDirection(opt.direction); + if (opt.text.isRightToLeft()) + textOption.setTextDirection(Qt::RightToLeft); + else + textOption.setTextDirection(Qt::LeftToRight); layout.setTextOption(textOption); qreal height = 0; qreal width = 0; @@ -188,7 +196,7 @@ void FolderItemDelegate::drawText(QPainter* painter, QStyleOptionViewItemV4& opt if (opt.state & QStyle::State_Selected || opt.state & QStyle::State_MouseOver) { if (const QWidget* widget = opt.widget) { // let the style engine do it QStyle* style = widget->style() ? widget->style() : qApp->style(); - QStyleOptionViewItemV4 o(opt); + QStyleOptionViewItem o(opt); o.text = QString(); o.rect = selRect.toAlignedRect().intersected(opt.rect); // due to clipping and rounding, we might lose 1px o.showDecorationSelected = true; diff --git a/src/folderitemdelegate.h b/src/folderitemdelegate.h index 8df5b42..4035f78 100644 --- a/src/folderitemdelegate.h +++ b/src/folderitemdelegate.h @@ -45,7 +45,7 @@ public: virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; private: - void drawText(QPainter* painter, QStyleOptionViewItemV4& opt, QRectF& textRect) const; + void drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const; static QIcon::Mode iconModeFromState(QStyle::State state); private: diff --git a/src/foldermenu.cpp b/src/foldermenu.cpp index fb74883..a5fb5b7 100644 --- a/src/foldermenu.cpp +++ b/src/foldermenu.cpp @@ -115,10 +115,12 @@ void FolderMenu::addCustomActionItem(QMenu* menu, FmFileActionItem* item) { 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); + if (subitems != NULL) { QMenu* submenu = new QMenu(menu); - addCustomActionItem(submenu, subitem); + for(GList* l = subitems; l; l = l->next) { + FmFileActionItem* subitem = FM_FILE_ACTION_ITEM(l->data); + addCustomActionItem(submenu, subitem); + } action->setMenu(submenu); } } diff --git a/src/folderview.cpp b/src/folderview.cpp index eeee41f..7f1f642 100644 --- a/src/folderview.cpp +++ b/src/folderview.cpp @@ -181,8 +181,8 @@ void FolderViewListView::activation(const QModelIndex &index) { FolderViewTreeView::FolderViewTreeView(QWidget* parent): QTreeView(parent), - layoutTimer_(nullptr), doingLayout_(false), + layoutTimer_(nullptr), activationAllowed_(true) { header()->setStretchLastSection(true); @@ -388,12 +388,12 @@ void FolderViewTreeView::onSortFilterChanged() { FolderView::FolderView(ViewMode _mode, QWidget* parent): QWidget(parent), view(nullptr), + model_(nullptr), mode((ViewMode)0), + fileLauncher_(nullptr), autoSelectionDelay_(600), autoSelectionTimer_(nullptr), selChangedTimer_(nullptr), - fileLauncher_(nullptr), - model_(nullptr), itemDelegateMargins_(QSize(3, 3)) { iconSize_[IconMode - FirstViewMode] = QSize(48, 48); @@ -656,7 +656,8 @@ bool FolderView::event(QEvent* event) { case QEvent::FontChange: updateGridSize(); break; - }; + default: break; + } return QWidget::event(event); } @@ -720,15 +721,15 @@ QItemSelectionModel* FolderView::selectionModel() const { return view ? view->selectionModel() : nullptr; } -FmPathList* FolderView::selectedFilePaths() const { +Fm::PathList FolderView::selectedFilePaths() const { if(model_) { QModelIndexList selIndexes = mode == DetailedListMode ? selectedRows() : selectedIndexes(); if(!selIndexes.isEmpty()) { - FmPathList* paths = fm_path_list_new(); + PathList paths; QModelIndexList::const_iterator it; for(it = selIndexes.begin(); it != selIndexes.end(); ++it) { FmFileInfo* file = model_->fileInfoFromIndex(*it); - fm_path_list_push_tail(paths, fm_file_info_get_path(file)); + paths.pushTail(fm_file_info_get_path(file)); } return paths; } @@ -749,15 +750,15 @@ QModelIndex FolderView::indexFromFolderPath(FmPath* folderPath) const { return QModelIndex(); } -FmFileInfoList* FolderView::selectedFiles() const { +Fm::FileInfoList FolderView::selectedFiles() const { if(model_) { QModelIndexList selIndexes = mode == DetailedListMode ? selectedRows() : selectedIndexes(); if(!selIndexes.isEmpty()) { - FmFileInfoList* files = fm_file_info_list_new(); + FileInfoList files; QModelIndexList::const_iterator it; for(it = selIndexes.constBegin(); it != selIndexes.constEnd(); ++it) { FmFileInfo* file = model_->fileInfoFromIndex(*it); - fm_file_info_list_push_tail(files, file); + files.pushTail(file); } return files; } @@ -830,10 +831,9 @@ void FolderView::childDropEvent(QDropEvent* e) { const QWidget* targetWidget = childView()->viewport(); // these are dynamic QObject property set by our XDND workarounds in xworkaround.cpp. xcb_window_t dndSource = xcb_window_t(targetWidget->property("xdnd::lastDragSource").toUInt()); - xcb_timestamp_t dropTimestamp = (xcb_timestamp_t)targetWidget->property("xdnd::lastDropTime").toUInt(); + //xcb_timestamp_t dropTimestamp = (xcb_timestamp_t)targetWidget->property("xdnd::lastDropTime").toUInt(); // qDebug() << "XDS: source window" << dndSource << dropTimestamp; if(dndSource != 0) { - xcb_connection_t* conn = QX11Info::connection(); xcb_atom_t XdndDirectSaveAtom = XdndWorkaround::internAtom("XdndDirectSave0", 15); xcb_atom_t textAtom = XdndWorkaround::internAtom("text/plain", 10); @@ -841,7 +841,7 @@ void FolderView::childDropEvent(QDropEvent* e) { QByteArray basename = XdndWorkaround::windowProperty(dndSource, XdndDirectSaveAtom, textAtom, 1024); // 2. construct the fill URI for the file, and update the source window property. - Path filePath = Path(path()).child(basename); + Path filePath = Path(path()).newChild(basename); QByteArray fileUri = filePath.toUri(); XdndWorkaround::setWindowProperty(dndSource, XdndDirectSaveAtom, textAtom, (void*)fileUri.constData(), fileUri.length()); @@ -923,6 +923,7 @@ bool FolderView::eventFilter(QObject* watched, QEvent* event) { } } break; + default: break; } } return QObject::eventFilter(watched, event); @@ -999,22 +1000,22 @@ void FolderView::onFileClicked(int type, FmFileInfo* fileInfo) { } else if(type == ContextMenuClick) { FmPath* folderPath = nullptr; - if (FmFileInfoList* files = selectedFiles()) { - FmFileInfo* first = fm_file_info_list_peek_head(files); - if (fm_file_info_list_get_length(files) == 1 && fm_file_info_is_dir(first)) + FileInfoList files = selectedFiles(); + if (!files.isNull()) { + FmFileInfo* first = files.peekHead(); + if (files.getLength() == 1 && fm_file_info_is_dir(first)) folderPath = fm_file_info_get_path(first); - fm_file_info_list_unref(files); } 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); + FileInfoList files = selectedFiles(); + if (!files.isNull()) { + Fm::FileMenu* fileMenu = new Fm::FileMenu(files.dataPtr(), fileInfo, folderPath); fileMenu->setFileLauncher(fileLauncher_); prepareFileMenu(fileMenu); - fm_file_info_list_unref(files); menu = fileMenu; } } diff --git a/src/folderview.h b/src/folderview.h index cb21667..5173d94 100644 --- a/src/folderview.h +++ b/src/folderview.h @@ -29,6 +29,8 @@ #include #include "foldermodel.h" #include "proxyfoldermodel.h" +#include "fileinfo.h" +#include "path.h" class QTimer; @@ -92,8 +94,8 @@ public: } QItemSelectionModel* selectionModel() const; - FmFileInfoList* selectedFiles() const; - FmPathList* selectedFilePaths() const; + Fm::FileInfoList selectedFiles() const; + Fm::PathList selectedFilePaths() const; QModelIndex indexFromFolderPath(FmPath* folderPath) const; void selectAll(); diff --git a/src/icon.h b/src/icon.h new file mode 100644 index 0000000..794fdc9 --- /dev/null +++ b/src/icon.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_ICON_H__ +#define __LIBFM_QT_FM_ICON_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Icon { +public: + + + // default constructor + Icon() { + dataPtr_ = nullptr; + } + + + Icon(FmIcon* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_icon_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Icon(const Icon& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_icon_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Icon(Icon&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~Icon() { + if(dataPtr_ != nullptr) { + fm_icon_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Icon wrapPtr(FmIcon* dataPtr) { + Icon obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmIcon* takeDataPtr() { + FmIcon* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmIcon* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmIcon*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Icon& operator=(const Icon& other) { + if(dataPtr_ != nullptr) { + fm_icon_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_icon_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Icon& operator=(Icon&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + static void unloadCache( ) { + fm_icon_unload_cache(); + } + + + static void resetUserDataCache(GQuark quark) { + fm_icon_reset_user_data_cache(quark); + } + + + static void unloadUserDataCache( ) { + fm_icon_unload_user_data_cache(); + } + + + static void setUserDataDestroy(GDestroyNotify func) { + fm_icon_set_user_data_destroy(func); + } + + + void setUserData(gpointer user_data) { + fm_icon_set_user_data(dataPtr(), user_data); + } + + + gpointer getUserData(void) { + return fm_icon_get_user_data(dataPtr()); + } + + + static Icon fromName(const char* name) { + return Icon::wrapPtr(fm_icon_from_name(name)); + } + + + static Icon fromGicon(GIcon* gicon) { + return Icon::wrapPtr(fm_icon_from_gicon(gicon)); + } + + + +private: + FmIcon* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_ICON_H__ diff --git a/src/job.h b/src/job.h new file mode 100644 index 0000000..12e337b --- /dev/null +++ b/src/job.h @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_JOB_H__ +#define __LIBFM_QT_FM_JOB_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Job { +public: + + + // default constructor + Job() { + dataPtr_ = nullptr; + } + + + Job(FmJob* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Job(const Job& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Job(Job&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~Job() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Job wrapPtr(FmJob* dataPtr) { + Job obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmJob* takeDataPtr() { + FmJob* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmJob* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmJob*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Job& operator=(const Job& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Job& operator=(Job&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void resume(void) { + fm_job_resume(dataPtr()); + } + + + bool pause(void) { + return fm_job_pause(dataPtr()); + } + + + int askValist(const char* question, va_list options) { + return fm_job_ask_valist(dataPtr(), question, options); + } + + + int askv(const char* question, gchar* const* options) { + return fm_job_askv(dataPtr(), question, options); + } + + + int ask(const char* question, ... ) { + + int ret; + va_list args; + va_start (args, question); + ret = fm_job_ask_valist(dataPtr(), question, args); + va_end (args); + return ret; + + } + + + FmJobErrorAction emitError(GError* err, FmJobErrorSeverity severity) { + return fm_job_emit_error(dataPtr(), err, severity); + } + + + void finish(void) { + fm_job_finish(dataPtr()); + } + + + void setCancellable(GCancellable* cancellable) { + fm_job_set_cancellable(dataPtr(), cancellable); + } + + + GCancellable* getCancellable(void) { + return fm_job_get_cancellable(dataPtr()); + } + + + void initCancellable(void) { + fm_job_init_cancellable(dataPtr()); + } + + + gpointer callMainThread(FmJobCallMainThreadFunc func, gpointer user_data) { + return fm_job_call_main_thread(dataPtr(), func, user_data); + } + + + void cancel(void) { + fm_job_cancel(dataPtr()); + } + + + bool runSyncWithMainloop(void) { + return fm_job_run_sync_with_mainloop(dataPtr()); + } + + + bool runSync(void) { + return fm_job_run_sync(dataPtr()); + } + + + bool runAsync(void) { + return fm_job_run_async(dataPtr()); + } + + + bool isRunning(void) { + return fm_job_is_running(dataPtr()); + } + + + bool isCancelled(void) { + return fm_job_is_cancelled(dataPtr()); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_JOB_H__ diff --git a/src/list.h b/src/list.h new file mode 100644 index 0000000..e207004 --- /dev/null +++ b/src/list.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_LIST_H__ +#define __LIBFM_QT_FM_LIST_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API List { +public: + + + List(FmListFuncs* funcs) { + dataPtr_ = reinterpret_cast(fm_list_new(funcs)); + } + + + // default constructor + List() { + dataPtr_ = nullptr; + } + + + List(FmList* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_list_ref(dataPtr)) : nullptr; + } + + + // copy constructor + List(const List& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_list_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + List(List&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~List() { + if(dataPtr_ != nullptr) { + fm_list_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static List wrapPtr(FmList* dataPtr) { + List obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmList* takeDataPtr() { + FmList* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmList* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmList*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + List& operator=(const List& other) { + if(dataPtr_ != nullptr) { + fm_list_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_list_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + List& operator=(List&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void deleteLink(GList* l_) { + fm_list_delete_link(dataPtr(), l_); + } + + + void removeAll(gpointer data) { + fm_list_remove_all(dataPtr(), data); + } + + + void remove(gpointer data) { + fm_list_remove(dataPtr(), data); + } + + + void clear(void) { + fm_list_clear(dataPtr()); + } + + + +private: + FmList* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_LIST_H__ diff --git a/src/mimetype.h b/src/mimetype.h new file mode 100644 index 0000000..5cf402d --- /dev/null +++ b/src/mimetype.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_MIME_TYPE_H__ +#define __LIBFM_QT_FM_MIME_TYPE_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API MimeType { +public: + + + // default constructor + MimeType() { + dataPtr_ = nullptr; + } + + + MimeType(FmMimeType* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_mime_type_ref(dataPtr)) : nullptr; + } + + + // copy constructor + MimeType(const MimeType& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_mime_type_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + MimeType(MimeType&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~MimeType() { + if(dataPtr_ != nullptr) { + fm_mime_type_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static MimeType wrapPtr(FmMimeType* dataPtr) { + MimeType obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmMimeType* takeDataPtr() { + FmMimeType* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmMimeType* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmMimeType*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + MimeType& operator=(const MimeType& other) { + if(dataPtr_ != nullptr) { + fm_mime_type_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_mime_type_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + MimeType& operator=(MimeType&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void removeThumbnailer(gpointer thumbnailer) { + fm_mime_type_remove_thumbnailer(dataPtr(), thumbnailer); + } + + + void addThumbnailer(gpointer thumbnailer) { + fm_mime_type_add_thumbnailer(dataPtr(), thumbnailer); + } + + + GList* getThumbnailersList(void) { + return fm_mime_type_get_thumbnailers_list(dataPtr()); + } + + + FmIcon* getIcon(void) { + return fm_mime_type_get_icon(dataPtr()); + } + + + static MimeType fromName(const char* type) { + return MimeType::wrapPtr(fm_mime_type_from_name(type)); + } + + + static MimeType fromNativeFile(const char* file_path, const char* base_name, struct stat* pstat) { + return MimeType::wrapPtr(fm_mime_type_from_native_file(file_path, base_name, pstat)); + } + + + static MimeType fromFileName(const char* ufile_name) { + return MimeType::wrapPtr(fm_mime_type_from_file_name(ufile_name)); + } + + + +private: + FmMimeType* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_MIME_TYPE_H__ diff --git a/src/monitor.h b/src/monitor.h new file mode 100644 index 0000000..e69de29 diff --git a/src/mountoperation.cpp b/src/mountoperation.cpp index bc3e0b8..b7fb9cc 100644 --- a/src/mountoperation.cpp +++ b/src/mountoperation.cpp @@ -31,10 +31,10 @@ namespace Fm { MountOperation::MountOperation(bool interactive, QWidget* parent): QObject(parent), - interactive_(interactive), - running(false), op(g_mount_operation_new()), cancellable_(g_cancellable_new()), + running(false), + interactive_(interactive), eventLoop(NULL), autoDestroy_(true) { diff --git a/src/mountoperationpassworddialog.cpp b/src/mountoperationpassworddialog.cpp index 4305b0a..f2783e3 100644 --- a/src/mountoperationpassworddialog.cpp +++ b/src/mountoperationpassworddialog.cpp @@ -27,11 +27,11 @@ namespace Fm { MountOperationPasswordDialog::MountOperationPasswordDialog(MountOperation* op, GAskPasswordFlags flags): QDialog(), mountOperation(op), - canAnonymous(flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED ? true : false), - canSavePassword(flags & G_ASK_PASSWORD_SAVING_SUPPORTED ? true : false), - needUserName(flags & G_ASK_PASSWORD_NEED_USERNAME ? true : false), needPassword(flags & G_ASK_PASSWORD_NEED_PASSWORD ? true : false), - needDomain(flags & G_ASK_PASSWORD_NEED_DOMAIN ? true : false) { + needUserName(flags & G_ASK_PASSWORD_NEED_USERNAME ? true : false), + needDomain(flags & G_ASK_PASSWORD_NEED_DOMAIN ? true : false), + canSavePassword(flags & G_ASK_PASSWORD_SAVING_SUPPORTED ? true : false), + canAnonymous(flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED ? true : false) { ui = new Ui::MountOperationPasswordDialog(); ui->setupUi(this); diff --git a/src/navhistory.h b/src/navhistory.h new file mode 100644 index 0000000..f88ef4c --- /dev/null +++ b/src/navhistory.h @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_NAV_HISTORY_H__ +#define __LIBFM_QT_FM_NAV_HISTORY_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API NavHistory { +public: + + + NavHistory(void ) { + dataPtr_ = reinterpret_cast(fm_nav_history_new()); + } + + + NavHistory(FmNavHistory* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + NavHistory(const NavHistory& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + NavHistory(NavHistory&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~NavHistory() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static NavHistory wrapPtr(FmNavHistory* dataPtr) { + NavHistory obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmNavHistory* takeDataPtr() { + FmNavHistory* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmNavHistory* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmNavHistory*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + NavHistory& operator=(const NavHistory& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + NavHistory& operator=(NavHistory&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + void setMax(guint num) { + fm_nav_history_set_max(dataPtr(), num); + } + + + void clear(void) { + fm_nav_history_clear(dataPtr()); + } + + + void chdir(FmPath* path, gint old_scroll_pos) { + fm_nav_history_chdir(dataPtr(), path, old_scroll_pos); + } + + + bool canBack(void) { + return fm_nav_history_can_back(dataPtr()); + } + + + int getScrollPos(void) { + return fm_nav_history_get_scroll_pos(dataPtr()); + } + + + FmPath* goTo(guint n, gint old_scroll_pos) { + return fm_nav_history_go_to(dataPtr(), n, old_scroll_pos); + } + + + FmPath* getNthPath(guint n) { + return fm_nav_history_get_nth_path(dataPtr(), n); + } + + + unsigned int getCurIndex(void) { + return fm_nav_history_get_cur_index(dataPtr()); + } + + + void jump(GList* l, int old_scroll_pos) { + fm_nav_history_jump(dataPtr(), l, old_scroll_pos); + } + + + void forward(int old_scroll_pos) { + fm_nav_history_forward(dataPtr(), old_scroll_pos); + } + + + bool canForward(void) { + return fm_nav_history_can_forward(dataPtr()); + } + + + void back(int old_scroll_pos) { + fm_nav_history_back(dataPtr(), old_scroll_pos); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_NAV_HISTORY_H__ diff --git a/src/path.h b/src/path.h index be4a610..dccf91e 100644 --- a/src/path.h +++ b/src/path.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 - 2015 Hong Jen Yee (PCMan) + * Copyright (C) 2016 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 @@ -17,231 +17,425 @@ * */ -#ifndef FM_PATH_H -#define FM_PATH_H +#ifndef __LIBFM_QT_FM_PATH_H__ +#define __LIBFM_QT_FM_PATH_H__ -#include "libfmqtglobals.h" #include -#include +#include +#include #include +#include "libfmqtglobals.h" + namespace Fm { -class LIBFM_QT_API Path { + +class LIBFM_QT_API PathList { public: - Path(): data_(nullptr) { + + PathList(void ) { + dataPtr_ = reinterpret_cast(fm_path_list_new()); } - Path(FmPath* path, bool takeOwnership = false): data_(path) { - if(path && !takeOwnership) - fm_path_ref(data_); + + PathList(FmPathList* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_list_ref(FM_LIST(dataPtr))) : nullptr; } - Path(const Path& other): data_(other.data_ ? fm_path_ref(other.data_) : nullptr) { + + // copy constructor + PathList(const PathList& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_list_ref(FM_LIST(other.dataPtr_))) : nullptr; } - Path(GFile* gf): data_(fm_path_new_for_gfile(gf)) { + + // move constructor + PathList(PathList&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); } - ~Path() { - if(data_) - fm_path_unref(data_); + + // destructor + ~PathList() { + if(dataPtr_ != nullptr) { + fm_list_unref(FM_LIST(dataPtr_)); + } } - static Path fromPathName(const char* path_name) { - return Path(fm_path_new_for_path(path_name), true); + + // create a wrapper for the data pointer without increasing the reference count + static PathList wrapPtr(FmPathList* dataPtr) { + PathList obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; } - static Path fromUri(const char* uri) { - return Path(fm_path_new_for_uri(uri), true); + // disown the managed data pointer + FmPathList* takeDataPtr() { + FmPathList* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; } - static Path fromDisplayName(const char* path_name) { - return Path(fm_path_new_for_display_name(path_name), true); + // get the raw pointer wrapped + FmPathList* dataPtr() { + return reinterpret_cast(dataPtr_); } - static Path fromString(const char* path_str) { - return Path(fm_path_new_for_str(path_str), true); + // automatic type casting + operator FmPathList*() { + return dataPtr(); } - static Path fromCommandlineArg(const char* arg) { - return Path(fm_path_new_for_commandline_arg(arg), true); + // copy assignment + PathList& operator=(const PathList& other) { + if(dataPtr_ != nullptr) { + fm_list_unref(FM_LIST(dataPtr_)); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_list_ref(FM_LIST(other.dataPtr_))) : nullptr; + return *this; } - Path child(const char* basename) { - return Path(fm_path_new_child(data_, basename), true); + + // move assignment + PathList& operator=(PathList&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; } - Path child(const char* basename, int name_len) { - return Path(fm_path_new_child_len(data_, basename, name_len), true); + bool isNull() { + return (dataPtr_ == nullptr); } - Path relative(const char* rel) { - return Path(fm_path_new_relative(data_, rel), true); + // methods + + void writeUriList(GString* buf) { + fm_path_list_write_uri_list(dataPtr(), buf); } - /* predefined paths */ - static Path root(void) { /* / */ - return Path(fm_path_get_root(), false); + char* toUriList(void) { + return fm_path_list_to_uri_list(dataPtr()); } - static Path home(void) { /* home directory */ - return Path(fm_path_get_home(), false); + unsigned int getLength() { + return fm_path_list_get_length(dataPtr()); } - static Path desktop(void) { /* $HOME/Desktop */ - return Path(fm_path_get_desktop(), false); + bool isEmpty() { + return fm_path_list_is_empty(dataPtr()); } - static Path trash(void) { /* trash:/// */ - return Path(fm_path_get_trash(), false); + FmPath* peekHead() { + return fm_path_list_peek_head(dataPtr()); } - static Path appsMenu(void) { /* menu://applications.menu/ */ - return Path(fm_path_get_apps_menu(), false); + GList* peekHeadLink() { + return fm_path_list_peek_head_link(dataPtr()); } - Path parent() { - return Path(data_ != nullptr ? fm_path_get_parent(data_) : nullptr, false); + void pushTail(FmPath* path) { + fm_path_list_push_tail(dataPtr(), path); } - const char* basename() { - return fm_path_get_basename(data_); + static PathList newFromFileInfoGslist(GSList* fis) { + return PathList::wrapPtr(fm_path_list_new_from_file_info_gslist(fis)); } - FmPathFlags flags() { - return fm_path_get_flags(data_); + + static PathList newFromFileInfoGlist(GList* fis) { + return PathList::wrapPtr(fm_path_list_new_from_file_info_glist(fis)); } - bool hasPrefix(FmPath* prefix) { - return fm_path_has_prefix(data_, prefix); + + static PathList newFromFileInfoList(FmFileInfoList* fis) { + return PathList::wrapPtr(fm_path_list_new_from_file_info_list(fis)); + } + + + static PathList newFromUris(char* const* uris) { + return PathList::wrapPtr(fm_path_list_new_from_uris(uris)); + } + + + static PathList newFromUriList(const char* uri_list) { + return PathList::wrapPtr(fm_path_list_new_from_uri_list(uri_list)); + } + + + +private: + FmPathList* dataPtr_; // data pointer for the underlying C struct + +}; + + + +class LIBFM_QT_API Path { +public: + + + // default constructor + Path() { + dataPtr_ = nullptr; + } + + + Path(FmPath* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_path_ref(dataPtr)) : nullptr; } - Path schemePath() { - return Path(fm_path_get_scheme_path(data_), true); + + // copy constructor + Path(const Path& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_path_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Path(Path&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~Path() { + if(dataPtr_ != nullptr) { + fm_path_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Path wrapPtr(FmPath* dataPtr) { + Path obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmPath* takeDataPtr() { + FmPath* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmPath* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmPath*() { + return dataPtr(); + } + + // copy assignment + Path& operator=(const Path& other) { + if(dataPtr_ != nullptr) { + fm_path_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_path_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Path& operator=(Path&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; } + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods bool isNative() { - return fm_path_is_native(data_); + return fm_path_is_native(dataPtr()); } bool isTrash() { - return fm_path_is_trash(data_); + return fm_path_is_trash(dataPtr()); } bool isTrashRoot() { - return fm_path_is_trash_root(data_); + return fm_path_is_trash_root(dataPtr()); } bool isNativeOrTrash() { - return fm_path_is_native_or_trash(data_); + return fm_path_is_native_or_trash(dataPtr()); } - char* toString() { - return fm_path_to_str(data_); + int depth(void) { + return fm_path_depth(dataPtr()); } - QByteArray toByteArray() { - char* s = fm_path_to_str(data_); - QByteArray str(s); - g_free(s); - return str; + + bool equalStr(const gchar* str, int n) { + return fm_path_equal_str(dataPtr(), str, n); } - char* toUri() { - return fm_path_to_uri(data_); + + int compare(FmPath* p2) { + return fm_path_compare(dataPtr(), p2); } - GFile* toGfile() { - return fm_path_to_gfile(data_); + int compare(Path& p2) { + return fm_path_compare(dataPtr(), p2.dataPtr()); } - /* - char* displayName(bool human_readable = true) { - return fm_path_display_name(data_, human_readable); + bool equal(FmPath* p2) { + return fm_path_equal(dataPtr(), p2); } - */ - QString displayName(bool human_readable = true) { - char* dispname = fm_path_display_name(data_, human_readable); - QString str = QString::fromUtf8(dispname); - g_free(dispname); - return str; + bool equal(Path& p2) { + return fm_path_equal(dataPtr(), p2.dataPtr()); } - /* - char* displayBasename() { - return fm_path_display_basename(data_); + bool operator == (Path& other) { + return fm_path_equal(dataPtr(), other.dataPtr()); } - */ - QString displayBasename() { - char* basename = fm_path_display_basename(data_); - QString s = QString::fromUtf8(basename); - g_free(basename); - return s; + bool operator != (Path& other) { + return !fm_path_equal(dataPtr(), other.dataPtr()); } - /* For used in hash tables */ - guint hash() { - return fm_path_hash(data_); + bool operator < (Path& other) { + return compare(other); } - void take(FmPath* path) { // take the ownership of the "path" - if(data_) - fm_path_unref(data_); - data_ = path; + bool operator > (Path& other) { + return (other < *this); } - Path& operator = (const Path& other) { - if(data_) - fm_path_unref(data_); - data_ = fm_path_ref(other.data_); - return *this; + unsigned int hash(void) { + return fm_path_hash(dataPtr()); } - bool operator == (const Path& other) const { - return fm_path_equal(data_, other.data_); + + char* displayBasename(void) { + return fm_path_display_basename(dataPtr()); } - bool operator != (const Path& other) const { - return !fm_path_equal(data_, other.data_); + char* displayName(gboolean human_readable) { + return fm_path_display_name(dataPtr(), human_readable); } - bool operator < (const Path& other) const { - return compare(other); + + GFile* toGfile(void) { + return fm_path_to_gfile(dataPtr()); } - bool operator > (const Path& other) const { - return (other < *this); + + char* toUri(void) { + return fm_path_to_uri(dataPtr()); } - /* can be used for sorting */ - int compare(const Path& other) const { - return fm_path_compare(data_, other.data_); + + char* toStr(void) { + return fm_path_to_str(dataPtr()); } - /* used for completion in entry */ - bool equal(const gchar *str, int n) const { - return fm_path_equal_str(data_, str, n); + + Path getSchemePath(void) { + return Path(fm_path_get_scheme_path(dataPtr())); } - /* calculate how many elements are in this path. */ - int depth() const { - return fm_path_depth(data_); + + bool hasPrefix(FmPath* prefix) { + return fm_path_has_prefix(dataPtr(), prefix); } - FmPath* data() const { - return data_; + + FmPathFlags getFlags(void) { + return fm_path_get_flags(dataPtr()); } + + Path getParent(void) { + return Path(fm_path_get_parent(dataPtr())); + } + + + static Path getAppsMenu(void ) { + return Path(fm_path_get_apps_menu()); + } + + + static Path getTrash(void ) { + return Path(fm_path_get_trash()); + } + + + static Path getDesktop(void ) { + return Path(fm_path_get_desktop()); + } + + + static Path getHome(void ) { + return Path(fm_path_get_home()); + } + + + static Path getRoot(void ) { + return Path(fm_path_get_root()); + } + + + static Path newForGfile(GFile* gf) { + return Path::wrapPtr(fm_path_new_for_gfile(gf)); + } + + + Path newRelative(const char* rel) { + return Path::wrapPtr(fm_path_new_relative(dataPtr(), rel)); + } + + + Path newChildLen(const char* basename, int name_len) { + return Path::wrapPtr(fm_path_new_child_len(dataPtr(), basename, name_len)); + } + + + Path newChild(const char* basename) { + return Path::wrapPtr(fm_path_new_child(dataPtr(), basename)); + } + + + static Path newForCommandlineArg(const char* arg) { + return Path::wrapPtr(fm_path_new_for_commandline_arg(arg)); + } + + + static Path newForStr(const char* path_str) { + return Path::wrapPtr(fm_path_new_for_str(path_str)); + } + + + static Path newForDisplayName(const char* path_name) { + return Path::wrapPtr(fm_path_new_for_display_name(path_name)); + } + + + static Path newForUri(const char* uri) { + return Path::wrapPtr(fm_path_new_for_uri(uri)); + } + + + static Path newForPath(const char* path_name) { + return Path::wrapPtr(fm_path_new_for_path(path_name)); + } + + + private: - FmPath* data_; + FmPath* dataPtr_; // data pointer for the underlying C struct + }; } Q_DECLARE_OPAQUE_POINTER(FmPath*) -#endif // FM_PATH_H +#endif // __LIBFM_QT_FM_PATH_H__ diff --git a/src/pathedit.cpp b/src/pathedit.cpp index 01fd35a..50b866d 100644 --- a/src/pathedit.cpp +++ b/src/pathedit.cpp @@ -69,9 +69,9 @@ void PathEditJob::runJob() { PathEdit::PathEdit(QWidget* parent): QLineEdit(parent), - cancellable_(NULL), + completer_(new QCompleter()), model_(new QStringListModel()), - completer_(new QCompleter()) { + cancellable_(NULL) { setCompleter(completer_); completer_->setModel(model_); connect(this, &PathEdit::textChanged, this, &PathEdit::onTextChanged); diff --git a/src/placesmodelitem.cpp b/src/placesmodelitem.cpp index 8df7608..1f18f1f 100644 --- a/src/placesmodelitem.cpp +++ b/src/placesmodelitem.cpp @@ -27,15 +27,15 @@ namespace Fm { PlacesModelItem::PlacesModelItem(): QStandardItem(), path_(NULL), - icon_(NULL), - fileInfo_(NULL) { + fileInfo_(NULL), + icon_(NULL) { } PlacesModelItem::PlacesModelItem(const char* iconName, QString title, FmPath* path): QStandardItem(title), path_(path ? fm_path_ref(path) : NULL), - icon_(fm_icon_from_name(iconName)), - fileInfo_(NULL) { + fileInfo_(NULL), + icon_(fm_icon_from_name(iconName)) { if(icon_) QStandardItem::setIcon(IconTheme::icon(icon_)); setEditable(false); @@ -44,8 +44,8 @@ PlacesModelItem::PlacesModelItem(const char* iconName, QString title, FmPath* pa PlacesModelItem::PlacesModelItem(FmIcon* icon, QString title, FmPath* path): QStandardItem(title), path_(path ? fm_path_ref(path) : NULL), - icon_(icon ? fm_icon_ref(icon) : NULL), - fileInfo_(NULL) { + fileInfo_(NULL), + icon_(icon ? fm_icon_ref(icon) : NULL) { if(icon_) QStandardItem::setIcon(IconTheme::icon(icon)); setEditable(false); @@ -53,9 +53,9 @@ PlacesModelItem::PlacesModelItem(FmIcon* icon, QString title, FmPath* path): PlacesModelItem::PlacesModelItem(QIcon icon, QString title, FmPath* path): QStandardItem(icon, title), - icon_(NULL), path_(path ? fm_path_ref(path) : NULL), - fileInfo_(NULL) { + fileInfo_(NULL), + icon_(NULL) { setEditable(false); } diff --git a/src/proxyfoldermodel.cpp b/src/proxyfoldermodel.cpp index b375a2d..94accc1 100644 --- a/src/proxyfoldermodel.cpp +++ b/src/proxyfoldermodel.cpp @@ -26,10 +26,10 @@ namespace Fm { ProxyFolderModel::ProxyFolderModel(QObject * parent): QSortFilterProxyModel(parent), - thumbnailSize_(0), showHidden_(false), + folderFirst_(true), showThumbnails_(false), - folderFirst_(true) { + thumbnailSize_(0) { setDynamicSortFilter(true); setSortCaseSensitivity(Qt::CaseInsensitive); } diff --git a/src/sidepane.cpp b/src/sidepane.cpp index 9c9a20f..959245d 100644 --- a/src/sidepane.cpp +++ b/src/sidepane.cpp @@ -32,12 +32,12 @@ namespace Fm { SidePane::SidePane(QWidget* parent): QWidget(parent), - showHidden_(false), - mode_(ModeNone), + currentPath_(NULL), view_(NULL), combo_(NULL), - currentPath_(NULL), - iconSize_(24, 24) { + iconSize_(24, 24), + mode_(ModeNone), + showHidden_(false) { verticalLayout = new QVBoxLayout(this); verticalLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/simplejob.h b/src/simplejob.h new file mode 100644 index 0000000..e69de29 diff --git a/src/templates.h b/src/templates.h new file mode 100644 index 0000000..fa55979 --- /dev/null +++ b/src/templates.h @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_TEMPLATES_H__ +#define __LIBFM_QT_FM_TEMPLATES_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Template { +public: + + + // default constructor + Template() { + dataPtr_ = nullptr; + } + + + Template(FmTemplate* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Template(const Template& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Template(Template&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~Template() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Template wrapPtr(FmTemplate* dataPtr) { + Template obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmTemplate* takeDataPtr() { + FmTemplate* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmTemplate* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmTemplate*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Template& operator=(const Template& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Template& operator=(Template&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + bool createFile(GFile* path, GError** error, gboolean run_default) { + return fm_template_create_file(dataPtr(), path, error, run_default); + } + + + bool isDirectory(void) { + return fm_template_is_directory(dataPtr()); + } + + + FmIcon* getIcon(void) { + return fm_template_get_icon(dataPtr()); + } + + + FmMimeType* getMimeType(void) { + return fm_template_get_mime_type(dataPtr()); + } + + + static GList* listAll(gboolean user_only) { + return fm_template_list_all(user_only); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_TEMPLATES_H__ diff --git a/src/terminal.h b/src/terminal.h new file mode 100644 index 0000000..cd7a31c --- /dev/null +++ b/src/terminal.h @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_TERMINAL_H__ +#define __LIBFM_QT_FM_TERMINAL_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Terminal { +public: + + + // default constructor + Terminal() { + dataPtr_ = nullptr; + } + + + Terminal(FmTerminal* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(g_object_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Terminal(const Terminal& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Terminal(Terminal&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + virtual ~Terminal() { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Terminal wrapPtr(FmTerminal* dataPtr) { + Terminal obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmTerminal* takeDataPtr() { + FmTerminal* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmTerminal* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmTerminal*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Terminal& operator=(const Terminal& other) { + if(dataPtr_ != nullptr) { + g_object_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(g_object_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Terminal& operator=(Terminal&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + static bool launch(const gchar* dir, GError** error) { + return fm_terminal_launch(dir, error); + } + + + static Terminal dupDefault(GError** error) { + return Terminal::wrapPtr(fm_terminal_dup_default(error)); + } + + + // automatic type casting for GObject + operator GObject*() { + return reinterpret_cast(dataPtr_); + } + + +protected: + GObject* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_TERMINAL_H__ diff --git a/src/thumbnailer.h b/src/thumbnailer.h new file mode 100644 index 0000000..bbf3db2 --- /dev/null +++ b/src/thumbnailer.h @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2016 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 __LIBFM_QT_FM_THUMBNAILER_H__ +#define __LIBFM_QT_FM_THUMBNAILER_H__ + +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + +class LIBFM_QT_API Thumbnailer { +public: + + + // default constructor + Thumbnailer() { + dataPtr_ = nullptr; + } + + + Thumbnailer(FmThumbnailer* dataPtr){ + dataPtr_ = dataPtr != nullptr ? reinterpret_cast(fm_thumbnailer_ref(dataPtr)) : nullptr; + } + + + // copy constructor + Thumbnailer(const Thumbnailer& other) { + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_thumbnailer_ref(other.dataPtr_)) : nullptr; + } + + + // move constructor + Thumbnailer(Thumbnailer&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + } + + + // destructor + ~Thumbnailer() { + if(dataPtr_ != nullptr) { + fm_thumbnailer_unref(dataPtr_); + } + } + + + // create a wrapper for the data pointer without increasing the reference count + static Thumbnailer wrapPtr(FmThumbnailer* dataPtr) { + Thumbnailer obj; + obj.dataPtr_ = reinterpret_cast(dataPtr); + return obj; + } + + // disown the managed data pointer + FmThumbnailer* takeDataPtr() { + FmThumbnailer* data = reinterpret_cast(dataPtr_); + dataPtr_ = nullptr; + return data; + } + + // get the raw pointer wrapped + FmThumbnailer* dataPtr() { + return reinterpret_cast(dataPtr_); + } + + // automatic type casting + operator FmThumbnailer*() { + return dataPtr(); + } + + // automatic type casting + operator void*() { + return dataPtr(); + } + + + // copy assignment + Thumbnailer& operator=(const Thumbnailer& other) { + if(dataPtr_ != nullptr) { + fm_thumbnailer_unref(dataPtr_); + } + dataPtr_ = other.dataPtr_ != nullptr ? reinterpret_cast(fm_thumbnailer_ref(other.dataPtr_)) : nullptr; + return *this; + } + + + // move assignment + Thumbnailer& operator=(Thumbnailer&& other) { + dataPtr_ = reinterpret_cast(other.takeDataPtr()); + return *this; + } + + bool isNull() { + return (dataPtr_ == nullptr); + } + + // methods + + static void checkUpdate( ) { + fm_thumbnailer_check_update(); + } + + + void free(void) { + fm_thumbnailer_free(dataPtr()); + } + + + bool launchForUri(const char* uri, const char* output_file, guint size) { + return fm_thumbnailer_launch_for_uri(dataPtr(), uri, output_file, size); + } + + + GPid launchForUriAsync(const char* uri, const char* output_file, guint size, GError** error) { + return fm_thumbnailer_launch_for_uri_async(dataPtr(), uri, output_file, size, error); + } + + + char* commandForUri(const char* uri, const char* output_file, guint size) { + return fm_thumbnailer_command_for_uri(dataPtr(), uri, output_file, size); + } + + + static Thumbnailer newFromKeyfile(const char* id, GKeyFile* kf) { + return Thumbnailer::wrapPtr(fm_thumbnailer_new_from_keyfile(id, kf)); + } + + + +private: + FmThumbnailer* dataPtr_; // data pointer for the underlying C struct + +}; + + +} + +#endif // __LIBFM_QT_FM_THUMBNAILER_H__ diff --git a/src/thumbnailloader.cpp b/src/thumbnailloader.cpp index af60fd6..8b46cdb 100644 --- a/src/thumbnailloader.cpp +++ b/src/thumbnailloader.cpp @@ -98,7 +98,7 @@ ThumbnailLoader::ThumbnailLoader() { getImageText, setImageText }; - gboolean success = fm_thumbnail_loader_set_backend(&qt_backend); + fm_thumbnail_loader_set_backend(&qt_backend); } ThumbnailLoader::~ThumbnailLoader() { @@ -117,7 +117,7 @@ GObject* ThumbnailLoader::readImageFromStream(GInputStream* stream, guint64 len, // FIXME: should we set a limit here? Otherwise if len is too large, we can run out of memory. QScopedArrayPointer buffer(new unsigned char[len]); // allocate enough buffer unsigned char* pbuffer = buffer.data(); - int totalReadSize = 0; + unsigned int totalReadSize = 0; while(!g_cancellable_is_cancelled(cancellable) && totalReadSize < len) { int bytesToRead = totalReadSize + 4096 > len ? len - totalReadSize : 4096; gssize readSize = g_input_stream_read(stream, pbuffer, bytesToRead, cancellable, NULL); diff --git a/src/utilities.cpp b/src/utilities.cpp index 8823d60..57cb451 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -93,7 +93,7 @@ void copyFilesToClipboard(FmPathList* files) { QMimeData* data = new QMimeData(); char* urilist = fm_path_list_to_uri_list(files); // Gnome, LXDE, and XFCE - data->setData("x-special/gnome-copied-files", (QString("copy\n") + urilist).toUtf8()); + data->setData("x-special/gnome-copied-files", QByteArray("copy\n") + QByteArray(urilist)); // The KDE way data->setData("text/uri-list", urilist); // data.setData("x-kde-cut-selection", "0"); @@ -106,7 +106,7 @@ void cutFilesToClipboard(FmPathList* files) { QMimeData* data = new QMimeData(); char* urilist = fm_path_list_to_uri_list(files); // Gnome, LXDE, and XFCE - data->setData("x-special/gnome-copied-files", (QString("cut\n") + urilist).toUtf8()); + data->setData("x-special/gnome-copied-files", QByteArray("cut\n") + QByteArray(urilist)); // The KDE way data->setData("text/uri-list", urilist); data->setData("x-kde-cut-selection", "1"); diff --git a/src/path.cpp b/src/utils.h similarity index 73% rename from src/path.cpp rename to src/utils.h index 5af020f..109146d 100644 --- a/src/path.cpp +++ b/src/utils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 - 2015 Hong Jen Yee (PCMan) + * Copyright (C) 2016 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 @@ -17,6 +17,19 @@ * */ -#include "path.h" +#ifndef __LIBFM_QT_FM_UTILS_H__ +#define __LIBFM_QT_FM_UTILS_H__ -using namespace Fm; +#include +#include +#include +#include "libfmqtglobals.h" + + +namespace Fm { + + + +} + +#endif // __LIBFM_QT_FM_UTILS_H__ diff --git a/src/xdndworkaround.cpp b/src/xdndworkaround.cpp index b7b73a8..ef8238e 100644 --- a/src/xdndworkaround.cpp +++ b/src/xdndworkaround.cpp @@ -84,7 +84,6 @@ XdndWorkaround::~XdndWorkaround() { bool XdndWorkaround::nativeEventFilter(const QByteArray & eventType, void * message, long * result) { if(Q_LIKELY(eventType == "xcb_generic_event_t")) { xcb_generic_event_t* event = static_cast(message); - uint8_t response_type = event->response_type & uint8_t(~0x80); switch(event->response_type & ~0x80) { case XCB_CLIENT_MESSAGE: return clientMessage(reinterpret_cast(event)); @@ -163,12 +162,11 @@ QByteArray XdndWorkaround::windowProperty(xcb_window_t window, xcb_atom_t propAt // static void XdndWorkaround::setWindowProperty(xcb_window_t window, xcb_atom_t propAtom, xcb_atom_t typeAtom, void* data, int len, int format) { xcb_connection_t* conn = QX11Info::connection(); - xcb_void_cookie_t cookie = xcb_change_property(conn, XCB_PROP_MODE_REPLACE, window, propAtom, typeAtom, format, len, data); + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, window, propAtom, typeAtom, format, len, data); } bool XdndWorkaround::clientMessage(xcb_client_message_event_t* event) { - xcb_connection_t* conn = QX11Info::connection(); QByteArray event_type = atomName(event->type); // qDebug() << "client message:" << event_type;