From f70ba3e769cb134fba37420fcdb45228d3bac843 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Sat, 24 Sep 2016 12:54:58 +0200 Subject: [PATCH] Adding upstream version 0.11.1. --- .gitignore | 3 + CHANGELOG | 569 ++++++++++++++++++ CMakeLists.txt | 30 +- README.md | 41 +- pcmanfm/application.cpp | 46 +- pcmanfm/application.h | 4 +- pcmanfm/autorundialog.cpp | 3 +- pcmanfm/desktopitemdelegate.cpp | 15 +- pcmanfm/desktopitemdelegate.h | 2 +- pcmanfm/desktopwindow.cpp | 53 +- pcmanfm/desktopwindow.h | 3 +- pcmanfm/launcher.cpp | 8 +- pcmanfm/main-win.ui | 47 +- pcmanfm/mainwindow.cpp | 149 ++--- pcmanfm/mainwindow.h | 13 +- pcmanfm/settings.cpp | 103 +++- pcmanfm/settings.h | 98 +++ pcmanfm/tabpage.cpp | 219 ++++--- pcmanfm/tabpage.h | 66 +- .../pcmanfm-qt-desktop-pref_ar.desktop | 4 + pcmanfm/translations/pcmanfm-qt_ar.desktop | 4 + pcmanfm/view.cpp | 14 +- 22 files changed, 1181 insertions(+), 313 deletions(-) create mode 100644 .gitignore create mode 100644 CHANGELOG create mode 100644 pcmanfm/translations/pcmanfm-qt-desktop-pref_ar.desktop create mode 100644 pcmanfm/translations/pcmanfm-qt_ar.desktop diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0df463 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +*.kdev4 +pcmanfm/translations/pcmanfm-qt diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..60f7ddc --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,569 @@ + +pcmanfm-qt-0.11.1 / 2016-09-24 +============================== + + * Bump version to 0.11.1 (#399) + * Extend README.md + * Ensure the existence of libfm dir. + * Fix the bug that breaks sort folder first option. + * Preserve per-folder view settings. * Code refactor and cleanup. * Use Fm::FolderConfig internally for storing the per-folder settings. + * Per-folder saving of sorting and view mode + * Use libfm-qt C++ wrappers instead of the original libfm C API whenever possible. + * Replace tilde with home path (#371) + * Fix -Wswitch warning + * Use LXQtCompilerSettings cmake module + * Replaces deprecated QStyleOptionViewItemV4 + * Fixes two typos (#381) + * Add Arabic Translations for Desktop Files + * I18N: Fix plural string (#374) + * Fix some icons for RTL (#366) + * Use a wide spread icon theme as fallback for the time beeing (#359) + * build: Use external translations + * ts-files removal (#352) + * Fix memory leak in main window tool bar (#350) + * Change "compact icon view" in "icon view" (#349) + * Merge pull request #341 from lxde/desktop_sort_settings + * Add some tooltips to Pref dialog + * Add setting for Desktop con size + * Fix a few compiler warnings + +0.11.0 / 2016-03-13 +=================== + + * Switch automatically to newly opened tabs + * Fixes libfm-qt dependency contradiction on README.md + * Optional fullwidth tabbar By default, the tabbar is stretched over the left pane too. This commit makes that optional with a check button in the UI page of the Preferences dialog. It's checked by default but if unchecked, the tabbar will be positioned right above the folder-view. + * A toolbar button appearing on hiding menubar It has a dropdown menu containing all menubar items, is added to the end of toolbar, after a separator, when menubar is hidden and is removed (hidden) with its separator when menubar is shown. + * fix new grep 2.23 behaviour for the time beeing + * Bump year + * Bump version number to 0.11.0, preparing for a new release. + * Add hide menu bar menu entry + * Add menubar actions to the main window + * Return focus to the folder view when hitting escape + * Added options for min. item margins. Also included a fix (or workaround) for text shadow resetting. + * Added shortcut(s) for filterbar. Also added Ctrl+F, in addition to F3, for the search utility and cleared filter string for all tabs when closing the filterbar. + * Make it possible to hide the menu bar + * Set quit shortcut from the ui file + * Update the tab bar visibility when the settings change + * Add quit shortcut + * Always draw the text shadow on desktop. Also fixed the selected text color. + * Update czech translation (by Petr Balíček ) + * Improve french translation + * Move the XdndWorkaround to libfm-qt internal instead. + * Fixed a crash on right clicking trashed files. + * Select all of the text in the path entry when focusing it using shortcut keys Alt+D and Ctrl+L. + * Use lxqt-sudo as the default su tool instead of gksu. + * Add some ``beautiful'' workarounds that bypass Qt bug #49947 and 47981. This should fix the bug lxqt/#688 temporarily. + * Prevent large gaps at desktop bottom + * Update pcmanfm-qt_it.ts + * Let the style engine draw the text selection rect on desktop. + * options: Make options of wallpaper-mode switch untranslatable + * turkiash translate files added + * Fix --wallpaper-mode description in translations + * Polish translation updated + * Polish translation updated + * Fix --show-pref option not switching to next name + * Add config values for customizing "places" (not implemented yet). + * Updated Russian translation Removed ru_RU files + +0.10.1 / 2015-12-05 +=================== + + * hide 'Create New...' menu for files + * Russian translation update + * Deal with CMAKE POLICY 0063 + * Use CMAKE_CXX_VISIBILITY_PRESET and CMAKE_VISIBILITY_INLINES_HIDDEN + * Adds Clang support to symbols visibility + * Fix typo in setting key + * hide 'Paste' in file context menu + * restore 'Open with...' for directories in left panel + * Fix referencing generated headers in translations + * CMake: Drop qt5_use_modules() + * CMake: Use the new libfm-qt Targets + * Move libfm-qt to its own repository. + +split-libfm-qt / 2015-11-24 +=========================== + + * Fix typos in man page + * Update French translation + * Tab context menu for closing other tabs + * Italian translation updates + * Add bindings to Ctrl+PgUp/Ctrl+PgDn. + * Update French translation of GPL license + * Fix a random crash related to editing the bookmarks by disconnecting from GObject signals properly. + * 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.) + * Select the item of the previously folder in current folder view if it's a direct child of the current folder. + * 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 + * Fix setting a SIGTERM handler with undefined flags + * Fix two typos in README + * Force the root config dir on the root instance + * Fix --version option not displaying version + * hu translations updated + * Fixed several problems with item selection and alignment + * Fix CMake LICENSE path + * Fix compiling with Qt < 5.4 + * Move LICENSE file + * Check for null pointers. + * Changed the static wentUp to the private variable wentUp_. + * Select the folder from where we have gone up. + +0.10.0 / 2015-11-02 +=================== + + * Release 0.10.0 + * Remove unnecessary qDebug traces + * Update zh_TW translations. + * Update translations. + * Provide an option in the view menu to turn off the filter bar (turned off by default). + * 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. + * Fix CPack README path + * Update translations + * Use markdown for README + * Bump minimum CMake to 3.0.2 + * Reduce margin and spacing of the central widget + * 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 + * Some code cleanup. + * desktop: Makes the Desktop Folder Edit functionality optional + * desktop: Renames Advanced page config layout manager + * PlacesView: activate on click on the second column + * SidePane: reduce size of button's column width + * Remove ugly board of main window's central widget + * Added a filterbar + Handle virtually hidden files + * Russian translation update + * Prevent the desktop window from being closed accidentally. This fixes #194. + * mouse fix + * Update cs_CZ translation with the strings provided by petrbal in pull request #218. + * Add apply button to desktop preferences dialog + * Removed pcmanfm-qt.kdev4 and fixed .gitignore + * desktop: Makes the preferences dialog General page tighter + * Add a shortcut key "F3" for launching the file searching utility. * Small UI layout adjistment. + * 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 #197 by using a different method to forward the XCB mouse events to the root window. + * 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) + * 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 + * Add few missing Polish translations and modify few existing. + * xdg main category added + * Update German translation + * fixed paths in .ts files + lupdate + * Update German translation + * Update Russian translation + * CMake: Remove unused INSTALL variables + * Support opening items in the bookmarks menu in new tabs or new windows. + * 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. + * Fix relative paths in command line arguments. Close lxde/pcmanfm-qt#170 - relative paths stated by xdg-open not considered. + * Create New menu actions, context menu in tree side pane, #163. + * Install SIGTERM handler to save settings when logging out, #157. + * Store side pane mode setting, #157. + * Adds UPDATE_TRANSLATIONS option to the top CMakeLists + * Fixes an translation regression + * Updates translations + * Handles .desktop files translations + * Uses LXQt lxqt_translate_ts() to handle translations + * Add German translation of pcmanfm-qt.desktop + * 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. + *_hu desktops added + * 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. + * Update pcmanfm-qt_it.ts + * Fix loading new desktop dir + * Hungarian translation + * Fix #627 - long startup time. (This blocking is caused by checking the availability of "network:///".) + * Enable text selection in file properties dialog + * Fixes #168 - qunsetenv("QT_NO_GLIB"); required before constructing the application. + * 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. + * Fix lxde/lxqt#512 - "pcmanfm-qt: cannot delete to trash" by using a safer way to check trash:/// support. + * Polish translations added + * Bumps version + * Rearrange tab order (tabstops) + * 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. + +0.9.0 / 2015-02-05 +================== + + * Add more null checks. + * Fix #130 - Remember width of side panel. + * 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. + * remember maximized state + * 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. + * Support NoUsbTrash option and fix #125 - "Move to trash " on mounted devices. + * Bump version numbers, preparing for a new release. + * Completely remove dependency on libqtxdg. + * 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. + * Fix broken rememberWindowSize settings. + * Portuguese update + * Support linguistic sorting of file names. This fixes #105. + * Avoid using Qt 5.4 API if compiled with older Qt versions. Fix #121. + * Update the folder model & view after files are changed. + * Open folders in new tabs by middle clicking on items in the side pane. + * Support reordering of tabs using drag and drop. + * 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. + * Fix #396: pcmanfm-qt back and/or up does not remember position. + * Add spanish translations + * Adds GUI to change desktop dir in Desktop preferences. Uses libqtxdg. + * Add .gitignore + * Update Japanese translation + * Add German translation + * add Japanese translation + * Implement "UnTrash" for files in trash:/// and close lxde/lxqt#136. + * Handle command line URIs correctly and fix bug lxde/lxqt#414. + * Handle command line arguments with QCommandLineParser instead of using glib. Requires Qt >= 5.2. + * 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 + +0.8.0 / 2014-09-28 +================== + + * 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.: 1008 of 1008 strings translated (0 need review). + * Commit from LXDE Pootle server by user mbouzada.: 891 of 1008 strings translated (0 need review). + * Commit from LXDE Pootle server by user mbouzada.: 615 of 1008 strings translated (0 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 + * Keep CMAKE_CXX_FLAGS value + * Update ts files. + * Add manpage for pcmanfm-qt + * Add cs_CZ translation for libfm-qt. + * Commit from LXDE Pootle server by user dforsi.: 520 of 644 strings translated (0 need review). + * 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). + * Change version number to 0.8 and update the info in the about dialog. + * Ensure that Qt 5.1 and above is used when built with Qt5 support. + * Bump package version number and library soversion to prepare for 0.2 release. + * queue relayout of desktop items when the desktop window is resized. + * Add cs_CZ translation for pcmanfm-qt. + * Fix broken Qt4 build. + * Fix bugs in multihead support and also add workaround for Qt5 bug #40681. * Handle switches between virtual desktop mode and non-virtual mode correctly. * Disable desktop wallpaper cache for non-primary screens. + * Correctly reposition desktop items when the icon size, font, or Qt style is changed. + * Slight improvement of the preference dialog for the newly added "remember window size" option. + * 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. + * Replace the very broken QDesktopWidget with QScreen in Qt 5 when handling multihead support. + * 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. + * Re-layout desktop icons properly on QEvent::StyleChange and QEvent::FontChange. + * Try to support multihead setup in virtual screen mode (used by XRandR). + * Handle QEvent::WinIdChange event and reset X11 window properties correctly. + * New files added from LXDE Pootle server based on templates + * New files added from LXDE Pootle server based on templates + * Support forced deletion of files which bypasses the trash can with "Shift+Delete" shortcut key. * Simplify shortcut setup code a little. + * Add proper keyboard shortcuts to the desktop window. This closes bug #67. + * Add an option to go to home directory when the currently shown folder is deleted or unmounted. + * Improve update of translations to avoid unnecessary regeneration of ts files. + * Improve handling of fallback icons. This closes bug #57. + * Fix the mark for current history item in the popup menu of forward and backward buttons. + * Translations are lost accidentally in a previous commit. Restore them all. + * Add a workaround for Qt bug 32567 which causes bug #251 of lxde/lxde-qt. Now the desktop window should monitor the change of work area correctly. + * Avoid ambiguity when including path.h from libfm-qt. + * Fix a crash in Fm::PlacesModel when gvfs is not available. This closes bug #35 - Ctrl+W closes all windows. + * Fix a memory leak and free the file info list properly when renaming files. + * 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. + * Show browse history in the context menu of back and forward tool buttons. + * Remove an unnecessary slot. + * Backspace to go up + * Fix bug #80 - make execute in context menu doesn't do change permissions. + * Remove unnecessary matrix set on the background brush. + * Avoid unnecessary writes to the desktop icon config file. + * Revert "fixed selection issue #45" This patch breaks copying files by DND in icon view mode and moving desktop icons. + * Avoid unnecessary relayout. + * Fix lxde/lxde-qt #184 - cannot move icons on desktop. + * Support showing the desktop menu provided by the window manager. + * Use qss instead of QPalette to set the background color of ColorButton. This fixed bug #192 of lxde-qt. + * Adds option to remember last window size + * Replace hard-coded version number 0x050000 with QT_VERSION_CHECK(5, 0, 0) for better readability. + * Rename the library from libfm-qt to libfm-qt5 when built with Qt5. + * fixed selection issue #45 + * Make settings of size of icons be properly loaded + * Makes the "Show Hidden" option be saved in settings file and properly loaded. I don't understand why it was not done yet, bu here it is. + * Close tabs by middle click + * 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 + * Replaces ${CMAKE_SOURCE_DIR} by ${PROJECT_SOURCE_DIR} + * Fix LICENSE. It's GPL2. Oops. + * Make sure clang compiler does not complain + * Clean up desktop files + * Install pkgconfig file of libfm-qt to correct location in FreeBSD + * Fix missing return values in several methods. + +0.7.0 / 2014-05-07 +================== + + * Update README + * Avoid endless popups of error dialogs when there are errors launching files. + * Fix encoding handling of filenames passed via command line arguments. + * Save thumbnails as png files correctly. + +0.6.99 / 2014-04-29 +=================== + + * Update AUTHORS and COPYING + * Cached the scaled version of the wallpaper as needed to speed up program startup. + * Correctly relayout items when the work area is changed + * Adjust size of the preference dialog + * Remember custom positions for desktop icons and fix #29. + * Use new FmTerminal APIs provided by libfm. Also fix #31. + * 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. + * Last fix for #36 is incorrect. Fix it again. + * Delete the tab if the folder currently being shown is deleted or unmounted. + * 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. + * Add Doxygen support for API doc generation. + * Fix a regression bug, hiding "Open with..." sub menu of Fm::FileMenu for selected folders. + * 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 + * Don't append library suffix to library install path, but use it by default + * 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. + * Fix #18 New windows should always show up in front. + * Fix #18 New windows should always show up in front. + * Remove x-directory/normal, close github bug #6 and #17. + * Add a wrapper class Fm::Path for FmPath C struct. + * Do not emit StyleChange events if the icon theme is not really changed. + * 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 + * Correctly save new wallpaper config. + * Support changing wallpaper from command line & dbus. + * Read fallback default settings from /etc/xdg/pcmanfm-qt. + * 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. + * Put cmake_minimum_required(VERSION 2.8.6) at the right place. + * Add "Empty trash" and fix a memory leak. + * Fix persistent busy cursor when loading menu://applications/ + * Fix memory leaks for bookmarks. Fix the broken "Network" item in places. + * Select correct folder view mode in the preference dialog. + * 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". + * Paint the background of the whole desktop window with wallpaper, including the reserved spaces. + * Set workare with QSS does not work properly. Revert the change. + * 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. + * Resize the left list widget in the preference dialog according to its content. + * Detect icon theme name automatically using Xsettings or other desktop-specific way. * Rename "IconThemeName" key in the config file to "FallbackIconThemeName". * Hide the icon theme selection combo box if an icon theme name is detected automatically. + * 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. + * Fix work area problems of desktop window. + * Trivial fix. + * Add additional custom filter support to ProxyFolderModel. + * Add some keyboard shortcuts to the main window + * 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. + * Enable thumbnail related settings. + * 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. + * Add basic thumbnail support (need the latest thumbnail branch of libfm). + +0.1 / 2013-03-26 +================ + + * Add soname 0.0.0 for libfm-qt, preparing for 0.1 release. + * Fix crashes caused by incorrect deletion of dialog objects. + * Update zh_TW translations and translation templates. + * Add Portuguese translation (pt). + * Add Lithuanian translation (lt_LT). + * Fix a crash caused by accessing data for invalid model index. + * Add a Qt designer ui file for "Find Files" utility (not yet implemented). + * 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". + * Enable auto-run related options in preferences dialog. + * 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 desktop entry files for pcmanfm-qt & its desktop preferences dialog. + * Install a pkgconfig file for libfm-qt for use in other projects. + * Fix typos causing crashes. + * 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. + * Make desktop preferences accessible from popup menu of desktop window. + * Convert enum values to/from strings for saving/loading config files. + * 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. Improve loading/saving of config file. + * Improve preferences dialog. Change base class of SidePane to QWidget. + * Add basic skeleton of preferences dialog options. + * Add -fno-exceptions to compiler flags. + * Fix a crash during updating View menu. + * 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. + * Add COPYING, AUTHORS, and README and add basic CPack support. + * Build libfm-qt as a separate shared library and install haeder files. + * Little fix for desktop item text shadow. + * Add DesktopItemDelegate to draw better desktop icons. + * Add code used to draw desktop wallpapers. + * 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. + * Add desktopManagerEnabled dbus property. Little fix for command line descriptions. + * Little fix. + * Little fix for translatable strings. + * Improve desktop management support (wallpaper & icons). + * Replace QCommandLine with glib GOptionContext for command line parsing. * Improve IPC. + * Add command line parsing and basic IPC via dbus. + * Try to use QCommandLine for command line parsing. + * Move application initialization code to PCManFM::Applicaion class. + * Move files for libfm-qt and pcmanfm-qt to separate subdirs. + * Implement cut and copy files to clipboard. + * Add a item delegate to overriding the incredibly small width of text label. Special thanks to razor-qt developers for the hint! + * Make Settings class more complete, add getters and setters. + * Trivial fix. + * Add PCManFM::Settings class for config file loading/saving. Enable dragging of items in Fm::Folderview (Dnd does not fully work yet). + * Add missing files again. + * Add missing files. + * Add the basic skeleton of "ask for rename or overwrite" dialog. + * Polishing file operation dialogs. + * Add a very primitive desktop icons window implementation. + * Add basic skeleton for preferences dialog. + * Put PCManFM specific classes under new namespace PCManFM. + * Implement very primitive and basic file operations and partial clipboard support. + * Fix bugs in Fm::FileLauncher (should not free string returned by DisplayString()). + * Add a combobox to file properties dialog to select default application. + * Implement context menu for places view to remove bookmarks and unmount volumes. Little fixes for mount operation. + * Fully implement GUI for GMountOperation. + * Implement Qt-based GUI for GMountOperation. + * Improve icon theme handling. + * Implement bookmarks menu. + * Update PlacesModel when volumes/mounts/bookmarks change. + * Improve volume mounting APIs. + * Improve internal implementation of Fm::PlacesModel. Add skelaton of file operation progress dialog. + * Handle file selection correctly. + * Improve the file properties dialog. + * Add primitive implementation of properties dialog. * Some UI polishing. + * Use Fm::ProxyFolderModel to do filter and sorting. * Little fix for Fm::IconTheme and Fm::PlacesView/Model. + * Rework Fm::IconTheme, replacing QPixmap with QIcon. Improve Fm::ProxyFolderModel and use it to implement showHidden(). + * Add a more professional about dialog. + * Little fix to ensure glib/GObject and libfm are correctly initialized. + * Use QTabBar + QStackedWidget to replace QTabWidget so we can share the same side pane among all tab pages. + * Slightly improve places view/model. + * Rename to pcmanfm-qt. * Implement tabbed-browsing. * Implement basic skeleton of GMountOperation. * Implement basic skeleton of Fm::PlacesView. + * Handle "returnPressed()" of the path entry. + * Use both of QListView and QTreeView to implement Fm::FolderView. + * Initial import, an attempt to create qt4 support for libfm. diff --git a/CMakeLists.txt b/CMakeLists.txt index becda77..9acaf46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ endif (POLICY CMP0063) set(PCMANFM_QT_VERSION_MAJOR 0) set(PCMANFM_QT_VERSION_MINOR 11) -set(PCMANFM_QT_VERSION_PATCH 0) +set(PCMANFM_QT_VERSION_PATCH 1) set(PCMANFM_QT_VERSION ${PCMANFM_QT_VERSION_MAJOR}.${PCMANFM_QT_VERSION_MINOR}.${PCMANFM_QT_VERSION_PATCH}) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -28,33 +28,7 @@ option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" O include(GNUInstallDirs) include(LXQtTranslateTs) include(LXQtTranslateDesktop) - -# set visibility to hidden to hide symbols, unless they're exported manually in the code -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 visibility to hidden to hide symbols, unless they're exported manually in the code - set(CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}") -endif() +include(LXQtCompilerSettings NO_POLICY_SCOPE) set(CMAKE_AUTOMOC TRUE) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/README.md b/README.md index 207fdfe..7c90abe 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,39 @@ # PCManFM-Qt -The Qt port of the LXDE file manager PCManFM. +## Overview -Issue tracker: - https://github.com/lxde/pcmanfm-qt/issues +PCManFM-Qt is the Qt port of PCManFM, the file manager of [LXDE](http://lxde.org). -LXQt website: - http://lxqt.org +In LXQt sessions it is in addition used to handle the desktop. Nevertheless it can be used independently of LXQt as well. -LXDE website: - http://lxde.org +PCManFM-Qt is licensed under the terms of the [GPLv2](https://www.gnu.org/licenses/gpl-2.0.en.html) or any later version. See file LICENSE for its full text. +## Installation -# License +### Compiling source code -PCManFM is licensed under the terms of the -[GPLv2](https://www.gnu.org/licenses/gpl-2.0.en.html) or any later version. +Runtime dependencies are qtx11extras, lxmenu-data, [liblxqt](https://github.com/lxde/liblxqt) and [libfm-qt](https://github.com/lxde/libfm-qt). +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. -See the LICENSE file for the full text of the license. +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. + +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), Fedora (version 0.10.0 only so far) and openSUSE (Leap 42.1 and Tumbleweed). + +## Usage + +The file manager functionality should be self-explanatory, handling of the desktop deserves some notes: + +To handle the desktop binary `pcmanfm-qt` has to be launched with switch `--desktop` set. Optionally switch `--profile` can be used to safe settings specific to certain session types like the different desktop environments. +In LXQt sessions, PCManFM-Qt is launched with theses switches set as [LXQt Module](https://github.com/lxde/lxqt-session#lxqt-modules). + +To configure the desktop there's a dialogue "Desktop Preferences". Technically it corresponds with launching `pcmanfm-qt` with switch `--desktop-pref` set. It is available in the desktop's context menu and included as topic "Desktop" in sub-menu Preferences - LXQt settings of the panel's main menu as well as the [Configuration Center](https://github.com/lxde/lxqt-config#configuration-center) of lxqt-config. + +All switches (command line options) mentioned above are explained in detail in `man 1 pcmanfm-qt`. + +## Development + +Issues should go to the tracker of PCManFM-Qt at https://github.com/lxde/pcmanfm-qt/issues. diff --git a/pcmanfm/application.cpp b/pcmanfm/application.cpp index 21c47f4..b81a8dc 100644 --- a/pcmanfm/application.cpp +++ b/pcmanfm/application.cpp @@ -43,6 +43,8 @@ #include "autorundialog.h" #include "launcher.h" #include +#include +#include #include #include @@ -352,11 +354,10 @@ void Application::onAboutToQuit() { bool Application::eventFilter(QObject* watched, QEvent* event) { if(watched == desktop()) { - switch(event->type()) { - case QEvent::StyleChange: - case QEvent::ThemeChange: + if (event->type() == QEvent::StyleChange || + event->type() == QEvent::ThemeChange) { setStyle(new ProxyStyle()); - }; + } } return QObject::eventFilter(watched, event); } @@ -440,10 +441,9 @@ void Application::onFindFileAccepted() { Fm::FileSearchDialog* dlg = static_cast(sender()); Fm::Path uri = dlg->searchUri(); // FIXME: we should be able to open it in an existing window - FmPathList* paths = fm_path_list_new(); - fm_path_list_push_tail(paths, uri.data()); + Fm::PathList paths; + paths.pushTail(uri); Launcher(NULL).launchPaths(NULL, paths); - fm_path_list_unref(paths); } void Application::findFiles(QStringList paths) { @@ -455,50 +455,46 @@ void Application::findFiles(QStringList paths) { } void Application::launchFiles(QString cwd, QStringList paths, bool inNewWindow) { - FmPathList* pathList = fm_path_list_new(); - FmPath* cwd_path = NULL; + Fm::PathList pathList; + Fm::Path cwd_path; QStringList::iterator it; Q_FOREACH(const QString& it, paths) { QByteArray pathName = it.toLocal8Bit(); - FmPath* path = NULL; + Fm::Path path; if(pathName[0] == '/') // absolute path - path = fm_path_new_for_path(pathName.constData()); + path = Fm::Path::newForPath(pathName.constData()); else if(pathName.contains(":/")) // URI - path = fm_path_new_for_uri(pathName.constData()); + path = Fm::Path::newForUri(pathName.constData()); else if(pathName == "~") // special case for home dir - path = fm_path_ref(fm_path_get_home()); + path = Fm::Path::getHome(); else // basename { if(Q_UNLIKELY(!cwd_path)) - cwd_path = fm_path_new_for_str(cwd.toLocal8Bit().constData()); - path = fm_path_new_relative(cwd_path, pathName.constData()); + cwd_path = Fm::Path::newForStr(cwd.toLocal8Bit().constData()); + path = cwd_path.newRelative(pathName.constData()); } fm_path_list_push_tail(pathList, path); - fm_path_unref(path); } - if(cwd_path) - fm_path_unref(cwd_path); Launcher(NULL).launchPaths(NULL, pathList); - fm_path_list_unref(pathList); } -void Application::openFolders(FmFileInfoList* files) { +void Application::openFolders(Fm::FileInfoList files) { Launcher(NULL).launchFiles(NULL, files); } -void Application::openFolderInTerminal(FmPath* path) { +void Application::openFolderInTerminal(Fm::Path path) { if(!settings_.terminal().isEmpty()) { char* cwd_str; - if(fm_path_is_native(path)) - cwd_str = fm_path_to_str(path); + if(path.isNative()) + cwd_str = path.toStr(); else { // gio will map remote filesystems to local FUSE-mounted paths here. - GFile* gf = fm_path_to_gfile(path); + GFile* gf = path.toGfile(); cwd_str = g_file_get_path(gf); g_object_unref(gf); } GError* err = NULL; - if(!fm_terminal_launch(cwd_str, &err)) { + if(!Fm::Terminal::launch(cwd_str, &err)) { QMessageBox::critical(NULL, tr("Error"), QString::fromUtf8(err->message)); g_error_free(err); } diff --git a/pcmanfm/application.h b/pcmanfm/application.h index dfaaf96..4351963 100644 --- a/pcmanfm/application.h +++ b/pcmanfm/application.h @@ -84,8 +84,8 @@ public: void updateFromSettings(); void updateDesktopsFromSettings(); - void openFolderInTerminal(FmPath* path); - void openFolders(FmFileInfoList* files); + void openFolderInTerminal(Fm::Path path); + void openFolders(Fm::FileInfoList files); QString profileName() { return profileName_; diff --git a/pcmanfm/autorundialog.cpp b/pcmanfm/autorundialog.cpp index 413b809..4036d1b 100644 --- a/pcmanfm/autorundialog.cpp +++ b/pcmanfm/autorundialog.cpp @@ -74,11 +74,10 @@ void AutoRunDialog::accept() { // the default action, open the mounted folder in the file manager Application* app = static_cast(qApp); Settings& settings = app->settings(); - FmPath* path = fm_path_new_for_gfile(gf); + Fm::Path path = Fm::Path::newForGfile(gf); // open the path in a new window // FIXME: or should we open it in a new tab? Make this optional later MainWindow* win = new MainWindow(path); - fm_path_unref(path); win->resize(settings.windowWidth(), settings.windowHeight()); if(settings.windowMaximized()) { win->setWindowState(win->windowState() | Qt::WindowMaximized); diff --git a/pcmanfm/desktopitemdelegate.cpp b/pcmanfm/desktopitemdelegate.cpp index 22a569f..9ecb43e 100644 --- a/pcmanfm/desktopitemdelegate.cpp +++ b/pcmanfm/desktopitemdelegate.cpp @@ -20,6 +20,7 @@ #include "desktopitemdelegate.h" #include +#include #include #include #include @@ -41,7 +42,7 @@ DesktopItemDelegate::DesktopItemDelegate(QListView* view, QObject* parent): // FIXME: we need to figure out a way to derive from Fm::FolderItemDelegate to avoid code duplication. void DesktopItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { Q_ASSERT(index.isValid()); - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); painter->save(); @@ -67,9 +68,9 @@ void DesktopItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o // draw some emblems for the item if needed // we only support symlink emblem at the moment - FmFileInfo* file = static_cast(index.data(Fm::FolderModel::FileInfoRole).value()); - if(file) { - if(fm_file_info_is_symlink(file)) { + Fm::FileInfo file = static_cast(index.data(Fm::FolderModel::FileInfoRole).value()); + if(!file.isNull()) { + if(file.isSymlink()) { painter->drawPixmap(iconPos, symlinkIcon_.pixmap(opt.decorationSize / 2, iconMode)); } } @@ -88,7 +89,7 @@ void DesktopItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o painter->restore(); } -void DesktopItemDelegate::drawText(QPainter* painter, QStyleOptionViewItemV4& opt, QRectF& textRect) const { +void DesktopItemDelegate::drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const { QTextLayout layout(opt.text, opt.font); QTextOption textOption; @@ -137,7 +138,7 @@ void DesktopItemDelegate::drawText(QPainter* painter, QStyleOptionViewItemV4& op 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; @@ -185,7 +186,7 @@ QSize DesktopItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QM QVariant value = index.data(Qt::SizeHintRole); if(value.isValid()) return qvariant_cast(value); - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); opt.decorationAlignment = Qt::AlignHCenter|Qt::AlignTop; opt.displayAlignment = Qt::AlignTop|Qt::AlignHCenter; diff --git a/pcmanfm/desktopitemdelegate.h b/pcmanfm/desktopitemdelegate.h index deb9bed..fc8bd89 100644 --- a/pcmanfm/desktopitemdelegate.h +++ b/pcmanfm/desktopitemdelegate.h @@ -50,7 +50,7 @@ public: } private: - void drawText(QPainter* painter, QStyleOptionViewItemV4& opt, QRectF& textRect) const; + void drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const; private: QListView* view_; diff --git a/pcmanfm/desktopwindow.cpp b/pcmanfm/desktopwindow.cpp index 4037f7a..6426e03 100644 --- a/pcmanfm/desktopwindow.cpp +++ b/pcmanfm/desktopwindow.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include "xdgdir.h" #include @@ -61,7 +62,6 @@ DesktopWindow::DesktopWindow(int screenNum): View(Fm::FolderView::IconMode), proxyModel_(NULL), model_(NULL), - folder_(NULL), wallpaperMode_(WallpaperNone), fileLauncher_(NULL), showWmMenu_(false), @@ -90,8 +90,8 @@ DesktopWindow::DesktopWindow(int screenNum): loadItemPositions(); Settings& settings = static_cast(qApp)->settings(); - model_ = Fm::CachedFolderModel::modelFromPath(fm_path_get_desktop()); - folder_ = reinterpret_cast(g_object_ref(model_->folder())); + model_ = Fm::CachedFolderModel::modelFromPath(Fm::Path::getDesktop()); + folder_ = model_->folder(); proxyModel_ = new Fm::ProxyFolderModel(); proxyModel_->setSourceModel(model_); @@ -159,9 +159,6 @@ DesktopWindow::~DesktopWindow() { if(model_) model_->unref(); - - if(folder_) - g_object_unref(folder_); } void DesktopWindow::setBackground(const QColor& color) { @@ -201,7 +198,7 @@ void DesktopWindow::resizeEvent(QResizeEvent* event) { } void DesktopWindow::setDesktopFolder() { - FmPath *path = fm_path_new_for_path(XdgDir::readDesktopDir().toStdString().c_str()); + Fm::Path path = Fm::Path::newForPath(XdgDir::readDesktopDir().toStdString().c_str()); model_ = Fm::CachedFolderModel::modelFromPath(path); proxyModel_->setSourceModel(model_); } @@ -371,11 +368,11 @@ void DesktopWindow::prepareFileMenu(Fm::FileMenu* menu) { menu->insertSeparator(menu->separator2()); menu->insertAction(menu->separator2(), action); - FmFileInfoList* files = menu->files(); + Fm::FileInfoList files = menu->files(); // select exactly one item if(fm_file_info_list_get_length(files) == 1) { - FmFileInfo* file = menu->firstFile(); - if(customItemPos_.find(fm_file_info_get_name(file)) != customItemPos_.end()) { + Fm::FileInfo file = menu->firstFile(); + if(customItemPos_.find(file.getName()) != customItemPos_.end()) { // the file item has a custom position action->setChecked(true); } @@ -409,7 +406,7 @@ void DesktopWindow::onRowsAboutToBeRemoved(const QModelIndex& parent, int start, // Here we can't rely on ProxyFolderModel::fileInfoFromIndex() because, although rows // aren't removed yet, files are already removed. QHash _customItemPos = customItemPos_; - char* dektopPath = fm_path_to_str(fm_path_get_desktop()); + char* dektopPath = Fm::Path::getDesktop().toStr(); QString desktopDir = QString(dektopPath) + QString("/"); g_free(dektopPath); QHash::iterator it; @@ -444,7 +441,7 @@ void DesktopWindow::onIndexesMoved(const QModelIndexList& indexes) { // Since we only care about rows, not individual cells, // let's handle column 0 of every row here. if(index.column() == 0) { - FmFileInfo* file = proxyModel_->fileInfoFromIndex(index); + Fm::FileInfo file = proxyModel_->fileInfoFromIndex(index); QRect itemRect = listView_->rectForIndex(index); QPoint tl = itemRect.topLeft(); QRect workArea = qApp->desktop()->availableGeometry(screenNum_); @@ -453,7 +450,7 @@ void DesktopWindow::onIndexesMoved(const QModelIndexList& indexes) { && tl.x() >= workArea.x() && tl.y() >= workArea.y() && tl.x() + listView_->gridSize().width() <= workArea.right() + 1 // for historical reasons (-> Qt doc) && tl.y() + listView_->gridSize().height() <= workArea.bottom() + 1) { // as above - QByteArray name = fm_file_info_get_name(file); + QByteArray name = file.getName(); customItemPos_[name] = tl; // qDebug() << "indexMoved:" << name << index << itemRect; } @@ -536,8 +533,8 @@ void DesktopWindow::relayoutItems() { for(; row < rowCount; ++row) { QModelIndex index = proxyModel_->index(row, 0); int itemWidth = delegate_->sizeHint(listView_->getViewOptions(), index).width(); - FmFileInfo* file = proxyModel_->fileInfoFromIndex(index); - QByteArray name = fm_file_info_get_name(file); + Fm::FileInfo file = proxyModel_->fileInfoFromIndex(index); + QByteArray name = file.getName(); QHash::iterator it = customItemPos_.find(name); if(it != customItemPos_.end()) { // the item has a custom position QPoint customPos = *it; @@ -594,7 +591,7 @@ void DesktopWindow::loadItemPositions() { QSize grid = listView_->gridSize(); QRect workArea = qApp->desktop()->availableGeometry(screenNum_); workArea.adjust(12, 12, -12, -12); - char* dektopPath = fm_path_to_str(fm_path_get_desktop()); + char* dektopPath = Fm::Path::getDesktop().toStr(); QString desktopDir = QString(dektopPath) + QString("/"); g_free(dektopPath); Q_FOREACH(const QString& name, file.childGroups()) { @@ -656,8 +653,8 @@ void DesktopWindow::onStickToCurrentPos(bool toggled) { QModelIndexList indexes = listView_->selectionModel()->selectedIndexes(); if(!indexes.isEmpty()) { - FmFileInfo* file = menu->firstFile(); - QByteArray name = fm_file_info_get_name(file); + Fm::FileInfo file = menu->firstFile(); + QByteArray name = file.getName(); QModelIndex index = indexes.first(); if(toggled) { // remember to current custom position QRect itemRect = listView_->rectForIndex(index); @@ -689,16 +686,16 @@ void DesktopWindow::queueRelayout(int delay) { // slots for file operations void DesktopWindow::onCutActivated() { - if(FmPathList* paths = selectedFilePaths()) { + Fm::PathList paths = selectedFilePaths(); + if(!paths.isNull()) { Fm::cutFilesToClipboard(paths); - fm_path_list_unref(paths); } } void DesktopWindow::onCopyActivated() { - if(FmPathList* paths = selectedFilePaths()) { + Fm::PathList paths = selectedFilePaths(); + if(!paths.isNull()) { Fm::copyFilesToClipboard(paths); - fm_path_list_unref(paths); } } @@ -707,31 +704,31 @@ void DesktopWindow::onPasteActivated() { } void DesktopWindow::onDeleteActivated() { - if(FmPathList* paths = selectedFilePaths()) { + Fm::PathList paths = selectedFilePaths(); + if(!paths.isNull()) { Settings& settings = static_cast(qApp)->settings(); bool shiftPressed = (qApp->keyboardModifiers() & Qt::ShiftModifier ? true : false); if(settings.useTrash() && !shiftPressed) Fm::FileOperation::trashFiles(paths, settings.confirmTrash()); else Fm::FileOperation::deleteFiles(paths, settings.confirmDelete()); - fm_path_list_unref(paths); } } void DesktopWindow::onRenameActivated() { - if(FmFileInfoList* files = selectedFiles()) { + Fm::FileInfoList files = selectedFiles(); + if(!files.isNull()) { for(GList* l = fm_file_info_list_peek_head_link(files); l; l = l->next) { FmFileInfo* info = FM_FILE_INFO(l->data); Fm::renameFile(info, NULL); - fm_file_info_list_unref(files); } } } void DesktopWindow::onFilePropertiesActivated() { - if(FmFileInfoList* files = selectedFiles()) { + Fm::FileInfoList files = selectedFiles(); + if(!files.isNull()) { Fm::FilePropsDialog::showForFiles(files); - fm_file_info_list_unref(files); } } diff --git a/pcmanfm/desktopwindow.h b/pcmanfm/desktopwindow.h index a6f5413..fe6d8f3 100644 --- a/pcmanfm/desktopwindow.h +++ b/pcmanfm/desktopwindow.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace Fm { class CachedFolderModel; @@ -120,7 +121,7 @@ private: private: Fm::ProxyFolderModel* proxyModel_; Fm::CachedFolderModel* model_; - FmFolder* folder_; + Fm::Folder folder_; Fm::FolderViewListView* listView_; QColor fgColor_; diff --git a/pcmanfm/launcher.cpp b/pcmanfm/launcher.cpp index d376fc9..4d6e862 100644 --- a/pcmanfm/launcher.cpp +++ b/pcmanfm/launcher.cpp @@ -38,11 +38,11 @@ Launcher::~Launcher() { bool Launcher::openFolder(GAppLaunchContext* ctx, GList* folder_infos, GError** err) { GList* l = folder_infos; - FmFileInfo* fi = FM_FILE_INFO(l->data); + Fm::FileInfo fi = FM_FILE_INFO(l->data); Application* app = static_cast(qApp); MainWindow* mainWindow = mainWindow_; if(!mainWindow) { - mainWindow = new MainWindow(fm_file_info_get_path(fi)); + mainWindow = new MainWindow(fi.getPath()); mainWindow->resize(app->settings().windowWidth(), app->settings().windowHeight()); if(app->settings().windowMaximized()) { @@ -50,11 +50,11 @@ bool Launcher::openFolder(GAppLaunchContext* ctx, GList* folder_infos, GError** } } else - mainWindow->chdir(fm_file_info_get_path(fi)); + mainWindow->chdir(fi.getPath()); l = l->next; for(; l; l = l->next) { fi = FM_FILE_INFO(l->data); - mainWindow->addTab(fm_file_info_get_path(fi)); + mainWindow->addTab(fi.getPath()); } mainWindow->show(); mainWindow->raise(); diff --git a/pcmanfm/main-win.ui b/pcmanfm/main-win.ui index c70af4a..e632f77 100644 --- a/pcmanfm/main-win.ui +++ b/pcmanfm/main-win.ui @@ -86,15 +86,15 @@ + + Focus with Ctrl+I + Filter by string... true - - Focus with Ctrl+I - @@ -109,7 +109,7 @@ 0 0 460 - 23 + 30 @@ -160,15 +160,23 @@ + + + &View + + + + + + + - - - - - - + + + + @@ -531,6 +539,14 @@ &Folder First + + + true + + + &Preserve sorting for this folder + + @@ -751,7 +767,8 @@ - + + .. Menu @@ -760,6 +777,14 @@ Menu + + + true + + + &Preserve Settings for This Folder + + diff --git a/pcmanfm/mainwindow.cpp b/pcmanfm/mainwindow.cpp index f72c8cc..79b0c0d 100644 --- a/pcmanfm/mainwindow.cpp +++ b/pcmanfm/mainwindow.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include "tabpage.h" @@ -39,9 +41,11 @@ #include #include #include +#include +#include +#include #include "ui_about.h" #include "application.h" -#include // #include "qmodeltest/modeltest.h" @@ -49,10 +53,11 @@ using namespace Fm; namespace PCManFM { -MainWindow::MainWindow(FmPath* path): +MainWindow::MainWindow(Path path): QMainWindow(), fileLauncher_(this), - rightClickIndex(-1) { + rightClickIndex(-1), + updatingViewMenu_(false) { Settings& settings = static_cast(qApp)->settings(); setAttribute(Qt::WA_DeleteOnClose); @@ -128,6 +133,7 @@ MainWindow::MainWindow(FmPath* path): // path bar pathEntry = new Fm::PathEdit(this); connect(pathEntry, &Fm::PathEdit::returnPressed, this, &MainWindow::onPathEntryReturnPressed); + connect(pathEntry, &QLineEdit::textEdited, this, &MainWindow::onPathEntryEdited); ui.toolBar->insertWidget(ui.actionGo, pathEntry); // add filesystem info to status bar @@ -142,7 +148,7 @@ MainWindow::MainWindow(FmPath* path): ui.splitter->setSizes(sizes); // load bookmark menu - bookmarks = fm_bookmarks_dup(); + bookmarks = Fm::Bookmarks::dup(); g_signal_connect(bookmarks, "changed", G_CALLBACK(onBookmarksChanged), this); loadBookmarksMenu(); @@ -250,7 +256,7 @@ MainWindow::MainWindow(FmPath* path): connect(shortcut, &QShortcut::activated, ui.filterBar, &QLineEdit::clear); } - if(path) + if(!path.isNull()) addTab(path); // size from settings @@ -265,13 +271,12 @@ MainWindow::MainWindow(FmPath* path): } MainWindow::~MainWindow() { - if(bookmarks) { + if(!bookmarks.isNull()) { g_signal_handlers_disconnect_by_func(bookmarks, (gpointer)G_CALLBACK(onBookmarksChanged), this); - g_object_unref(bookmarks); } } -void MainWindow::chdir(FmPath* path) { +void MainWindow::chdir(Path path) { TabPage* page = currentPage(); if(page) { @@ -282,7 +287,7 @@ void MainWindow::chdir(FmPath* path) { } // add a new tab -int MainWindow::addTab(FmPath* path) { +int MainWindow::addTab(Path path) { Settings& settings = static_cast(qApp)->settings(); TabPage* newPage = new TabPage(path, this); @@ -331,9 +336,15 @@ void MainWindow::toggleMenuBar(bool checked) { void MainWindow::onPathEntryReturnPressed() { QString text = pathEntry->text(); QByteArray utext = text.toUtf8(); - FmPath* path = fm_path_new_for_display_name(utext); - chdir(path); - fm_path_unref(path); + chdir(Fm::Path::newForDisplayName(utext)); +} + +void MainWindow::onPathEntryEdited(const QString& text) { + QString realText(text); + if(realText == "~" || realText.startsWith("~/")) { + realText.replace(0, 1, QDir::homePath()); + pathEntry->setText(realText); + } } void MainWindow::on_actionGoUp_triggered() { @@ -367,11 +378,12 @@ void MainWindow::on_actionGoForward_triggered() { } void MainWindow::on_actionHome_triggered() { - chdir(fm_path_get_home()); + chdir(Fm::Path::getHome()); } void MainWindow::on_actionReload_triggered() { currentPage()->reload(); + pathEntry->setText(currentPage()->pathName()); } void MainWindow::on_actionGo_triggered() { @@ -379,19 +391,19 @@ void MainWindow::on_actionGo_triggered() { } void MainWindow::on_actionNewTab_triggered() { - FmPath* path = currentPage()->path(); + Fm::Path path = currentPage()->path(); int index = addTab(path); ui.tabBar->setCurrentIndex(index); } void MainWindow::on_actionNewWin_triggered() { - FmPath* path = currentPage()->path(); + Fm::Path path = currentPage()->path(); (new MainWindow(path))->show(); } void MainWindow::on_actionNewFolder_triggered() { if(TabPage* tabPage = currentPage()) { - FmPath* dirPath = tabPage->folderView()->path(); + Fm::Path dirPath = tabPage->folderView()->path(); if(dirPath) createFileOrFolder(CreateNewFolder, dirPath); @@ -400,7 +412,7 @@ void MainWindow::on_actionNewFolder_triggered() { void MainWindow::on_actionNewBlankFile_triggered() { if(TabPage* tabPage = currentPage()) { - FmPath* dirPath = tabPage->folderView()->path(); + Fm::Path dirPath = tabPage->folderView()->path(); if(dirPath) createFileOrFolder(CreateNewTextFile, dirPath); @@ -419,13 +431,10 @@ void MainWindow::on_actionCloseWindow_triggered() { void MainWindow::on_actionFileProperties_triggered() { TabPage* page = currentPage(); - if(page) { - FmFileInfoList* files = page->selectedFiles(); - - if(files) { + Fm::FileInfoList files = page->selectedFiles(); + if(!files.isNull()) { Fm::FilePropsDialog::showForFiles(files); - fm_file_info_list_unref(files); } } } @@ -434,22 +443,18 @@ void MainWindow::on_actionFolderProperties_triggered() { TabPage* page = currentPage(); if(page) { - FmFolder* folder = page->folder(); - - if(folder) { - FmFileInfo* info = fm_folder_get_info(folder); - - if(info) + Fm::Folder folder = page->folder(); + if(!folder.isNull()) { + Fm::FileInfo info = folder.getInfo(); + if(!info.isNull()) Fm::FilePropsDialog::showForFile(info); } } } void MainWindow::on_actionShowHidden_triggered(bool checked) { - TabPage* tabPage = currentPage(); - tabPage->setShowHidden(checked); + currentPage()->setShowHidden(checked); ui.sidePane->setShowHidden(checked); - static_cast(qApp)->settings().setShowHidden(checked); } void MainWindow::on_actionByFileName_triggered(bool checked) { @@ -488,6 +493,11 @@ void MainWindow::on_actionFolderFirst_triggered(bool checked) { currentPage()->setSortFolderFirst(checked); } +void MainWindow::on_actionPreserveView_triggered(bool checked) { + TabPage* page = currentPage(); + page->setCustomizedView(!page->hasCustomizedView()); +} + void MainWindow::on_actionFilter_triggered(bool checked) { ui.filterBar->setVisible(checked); if(checked) @@ -509,38 +519,32 @@ void MainWindow::on_actionFilter_triggered(bool checked) { } void MainWindow::on_actionComputer_triggered() { - FmPath* path = fm_path_new_for_uri("computer:///"); - chdir(path); - fm_path_unref(path); + chdir(Fm::Path::newForUri("computer:///")); } void MainWindow::on_actionApplications_triggered() { - chdir(fm_path_get_apps_menu()); + chdir(Fm::Path::getAppsMenu()); } void MainWindow::on_actionTrash_triggered() { - chdir(fm_path_get_trash()); + chdir(Fm::Path::getTrash()); } void MainWindow::on_actionNetwork_triggered() { - FmPath* path = fm_path_new_for_uri("network:///"); - chdir(path); - fm_path_unref(path); + chdir(Fm::Path::newForUri("network:///")); } void MainWindow::on_actionDesktop_triggered() { - chdir(fm_path_get_desktop()); + chdir(Fm::Path::getDesktop()); } void MainWindow::on_actionAddToBookmarks_triggered() { TabPage* page = currentPage(); - if(page) { - FmPath* cwd = page->path(); - - if(cwd) { - char* dispName = fm_path_display_basename(cwd); - fm_bookmarks_insert(bookmarks, cwd, dispName, -1); + Fm::Path cwd = page->path(); + if(!cwd.isNull()) { + char* dispName = cwd.displayBasename(); + bookmarks.insert(cwd, dispName, -1); g_free(dispName); } } @@ -682,11 +686,14 @@ void MainWindow::updateStatusBarForCurrentPage() { } void MainWindow::updateViewMenuForCurrentPage() { + if(updatingViewMenu_) // prevent recursive calls + return; + updatingViewMenu_ = true; TabPage* tabPage = currentPage(); - if(tabPage) { // update menus. FIXME: should we move this to another method? ui.actionShowHidden->setChecked(tabPage->showHidden()); + ui.actionPreserveView->setChecked(tabPage->hasCustomizedView()); // view mode QAction* modeAction = NULL; @@ -725,10 +732,10 @@ void MainWindow::updateViewMenuForCurrentPage() { ui.actionAscending->setChecked(true); else ui.actionDescending->setChecked(true); - ui.actionCaseSensitive->setChecked(tabPage->sortCaseSensitive()); ui.actionFolderFirst->setChecked(tabPage->sortFolderFirst()); } + updatingViewMenu_ = false; } void MainWindow::updateUIForCurrentPage() { @@ -814,22 +821,23 @@ void MainWindow::onTabPageOpenDirRequested(FmPath* path, int target) { addTab(path); break; - case OpenInNewWindow: { + case OpenInNewWindow: (new MainWindow(path))->show(); break; } - } } void MainWindow::onTabPageSortFilterChanged() { TabPage* tabPage = static_cast(sender()); - if(tabPage == currentPage()) { updateViewMenuForCurrentPage(); - Settings& settings = static_cast(qApp)->settings(); - settings.setSortColumn(static_cast(tabPage->sortColumn())); - settings.setSortOrder(tabPage->sortOrder()); - settings.setSortFolderFirst(tabPage->sortFolderFirst()); + if(!tabPage->hasCustomizedView()) { + Settings& settings = static_cast(qApp)->settings(); + settings.setSortColumn(static_cast(tabPage->sortColumn())); + settings.setSortOrder(tabPage->sortOrder()); + settings.setSortFolderFirst(tabPage->sortFolderFirst()); + settings.setSortCaseSensitive(tabPage->sortCaseSensitive()); + } } } @@ -871,7 +879,7 @@ void MainWindow::onSplitterMoved(int pos, int index) { } void MainWindow::loadBookmarksMenu() { - GList* allBookmarks = fm_bookmarks_get_all(bookmarks); + GList* allBookmarks = bookmarks.getAll(); QAction* before = ui.actionAddToBookmarks; for(GList* l = allBookmarks; l; l = l->next) { @@ -902,7 +910,7 @@ void MainWindow::onBookmarksChanged(FmBookmarks* bookmarks, MainWindow* pThis) { void MainWindow::onBookmarkActionTriggered() { BookmarkAction* action = static_cast(sender()); - FmPath* path = action->path(); + Fm::Path path = action->path(); if(path) { Application* app = static_cast(qApp); Settings& settings = app->settings(); @@ -923,16 +931,14 @@ void MainWindow::onBookmarkActionTriggered() { void MainWindow::on_actionCopy_triggered() { TabPage* page = currentPage(); - FmPathList* paths = page->selectedFilePaths(); + Fm::PathList paths = page->selectedFilePaths(); copyFilesToClipboard(paths); - fm_path_list_unref(paths); } void MainWindow::on_actionCut_triggered() { TabPage* page = currentPage(); - FmPathList* paths = page->selectedFilePaths(); + Fm::PathList paths = page->selectedFilePaths(); cutFilesToClipboard(paths); - fm_path_list_unref(paths); } void MainWindow::on_actionPaste_triggered() { @@ -943,26 +949,22 @@ void MainWindow::on_actionDelete_triggered() { Application* app = static_cast(qApp); Settings& settings = app->settings(); TabPage* page = currentPage(); - FmPathList* paths = page->selectedFilePaths(); + Fm::PathList paths = page->selectedFilePaths(); bool shiftPressed = (qApp->keyboardModifiers() & Qt::ShiftModifier ? true : false); if(settings.useTrash() && !shiftPressed) FileOperation::trashFiles(paths, settings.confirmTrash(), this); else FileOperation::deleteFiles(paths, settings.confirmDelete(), this); - - fm_path_list_unref(paths); } void MainWindow::on_actionRename_triggered() { TabPage* page = currentPage(); - FmFileInfoList* files = page->selectedFiles(); - + Fm::FileInfoList files = page->selectedFiles(); for(GList* l = fm_file_info_list_peek_head_link(files); l; l = l->next) { FmFileInfo* file = FM_FILE_INFO(l->data); Fm::renameFile(file, NULL); } - fm_file_info_list_unref(files); } @@ -1018,7 +1020,9 @@ void MainWindow::onBackForwardContextMenu(QPoint pos) { for(int i = 0; i < history.size(); ++i) { const BrowseHistoryItem& item = history.at(i); Fm::Path path = item.path(); - QAction* action = menu.addAction(path.displayName()); + char* name = path.displayName(true); + QAction* action = menu.addAction(QString::fromUtf8(name)); + g_free(name); if(i == current) { // make the current path bold and checked action->setCheckable(true); @@ -1144,9 +1148,9 @@ void MainWindow::on_actionOpenAsRoot_triggered() { g_free(cmd); if(appInfo) { - FmPath* cwd = page->path(); + Fm::Path cwd = page->path(); GError* err = NULL; - char* uri = fm_path_to_uri(cwd); + char* uri = cwd.toUri(); GList* uris = g_list_prepend(NULL, uri); if(!g_app_info_launch_uris(appInfo, uris, NULL, &err)) { @@ -1169,16 +1173,15 @@ void MainWindow::on_actionOpenAsRoot_triggered() { void MainWindow::on_actionFindFiles_triggered() { Application* app = static_cast(qApp); - FmPathList* selectedPaths = currentPage()->selectedFilePaths(); + Fm::PathList selectedPaths = currentPage()->selectedFilePaths(); QStringList paths; - if(selectedPaths) { + if(!selectedPaths.isNull()) { for(GList* l = fm_path_list_peek_head_link(selectedPaths); l; l = l->next) { // FIXME: is it ok to use display name here? // This might be broken on filesystems with non-UTF-8 filenames. Fm::Path path(FM_PATH(l->data)); paths.append(path.displayName(false)); } - fm_path_list_unref(selectedPaths); } else { paths.append(currentPage()->pathName()); diff --git a/pcmanfm/mainwindow.h b/pcmanfm/mainwindow.h index 0a93476..4526dda 100644 --- a/pcmanfm/mainwindow.h +++ b/pcmanfm/mainwindow.h @@ -32,6 +32,8 @@ #include #include #include "launcher.h" +#include +#include namespace PCManFM { @@ -41,11 +43,11 @@ class Settings; class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow(FmPath* path = NULL); + MainWindow(Fm::Path path = Fm::Path()); virtual ~MainWindow(); - void chdir(FmPath* path); - int addTab(FmPath* path); + void chdir(Fm::Path path); + int addTab(Fm::Path path); TabPage* currentPage() { return reinterpret_cast(ui.stackedWidget->currentWidget()); @@ -56,6 +58,7 @@ public: protected Q_SLOTS: void onPathEntryReturnPressed(); + void onPathEntryEdited(const QString& text); void on_actionNewTab_triggered(); void on_actionNewWin_triggered(); @@ -88,6 +91,7 @@ protected Q_SLOTS: void on_actionGo_triggered(); void on_actionShowHidden_triggered(bool check); + void on_actionPreserveView_triggered(bool checked); void on_actionByFileName_triggered(bool checked); void on_actionByMTime_triggered(bool checked); @@ -173,9 +177,10 @@ private: Ui::MainWindow ui; QLineEdit* pathEntry; QLabel* fsInfoLabel; - FmBookmarks* bookmarks; + Fm::Bookmarks bookmarks; Launcher fileLauncher_; int rightClickIndex; + bool updatingViewMenu_; }; } diff --git a/pcmanfm/settings.cpp b/pcmanfm/settings.cpp index 9da90fa..341061c 100644 --- a/pcmanfm/settings.cpp +++ b/pcmanfm/settings.cpp @@ -26,7 +26,8 @@ #include #include "desktopwindow.h" #include -// #include +#include +#include namespace PCManFM { @@ -88,6 +89,7 @@ Settings::Settings(): sortOrder_(Qt::AscendingOrder), sortColumn_(Fm::FolderModel::ColumnFileName), sortFolderFirst_(true), + sortCaseSensitive_(false), showFilter_(false), // settings for use with libfm singleClick_(false), @@ -119,16 +121,20 @@ Settings::~Settings() { } -QString Settings::profileDir(QString profile, bool useFallback) { - // NOTE: it's a shame that QDesktopServices does not handle XDG_CONFIG_HOME - // try user-specific config file first +QString Settings::xdgUserConfigDir() { QString dirName; // WARNING: Don't use XDG_CONFIG_HOME with root because it might // give the user config directory if gksu-properties is set to su. - if(geteuid()) - dirName = QLatin1String(qgetenv("XDG_CONFIG_HOME")); + if(geteuid() != 0) // non-root user + dirName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); if (dirName.isEmpty()) dirName = QDir::homePath() % QLatin1String("/.config"); + return dirName; +} + +QString Settings::profileDir(QString profile, bool useFallback) { + // try user-specific config file first + QString dirName = xdgUserConfigDir(); dirName = dirName % "/pcmanfm-qt/" % profile; QDir dir(dirName); @@ -233,6 +239,7 @@ bool Settings::loadFile(QString filePath) { sortOrder_ = sortOrderFromString(settings.value("SortOrder").toString()); sortColumn_ = sortColumnFromString(settings.value("SortColumn").toString()); sortFolderFirst_ = settings.value("SortFolderFirst", true).toBool(); + sortCaseSensitive_ = settings.value("SortCaseSensitive", false).toBool(); showFilter_ = settings.value("ShowFilter", false).toBool(); setBackupAsHidden(settings.value("BackupAsHidden", false).toBool()); @@ -342,6 +349,7 @@ bool Settings::saveFile(QString filePath) { settings.setValue("SortOrder", sortOrderToString(sortOrder_)); settings.setValue("SortColumn", sortColumnToString(sortColumn_)); settings.setValue("SortFolderFirst", sortFolderFirst_); + settings.setValue("SortCaseSensitive", sortCaseSensitive_); settings.setValue("ShowFilter", showFilter_); settings.setValue("BackupAsHidden", backupAsHidden_); @@ -381,6 +389,10 @@ bool Settings::saveFile(QString filePath) { settings.setValue("ShowMenuBar", showMenuBar_); settings.setValue("FullWidthTabBar", fullWidthTabBar_); settings.endGroup(); + + // save per-folder settings + Fm::FolderConfig::saveCache(); + return true; } @@ -568,4 +580,83 @@ void Settings::setTerminal(QString terminalCommand) { } +// per-folder settings +FolderSettings Settings::loadFolderSettings(Fm::Path path) const { + FolderSettings settings; + Fm::FolderConfig cfg(path); + // set defaults + settings.setSortOrder(sortOrder()); + settings.setSortColumn(sortColumn()); + settings.setViewMode(viewMode()); + settings.setShowHidden(showHidden()); + settings.setSortFolderFirst(sortFolderFirst()); + settings.setSortCaseSensitive(sortCaseSensitive()); + // columns? + if(!cfg.isEmpty()) { + // load folder-specific settings + settings.setCustomized(true); + + char* str; + // load sorting + str = cfg.getString("SortOrder"); + if(str != nullptr) { + settings.setSortOrder(sortOrderFromString(str)); + g_free(str); + } + + str = cfg.getString("SortColumn"); + if(str != nullptr) { + settings.setSortColumn(sortColumnFromString(str)); + g_free(str); + } + + str = cfg.getString("ViewMode"); + if(str != nullptr) { + // set view mode + settings.setViewMode(viewModeFromString(str)); + g_free(str); + } + + gboolean show_hidden; + if(cfg.getBoolean("ShowHidden", &show_hidden)) { + settings.setShowHidden(show_hidden); + } + + gboolean folder_first; + if(cfg.getBoolean("SortFolderFirst", &folder_first)) { + settings.setSortFolderFirst(folder_first); + } + + gboolean case_sensitive; + if(cfg.getBoolean("SortCaseSensitive", &case_sensitive)) { + settings.setSortCaseSensitive(case_sensitive); + } + } + return settings; +} + +void Settings::saveFolderSettings(Fm::Path path, const FolderSettings& settings) { + if(!path.isNull()) { + // ensure that we have the libfm dir + QString dirName = xdgUserConfigDir() % QStringLiteral("/libfm"); + QDir().mkpath(dirName); // if libfm config dir does not exist, create it + + Fm::FolderConfig cfg(path); + cfg.setString("SortOrder", sortOrderToString(settings.sortOrder())); + cfg.setString("SortColumn", sortColumnToString(settings.sortColumn())); + cfg.setString("ViewMode", viewModeToString(settings.viewMode())); + cfg.setBoolean("ShowHidden", settings.showHidden()); + cfg.setBoolean("SortFolderFirst", settings.sortFolderFirst()); + cfg.setBoolean("SortCaseSensitive", settings.sortCaseSensitive()); + } +} + +void Settings::clearFolderSettings(Fm::Path path) const { + if(!path.isNull()) { + Fm::FolderConfig cfg(path); + cfg.purge(); + } +} + + } // namespace PCManFM diff --git a/pcmanfm/settings.h b/pcmanfm/settings.h index 2c2107d..75a4c5a 100644 --- a/pcmanfm/settings.h +++ b/pcmanfm/settings.h @@ -38,6 +38,86 @@ enum OpenDirTargetType { OpenInLastActiveWindow }; +class FolderSettings { +public: + FolderSettings(): + isCustomized_(false), + sortOrder_(Qt::AscendingOrder), + sortColumn_(Fm::FolderModel::ColumnFileName), + viewMode_(Fm::FolderView::IconMode), + showHidden_(false), + sortFolderFirst_(true), + sortCaseSensitive_(true) { + } + + bool isCustomized() const { + return isCustomized_; + } + + void setCustomized(bool value) { + isCustomized_ = value; + } + + Qt::SortOrder sortOrder() const { + return sortOrder_; + } + + void setSortOrder(Qt::SortOrder value) { + sortOrder_ = value; + } + + Fm::FolderModel::ColumnId sortColumn() const { + return sortColumn_; + } + + void setSortColumn(Fm::FolderModel::ColumnId value) { + sortColumn_ = value; + } + + Fm::FolderView::ViewMode viewMode() const { + return viewMode_; + } + + void setViewMode(Fm::FolderView::ViewMode value) { + viewMode_ = value; + } + + bool sortFolderFirst() const { + return sortFolderFirst_; + } + + void setSortFolderFirst(bool value) { + sortFolderFirst_ = value; + } + + bool showHidden() const { + return showHidden_; + } + + void setShowHidden(bool value) { + showHidden_ = value; + } + + bool sortCaseSensitive() const { + return sortCaseSensitive_; + } + + void setSortCaseSensitive(bool value) { + sortCaseSensitive_ = value; + } + +private: + bool isCustomized_; + Qt::SortOrder sortOrder_; + Fm::FolderModel::ColumnId sortColumn_; + Fm::FolderView::ViewMode viewMode_; + bool showHidden_; + bool sortFolderFirst_; + bool sortCaseSensitive_; + // columns? +}; + + class Settings : public QObject { Q_OBJECT public: @@ -50,6 +130,8 @@ public: bool loadFile(QString filePath); bool saveFile(QString filePath); + static QString xdgUserConfigDir(); + QString profileDir(QString profile, bool useFallback = false); // setter/getter functions @@ -354,6 +436,15 @@ public: showHidden_ = showHidden; } + bool sortCaseSensitive() const { + return sortCaseSensitive_; + } + + void setSortCaseSensitive(bool value) { + sortCaseSensitive_ = value; + } + + bool placesHome() const { return placesHome_; } @@ -642,6 +733,12 @@ public: fm_config->template_run_app = templateRunApp_; } + // per-folder settings + FolderSettings loadFolderSettings(Fm::Path path) const; + + void saveFolderSettings(Fm::Path path, const FolderSettings &settings); + + void clearFolderSettings(Fm::Path path) const; private: QString profileName_; @@ -691,6 +788,7 @@ private: Qt::SortOrder sortOrder_; Fm::FolderModel::ColumnId sortColumn_; bool sortFolderFirst_; + bool sortCaseSensitive_; bool showFilter_; // settings for use with libfm diff --git a/pcmanfm/tabpage.cpp b/pcmanfm/tabpage.cpp index 72c22c6..3ef3b36 100644 --- a/pcmanfm/tabpage.cpp +++ b/pcmanfm/tabpage.cpp @@ -22,16 +22,18 @@ #include "launcher.h" #include #include +#include +#include +#include #include #include #include #include -#include #include "settings.h" #include "application.h" -#include #include #include +#include using namespace Fm; @@ -48,14 +50,17 @@ bool ProxyFilter::filterAcceptsRow(const Fm::ProxyFolderModel* model, FmFileInfo return true; } -void ProxyFilter::setVirtHidden(FmFolder* folder) { +void ProxyFilter::setVirtHidden(Fm::Folder folder) { virtHiddenList_ = QStringList(); // reset the list - if(!folder) return; - if(FmPath* path = fm_folder_get_path(folder)) { - char* pathStr = fm_path_to_str(path); + if(folder.isNull()) + return; + Fm::Path path = folder.getPath(); + if(!path.isNull()) { + char* pathStr = path.toStr(); if(pathStr) { - QString dotHidden = QString(pathStr) + QString("/.hidden"); + QString dotHidden = QString::fromUtf8(pathStr) + QString("/.hidden"); g_free(pathStr); + // FIXME: this does not work for non-local filesystems QFile file(dotHidden); if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); @@ -67,10 +72,9 @@ void ProxyFilter::setVirtHidden(FmFolder* folder) { } } -TabPage::TabPage(FmPath* path, QWidget* parent): +TabPage::TabPage(Fm::Path path, QWidget* parent): QWidget(parent), folderModel_(NULL), - folder_(NULL), overrideCursor_(false) { Settings& settings = static_cast(qApp)->settings(); @@ -79,7 +83,7 @@ TabPage::TabPage(FmPath* path, QWidget* parent): proxyModel_ = new ProxyFolderModel(); proxyModel_->setShowHidden(settings.showHidden()); proxyModel_->setShowThumbnails(settings.showThumbnails()); - connect(proxyModel_, &ProxyFolderModel::sortFilterChanged, this, &TabPage::onModelSortFilterChanged); + connect(proxyModel_, &ProxyFolderModel::sortFilterChanged, this, &TabPage::sortFilterChanged); verticalLayout = new QVBoxLayout(this); verticalLayout->setContentsMargins(0, 0, 0, 0); @@ -117,7 +121,11 @@ TabPage::~TabPage() { } void TabPage::freeFolder() { - if(folder_) { + if(!folder_.isNull()) { + if(folderSettings_.isCustomized()) { + // save custom view settings for this folder + static_cast(qApp)->settings().saveFolderSettings(folder_.getPath(), folderSettings_); + } g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderStartLoading, this); g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderFinishLoading, this); g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderError, this); @@ -125,8 +133,7 @@ void TabPage::freeFolder() { g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderRemoved, this); g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderUnmount, this); g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderContentChanged, this); - g_object_unref(folder_); - folder_ = NULL; + folder_ = nullptr; } } @@ -165,8 +172,8 @@ void TabPage::restoreScrollPos() { // if the current folder is the parent folder of the last browsed folder, // select the folder item in current view. - if(lastFolderPath_.parent() == path()) { - QModelIndex index = folderView_->indexFromFolderPath(lastFolderPath_.data()); + if(!lastFolderPath_.isNull() && lastFolderPath_.getParent() == path()) { + QModelIndex index = folderView_->indexFromFolderPath(lastFolderPath_); if(index.isValid()) { folderView_->childView()->scrollTo(index, QAbstractItemView::EnsureVisible); folderView_->childView()->setCurrentIndex(index); @@ -276,8 +283,8 @@ void TabPage::restoreScrollPos() { } QString TabPage::formatStatusText() { - if(proxyModel_ && folder_) { - FmFileInfoList* files = fm_folder_get_files(folder_); + if(proxyModel_ && !folder_.isNull()) { + Fm::FileInfoList files = folder_.getFiles(); int total_files = fm_file_info_list_get_length(files); int shown_files = proxyModel_->rowCount(); int hidden_files = total_files - shown_files; @@ -300,7 +307,7 @@ QString TabPage::formatStatusText() { if(settings.closeOnUnmount()) QTimer::singleShot(0, pThis, SLOT(deleteLater())); else - pThis->chdir(fm_path_get_home()); + pThis->chdir(Fm::Path::getHome()); } /*static*/ void TabPage::onFolderUnmount(FmFolder* _folder, TabPage* pThis) { @@ -318,7 +325,7 @@ QString TabPage::formatStatusText() { if(settings.closeOnUnmount()) QTimer::singleShot(0, pThis, SLOT(deleteLater())); else - pThis->chdir(fm_path_get_home()); + pThis->chdir(Fm::Path::getHome()); } /*static */ void TabPage::onFolderContentChanged(FmFolder* _folder, TabPage* pThis) { @@ -328,20 +335,20 @@ QString TabPage::formatStatusText() { } QString TabPage::pathName() { - char* disp_path = fm_path_display_name(path(), TRUE); + char* disp_path = path().displayName(true); QString ret = QString::fromUtf8(disp_path); g_free(disp_path); return ret; } -void TabPage::chdir(FmPath* newPath, bool addHistory) { - if(folder_) { +void TabPage::chdir(Path newPath, bool addHistory) { + if(!folder_.isNull()) { // we're already in the specified dir - if(fm_path_equal(newPath, fm_folder_get_path(folder_))) + if(newPath == fm_folder_get_path(folder_)) return; // remember the previous folder path that we have browsed. - lastFolderPath_ = fm_folder_get_path(folder_); + lastFolderPath_ = folder_.getPath(); if(addHistory) { // store current scroll pos in the browse history @@ -360,12 +367,12 @@ void TabPage::chdir(FmPath* newPath, bool addHistory) { freeFolder(); } - char* disp_name = fm_path_display_basename(newPath); + char* disp_name = newPath.displayBasename(); title_ = QString::fromUtf8(disp_name); Q_EMIT titleChanged(title_); g_free(disp_name); - folder_ = fm_folder_from_path(newPath); + folder_ = Fm::Folder::fromPath(newPath); proxyFilter_->setVirtHidden(folder_); if(addHistory) { // add current path to browse history @@ -381,13 +388,19 @@ void TabPage::chdir(FmPath* newPath, bool addHistory) { g_signal_connect(folder_, "content-changed", G_CALLBACK(onFolderContentChanged), this); folderModel_ = CachedFolderModel::modelFromFolder(folder_); - proxyModel_->setSourceModel(folderModel_); - proxyModel_->sort(proxyModel_->sortColumn(), proxyModel_->sortOrder()); + + // set sorting, considering customized folders Settings& settings = static_cast(qApp)->settings(); - proxyModel_->setFolderFirst(settings.sortFolderFirst()); - proxyModel_->sort(settings.sortColumn(), settings.sortOrder()); + folderSettings_ = settings.loadFolderSettings(path()); + proxyModel_->sort(folderSettings_.sortColumn(), folderSettings_.sortOrder()); + proxyModel_->setFolderFirst(folderSettings_.sortFolderFirst()); + proxyModel_->setShowHidden(folderSettings_.showHidden()); + proxyModel_->setSortCaseSensitivity(folderSettings_.sortCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive); + proxyModel_->setSourceModel(folderModel_); - if(fm_folder_is_loaded(folder_)) { + folderView_->setViewMode(folderSettings_.viewMode()); + + if(folder_.isLoaded()) { onFolderStartLoading(folder_, this); onFolderFinishLoading(folder_, this); onFolderFsInfo(folder_, this); @@ -414,48 +427,51 @@ void TabPage::onSelChanged(int numSel) { if(numSel > 0) { /* FIXME: display total size of all selected files. */ if(numSel == 1) { /* only one file is selected */ - FmFileInfoList* files = folderView_->selectedFiles(); - FmFileInfo* fi = fm_file_info_list_peek_head(files); - const char* size_str = fm_file_info_get_disp_size(fi); - if(size_str) { - msg = QString("\"%1\" (%2) %3") - .arg(QString::fromUtf8(fm_file_info_get_disp_name(fi))) - .arg(QString::fromUtf8(size_str ? size_str : "")) - .arg(QString::fromUtf8(fm_file_info_get_desc(fi))); - } - else { - msg = QString("\"%1\" %2") - .arg(QString::fromUtf8(fm_file_info_get_disp_name(fi))) - .arg(QString::fromUtf8(fm_file_info_get_desc(fi))); - } + Fm::FileInfoList files = folderView_->selectedFiles(); + if(!files.isNull()) { + Fm::FileInfo fi = fm_file_info_list_peek_head(files); + const char* size_str = fi.getDispSize(); + if(size_str) { + msg = QString("\"%1\" (%2) %3") + .arg(QString::fromUtf8(fi.getDispName())) + .arg(QString::fromUtf8(size_str)) + .arg(QString::fromUtf8(fi.getDesc())); + } + else { + msg = QString("\"%1\" %2") + .arg(QString::fromUtf8(fi.getDispName())) + .arg(QString::fromUtf8(fi.getDesc())); + } /* FIXME: should we support statusbar plugins as in the gtk+ version? */ - fm_file_info_list_unref(files); + } } else { goffset sum; GList* l; - msg = tr("%n item(s) selected", nullptr, numSel).arg(numSel); + msg = tr("%n item(s) selected", nullptr, numSel); /* don't count if too many files are selected, that isn't lightweight */ if(numSel < 1000) { sum = 0; - FmFileInfoList* files = folderView_->selectedFiles(); - for(l = fm_file_info_list_peek_head_link(files); l; l = l->next) { - if(fm_file_info_is_dir(FM_FILE_INFO(l->data))) { - /* if we got a directory then we cannot tell it's size - unless we do deep count but we cannot afford it */ - sum = -1; - break; + Fm::FileInfoList files = folderView_->selectedFiles(); + if(!files.isNull()) { + for(l = files.peekHeadLink(); l; l = l->next) { + Fm::FileInfo fi = FM_FILE_INFO(l->data); + if(fi.isDir()) { + /* if we got a directory then we cannot tell it's size + unless we do deep count but we cannot afford it */ + sum = -1; + break; + } + sum += fi.getSize(); } - sum += fm_file_info_get_size(FM_FILE_INFO(l->data)); } if(sum >= 0) { char size_str[128]; fm_file_size_to_str(size_str, sizeof(size_str), sum, fm_config->si_unit); - msg += QString(" (%1)").arg(QString::fromUtf8(size_str)); + msg += QString(" (%1)").arg(QString::fromUtf8(size_str)); } - /* FIXME: should we support statusbar plugins as in the gtk+ version? */ - fm_file_info_list_unref(files); + /* FIXME: should we support statusbar plugins as in the gtk+ version? */ } /* FIXME: can we show some more info on selection? that isn't lightweight if a lot of files are selected */ @@ -500,28 +516,74 @@ void TabPage::jumpToHistory(int index) } bool TabPage::canUp() { - return (path() != NULL && fm_path_get_parent(path()) != NULL); + Fm::Path _path = path(); + return (!_path.isNull() && !_path.getParent().isNull()); } void TabPage::up() { - FmPath* _path = path(); - if(_path) { - FmPath* parent = fm_path_get_parent(_path); - if(parent) { + Fm::Path _path = path(); + if(!_path.isNull()) { + Fm::Path parent = _path.getParent(); + if(!parent.isNull()) { chdir(parent, true); } } } -void TabPage::onModelSortFilterChanged() { - Q_EMIT sortFilterChanged(); -} - void TabPage::updateFromSettings(Settings& settings) { folderView_->updateFromSettings(settings); } +void TabPage::setViewMode(Fm::FolderView::ViewMode mode) { + if(folderSettings_.viewMode() != mode) { + folderSettings_.setViewMode(mode); + if(folderSettings_.isCustomized()) { + static_cast(qApp)->settings().saveFolderSettings(path(), folderSettings_); + } + } + folderView_->setViewMode(mode); +} + +void TabPage::sort(int col, Qt::SortOrder order) { + if(folderSettings_.sortColumn() != col || folderSettings_.sortOrder() != order) { + folderSettings_.setSortColumn(Fm::FolderModel::ColumnId(col)); + folderSettings_.setSortOrder(order); + if(folderSettings_.isCustomized()) { + static_cast(qApp)->settings().saveFolderSettings(path(), folderSettings_); + } + } + if(proxyModel_) + proxyModel_->sort(col, order); +} + +void TabPage::setSortFolderFirst(bool value) { + if(folderSettings_.sortFolderFirst() != value) { + folderSettings_.setSortFolderFirst(value); + if(folderSettings_.isCustomized()) { + static_cast(qApp)->settings().saveFolderSettings(path(), folderSettings_); + } + } + proxyModel_->setFolderFirst(value); +} + +void TabPage::setSortCaseSensitive(bool value) { + if(folderSettings_.sortCaseSensitive() != value) { + folderSettings_.setSortCaseSensitive(value); + if(folderSettings_.isCustomized()) { + static_cast(qApp)->settings().saveFolderSettings(path(), folderSettings_); + } + } + proxyModel_->setSortCaseSensitivity(value ? Qt::CaseSensitive : Qt::CaseInsensitive); +} + + void TabPage::setShowHidden(bool showHidden) { + if(folderSettings_.showHidden() != showHidden) { + folderSettings_.setShowHidden(showHidden); + if(folderSettings_.isCustomized()) { + static_cast(qApp)->settings().saveFolderSettings(path(), folderSettings_); + } + } if(!proxyModel_ || showHidden == proxyModel_->showHidden()) return; proxyModel_->setShowHidden(showHidden); @@ -529,11 +591,30 @@ void TabPage::setShowHidden(bool showHidden) { Q_EMIT statusChanged(StatusTextNormal, statusText_[StatusTextNormal]); } -void TabPage:: applyFilter() { - if(!proxyModel_) return; +void TabPage::applyFilter() { + if(!proxyModel_) + return; proxyModel_->updateFilters(); statusText_[StatusTextNormal] = formatStatusText(); Q_EMIT statusChanged(StatusTextNormal, statusText_[StatusTextNormal]); } +void TabPage::setCustomizedView(bool value) { + if(folderSettings_.isCustomized() == value) + return; + + Settings& settings = static_cast(qApp)->settings(); + folderSettings_.setCustomized(value); + if(value) { // save customized folder view settings + settings.saveFolderSettings(path(), folderSettings_); + } + else { // use default folder view settings + settings.clearFolderSettings(path()); + setShowHidden(settings.showHidden()); + setSortCaseSensitive(settings.sortCaseSensitive()); + setSortFolderFirst(settings.sortFolderFirst()); + sort(settings.sortColumn(), settings.sortOrder()); + } +} + } // namespace PCManFM diff --git a/pcmanfm/tabpage.h b/pcmanfm/tabpage.h index 3a0f145..5187cd3 100644 --- a/pcmanfm/tabpage.h +++ b/pcmanfm/tabpage.h @@ -27,6 +27,9 @@ #include #include "view.h" #include +#include +#include +#include "settings.h" namespace Fm { class FileLauncher; @@ -37,14 +40,13 @@ namespace Fm { namespace PCManFM { -class Settings; class Launcher; class ProxyFilter : public Fm::ProxyFolderModelFilter { public: bool filterAcceptsRow(const Fm::ProxyFolderModel* model, FmFileInfo* info) const; virtual ~ProxyFilter() {} - void setVirtHidden(FmFolder* folder); + void setVirtHidden(Fm::Folder folder); QString getFilterStr() { return filterStr_; } @@ -69,61 +71,51 @@ public: }; public: - explicit TabPage(FmPath* path, QWidget* parent = nullptr); + explicit TabPage(Fm::Path path, QWidget* parent = nullptr); virtual ~TabPage(); - void chdir(FmPath* newPath, bool addHistory = true); + void chdir(Fm::Path newPath, bool addHistory = true); Fm::FolderView::ViewMode viewMode() { - return folderView_->viewMode(); + return folderSettings_.viewMode(); } - void setViewMode(Fm::FolderView::ViewMode mode) { - folderView_->setViewMode(mode); - } + void setViewMode(Fm::FolderView::ViewMode mode); - void sort(int col, Qt::SortOrder order = Qt::AscendingOrder) { - // if(folderModel_) - // folderModel_->sort(col, order); - if(proxyModel_) - proxyModel_->sort(col, order); - } + void sort(int col, Qt::SortOrder order = Qt::AscendingOrder); int sortColumn() { - return proxyModel_->sortColumn(); + return folderSettings_.sortColumn(); } Qt::SortOrder sortOrder() { - return proxyModel_->sortOrder(); + return folderSettings_.sortOrder(); } bool sortFolderFirst() { - return proxyModel_->folderFirst(); - } - void setSortFolderFirst(bool value) { - proxyModel_->setFolderFirst(value); + return folderSettings_.sortFolderFirst(); } + void setSortFolderFirst(bool value); bool sortCaseSensitive() { - return proxyModel_->sortCaseSensitivity(); - } - void setSortCaseSensitive(bool value) { - proxyModel_->setSortCaseSensitivity(value ? Qt::CaseSensitive : Qt::CaseInsensitive); + return folderSettings_.sortCaseSensitive(); } + void setSortCaseSensitive(bool value); + bool showHidden() { - return proxyModel_->showHidden(); + return folderSettings_.showHidden(); } void setShowHidden(bool showHidden); - FmPath* path() { - return folder_ ? fm_folder_get_path(folder_) : nullptr; + Fm::Path path() { + return Fm::Path(!folder_.isNull() ? folder_.getPath() : nullptr); } QString pathName(); - FmFolder* folder() { + Fm::Folder& folder() { return folder_; } @@ -139,11 +131,11 @@ public: return history_; } - FmFileInfoList* selectedFiles() { + Fm::FileInfoList selectedFiles() { return folderView_->selectedFiles(); } - FmPathList* selectedFilePaths() { + Fm::PathList selectedFilePaths() { return folderView_->selectedFilePaths(); } @@ -152,9 +144,9 @@ public: void invertSelection(); void reload() { - if(folder_) { + if(!folder_.isNull()) { proxyFilter_->setVirtHidden(folder_); // reread ".hidden" - fm_folder_reload(folder_); + folder_.reload(); } } @@ -207,6 +199,12 @@ public: void applyFilter(); + bool hasCustomizedView() { + return folderSettings_.isCustomized(); + } + + void setCustomizedView(bool value); + Q_SIGNALS: void statusChanged(int type, QString statusText); void titleChanged(QString title); @@ -217,7 +215,6 @@ Q_SIGNALS: protected Q_SLOTS: void onOpenDirRequested(FmPath* path, int target); - void onModelSortFilterChanged(); void onSelChanged(int numSel); void restoreScrollPos(); @@ -239,12 +236,13 @@ private: Fm::ProxyFolderModel* proxyModel_; ProxyFilter* proxyFilter_; QVBoxLayout* verticalLayout; - FmFolder* folder_; + Fm::Folder folder_; QString title_; QString statusText_[StatusTextNum]; Fm::BrowseHistory history_; // browsing history Fm::Path lastFolderPath_; // last browsed folder bool overrideCursor_; + FolderSettings folderSettings_; }; } diff --git a/pcmanfm/translations/pcmanfm-qt-desktop-pref_ar.desktop b/pcmanfm/translations/pcmanfm-qt-desktop-pref_ar.desktop new file mode 100644 index 0000000..e329a6c --- /dev/null +++ b/pcmanfm/translations/pcmanfm-qt-desktop-pref_ar.desktop @@ -0,0 +1,4 @@ +#Translations +Name[ar]=سطح المكتب +GenericName[ar]=تفضيلات سطح المكتب +Comment[ar]=غيّر خلفيّات مدير سطح المكتب وسلوكه diff --git a/pcmanfm/translations/pcmanfm-qt_ar.desktop b/pcmanfm/translations/pcmanfm-qt_ar.desktop new file mode 100644 index 0000000..d9ec376 --- /dev/null +++ b/pcmanfm/translations/pcmanfm-qt_ar.desktop @@ -0,0 +1,4 @@ +#Translations +Name[ar]=مدير الملفّات PCManFM +GenericName[ar]=مدير ملفّات +Comment[ar]=تصفّح نظام الملفّات وأدر ملفّاتك diff --git a/pcmanfm/view.cpp b/pcmanfm/view.cpp index e941b92..b136d68 100644 --- a/pcmanfm/view.cpp +++ b/pcmanfm/view.cpp @@ -70,8 +70,8 @@ void View::onOpenInTerminal() { Application* app = static_cast(qApp); Fm::FileMenu* menu = static_cast(sender()->parent()); for(GList* l = fm_file_info_list_peek_head_link(menu->files()); l; l = l->next) { - FmFileInfo* file = FM_FILE_INFO(l->data); - app->openFolderInTerminal(fm_file_info_get_path(file)); + Fm::FileInfo file = FM_FILE_INFO(l->data); + app->openFolderInTerminal(file.getPath()); } } @@ -88,12 +88,12 @@ void View::prepareFileMenu(Fm::FileMenu* menu) { // add some more menu items for dirs bool all_native = true; bool all_directory = true; - FmFileInfoList* files = menu->files(); - for(GList* l = fm_file_info_list_peek_head_link(files); l; l = l->next) { - FmFileInfo* fi = FM_FILE_INFO(l->data); - if(!fm_file_info_is_dir(fi)) + Fm::FileInfoList files = menu->files(); + for(GList* l = files.peekHeadLink(); l; l = l->next) { + Fm::FileInfo fi = FM_FILE_INFO(l->data); + if(!fi.isDir()) all_directory = false; - else if(fm_file_info_is_dir(fi) && !fm_file_info_is_native(fi)) + else if(fi.isDir() && !fi.isNative()) all_native = false; }