Adding upstream version 0.12.0.
Signed-off-by: Alf Gaida <agaida@siduction.org>
This commit is contained in:
parent
470f3cea46
commit
ce1f1c5172
88
CHANGELOG
88
CHANGELOG
@ -1,7 +1,93 @@
|
||||
|
||||
pcmanfm-qt-0.11.3 / 2017-01-14
|
||||
pcmanfm-qt-0.12.0 / 2017-10-21
|
||||
==============================
|
||||
|
||||
* Set Version
|
||||
* removed dangeling symlink to debian dir
|
||||
* Text eliding, long texts and newline
|
||||
* Update status message appropriately
|
||||
* fixup...use static const
|
||||
* Fix icon sizes
|
||||
* Just fixed my typo in search settings (#574)
|
||||
* Lithuanian translation
|
||||
* Lithuanian translation
|
||||
* Disable menubar actions that cannot be used
|
||||
* Save and restore search settings
|
||||
* Don't export github templates
|
||||
* Wallpaper Slide Show
|
||||
* Inline renaming with F2 for detailed list view (#554)
|
||||
* Inline renaming with F2
|
||||
* Fix showing/hiding hidden files (#535)
|
||||
* Don't select or scroll to child folder on reloading (#536)
|
||||
* Replace customized DesktopItemDelegate hacks with the standard Fm::FolderItemDelegate provided by libfm-qt. (#529)
|
||||
* liblxqt version make no sense here
|
||||
* Copied issue template
|
||||
* Fix Ctrl+A on desktop (#526)
|
||||
* Update statusbar size info when needed
|
||||
* Drops Qt5Core_VERSION_STRING
|
||||
* set Qt::AA_UseHighDpiPixmaps to true
|
||||
* Fix jerky desktop items
|
||||
* Place dropped item at drop position (#504)
|
||||
* Make custom pos checkbox work for multiple items (#499)
|
||||
* Fix crash on removing desktop items with custom position (#496)
|
||||
* Fix cursor on hovering desktop items
|
||||
* Fix pressing RETURN in location bar
|
||||
* Remove the old tilde replacement
|
||||
* Included LXQTConfigVars
|
||||
* Fixed config/CMakeLists.txt - removed not needed things
|
||||
* Added merged autostart and config to CMakeLists.txt
|
||||
* Updated *_da.desktop files and removed *_da_DK.desktop files
|
||||
* Update desktop entries and Replace fr_FR by fr
|
||||
* lxqt-rc.xml: Change default config install path
|
||||
* PCManFM-Qt: Update default wallpaper (#49)
|
||||
* Merge pull request #48 from lxde/pcmanfm-qt-sort-order
|
||||
* Settings Openbox updated.
|
||||
* Default key shortcuts added to lxqt-globalkeysd.
|
||||
* Use lxqt-sudo in pcmanfm-qt config file by default.
|
||||
* Update Greek translation (el) Remove country variant from language code
|
||||
* CMake: Adds Runtime and Devel install COMPONENTs
|
||||
* Coding style changes
|
||||
* Adds double quotes to everything that may break
|
||||
* Updates the build system to use the Targets infrastructure
|
||||
* adjust default wallpaper to default theme
|
||||
* Drops hardcoded /etc/xdg paths
|
||||
* Updated german translation, replaced Qt4 by Qt in all xsession/translations
|
||||
* Updates translations infrastructure
|
||||
* Update the required minimum cmake version
|
||||
* remove dead template lines switch OnlyShowIn from Razor -> LXQt stringchanges LxQt -> LXQt
|
||||
* Add session.conf and windowmanagers.conf.
|
||||
* Support lxqt-session and add necessary xdg autostart desktop entry files.
|
||||
* Rename dirs and replace razor with lxqt. Install lxqt.conf to /etc/xdg/lxqt and provide theme config.
|
||||
* Properly set default wallpaper for pcmanfm-qt. Comment out openbox config handling in startlxde-qt since it's not needed.
|
||||
* Remove custom openbox config file in desktop.conf temporarily until lxsession is fixed.
|
||||
* Fix file paths, replacing razor with lxqt. * Remove Alt+F2 and Ctrl+Esc from openbox config file to avoid conflicts with lxqt-panel & lxqt-globalkeys.
|
||||
* Add default configuration files for lxde-qt session.
|
||||
* Use const iterators (Fix a FTBFS in debug mode) (#483)
|
||||
* Fixed desktop items movement
|
||||
* Fixes some pedantic bugs
|
||||
* Correct alignment of small icons on desktop
|
||||
* Rename namespace Fm2 to Fm.
|
||||
* Remove unused header includes.
|
||||
* Fix a bug in correct tab page dir path which causes problems of file searching.
|
||||
* Fix incorrect URI of application menu.
|
||||
* Fix the broken folder reload.
|
||||
* Fix incorrect title update of tabs.
|
||||
* Add basic error handling when folder loading is failed.
|
||||
* Port status message handling to the new libfm C++ API.
|
||||
* Use Fm2::Path::homePath() API.
|
||||
* Use the new libfm C++ terminal emulator APIs.
|
||||
* Adopt to changes of libfm C++ APIs.
|
||||
* Deprecate the use of Fm::Thumbnailer.
|
||||
* Replace all NULL with C++ 11 nullptr.
|
||||
* Initial port to the new C++ libfm API.
|
||||
* DesktopWindow: Render tilled wallpaper manually
|
||||
* Use const iterators
|
||||
* Checks bookmarks iterators validity (#444)
|
||||
|
||||
0.11.3 / 2017-01-14
|
||||
===================
|
||||
|
||||
* Release 0.11.3: Update changelog
|
||||
* remove 0.11.3 changelog entries
|
||||
* Bump patch version
|
||||
* Release 0.11.3: Update changelog
|
||||
|
@ -6,12 +6,14 @@ if (POLICY CMP0063)
|
||||
cmake_policy (SET CMP0063 NEW)
|
||||
endif (POLICY CMP0063)
|
||||
|
||||
# PcmanFm-Qt Version
|
||||
set(PCMANFM_QT_VERSION_MAJOR 0)
|
||||
set(PCMANFM_QT_VERSION_MINOR 11)
|
||||
set(PCMANFM_QT_VERSION_PATCH 3)
|
||||
set(PCMANFM_QT_VERSION_MINOR 12)
|
||||
set(PCMANFM_QT_VERSION_PATCH 0)
|
||||
|
||||
set(PCMANFM_QT_VERSION ${PCMANFM_QT_VERSION_MAJOR}.${PCMANFM_QT_VERSION_MINOR}.${PCMANFM_QT_VERSION_PATCH})
|
||||
|
||||
set(LXQTBT_MINIMUM_VERSION "0.1.0")
|
||||
set(LXQTBT_MINIMUM_VERSION "0.4.0")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
@ -22,10 +24,11 @@ find_package(Qt5X11Extras 5.2 REQUIRED)
|
||||
find_package(fm-qt REQUIRED)
|
||||
find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
|
||||
|
||||
message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt5Core_VERSION_STRING}")
|
||||
message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt5Core_VERSION}")
|
||||
|
||||
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
|
||||
include(GNUInstallDirs)
|
||||
include(LXQtConfigVars)
|
||||
include(LXQtTranslateTs)
|
||||
include(LXQtTranslateDesktop)
|
||||
include(LXQtCompilerSettings NO_POLICY_SCOPE)
|
||||
@ -61,3 +64,7 @@ if(BUILD_DOCUMENTATION)
|
||||
)
|
||||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/docs" DESTINATION "${CMAKE_INSTALL_DOCDIR}")
|
||||
endif()
|
||||
|
||||
# merged from lxqt-common
|
||||
add_subdirectory(autostart)
|
||||
add_subdirectory(config)
|
||||
|
17
autostart/CMakeLists.txt
Normal file
17
autostart/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||
|
||||
file(GLOB DESKTOP_FILES_IN *.desktop.in)
|
||||
|
||||
# Translations **********************************
|
||||
lxqt_translate_desktop(DESKTOP_FILES
|
||||
SOURCES
|
||||
${DESKTOP_FILES_IN}
|
||||
)
|
||||
add_custom_target(autostart_desktop_files ALL DEPENDS ${DESKTOP_FILES})
|
||||
#************************************************
|
||||
|
||||
install(FILES
|
||||
${DESKTOP_FILES}
|
||||
DESTINATION "${LXQT_ETC_XDG_DIR}/autostart"
|
||||
COMPONENT Runtime
|
||||
)
|
9
autostart/lxqt-desktop.desktop.in
Normal file
9
autostart/lxqt-desktop.desktop.in
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Desktop
|
||||
Exec=pcmanfm-qt --desktop --profile=lxqt
|
||||
TryExec=pcmanfm-qt
|
||||
OnlyShowIn=LXQt;
|
||||
X-LXQt-Module=true
|
||||
|
||||
#TRANSLATIONS_DIR=translations
|
2
autostart/translations/lxqt-desktop_ar.desktop
Normal file
2
autostart/translations/lxqt-desktop_ar.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ar]=سطح المكتب
|
2
autostart/translations/lxqt-desktop_cs.desktop
Normal file
2
autostart/translations/lxqt-desktop_cs.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[cs]=Plocha
|
2
autostart/translations/lxqt-desktop_cs_CZ.desktop
Normal file
2
autostart/translations/lxqt-desktop_cs_CZ.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[cs_CZ]=Plocha
|
2
autostart/translations/lxqt-desktop_da.desktop
Normal file
2
autostart/translations/lxqt-desktop_da.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[da]=Skrivebord
|
2
autostart/translations/lxqt-desktop_de.desktop
Normal file
2
autostart/translations/lxqt-desktop_de.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[de]=Arbeitsfläche
|
2
autostart/translations/lxqt-desktop_el.desktop
Normal file
2
autostart/translations/lxqt-desktop_el.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[el]=Επιφάνεια εργασίας
|
2
autostart/translations/lxqt-desktop_eo.desktop
Normal file
2
autostart/translations/lxqt-desktop_eo.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[eo]=Labortablo
|
2
autostart/translations/lxqt-desktop_es.desktop
Normal file
2
autostart/translations/lxqt-desktop_es.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[es]=Escritorio
|
2
autostart/translations/lxqt-desktop_es_VE.desktop
Normal file
2
autostart/translations/lxqt-desktop_es_VE.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[es_VE]=Escritorio
|
2
autostart/translations/lxqt-desktop_eu.desktop
Normal file
2
autostart/translations/lxqt-desktop_eu.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[eu]=Mahaigaina
|
2
autostart/translations/lxqt-desktop_fi.desktop
Normal file
2
autostart/translations/lxqt-desktop_fi.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[fi]=Työpöytä
|
2
autostart/translations/lxqt-desktop_fr.desktop
Normal file
2
autostart/translations/lxqt-desktop_fr.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[fr]=Bureau
|
2
autostart/translations/lxqt-desktop_hu.desktop
Normal file
2
autostart/translations/lxqt-desktop_hu.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[hu]=Asztal
|
2
autostart/translations/lxqt-desktop_ia.desktop
Normal file
2
autostart/translations/lxqt-desktop_ia.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ia]=Scriptorio
|
2
autostart/translations/lxqt-desktop_it_IT.desktop
Normal file
2
autostart/translations/lxqt-desktop_it_IT.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[it_IT]=Desktop
|
2
autostart/translations/lxqt-desktop_ja.desktop
Normal file
2
autostart/translations/lxqt-desktop_ja.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ja]=デスクトップ
|
2
autostart/translations/lxqt-desktop_lt.desktop
Normal file
2
autostart/translations/lxqt-desktop_lt.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[lt]=Darbalaukis
|
2
autostart/translations/lxqt-desktop_nl.desktop
Normal file
2
autostart/translations/lxqt-desktop_nl.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[nl]=Bureaublad
|
2
autostart/translations/lxqt-desktop_pl_PL.desktop
Normal file
2
autostart/translations/lxqt-desktop_pl_PL.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[pl_PL]=Pulpit
|
2
autostart/translations/lxqt-desktop_pt.desktop
Normal file
2
autostart/translations/lxqt-desktop_pt.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[pt]=Área de trabalho
|
2
autostart/translations/lxqt-desktop_pt_BR.desktop
Normal file
2
autostart/translations/lxqt-desktop_pt_BR.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[pt_BR]=Área de trabalho
|
2
autostart/translations/lxqt-desktop_ro_RO.desktop
Normal file
2
autostart/translations/lxqt-desktop_ro_RO.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ro_RO]=Desktop
|
2
autostart/translations/lxqt-desktop_ru.desktop
Normal file
2
autostart/translations/lxqt-desktop_ru.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ru]=Pабочий стол
|
2
autostart/translations/lxqt-desktop_ru_RU.desktop
Normal file
2
autostart/translations/lxqt-desktop_ru_RU.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[ru_RU]=Рабочий стол
|
2
autostart/translations/lxqt-desktop_sl.desktop
Normal file
2
autostart/translations/lxqt-desktop_sl.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[sl]=Namizje
|
2
autostart/translations/lxqt-desktop_th_TH.desktop
Normal file
2
autostart/translations/lxqt-desktop_th_TH.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[th_TH]=เดสก์ท็อป
|
2
autostart/translations/lxqt-desktop_tr.desktop
Normal file
2
autostart/translations/lxqt-desktop_tr.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[tr]=Masaüstü
|
2
autostart/translations/lxqt-desktop_uk.desktop
Normal file
2
autostart/translations/lxqt-desktop_uk.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[uk]=Стільниця
|
2
autostart/translations/lxqt-desktop_zh_CN.desktop
Normal file
2
autostart/translations/lxqt-desktop_zh_CN.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[zh_CN]=桌面
|
2
autostart/translations/lxqt-desktop_zh_TW.desktop
Normal file
2
autostart/translations/lxqt-desktop_zh_TW.desktop
Normal file
@ -0,0 +1,2 @@
|
||||
# Translations
|
||||
Name[zh_TW]=桌面
|
8
config/CMakeLists.txt
Normal file
8
config/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# install default config files to /etc/xdg
|
||||
|
||||
configure_file(pcmanfm-qt/lxqt/settings.conf.in pcmanfm-qt/lxqt/settings.conf @ONLY)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pcmanfm-qt/lxqt/settings.conf"
|
||||
DESTINATION "${LXQT_ETC_XDG_DIR}/pcmanfm-qt/lxqt"
|
||||
COMPONENT Runtime
|
||||
)
|
53
config/pcmanfm-qt/lxqt/settings.conf.in
Normal file
53
config/pcmanfm-qt/lxqt/settings.conf.in
Normal file
@ -0,0 +1,53 @@
|
||||
[System]
|
||||
IconThemeName=elementary
|
||||
SuCommand=lxqt-sudo %s
|
||||
TerminalCommand=
|
||||
Archiver=file-roller
|
||||
SIUnit=false
|
||||
TerminalDirCommand=xterm
|
||||
TerminalExecCommand=xterm -e %s
|
||||
|
||||
[Behavior]
|
||||
BookmarkOpenMethod=0
|
||||
UseTrash=true
|
||||
SingleClick=false
|
||||
ConfirmDelete=true
|
||||
|
||||
[Desktop]
|
||||
WallpaperMode=stretch
|
||||
Wallpaper=@LXQT_SHARE_DIR@/themes/frost/lxqt-origami-light.png
|
||||
BgColor=#000000
|
||||
FgColor=#ffffff
|
||||
ShadowColor=#000000
|
||||
ShowHidden=false
|
||||
SortOrder=ascending
|
||||
SortColumn=name
|
||||
Font="Sans Serif,10,-1,5,50,0,0,0,0,0"
|
||||
|
||||
[Volume]
|
||||
MountOnStartup=true
|
||||
MountRemovable=true
|
||||
AutoRun=true
|
||||
|
||||
[FolderView]
|
||||
Mode=icon
|
||||
ShowHidden=false
|
||||
SortOrder=ascending
|
||||
SortColumn=name
|
||||
BigIconSize=48
|
||||
SmallIconSize=24
|
||||
SidePaneIconSize=24
|
||||
ThumbnailIconSize=128
|
||||
|
||||
[Window]
|
||||
Width=640
|
||||
Height=480
|
||||
AlwaysShowTabs=false
|
||||
ShowTabClose=true
|
||||
SplitterPos=150
|
||||
SidePaneMode=0
|
||||
|
||||
[Thumbnail]
|
||||
ShowThumbnails=true
|
||||
MaxThumbnailFileSize=4096
|
||||
ThumbnailLocalFilesOnly=true
|
@ -4,13 +4,13 @@ set(pcmanfm_SRCS
|
||||
mainwindow.cpp
|
||||
tabpage.cpp
|
||||
tabbar.cpp
|
||||
statusbar.cpp
|
||||
view.cpp
|
||||
launcher.cpp
|
||||
preferencesdialog.cpp
|
||||
xdgdir.cpp
|
||||
desktoppreferencesdialog.cpp
|
||||
desktopwindow.cpp
|
||||
desktopitemdelegate.cpp
|
||||
autorundialog.cpp
|
||||
connectserverdialog.cpp
|
||||
settings.cpp
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <libfm-qt/mountoperation.h>
|
||||
#include <libfm-qt/filesearchdialog.h>
|
||||
#include <libfm-qt/path.h>
|
||||
#include <libfm-qt/terminal.h>
|
||||
#include <libfm-qt/core/terminal.h>
|
||||
|
||||
#include "applicationadaptor.h"
|
||||
#include "preferencesdialog.h"
|
||||
@ -63,8 +63,9 @@ static const char* ifaceName = "org.pcmanfm.Application";
|
||||
|
||||
int ProxyStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWidget* widget, QStyleHintReturn* returnData) const {
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
if(hint == QStyle::SH_ItemView_ActivateItemOnSingleClick)
|
||||
if(hint == QStyle::SH_ItemView_ActivateItemOnSingleClick) {
|
||||
return app->settings().singleClick();
|
||||
}
|
||||
return QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||
}
|
||||
|
||||
@ -78,8 +79,8 @@ Application::Application(int& argc, char** argv):
|
||||
desktopWindows_(),
|
||||
preferencesDialog_(),
|
||||
editBookmarksialog_(),
|
||||
volumeMonitor_(NULL),
|
||||
userDirsWatcher_(NULL),
|
||||
volumeMonitor_(nullptr),
|
||||
userDirsWatcher_(nullptr),
|
||||
lxqtRunning_(false) {
|
||||
|
||||
argc_ = argc;
|
||||
@ -116,8 +117,8 @@ Application::Application(int& argc, char** argv):
|
||||
QDBusInterface* lxqtSessionIface = new QDBusInterface(
|
||||
QStringLiteral("org.lxqt.session"),
|
||||
QStringLiteral("/LXQtSession"));
|
||||
if (lxqtSessionIface) {
|
||||
if (lxqtSessionIface->isValid()) {
|
||||
if(lxqtSessionIface) {
|
||||
if(lxqtSessionIface->isValid()) {
|
||||
lxqtRunning_ = true;
|
||||
userDesktopFolder_ = XdgDir::readDesktopDir();
|
||||
initWatch();
|
||||
@ -145,13 +146,13 @@ Application::~Application() {
|
||||
// removeNativeEventFilter(this);
|
||||
}
|
||||
|
||||
void Application::initWatch()
|
||||
{
|
||||
QFile file_ (QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs"));
|
||||
void Application::initWatch() {
|
||||
QFile file_(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs"));
|
||||
if(! file_.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << Q_FUNC_INFO << "Could not read: " << userDirsFile_;
|
||||
userDirsFile_ = QString();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
userDirsFile_ = file_.fileName();
|
||||
}
|
||||
|
||||
@ -206,10 +207,12 @@ bool Application::parseCommandLineArgs() {
|
||||
if(isPrimaryInstance) {
|
||||
qDebug("isPrimaryInstance");
|
||||
|
||||
if(parser.isSet(daemonOption))
|
||||
if(parser.isSet(daemonOption)) {
|
||||
daemonMode_ = true;
|
||||
if(parser.isSet(profileOption))
|
||||
}
|
||||
if(parser.isSet(profileOption)) {
|
||||
profileName_ = parser.value(profileOption);
|
||||
}
|
||||
|
||||
// load settings
|
||||
settings_.load(profileName_);
|
||||
@ -219,8 +222,9 @@ bool Application::parseCommandLineArgs() {
|
||||
desktopManager(true);
|
||||
keepRunning = true;
|
||||
}
|
||||
else if(parser.isSet(desktopOffOption))
|
||||
else if(parser.isSet(desktopOffOption)) {
|
||||
desktopManager(false);
|
||||
}
|
||||
|
||||
if(parser.isSet(desktopPrefOption)) { // desktop preference dialog
|
||||
desktopPrefrences(parser.value(desktopPrefOption));
|
||||
@ -234,19 +238,22 @@ bool Application::parseCommandLineArgs() {
|
||||
preferences(parser.value(showPrefOption));
|
||||
keepRunning = true;
|
||||
}
|
||||
else if(parser.isSet(setWallpaperOption) || parser.isSet(wallpaperModeOption)) // set wall paper
|
||||
else if(parser.isSet(setWallpaperOption) || parser.isSet(wallpaperModeOption)) { // set wall paper
|
||||
setWallpaper(parser.value(setWallpaperOption), parser.value(wallpaperModeOption));
|
||||
}
|
||||
else {
|
||||
if(!parser.isSet(desktopOption) && !parser.isSet(desktopOffOption)) {
|
||||
QStringList paths = parser.positionalArguments();
|
||||
if(paths.isEmpty()) {
|
||||
// if no path is specified and we're using daemon mode,
|
||||
// don't open current working directory
|
||||
if(!daemonMode_)
|
||||
if(!daemonMode_) {
|
||||
paths.push_back(QDir::currentPath());
|
||||
}
|
||||
if(!paths.isEmpty())
|
||||
}
|
||||
if(!paths.isEmpty()) {
|
||||
launchFiles(QDir::currentPath(), paths, parser.isSet(newWindowOption));
|
||||
}
|
||||
keepRunning = true;
|
||||
}
|
||||
}
|
||||
@ -259,10 +266,12 @@ bool Application::parseCommandLineArgs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(parser.isSet(desktopOption))
|
||||
if(parser.isSet(desktopOption)) {
|
||||
iface.call("desktopManager", true);
|
||||
else if(parser.isSet(desktopOffOption))
|
||||
}
|
||||
else if(parser.isSet(desktopOffOption)) {
|
||||
iface.call("desktopManager", false);
|
||||
}
|
||||
|
||||
if(parser.isSet(desktopPrefOption)) { // desktop preference dialog
|
||||
iface.call("desktopPrefrences", parser.value(desktopPrefOption));
|
||||
@ -305,11 +314,13 @@ void Application::init() {
|
||||
|
||||
int Application::exec() {
|
||||
|
||||
if(!parseCommandLineArgs())
|
||||
if(!parseCommandLineArgs()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(daemonMode_) // keep running even when there is no window opened.
|
||||
if(daemonMode_) { // keep running even when there is no window opened.
|
||||
setQuitOnLastWindowClosed(false);
|
||||
}
|
||||
|
||||
volumeMonitor_ = g_volume_monitor_get();
|
||||
// delay the volume manager a little because in newer versions of glib/gio there's a problem.
|
||||
@ -324,8 +335,7 @@ int Application::exec() {
|
||||
}
|
||||
|
||||
|
||||
void Application::onUserDirsChanged()
|
||||
{
|
||||
void Application::onUserDirsChanged() {
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
bool file_deleted = !userDirsWatcher_->files().contains(userDirsFile_);
|
||||
if(file_deleted) {
|
||||
@ -334,15 +344,16 @@ void Application::onUserDirsChanged()
|
||||
}
|
||||
|
||||
const QString d = XdgDir::readDesktopDir();
|
||||
if (d != userDesktopFolder_) {
|
||||
if(d != userDesktopFolder_) {
|
||||
userDesktopFolder_ = d;
|
||||
const QDir dir(d);
|
||||
if (dir.exists()) {
|
||||
if(dir.exists()) {
|
||||
const int N = desktopWindows_.size();
|
||||
for(int i = 0; i < N; ++i) {
|
||||
desktopWindows_.at(i)->setDesktopFolder();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qWarning("Application::onUserDirsChanged: %s doesn't exist",
|
||||
userDesktopFolder_.toUtf8().constData());
|
||||
}
|
||||
@ -356,7 +367,7 @@ void Application::onAboutToQuit() {
|
||||
|
||||
bool Application::eventFilter(QObject* watched, QEvent* event) {
|
||||
if(watched == desktop()) {
|
||||
if (event->type() == QEvent::StyleChange ||
|
||||
if(event->type() == QEvent::StyleChange ||
|
||||
event->type() == QEvent::ThemeChange) {
|
||||
setStyle(new ProxyStyle());
|
||||
}
|
||||
@ -441,22 +452,29 @@ void Application::desktopPrefrences(QString page) {
|
||||
|
||||
void Application::onFindFileAccepted() {
|
||||
Fm::FileSearchDialog* dlg = static_cast<Fm::FileSearchDialog*>(sender());
|
||||
// get search settings
|
||||
settings_.setSearchNameCaseInsensitive(dlg->nameCaseInsensitive());
|
||||
settings_.setsearchContentCaseInsensitive(dlg->contentCaseInsensitive());
|
||||
settings_.setSearchNameRegexp(dlg->nameRegexp());
|
||||
settings_.setSearchContentRegexp(dlg->contentRegexp());
|
||||
settings_.setSearchRecursive(dlg->recursive());
|
||||
settings_.setSearchhHidden(dlg->searchhHidden());
|
||||
|
||||
Fm::Path uri = dlg->searchUri();
|
||||
Fm::PathList paths;
|
||||
paths.pushTail(uri);
|
||||
Fm::FilePathList paths;
|
||||
Fm::GFilePtr gf{uri.toGfile(), false};
|
||||
paths.push_back(Fm::FilePath{gf.get(), true});
|
||||
MainWindow* window = MainWindow::lastActive();
|
||||
Launcher(window).launchPaths(NULL, paths);
|
||||
Launcher(window).launchPaths(nullptr, paths);
|
||||
}
|
||||
|
||||
void Application::onConnectToServerAccepted() {
|
||||
ConnectServerDialog* dlg = static_cast<ConnectServerDialog*>(sender());
|
||||
QString uri = dlg->uriText();
|
||||
Fm::Path path = Fm::Path::newForStr(uri.toUtf8().constData());
|
||||
qDebug() << uri << " => " << path.toStr();
|
||||
Fm::PathList paths;
|
||||
paths.pushTail(path);
|
||||
Fm::FilePathList paths;
|
||||
paths.push_back(Fm::FilePath::fromDisplayName(uri.toUtf8().constData()));
|
||||
MainWindow* window = MainWindow::lastActive();
|
||||
Launcher(window).launchPaths(NULL, paths);
|
||||
Launcher(window).launchPaths(nullptr, paths);
|
||||
}
|
||||
|
||||
void Application::findFiles(QStringList paths) {
|
||||
@ -464,6 +482,14 @@ void Application::findFiles(QStringList paths) {
|
||||
Fm::FileSearchDialog* dlg = new Fm::FileSearchDialog(paths);
|
||||
connect(dlg, &QDialog::accepted, this, &Application::onFindFileAccepted);
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// set search settings
|
||||
dlg->setNameCaseInsensitive(settings_.searchNameCaseInsensitive());
|
||||
dlg->setContentCaseInsensitive(settings_.searchContentCaseInsensitive());
|
||||
dlg->setNameRegexp(settings_.searchNameRegexp());
|
||||
dlg->setContentRegexp(settings_.searchContentRegexp());
|
||||
dlg->setRecursive(settings_.searchRecursive());
|
||||
dlg->setSearchhHidden(settings_.searchhHidden());
|
||||
|
||||
dlg->show();
|
||||
}
|
||||
|
||||
@ -475,54 +501,48 @@ void Application::connectToServer() {
|
||||
}
|
||||
|
||||
void Application::launchFiles(QString cwd, QStringList paths, bool inNewWindow) {
|
||||
Fm::PathList pathList;
|
||||
Fm::Path cwd_path;
|
||||
Fm::FilePathList pathList;
|
||||
Fm::FilePath cwd_path;
|
||||
QStringList::iterator it;
|
||||
Q_FOREACH(const QString& it, paths) {
|
||||
QByteArray pathName = it.toLocal8Bit();
|
||||
Fm::Path path;
|
||||
if(pathName[0] == '/') // absolute path
|
||||
path = Fm::Path::newForPath(pathName.constData());
|
||||
else if(pathName.contains(":/")) // URI
|
||||
path = Fm::Path::newForUri(pathName.constData());
|
||||
else if(pathName == "~") // special case for home dir
|
||||
path = Fm::Path::getHome();
|
||||
else // basename
|
||||
{
|
||||
if(Q_UNLIKELY(!cwd_path))
|
||||
cwd_path = Fm::Path::newForStr(cwd.toLocal8Bit().constData());
|
||||
path = cwd_path.newRelative(pathName.constData());
|
||||
Fm::FilePath path;
|
||||
if(pathName == "~") { // special case for home dir
|
||||
path = Fm::FilePath::homeDir();
|
||||
}
|
||||
fm_path_list_push_tail(pathList, path);
|
||||
if(pathName[0] == '/') { // absolute path
|
||||
path = Fm::FilePath::fromLocalPath(pathName.constData());
|
||||
}
|
||||
else if(pathName.contains(":/")) { // URI
|
||||
path = Fm::FilePath::fromUri(pathName.constData());
|
||||
}
|
||||
else { // basename
|
||||
if(Q_UNLIKELY(!cwd_path)) {
|
||||
cwd_path = Fm::FilePath::fromLocalPath(cwd.toLocal8Bit().constData());
|
||||
}
|
||||
path = cwd_path.relativePath(pathName.constData());
|
||||
}
|
||||
pathList.push_back(std::move(path));
|
||||
}
|
||||
|
||||
Launcher(NULL).launchPaths(NULL, pathList);
|
||||
Launcher(nullptr).launchPaths(nullptr, pathList);
|
||||
}
|
||||
|
||||
void Application::openFolders(Fm::FileInfoList files) {
|
||||
Launcher(NULL).launchFiles(NULL, files);
|
||||
Launcher(nullptr).launchFiles(nullptr, std::move(files));
|
||||
}
|
||||
|
||||
void Application::openFolderInTerminal(Fm::Path path) {
|
||||
void Application::openFolderInTerminal(Fm::FilePath path) {
|
||||
if(!settings_.terminal().isEmpty()) {
|
||||
char* cwd_str;
|
||||
if(path.isNative())
|
||||
cwd_str = path.toStr();
|
||||
else { // gio will map remote filesystems to local FUSE-mounted paths here.
|
||||
GFile* gf = path.toGfile();
|
||||
cwd_str = g_file_get_path(gf);
|
||||
g_object_unref(gf);
|
||||
Fm::GErrorPtr err;
|
||||
auto terminalName = settings_.terminal().toUtf8();
|
||||
if(!Fm::launchTerminal(terminalName.constData(), path, err)) {
|
||||
QMessageBox::critical(nullptr, tr("Error"), err.message());
|
||||
}
|
||||
GError* err = NULL;
|
||||
if(!Fm::Terminal::launch(cwd_str, &err)) {
|
||||
QMessageBox::critical(NULL, tr("Error"), QString::fromUtf8(err->message));
|
||||
g_error_free(err);
|
||||
}
|
||||
g_free(cwd_str);
|
||||
}
|
||||
else {
|
||||
// show an error message and ask the user to set the command
|
||||
QMessageBox::critical(NULL, tr("Error"), tr("Terminal emulator is not set."));
|
||||
QMessageBox::critical(nullptr, tr("Error"), tr("Terminal emulator is not set."));
|
||||
preferences("advanced");
|
||||
}
|
||||
}
|
||||
@ -558,8 +578,9 @@ void Application::setWallpaper(QString path, QString modeString) {
|
||||
// defined in this function and we can clearly see that it does not
|
||||
// overflow.
|
||||
mode = static_cast<DesktopWindow::WallpaperMode>(i);
|
||||
if(mode != settings_.wallpaperMode())
|
||||
if(mode != settings_.wallpaperMode()) {
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -567,11 +588,13 @@ void Application::setWallpaper(QString path, QString modeString) {
|
||||
// update wallpaper
|
||||
if(changed) {
|
||||
if(enableDesktopManager_) {
|
||||
Q_FOREACH(DesktopWindow * desktopWindow, desktopWindows_) {
|
||||
if(!path.isEmpty())
|
||||
Q_FOREACH(DesktopWindow* desktopWindow, desktopWindows_) {
|
||||
if(!path.isEmpty()) {
|
||||
desktopWindow->setWallpaperFile(path);
|
||||
if(mode != settings_.wallpaperMode())
|
||||
}
|
||||
if(mode != settings_.wallpaperMode()) {
|
||||
desktopWindow->setWallpaperMode(mode);
|
||||
}
|
||||
desktopWindow->updateWallpaper();
|
||||
}
|
||||
settings_.save(); // save the settings to the config file
|
||||
@ -620,8 +643,9 @@ void Application::onScreenCountChanged(int newCount) {
|
||||
}
|
||||
|
||||
// we used non-virtual mode originally, but now we're switched to virtual mode
|
||||
if(isVirtual)
|
||||
if(isVirtual) {
|
||||
newCount = 1; // we only want one desktop window for all screens in virtual mode
|
||||
}
|
||||
|
||||
if(newCount > desktopWindows_.size()) {
|
||||
// add more desktop windows
|
||||
@ -641,10 +665,12 @@ void Application::onScreenCountChanged(int newCount) {
|
||||
|
||||
if(newCount == 1) { // now only 1 screen is in use
|
||||
DesktopWindow* desktop = desktopWindows_.at(0);
|
||||
if(isVirtual)
|
||||
if(isVirtual) {
|
||||
desktop->setScreenNum(-1);
|
||||
else // non-virtual mode, and we only have 1 screen
|
||||
}
|
||||
else { // non-virtual mode, and we only have 1 screen
|
||||
desktop->setScreenNum(0);
|
||||
}
|
||||
desktop->updateWallpaper();
|
||||
}
|
||||
}
|
||||
@ -664,15 +690,16 @@ void Application::updateFromSettings() {
|
||||
mainWindow->updateFromSettings(settings_);
|
||||
}
|
||||
}
|
||||
if(desktopManagerEnabled())
|
||||
if(desktopManagerEnabled()) {
|
||||
updateDesktopsFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::updateDesktopsFromSettings() {
|
||||
void Application::updateDesktopsFromSettings(bool changeSlide) {
|
||||
QVector<DesktopWindow*>::iterator it;
|
||||
for(it = desktopWindows_.begin(); it != desktopWindows_.end(); ++it) {
|
||||
DesktopWindow* desktopWindow = static_cast<DesktopWindow*>(*it);
|
||||
desktopWindow->updateFromSettings(settings_);
|
||||
desktopWindow->updateFromSettings(settings_, changeSlide);
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,8 +721,9 @@ void Application::initVolumeManager() {
|
||||
GList* vols = g_volume_monitor_get_volumes(volumeMonitor_);
|
||||
for(GList* l = vols; l; l = l->next) {
|
||||
GVolume* volume = G_VOLUME(l->data);
|
||||
if(g_volume_should_automount(volume))
|
||||
if(g_volume_should_automount(volume)) {
|
||||
autoMountVolume(volume, false);
|
||||
}
|
||||
g_object_unref(volume);
|
||||
}
|
||||
g_list_free(vols);
|
||||
@ -703,18 +731,21 @@ void Application::initVolumeManager() {
|
||||
}
|
||||
|
||||
bool Application::autoMountVolume(GVolume* volume, bool interactive) {
|
||||
if(!g_volume_should_automount(volume) || !g_volume_can_mount(volume))
|
||||
if(!g_volume_should_automount(volume) || !g_volume_can_mount(volume)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GMount* mount = g_volume_get_mount(volume);
|
||||
if(!mount) { // not mounted, automount is needed
|
||||
// try automount
|
||||
Fm::MountOperation* op = new Fm::MountOperation(interactive);
|
||||
op->mount(volume);
|
||||
if(!op->wait())
|
||||
if(!op->wait()) {
|
||||
return false;
|
||||
if(!interactive)
|
||||
}
|
||||
if(!interactive) {
|
||||
return true;
|
||||
}
|
||||
mount = g_volume_get_mount(volume);
|
||||
}
|
||||
|
||||
@ -730,17 +761,18 @@ bool Application::autoMountVolume(GVolume* volume, bool interactive) {
|
||||
|
||||
// static
|
||||
void Application::onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis) {
|
||||
if(pThis->settings_.mountRemovable())
|
||||
if(pThis->settings_.mountRemovable()) {
|
||||
pThis->autoMountVolume(volume, true);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Application::nativeEventFilter(const QByteArray & eventType, void * message, long * result) {
|
||||
bool Application::nativeEventFilter(const QByteArray& eventType, void* message, long* result) {
|
||||
if(eventType == "xcb_generic_event_t") { // XCB event
|
||||
// filter all native X11 events (xcb)
|
||||
xcb_generic_event_t* generic_event = reinterpret_cast<xcb_generic_event_t*>(message);
|
||||
// qDebug("XCB event: %d", generic_event->response_type & ~0x80);
|
||||
Q_FOREACH(DesktopWindow * window, desktopWindows_) {
|
||||
Q_FOREACH(DesktopWindow* window, desktopWindows_) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -788,9 +820,10 @@ void Application::onScreenDestroyed(QObject* screenObj) {
|
||||
reloadNeeded = true;
|
||||
}
|
||||
}
|
||||
if(reloadNeeded)
|
||||
if(reloadNeeded) {
|
||||
QTimer::singleShot(0, this, SLOT(reloadDesktopsAsNeeded()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::reloadDesktopsAsNeeded() {
|
||||
@ -845,13 +878,14 @@ void Application::installSigtermHandler() {
|
||||
if(::sigaction(SIGTERM, &action, 0) != 0) {
|
||||
qWarning("Couldn't install SIGTERM handler");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qWarning("Couldn't create SIGTERM socketpair");
|
||||
}
|
||||
}
|
||||
|
||||
void Application::onSigtermNotified() {
|
||||
if (QSocketNotifier* notifier = qobject_cast<QSocketNotifier*>(sender())) {
|
||||
if(QSocketNotifier* notifier = qobject_cast<QSocketNotifier*>(sender())) {
|
||||
notifier->setEnabled(false);
|
||||
char c;
|
||||
::read(sigterm_fd[1], &c, sizeof(c));
|
||||
|
@ -31,6 +31,9 @@
|
||||
#include <QTranslator>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include <libfm-qt/core/filepath.h>
|
||||
#include <libfm-qt/core/fileinfo.h>
|
||||
|
||||
class QScreen;
|
||||
|
||||
class QFileSystemWatcher;
|
||||
@ -47,7 +50,7 @@ class ProxyStyle: public QProxyStyle {
|
||||
public:
|
||||
ProxyStyle() : QProxyStyle() {}
|
||||
virtual ~ProxyStyle() {}
|
||||
virtual int styleHint(StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0) const;
|
||||
virtual int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
|
||||
};
|
||||
|
||||
class Application : public QApplication {
|
||||
@ -84,9 +87,9 @@ public:
|
||||
}
|
||||
|
||||
void updateFromSettings();
|
||||
void updateDesktopsFromSettings();
|
||||
void updateDesktopsFromSettings(bool changeSlide = true);
|
||||
|
||||
void openFolderInTerminal(Fm::Path path);
|
||||
void openFolderInTerminal(Fm::FilePath path);
|
||||
void openFolders(Fm::FileInfoList files);
|
||||
|
||||
QString profileName() {
|
||||
@ -98,7 +101,7 @@ protected Q_SLOTS:
|
||||
void onSigtermNotified();
|
||||
|
||||
void onLastWindowClosed();
|
||||
void onSaveStateRequest(QSessionManager & manager);
|
||||
void onSaveStateRequest(QSessionManager& manager);
|
||||
void onScreenResized(int num);
|
||||
void onScreenCountChanged(int newCount);
|
||||
void initVolumeManager();
|
||||
@ -140,7 +143,7 @@ private:
|
||||
QTranslator qtTranslator;
|
||||
GVolumeMonitor* volumeMonitor_;
|
||||
|
||||
QFileSystemWatcher *userDirsWatcher_;
|
||||
QFileSystemWatcher* userDirsWatcher_;
|
||||
QString userDirsFile_;
|
||||
QString userDesktopFolder_;
|
||||
bool lxqtRunning_;
|
||||
|
@ -23,20 +23,22 @@
|
||||
#include <QListWidgetItem>
|
||||
#include "application.h"
|
||||
#include "mainwindow.h"
|
||||
#include <libfm-qt/core/filepath.h>
|
||||
#include <libfm-qt/core/iconinfo.h>
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
AutoRunDialog::AutoRunDialog(GVolume* volume, GMount* mount, QWidget* parent, Qt::WindowFlags f):
|
||||
QDialog(parent, f),
|
||||
cancellable(g_cancellable_new()),
|
||||
applications(NULL),
|
||||
applications(nullptr),
|
||||
mount_(G_MOUNT(g_object_ref(mount))) {
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui.setupUi(this);
|
||||
|
||||
GIcon* gicon = g_volume_get_icon(volume);
|
||||
QIcon icon = Fm::IconTheme::icon(gicon);
|
||||
QIcon icon = Fm::IconInfo::fromGIcon(gicon)->qicon();
|
||||
ui.icon->setPixmap(icon.pixmap(QSize(48, 48)));
|
||||
|
||||
// add actions
|
||||
@ -47,11 +49,12 @@ AutoRunDialog::AutoRunDialog(GVolume* volume, GMount* mount, QWidget* parent, Qt
|
||||
}
|
||||
|
||||
AutoRunDialog::~AutoRunDialog() {
|
||||
g_list_foreach(applications, (GFunc)g_object_unref, NULL);
|
||||
g_list_foreach(applications, (GFunc)g_object_unref, nullptr);
|
||||
g_list_free(applications);
|
||||
|
||||
if(mount_)
|
||||
if(mount_) {
|
||||
g_object_unref(mount_);
|
||||
}
|
||||
|
||||
if(cancellable) {
|
||||
g_cancellable_cancel(cancellable);
|
||||
@ -66,15 +69,15 @@ void AutoRunDialog::accept() {
|
||||
void* p = item->data(Qt::UserRole).value<void*>();
|
||||
if(p) { // run the selected application
|
||||
GAppInfo* app = G_APP_INFO(p);
|
||||
GList* filelist = g_list_prepend(NULL, gf);
|
||||
g_app_info_launch(app, filelist, NULL, NULL);
|
||||
GList* filelist = g_list_prepend(nullptr, gf);
|
||||
g_app_info_launch(app, filelist, nullptr, nullptr);
|
||||
g_list_free(filelist);
|
||||
}
|
||||
else {
|
||||
// the default action, open the mounted folder in the file manager
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
Settings& settings = app->settings();
|
||||
Fm::Path path = Fm::Path::newForGfile(gf);
|
||||
Fm::FilePath path{gf, true};
|
||||
// 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);
|
||||
@ -93,19 +96,20 @@ void AutoRunDialog::accept() {
|
||||
void AutoRunDialog::onContentTypeFinished(GMount* mount, GAsyncResult* res, AutoRunDialog* pThis) {
|
||||
if(pThis->cancellable) {
|
||||
g_object_unref(pThis->cancellable);
|
||||
pThis->cancellable = NULL;
|
||||
pThis->cancellable = nullptr;
|
||||
}
|
||||
|
||||
char** types = g_mount_guess_content_type_finish(mount, res, NULL);
|
||||
char* desc = NULL;
|
||||
char** types = g_mount_guess_content_type_finish(mount, res, nullptr);
|
||||
char* desc = nullptr;
|
||||
|
||||
if(types) {
|
||||
if(types[0]) {
|
||||
for(char** type = types; *type; ++type) {
|
||||
GList* l = g_app_info_get_all_for_type(*type);
|
||||
if(l)
|
||||
if(l) {
|
||||
pThis->applications = g_list_concat(pThis->applications, l);
|
||||
}
|
||||
}
|
||||
desc = g_content_type_get_description(types[0]);
|
||||
}
|
||||
g_strfreev(types);
|
||||
@ -115,7 +119,7 @@ void AutoRunDialog::onContentTypeFinished(GMount* mount, GAsyncResult* res, Auto
|
||||
for(GList* l = pThis->applications; l; l = l->next, ++pos) {
|
||||
GAppInfo* app = G_APP_INFO(l->data);
|
||||
GIcon* gicon = g_app_info_get_icon(app);
|
||||
QIcon icon = Fm::IconTheme::icon(gicon);
|
||||
QIcon icon = Fm::IconInfo::fromGIcon(gicon)->qicon();
|
||||
QString text = QString::fromUtf8(g_app_info_get_name(app));
|
||||
QListWidgetItem* item = new QListWidgetItem(icon, text);
|
||||
item->setData(Qt::UserRole, qVariantFromValue<void*>(app));
|
||||
@ -128,8 +132,9 @@ void AutoRunDialog::onContentTypeFinished(GMount* mount, GAsyncResult* res, Auto
|
||||
pThis->ui.mediumType->setText(QString::fromUtf8(desc));
|
||||
g_free(desc);
|
||||
}
|
||||
else
|
||||
else {
|
||||
pThis->ui.mediumType->setText(tr("Removable Disk"));
|
||||
}
|
||||
|
||||
// select the first item
|
||||
pThis->ui.listWidget->item(0)->setSelected(true);
|
||||
|
@ -310,6 +310,144 @@ A space is also reserved for 3 lines of text.</string>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="bgPage">
|
||||
<attribute name="title">
|
||||
<string>Slide Show</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="slideShow">
|
||||
<property name="title">
|
||||
<string>Enable Slide Show</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0" colspan="7">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Wallpaper image folder:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="QPushButton" name="folderBrowse">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="hours">
|
||||
<property name="suffix">
|
||||
<string> hour(s)</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>and</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="toolTip">
|
||||
<string>Intervals less than 5min will be ignored</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interval:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QSpinBox" name="minutes">
|
||||
<property name="suffix">
|
||||
<string> minute(s)</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>55</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="QLineEdit" name="imageFolder">
|
||||
<property name="placeholderText">
|
||||
<string>Wallpaper folder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="6">
|
||||
<widget class="QCheckBox" name="randomize">
|
||||
<property name="text">
|
||||
<string>Randomize the slide show</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="advancedPage">
|
||||
<attribute name="title">
|
||||
<string>Advanced</string>
|
||||
|
@ -1,207 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright (C) 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "desktopitemdelegate.h"
|
||||
#include <libfm-qt/foldermodel.h>
|
||||
#include <libfm-qt/fileinfo.h>
|
||||
#include <QApplication>
|
||||
#include <QListView>
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
#include <QTextLayout>
|
||||
#include <QTextOption>
|
||||
#include <QTextLine>
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
DesktopItemDelegate::DesktopItemDelegate(QListView* view, QObject* parent):
|
||||
QStyledItemDelegate(parent ? parent : view),
|
||||
view_(view),
|
||||
symlinkIcon_(QIcon::fromTheme("emblem-symbolic-link")),
|
||||
shadowColor_(0, 0, 0),
|
||||
margins_(QSize(3, 3)) {
|
||||
}
|
||||
|
||||
// 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());
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
|
||||
painter->save();
|
||||
painter->setClipRect(option.rect);
|
||||
|
||||
opt.decorationAlignment = Qt::AlignHCenter | Qt::AlignTop;
|
||||
opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;
|
||||
|
||||
// draw the icon
|
||||
QIcon::Mode iconMode;
|
||||
if(opt.state & QStyle::State_Enabled) {
|
||||
if(opt.state & QStyle::State_Selected)
|
||||
iconMode = QIcon::Selected;
|
||||
else {
|
||||
iconMode = QIcon::Normal;
|
||||
}
|
||||
}
|
||||
else
|
||||
iconMode = QIcon::Disabled;
|
||||
QPoint iconPos(opt.rect.x() + (opt.rect.width() - opt.decorationSize.width()) / 2, opt.rect.y());
|
||||
QPixmap pixmap = opt.icon.pixmap(opt.decorationSize, iconMode);
|
||||
painter->drawPixmap(iconPos, pixmap);
|
||||
|
||||
// draw some emblems for the item if needed
|
||||
// we only support symlink emblem at the moment
|
||||
Fm::FileInfo file = static_cast<FmFileInfo*>(index.data(Fm::FolderModel::FileInfoRole).value<void*>());
|
||||
if(!file.isNull()) {
|
||||
if(file.isSymlink()) {
|
||||
painter->drawPixmap(iconPos, symlinkIcon_.pixmap(opt.decorationSize / 2, iconMode));
|
||||
}
|
||||
}
|
||||
|
||||
// draw text
|
||||
QSize gridSize = view_->gridSize() - 2 * margins_;
|
||||
QRectF textRect(opt.rect.x() - (gridSize.width() - opt.rect.width()) / 2,
|
||||
opt.rect.y() + opt.decorationSize.height(),
|
||||
gridSize.width(),
|
||||
gridSize.height() - opt.decorationSize.height());
|
||||
drawText(painter, opt, textRect);
|
||||
|
||||
if(opt.state & QStyle::State_HasFocus) {
|
||||
// FIXME: draw focus rect
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void DesktopItemDelegate::drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const {
|
||||
QTextLayout layout(opt.text, opt.font);
|
||||
|
||||
QTextOption textOption;
|
||||
textOption.setAlignment(opt.displayAlignment);
|
||||
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||
textOption.setTextDirection(opt.direction);
|
||||
layout.setTextOption(textOption);
|
||||
qreal height = 0;
|
||||
qreal width = 0;
|
||||
int visibleLines = 0;
|
||||
layout.beginLayout();
|
||||
QString elidedText;
|
||||
textRect.adjust(2, 2, -2, -2); // a 2-px margin is considered at FolderView::updateGridSize()
|
||||
for(;;) {
|
||||
QTextLine line = layout.createLine();
|
||||
if(!line.isValid())
|
||||
break;
|
||||
line.setLineWidth(textRect.width());
|
||||
height += opt.fontMetrics.leading();
|
||||
line.setPosition(QPointF(0, height));
|
||||
if((height + line.height() + textRect.y()) > textRect.bottom()) {
|
||||
// if part of this line falls outside the textRect, ignore it and quit.
|
||||
QTextLine lastLine = layout.lineAt(visibleLines - 1);
|
||||
elidedText = opt.text.mid(lastLine.textStart());
|
||||
elidedText = opt.fontMetrics.elidedText(elidedText, opt.textElideMode, textRect.width());
|
||||
break;
|
||||
}
|
||||
height += line.height();
|
||||
width = qMax(width, line.naturalTextWidth());
|
||||
++ visibleLines;
|
||||
}
|
||||
layout.endLayout();
|
||||
width = qMax(width, (qreal)opt.fontMetrics.width(elidedText));
|
||||
QRectF boundRect = layout.boundingRect();
|
||||
boundRect.setWidth(width);
|
||||
boundRect.setHeight(height);
|
||||
boundRect.moveTo(textRect.x() + (textRect.width() - width)/2, textRect.y());
|
||||
|
||||
QRectF selRect = boundRect.adjusted(-2, -2, 2, 2);
|
||||
|
||||
if(!painter) { // no painter, calculate the bounding rect only
|
||||
textRect = selRect;
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
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;
|
||||
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &o, painter, widget);
|
||||
}
|
||||
}
|
||||
|
||||
if((opt.state & QStyle::State_Selected)) {
|
||||
// qDebug("w: %f, h:%f, m:%f", boundRect.width(), boundRect.height(), layout.minimumWidth());
|
||||
if(!opt.widget)
|
||||
painter->fillRect(selRect, opt.palette.highlight());
|
||||
painter->setPen(opt.palette.color(QPalette::Normal, QPalette::HighlightedText));
|
||||
}
|
||||
else { // only draw shadow for non-selected items
|
||||
// draw shadow, FIXME: is it possible to use QGraphicsDropShadowEffect here?
|
||||
QPen prevPen = painter->pen();
|
||||
painter->setPen(QPen(shadowColor_));
|
||||
for(int i = 0; i < visibleLines; ++i) {
|
||||
QTextLine line = layout.lineAt(i);
|
||||
if(i == (visibleLines - 1) && !elidedText.isEmpty()) { // the last line, draw elided text
|
||||
QPointF pos(boundRect.x() + line.position().x() + 1, boundRect.y() + line.y() + line.ascent() + 1);
|
||||
painter->drawText(pos, elidedText);
|
||||
}
|
||||
else {
|
||||
line.draw(painter, textRect.topLeft() + QPointF(1, 1));
|
||||
}
|
||||
}
|
||||
painter->setPen(prevPen);
|
||||
}
|
||||
|
||||
// draw text
|
||||
for(int i = 0; i < visibleLines; ++i) {
|
||||
QTextLine line = layout.lineAt(i);
|
||||
if(i == (visibleLines - 1) && !elidedText.isEmpty()) { // the last line, draw elided text
|
||||
QPointF pos(boundRect.x() + line.position().x(), boundRect.y() + line.y() + line.ascent());
|
||||
painter->drawText(pos, elidedText);
|
||||
}
|
||||
else {
|
||||
line.draw(painter, textRect.topLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSize DesktopItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
|
||||
QVariant value = index.data(Qt::SizeHintRole);
|
||||
if(value.isValid())
|
||||
return qvariant_cast<QSize>(value);
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
opt.decorationAlignment = Qt::AlignHCenter|Qt::AlignTop;
|
||||
opt.displayAlignment = Qt::AlignTop|Qt::AlignHCenter;
|
||||
|
||||
QSize gridSize = view_->gridSize() - 2 * margins_;
|
||||
Q_ASSERT(gridSize != QSize());
|
||||
QRectF textRect(0, 0, gridSize.width(), gridSize.height() - opt.decorationSize.height());
|
||||
drawText(NULL, opt, textRect); // passing NULL for painter will calculate the bounding rect only.
|
||||
int width = qMax((int)textRect.width(), opt.decorationSize.width());
|
||||
int height = opt.decorationSize.height() + textRect.height();
|
||||
return QSize(width, height);
|
||||
}
|
||||
|
||||
DesktopItemDelegate::~DesktopItemDelegate() {
|
||||
|
||||
}
|
||||
|
||||
} // namespace PCManFM
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright (C) 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PCMANFM_DESKTOPITEMDELEGATE_H
|
||||
#define PCMANFM_DESKTOPITEMDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QColor>
|
||||
|
||||
class QListView;
|
||||
class QTextOption;
|
||||
class QTextLayout;
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
class DesktopItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DesktopItemDelegate(QListView* view, QObject* parent = 0);
|
||||
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
virtual ~DesktopItemDelegate();
|
||||
|
||||
void setShadowColor(const QColor& shadowColor) {
|
||||
shadowColor_ = shadowColor;
|
||||
}
|
||||
const QColor& shadowColor() const {
|
||||
return shadowColor_;
|
||||
}
|
||||
void setMargins(QSize margins) {
|
||||
margins_ = margins.expandedTo(QSize(0, 0));
|
||||
}
|
||||
|
||||
private:
|
||||
void drawText(QPainter* painter, QStyleOptionViewItem& opt, QRectF& textRect) const;
|
||||
|
||||
private:
|
||||
QListView* view_;
|
||||
QIcon symlinkIcon_;
|
||||
QColor shadowColor_;
|
||||
QSize margins_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PCMANFM_DESKTOPITEMDELEGATE_H
|
@ -84,6 +84,14 @@ DesktopPreferencesDialog::DesktopPreferencesDialog(QWidget* parent, Qt::WindowFl
|
||||
qDebug("wallpaper: %s", settings.wallpaper().toUtf8().data());
|
||||
ui.imageFile->setText(settings.wallpaper());
|
||||
|
||||
ui.slideShow->setChecked(settings.slideShowInterval() > 0);
|
||||
ui.imageFolder->setText(settings.wallpaperDir());
|
||||
int minutes = qMax(settings.slideShowInterval() / 60000, 5); // 5 min at least
|
||||
ui.hours->setValue(minutes / 60);
|
||||
ui.minutes->setValue(minutes % 60);
|
||||
ui.randomize->setChecked(settings.wallpaperRandomize());
|
||||
connect(ui.folderBrowse, &QPushButton::clicked, this, &DesktopPreferencesDialog::onFolderBrowseClicked);
|
||||
|
||||
for(std::size_t i = 0; i < G_N_ELEMENTS(iconSizes); ++i) {
|
||||
int size = iconSizes[i];
|
||||
ui.iconSize->addItem(QString("%1 x %1").arg(size), size);
|
||||
@ -145,12 +153,22 @@ void DesktopPreferencesDialog::applySettings()
|
||||
settings.setWallpaper(ui.imageFile->text());
|
||||
int mode = ui.wallpaperMode->itemData(ui.wallpaperMode->currentIndex()).toInt();
|
||||
settings.setWallpaperMode(mode);
|
||||
|
||||
settings.setWallpaperDir(ui.imageFolder->text());
|
||||
int interval = 0;
|
||||
if(ui.slideShow->isChecked())
|
||||
interval = (ui.minutes->value() + 60 * ui.hours->value()) * 60000;
|
||||
settings.setSlideShowInterval(interval);
|
||||
settings.setWallpaperRandomize(ui.randomize->isChecked());
|
||||
|
||||
settings.setDesktopIconSize(ui.iconSize->itemData(ui.iconSize->currentIndex()).toInt());
|
||||
|
||||
settings.setDesktopFont(ui.font->font());
|
||||
settings.setDesktopBgColor(ui.backgroundColor->color());
|
||||
settings.setDesktopFgColor(ui.textColor->color());
|
||||
settings.setDesktopShadowColor(ui.shadowColor->color());
|
||||
settings.setShowWmMenu(ui.showWmMenu->isChecked());
|
||||
|
||||
settings.setDesktopCellMargins(QSize(ui.hMargin->value(), ui.vMargin->value()));
|
||||
|
||||
settings.save();
|
||||
@ -164,7 +182,7 @@ void DesktopPreferencesDialog::onApplyClicked()
|
||||
|
||||
void DesktopPreferencesDialog::accept() {
|
||||
applySettings();
|
||||
static_cast<Application*>(qApp)->updateDesktopsFromSettings();
|
||||
static_cast<Application*>(qApp)->updateDesktopsFromSettings(false); // don't change slide wallpaper on clicking OK
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@ -201,6 +219,19 @@ void DesktopPreferencesDialog::onBrowseClicked() {
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopPreferencesDialog::onFolderBrowseClicked() {
|
||||
QFileDialog dlg;
|
||||
dlg.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
dlg.setFileMode(QFileDialog::Directory);
|
||||
dlg.setOption(QFileDialog::ShowDirsOnly);
|
||||
dlg.setDirectory(QDir::home().path());
|
||||
if(dlg.exec() == QDialog::Accepted) {
|
||||
QString foldername;
|
||||
foldername = dlg.selectedFiles().first();
|
||||
ui.imageFolder->setText(foldername);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopPreferencesDialog::onBrowseDesktopFolderClicked()
|
||||
{
|
||||
QFileDialog dlg;
|
||||
|
@ -46,6 +46,7 @@ protected Q_SLOTS:
|
||||
void onApplyClicked();
|
||||
void onWallpaperModeChanged(int index);
|
||||
void onBrowseClicked();
|
||||
void onFolderBrowseClicked();
|
||||
void onBrowseDesktopFolderClicked();
|
||||
void lockMargins(bool lock);
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QLayout>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
#include <QSettings>
|
||||
#include <QStringBuilder>
|
||||
#include <QDir>
|
||||
@ -37,19 +38,19 @@
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
#include <QPaintEvent>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "./application.h"
|
||||
#include "mainwindow.h"
|
||||
#include "desktopitemdelegate.h"
|
||||
#include <libfm-qt/foldermenu.h>
|
||||
#include <libfm-qt/filemenu.h>
|
||||
#include <libfm-qt/folderitemdelegate.h>
|
||||
#include <libfm-qt/cachedfoldermodel.h>
|
||||
#include <libfm-qt/folderview_p.h>
|
||||
#include <libfm-qt/fileoperation.h>
|
||||
#include <libfm-qt/filepropsdialog.h>
|
||||
#include <libfm-qt/utilities.h>
|
||||
#include <libfm-qt/path.h>
|
||||
#include <libfm-qt/fileinfo.h>
|
||||
#include <libfm-qt/core/fileinfo.h>
|
||||
#include "xdgdir.h"
|
||||
|
||||
#include <QX11Info>
|
||||
@ -57,17 +58,23 @@
|
||||
#include <xcb/xcb.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#define MIN_SLIDE_INTERVAL 5*60000 // 5 min
|
||||
#define MAX_SLIDE_INTERVAL (24*60+55)*60000 // 24 h and 55 min
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
DesktopWindow::DesktopWindow(int screenNum):
|
||||
View(Fm::FolderView::IconMode),
|
||||
proxyModel_(NULL),
|
||||
model_(NULL),
|
||||
proxyModel_(nullptr),
|
||||
model_(nullptr),
|
||||
wallpaperMode_(WallpaperNone),
|
||||
fileLauncher_(NULL),
|
||||
slideShowInterval_(0),
|
||||
wallpaperTimer_(nullptr),
|
||||
wallpaperRandomize_(false),
|
||||
fileLauncher_(nullptr),
|
||||
showWmMenu_(false),
|
||||
screenNum_(screenNum),
|
||||
relayoutTimer_(NULL) {
|
||||
relayoutTimer_(nullptr) {
|
||||
|
||||
QDesktopWidget* desktopWidget = QApplication::desktop();
|
||||
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
@ -84,9 +91,9 @@ DesktopWindow::DesktopWindow(int screenNum):
|
||||
|
||||
// This is to workaround Qt bug 54384 which affects Qt >= 5.6
|
||||
// https://bugreports.qt.io/browse/QTBUG-54384
|
||||
// Setting a QPixmap larger then the screen resolution to the background of a list view won't work.
|
||||
// So we did a hack here: Disable the automatic background painting.
|
||||
// Then paint the background of the list view ourselves by hook into its paint event handling method with a event filter.
|
||||
// Setting a QPixmap larger then the screen resolution to desktop's QPalette won't work.
|
||||
// So we make the viewport transparent by preventing its backround from being filled automatically.
|
||||
// Then we paint desktop's background ourselves by using its paint event handling method.
|
||||
listView_->viewport()->setAutoFillBackground(false);
|
||||
|
||||
// NOTE: When XRnadR is in use, the all screens are actually combined to form a
|
||||
@ -98,7 +105,8 @@ DesktopWindow::DesktopWindow(int screenNum):
|
||||
loadItemPositions();
|
||||
Settings& settings = static_cast<Application* >(qApp)->settings();
|
||||
|
||||
model_ = Fm::CachedFolderModel::modelFromPath(Fm::Path::getDesktop());
|
||||
auto desktopPath = Fm::FilePath::fromLocalPath(XdgDir::readDesktopDir().toStdString().c_str());
|
||||
model_ = Fm::CachedFolderModel::modelFromPath(desktopPath);
|
||||
folder_ = model_->folder();
|
||||
|
||||
proxyModel_ = new Fm::ProxyFolderModel();
|
||||
@ -116,10 +124,6 @@ DesktopWindow::DesktopWindow(int screenNum):
|
||||
connect(listView_, &QListView::indexesMoved, this, &DesktopWindow::onIndexesMoved);
|
||||
}
|
||||
|
||||
// set our own delegate
|
||||
delegate_ = new DesktopItemDelegate(listView_);
|
||||
listView_->setItemDelegateForColumn(Fm::FolderModel::ColumnFileName, delegate_);
|
||||
|
||||
// remove frame
|
||||
listView_->setFrameShape(QFrame::NoFrame);
|
||||
// inhibit scrollbars FIXME: this should be optional in the future
|
||||
@ -143,7 +147,7 @@ DesktopWindow::DesktopWindow(int screenNum):
|
||||
connect(shortcut, &QShortcut::activated, this, &DesktopWindow::onPasteActivated);
|
||||
|
||||
shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A), this); // select all
|
||||
connect(shortcut, &QShortcut::activated, listView_, &QListView::selectAll);
|
||||
connect(shortcut, &QShortcut::activated, this, &FolderView::selectAll);
|
||||
|
||||
shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), this); // delete
|
||||
connect(shortcut, &QShortcut::activated, this, &DesktopWindow::onDeleteActivated);
|
||||
@ -162,14 +166,23 @@ DesktopWindow::~DesktopWindow() {
|
||||
listView_->viewport()->removeEventFilter(this);
|
||||
listView_->removeEventFilter(this);
|
||||
|
||||
if(relayoutTimer_)
|
||||
if(relayoutTimer_) {
|
||||
relayoutTimer_->stop();
|
||||
delete relayoutTimer_;
|
||||
}
|
||||
|
||||
if(proxyModel_)
|
||||
if(wallpaperTimer_) {
|
||||
wallpaperTimer_->stop();
|
||||
delete wallpaperTimer_;
|
||||
}
|
||||
|
||||
if(proxyModel_) {
|
||||
delete proxyModel_;
|
||||
}
|
||||
|
||||
if(model_)
|
||||
if(model_) {
|
||||
model_->unref();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::setBackground(const QColor& color) {
|
||||
@ -185,10 +198,12 @@ void DesktopWindow::setForeground(const QColor& color) {
|
||||
|
||||
void DesktopWindow::setShadow(const QColor& color) {
|
||||
shadowColor_ = color;
|
||||
delegate_->setShadowColor(color);
|
||||
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(Fm::FolderModel::ColumnFileName));
|
||||
delegate->setShadowColor(color);
|
||||
}
|
||||
|
||||
void DesktopWindow::onOpenDirRequested(FmPath* path, int target) {
|
||||
void DesktopWindow::onOpenDirRequested(const Fm::FilePath& path, int target) {
|
||||
Q_UNUSED(target);
|
||||
// open in new window unconditionally.
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
MainWindow* newWin = new MainWindow(path);
|
||||
@ -209,7 +224,7 @@ void DesktopWindow::resizeEvent(QResizeEvent* event) {
|
||||
}
|
||||
|
||||
void DesktopWindow::setDesktopFolder() {
|
||||
Fm::Path path = Fm::Path::newForPath(XdgDir::readDesktopDir().toStdString().c_str());
|
||||
auto path = Fm::FilePath::fromLocalPath(XdgDir::readDesktopDir().toStdString().c_str());
|
||||
model_ = Fm::CachedFolderModel::modelFromPath(path);
|
||||
proxyModel_->setSourceModel(model_);
|
||||
}
|
||||
@ -222,6 +237,22 @@ void DesktopWindow::setWallpaperMode(WallpaperMode mode) {
|
||||
wallpaperMode_ = mode;
|
||||
}
|
||||
|
||||
void DesktopWindow::setLastSlide(QString filename) {
|
||||
lastSlide_ = filename;
|
||||
}
|
||||
|
||||
void DesktopWindow::setWallpaperDir(QString dirname) {
|
||||
wallpaperDir_ = dirname;
|
||||
}
|
||||
|
||||
void DesktopWindow::setSlideShowInterval(int interval) {
|
||||
slideShowInterval_ = interval;
|
||||
}
|
||||
|
||||
void DesktopWindow::setWallpaperRandomize(bool randomize) {
|
||||
wallpaperRandomize_ = randomize;
|
||||
}
|
||||
|
||||
QImage DesktopWindow::loadWallpaperFile(QSize requiredSize) {
|
||||
// NOTE: for ease of programming, we only use the cache for the primary screen.
|
||||
bool useCache = (screenNum_ == -1 || screenNum_ == 0);
|
||||
@ -230,8 +261,9 @@ QImage DesktopWindow::loadWallpaperFile(QSize requiredSize) {
|
||||
if(useCache) {
|
||||
// see if we have a scaled version cached on disk
|
||||
cacheFileName = QString::fromLocal8Bit(qgetenv("XDG_CACHE_HOME"));
|
||||
if(cacheFileName.isEmpty())
|
||||
if(cacheFileName.isEmpty()) {
|
||||
cacheFileName = QDir::homePath() % QLatin1String("/.cache");
|
||||
}
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
cacheFileName += QLatin1String("/pcmanfm-qt/") % app->profileName();
|
||||
QDir().mkpath(cacheFileName); // ensure that the cache dir exists
|
||||
@ -254,20 +286,22 @@ QImage DesktopWindow::loadWallpaperFile(QSize requiredSize) {
|
||||
if(cachedSize == requiredSize) { // see if the cached wallpaper has the size we want
|
||||
QImage image = reader.read(); // return the loaded image
|
||||
qDebug() << "origin" << origin;
|
||||
if(origin == wallpaperFile_)
|
||||
if(origin == wallpaperFile_) {
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "no cached wallpaper. generate a new one!";
|
||||
}
|
||||
|
||||
// we don't have a cached scaled image, load the original file
|
||||
QImage image(wallpaperFile_);
|
||||
qDebug() << "size of original image" << image.size();
|
||||
if(image.isNull() || image.size() == requiredSize) // if the original size is what we want
|
||||
if(image.isNull() || image.size() == requiredSize) { // if the original size is what we want
|
||||
return image;
|
||||
}
|
||||
|
||||
// scale the original image
|
||||
QImage scaled = image.scaled(requiredSize.width(), requiredSize.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
@ -281,10 +315,12 @@ QImage DesktopWindow::loadWallpaperFile(QSize requiredSize) {
|
||||
|
||||
// write the scaled cache image to disk
|
||||
const char* format; // we keep jpg format for *.jpg files, and use png format for others.
|
||||
if(wallpaperFile_.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive) || wallpaperFile_.endsWith(QLatin1String(".jpeg"), Qt::CaseInsensitive))
|
||||
if(wallpaperFile_.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive) || wallpaperFile_.endsWith(QLatin1String(".jpeg"), Qt::CaseInsensitive)) {
|
||||
format = "JPG";
|
||||
else
|
||||
}
|
||||
else {
|
||||
format = "PNG";
|
||||
}
|
||||
scaled.save(cacheFileName, format);
|
||||
}
|
||||
qDebug() << "wallpaper cached saved to " << cacheFileName;
|
||||
@ -300,7 +336,16 @@ void DesktopWindow::updateWallpaper() {
|
||||
QImage image;
|
||||
if(wallpaperMode_ == WallpaperTile) { // use the original size
|
||||
image = QImage(wallpaperFile_);
|
||||
pixmap = QPixmap::fromImage(image);
|
||||
// Note: We can't use the QPainter::drawTiledPixmap(), because it doesn't tile
|
||||
// correctly for background pixmaps bigger than the current screen size.
|
||||
const QSize s = size();
|
||||
pixmap = QPixmap{s};
|
||||
QPainter painter{&pixmap};
|
||||
for (int x = 0; x < s.width(); x += image.width()) {
|
||||
for (int y = 0; y < s.height(); y += image.height()) {
|
||||
painter.drawImage(x, y, image);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(wallpaperMode_ == WallpaperStretch) {
|
||||
image = loadWallpaperFile(size());
|
||||
@ -333,10 +378,97 @@ void DesktopWindow::updateWallpaper() {
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::updateFromSettings(Settings& settings) {
|
||||
bool DesktopWindow::pickWallpaper() {
|
||||
if(slideShowInterval_ <= 0
|
||||
|| !QFileInfo(wallpaperDir_).isDir()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<QByteArray> formats = QImageReader::supportedImageFormats();
|
||||
QStringList formatsFilters;
|
||||
for (const QByteArray& format: formats)
|
||||
formatsFilters << QString("*.") + format;
|
||||
QDir folder(wallpaperDir_);
|
||||
QStringList files = folder.entryList(formatsFilters,
|
||||
QDir::Files | QDir::NoDotAndDotDot,
|
||||
QDir::Name);
|
||||
if(!files.isEmpty()) {
|
||||
QString dir = wallpaperDir_ + QLatin1Char('/');
|
||||
if(!wallpaperRandomize_) {
|
||||
if(!lastSlide_.startsWith(dir)) { // not in the directory
|
||||
wallpaperFile_ = dir + files.first();
|
||||
}
|
||||
else {
|
||||
QString ls = lastSlide_.remove(0, dir.size());
|
||||
if(ls.isEmpty() // invalid
|
||||
|| ls.contains(QLatin1Char('/'))) { // in a subdirectory or invalid
|
||||
wallpaperFile_ = dir + files.first();
|
||||
}
|
||||
else {
|
||||
int index = files.indexOf(ls);
|
||||
if(index == -1) { // removed or invalid
|
||||
wallpaperFile_ = dir + files.first();
|
||||
}
|
||||
else {
|
||||
wallpaperFile_ = dir + (index + 1 < files.size()
|
||||
? files.at(index + 1)
|
||||
: files.first());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(files.size() > 1) {
|
||||
if(lastSlide_.startsWith(dir)) {
|
||||
QString ls = lastSlide_.remove(0, dir.size());
|
||||
if(!ls.isEmpty() && !ls.contains(QLatin1Char('/')))
|
||||
files.removeOne(ls); // choose from other images
|
||||
}
|
||||
// this is needed for the randomness, especially when choosing the first wallpaper
|
||||
qsrand((uint)QTime::currentTime().msec());
|
||||
int randomValue = qrand() % files.size();
|
||||
wallpaperFile_ = dir + files.at(randomValue);
|
||||
}
|
||||
else {
|
||||
wallpaperFile_ = dir + files.first();
|
||||
}
|
||||
}
|
||||
|
||||
if (lastSlide_ != wallpaperFile_) {
|
||||
lastSlide_ = wallpaperFile_;
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
settings.setLastSlide(lastSlide_);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DesktopWindow::nextWallpaper() {
|
||||
if(pickWallpaper()) {
|
||||
updateWallpaper();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::updateFromSettings(Settings& settings, bool changeSlide) {
|
||||
setDesktopFolder();
|
||||
setWallpaperFile(settings.wallpaper());
|
||||
setWallpaperMode(settings.wallpaperMode());
|
||||
setLastSlide(settings.lastSlide());
|
||||
QString wallpaperDir = settings.wallpaperDir();
|
||||
if(wallpaperDir_ != wallpaperDir) {
|
||||
changeSlide = true; // another wallpapaer directory; change slide!
|
||||
}
|
||||
setWallpaperDir(wallpaperDir);
|
||||
int interval = settings.slideShowInterval();
|
||||
if(interval > 0 && (interval < MIN_SLIDE_INTERVAL || interval > MAX_SLIDE_INTERVAL)) {
|
||||
interval = qBound(MIN_SLIDE_INTERVAL, interval, MAX_SLIDE_INTERVAL);
|
||||
settings.setSlideShowInterval(interval);
|
||||
}
|
||||
setSlideShowInterval(interval);
|
||||
setWallpaperRandomize(settings.wallpaperRandomize());
|
||||
setFont(settings.desktopFont());
|
||||
setIconSize(Fm::FolderView::IconMode, QSize(settings.desktopIconSize(), settings.desktopIconSize()));
|
||||
setMargins(settings.desktopCellMargins());
|
||||
@ -346,13 +478,44 @@ void DesktopWindow::updateFromSettings(Settings& settings) {
|
||||
setBackground(settings.desktopBgColor());
|
||||
setShadow(settings.desktopShadowColor());
|
||||
showWmMenu_ = settings.showWmMenu();
|
||||
|
||||
if(slideShowInterval_ > 0
|
||||
&& QFileInfo(wallpaperDir_).isDir()) {
|
||||
if(!wallpaperTimer_) {
|
||||
changeSlide = true; // slideshow activated; change slide!
|
||||
wallpaperTimer_ = new QTimer();
|
||||
connect(wallpaperTimer_, &QTimer::timeout, this, &DesktopWindow::nextWallpaper);
|
||||
}
|
||||
else {
|
||||
wallpaperTimer_->stop(); // restart the timer after updating wallpaper
|
||||
}
|
||||
if(changeSlide) {
|
||||
pickWallpaper();
|
||||
}
|
||||
else if(QFile::exists(lastSlide_)) {
|
||||
/* show the last slide if it still exists,
|
||||
otherwise show the wallpaper until timeout */
|
||||
wallpaperFile_ = lastSlide_;
|
||||
}
|
||||
}
|
||||
else if(wallpaperTimer_) {
|
||||
wallpaperTimer_->stop();
|
||||
delete wallpaperTimer_;
|
||||
wallpaperTimer_ = nullptr;
|
||||
}
|
||||
|
||||
updateWallpaper();
|
||||
update();
|
||||
|
||||
if(wallpaperTimer_) {
|
||||
wallpaperTimer_->start(slideShowInterval_);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::onFileClicked(int type, FmFileInfo* fileInfo) {
|
||||
if(!fileInfo && showWmMenu_)
|
||||
void DesktopWindow::onFileClicked(int type, const std::shared_ptr<const Fm::FileInfo>& fileInfo) {
|
||||
if(!fileInfo && showWmMenu_) {
|
||||
return; // do not show the popup if we want to use the desktop menu provided by the WM.
|
||||
}
|
||||
View::onFileClicked(type, fileInfo);
|
||||
}
|
||||
|
||||
@ -364,15 +527,15 @@ void DesktopWindow::prepareFileMenu(Fm::FileMenu* menu) {
|
||||
menu->insertSeparator(menu->separator2());
|
||||
menu->insertAction(menu->separator2(), action);
|
||||
|
||||
Fm::FileInfoList files = menu->files();
|
||||
// select exactly one item
|
||||
if(fm_file_info_list_get_length(files) == 1) {
|
||||
Fm::FileInfo file = menu->firstFile();
|
||||
if(customItemPos_.find(file.getName()) != customItemPos_.end()) {
|
||||
// the file item has a custom position
|
||||
action->setChecked(true);
|
||||
bool checked(true);
|
||||
auto files = menu->files();
|
||||
for(const auto& file : files) {
|
||||
if(customItemPos_.find(file->name()) == customItemPos_.cend()) {
|
||||
checked = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
action->setChecked(checked);
|
||||
connect(action, &QAction::toggled, this, &DesktopWindow::onStickToCurrentPos);
|
||||
}
|
||||
|
||||
@ -390,31 +553,42 @@ void DesktopWindow::onDesktopPreferences() {
|
||||
}
|
||||
|
||||
void DesktopWindow::onRowsInserted(const QModelIndex& parent, int start, int end) {
|
||||
queueRelayout();
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(start);
|
||||
Q_UNUSED(end);
|
||||
// disable view updates temporarily and delay relayout to prevent items from shaking
|
||||
listView_->setUpdatesEnabled(false);
|
||||
queueRelayout(100);
|
||||
}
|
||||
|
||||
void DesktopWindow::onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) {
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(start);
|
||||
Q_UNUSED(end);
|
||||
if(!customItemPos_.isEmpty()) {
|
||||
if(!customItemPos_.empty()) {
|
||||
// also delete stored custom item positions for the items currently being removed.
|
||||
// Here we can't rely on ProxyFolderModel::fileInfoFromIndex() because, although rows
|
||||
// aren't removed yet, files are already removed.
|
||||
QHash<QByteArray, QPoint> _customItemPos = customItemPos_;
|
||||
bool changed = false;
|
||||
char* dektopPath = Fm::Path::getDesktop().toStr();
|
||||
QString desktopDir = QString(dektopPath) + QString("/");
|
||||
g_free(dektopPath);
|
||||
QHash<QByteArray, QPoint>::iterator it;
|
||||
for(it = _customItemPos.begin(); it != _customItemPos.end(); ++it) {
|
||||
const QByteArray& name = it.key();
|
||||
if(!QFile::exists(desktopDir + QString::fromUtf8(name, name.length())))
|
||||
customItemPos_.remove(it.key());
|
||||
for(auto it = customItemPos_.cbegin(); it != customItemPos_.cend();) {
|
||||
auto& name = it->first;
|
||||
if(!QFile::exists(desktopDir + QString::fromStdString(name))) {
|
||||
it = customItemPos_.erase(it);
|
||||
changed = true;
|
||||
}
|
||||
if(customItemPos_ != _customItemPos)
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
if(changed) {
|
||||
saveItemPositions();
|
||||
}
|
||||
queueRelayout();
|
||||
}
|
||||
listView_->setUpdatesEnabled(false);
|
||||
queueRelayout(100);
|
||||
}
|
||||
|
||||
void DesktopWindow::onLayoutChanged() {
|
||||
@ -440,8 +614,8 @@ void DesktopWindow::onDataChanged(const QModelIndex& topLeft, const QModelIndex&
|
||||
for(int i = topLeft.row(); i <= bottomRight.row(); ++i) {
|
||||
QModelIndex index = topLeft.sibling(i, 0);
|
||||
if(index.isValid() && displayNames_.contains(index)) {
|
||||
Fm::FileInfo file = proxyModel_->fileInfoFromIndex(index);
|
||||
if(displayNames_[index] != file.getDispName()) {
|
||||
auto file = proxyModel_->fileInfoFromIndex(index);
|
||||
if(displayNames_[index] != file->displayName()) {
|
||||
relayout = true;
|
||||
break;
|
||||
}
|
||||
@ -456,6 +630,8 @@ void DesktopWindow::onDataChanged(const QModelIndex& topLeft, const QModelIndex&
|
||||
}
|
||||
|
||||
void DesktopWindow::onIndexesMoved(const QModelIndexList& indexes) {
|
||||
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
|
||||
auto itemSize = delegate->itemSize();
|
||||
// remember the custom position for the items
|
||||
Q_FOREACH(const QModelIndex& index, indexes) {
|
||||
// Under some circumstances, Qt might emit indexMoved for
|
||||
@ -464,17 +640,22 @@ 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) {
|
||||
Fm::FileInfo file = proxyModel_->fileInfoFromIndex(index);
|
||||
auto file = proxyModel_->fileInfoFromIndex(index);
|
||||
QRect itemRect = listView_->rectForIndex(index);
|
||||
QPoint tl = itemRect.topLeft();
|
||||
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
|
||||
workArea.adjust(12, 12, -12, -12);
|
||||
if(customItemPos_.keys(tl).isEmpty() // don't put items on each other
|
||||
|
||||
// check if the position is occupied by another item
|
||||
auto existingItem = std::find_if(customItemPos_.cbegin(), customItemPos_.cend(), [tl](const std::pair<std::string, QPoint>& elem){
|
||||
return elem.second == tl;
|
||||
});
|
||||
|
||||
if(existingItem == customItemPos_.cend() // don't put items on each other
|
||||
&& 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 = file.getName();
|
||||
customItemPos_[name] = tl;
|
||||
&& tl.x() + itemSize.width() <= workArea.right() + 1 // for historical reasons (-> Qt doc)
|
||||
&& tl.y() + itemSize.height() <= workArea.bottom() + 1) { // as above
|
||||
customItemPos_[file->name()] = tl;
|
||||
// qDebug() << "indexMoved:" << name << index << itemRect;
|
||||
}
|
||||
}
|
||||
@ -490,10 +671,13 @@ void DesktopWindow::removeBottomGap() {
|
||||
the vertical cell margin to prevent relatively large gaps
|
||||
from taking shape at the desktop bottom.
|
||||
************************************************************/
|
||||
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
|
||||
auto itemSize = delegate->itemSize();
|
||||
qDebug() << "delegate:" << delegate->itemSize();
|
||||
QSize cellMargins = getMargins();
|
||||
int workAreaHeight = qApp->desktop()->availableGeometry(screenNum_).height()
|
||||
- 24; // a 12-pix margin will be considered everywhere
|
||||
int cellHeight = listView_->gridSize().height() + listView_->spacing();
|
||||
int cellHeight = itemSize.height() + listView_->spacing();
|
||||
int iconNumber = workAreaHeight / cellHeight;
|
||||
int bottomGap = workAreaHeight % cellHeight;
|
||||
/*******************************************
|
||||
@ -516,20 +700,20 @@ void DesktopWindow::removeBottomGap() {
|
||||
/***************************************************
|
||||
... but if that can't be done, try to spread icons!
|
||||
***************************************************/
|
||||
else
|
||||
else {
|
||||
cellMargins += QSize(0, (bottomGap / iconNumber) / 2);
|
||||
}
|
||||
// set the new margins (if they're changed)
|
||||
delegate_->setMargins(cellMargins);
|
||||
delegate->setMargins(cellMargins);
|
||||
setMargins(cellMargins);
|
||||
// in case the text shadow is reset to (0,0,0,0)
|
||||
setShadow(settings.desktopShadowColor());
|
||||
}
|
||||
|
||||
void DesktopWindow::paintBackground(QPaintEvent *event) {
|
||||
void DesktopWindow::paintBackground(QPaintEvent* event) {
|
||||
// This is to workaround Qt bug 54384 which affects Qt >= 5.6
|
||||
// https://bugreports.qt.io/browse/QTBUG-54384
|
||||
// Since Qt does not paint the background of the QListView using the QPixmap we set properly, we do it ourselves.
|
||||
QPainter painter(listView_->viewport()); // the painter paints on the viewport widget, not the QListView.
|
||||
QPainter painter(this);
|
||||
if(wallpaperMode_ == WallpaperNone || wallpaperPixmap_.isNull()) {
|
||||
painter.fillRect(event->rect(), QBrush(bgColor_));
|
||||
}
|
||||
@ -547,47 +731,53 @@ void DesktopWindow::relayoutItems() {
|
||||
if(relayoutTimer_) {
|
||||
// this slot might be called from the timer, so we cannot delete it directly here.
|
||||
relayoutTimer_->deleteLater();
|
||||
relayoutTimer_ = NULL;
|
||||
relayoutTimer_ = nullptr;
|
||||
}
|
||||
|
||||
QDesktopWidget* desktop = qApp->desktop();
|
||||
int screen = 0;
|
||||
int row = 0;
|
||||
int rowCount = proxyModel_->rowCount();
|
||||
|
||||
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
|
||||
auto itemSize = delegate->itemSize();
|
||||
|
||||
for(;;) {
|
||||
if(desktop->isVirtualDesktop()) {
|
||||
if(screen >= desktop->numScreens())
|
||||
if(screen >= desktop->numScreens()) {
|
||||
break;
|
||||
}else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
screen = screenNum_;
|
||||
}
|
||||
QRect workArea = desktop->availableGeometry(screen);
|
||||
workArea.adjust(12, 12, -12, -12); // add a 12 pixel margin to the work area
|
||||
// qDebug() << "workArea" << screen << workArea;
|
||||
// FIXME: we use an internal class declared in a private header here, which is pretty bad.
|
||||
QSize grid = listView_->gridSize();
|
||||
QPoint pos = workArea.topLeft();
|
||||
for(; row < rowCount; ++row) {
|
||||
QModelIndex index = proxyModel_->index(row, 0);
|
||||
int itemWidth = delegate_->sizeHint(listView_->getViewOptions(), index).width();
|
||||
Fm::FileInfo file = proxyModel_->fileInfoFromIndex(index);
|
||||
int itemWidth = delegate->sizeHint(listView_->getViewOptions(), index).width();
|
||||
auto file = proxyModel_->fileInfoFromIndex(index);
|
||||
// remember display names of desktop entries and shortcuts
|
||||
if(file.isDesktopEntry() || file.isShortcut())
|
||||
displayNames_[index] = QString(file.getDispName());
|
||||
QByteArray name = file.getName();
|
||||
QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name);
|
||||
if(it != customItemPos_.end()) { // the item has a custom position
|
||||
QPoint customPos = *it;
|
||||
if(file->isDesktopEntry() || file->isShortcut()) {
|
||||
displayNames_[index] = file->displayName();
|
||||
}
|
||||
auto name = file->name();
|
||||
auto find_it = customItemPos_.find(name);
|
||||
if(find_it != customItemPos_.cend()) { // the item has a custom position
|
||||
QPoint customPos = find_it->second;
|
||||
// center the contents vertically
|
||||
listView_->setPositionForIndex(customPos + QPoint((grid.width() - itemWidth) / 2, 0), index);
|
||||
listView_->setPositionForIndex(customPos + QPoint((itemSize.width() - itemWidth) / 2, 0), index);
|
||||
// qDebug() << "set custom pos:" << name << row << index << customPos;
|
||||
continue;
|
||||
}
|
||||
// check if the current pos is alredy occupied by a custom item
|
||||
bool used = false;
|
||||
for(it = customItemPos_.begin(); it != customItemPos_.end(); ++it) {
|
||||
QPoint customPos = *it;
|
||||
if(QRect(customPos, grid).contains(pos)) {
|
||||
for(auto it = customItemPos_.cbegin(); it != customItemPos_.cend(); ++it) {
|
||||
QPoint customPos = it->second;
|
||||
if(QRect(customPos, itemSize).contains(pos)) {
|
||||
used = true;
|
||||
break;
|
||||
}
|
||||
@ -597,18 +787,18 @@ void DesktopWindow::relayoutItems() {
|
||||
}
|
||||
else {
|
||||
// center the contents vertically
|
||||
listView_->setPositionForIndex(pos + QPoint((grid.width() - itemWidth) / 2, 0), index);
|
||||
listView_->setPositionForIndex(pos + QPoint((itemSize.width() - itemWidth) / 2, 0), index);
|
||||
// qDebug() << "set pos" << name << row << index << pos;
|
||||
}
|
||||
// move to next cell in the column
|
||||
pos.setY(pos.y() + grid.height() + listView_->spacing());
|
||||
if(pos.y() + grid.height() > workArea.bottom() + 1) {
|
||||
pos.setY(pos.y() + itemSize.height() + listView_->spacing());
|
||||
if(pos.y() + itemSize.height() > workArea.bottom() + 1) {
|
||||
// if the next position may exceed the bottom of work area, go to the top of next column
|
||||
pos.setX(pos.x() + grid.width() + listView_->spacing());
|
||||
pos.setX(pos.x() + itemSize.width() + listView_->spacing());
|
||||
pos.setY(workArea.top());
|
||||
|
||||
// check if the new column exceeds the right margin of work area
|
||||
if(pos.x() + grid.width() > workArea.right() + 1) {
|
||||
if(pos.x() + itemSize.width() > workArea.right() + 1) {
|
||||
if(desktop->isVirtualDesktop()) {
|
||||
// in virtual desktop mode, go to next screen
|
||||
++screen;
|
||||
@ -617,9 +807,14 @@ void DesktopWindow::relayoutItems() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(row >= rowCount)
|
||||
if(row >= rowCount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!listView_->updatesEnabled()) {
|
||||
listView_->setUpdatesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::loadItemPositions() {
|
||||
@ -628,12 +823,21 @@ void DesktopWindow::loadItemPositions() {
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
QString configFile = QString("%1/desktop-items-%2.conf").arg(settings.profileDir(settings.profileName())).arg(screenNum_);
|
||||
QSettings file(configFile, QSettings::IniFormat);
|
||||
QSize grid = listView_->gridSize();
|
||||
|
||||
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
|
||||
auto grid = delegate->itemSize();
|
||||
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
|
||||
workArea.adjust(12, 12, -12, -12);
|
||||
char* dektopPath = Fm::Path::getDesktop().toStr();
|
||||
QString desktopDir = QString(dektopPath) + QString("/");
|
||||
g_free(dektopPath);
|
||||
|
||||
std::vector<QPoint> usedPos;
|
||||
for(auto& item: customItemPos_) {
|
||||
usedPos.push_back(item.second);
|
||||
}
|
||||
|
||||
// FIXME: this is inefficient
|
||||
Q_FOREACH(const QString& name, file.childGroups()) {
|
||||
if(!QFile::exists(desktopDir + name.toUtf8())) {
|
||||
// the file may have been removed from outside LXQT
|
||||
@ -643,25 +847,21 @@ void DesktopWindow::loadItemPositions() {
|
||||
QVariant var = file.value("pos");
|
||||
if(var.isValid()) {
|
||||
QPoint customPos = var.toPoint();
|
||||
if (customPos.x() >= workArea.x() && customPos.y() >= workArea.y()
|
||||
&& customPos.x() + listView_->gridSize().width() <= workArea.right() + 1
|
||||
&& customPos.y() + listView_->gridSize().height() <= workArea.bottom() + 1)
|
||||
{
|
||||
if(customPos.x() >= workArea.x() && customPos.y() >= workArea.y()
|
||||
&& customPos.x() + grid.width() <= workArea.right() + 1
|
||||
&& customPos.y() + grid.height() <= workArea.bottom() + 1) {
|
||||
// correct positions that are't aligned to the grid
|
||||
qreal w = qAbs((qreal)customPos.x() - (qreal)workArea.x())
|
||||
/ (qreal)(grid.width() + listView_->spacing());
|
||||
qreal h = qAbs(customPos.y() - (qreal)workArea.y())
|
||||
/ (qreal)(grid.height() + listView_->spacing());
|
||||
customPos.setX(workArea.x() + qRound(w) * (grid.width() + listView_->spacing()));
|
||||
customPos.setY(workArea.y() + qRound(h) * (grid.height() + listView_->spacing()));
|
||||
while(customItemPos_.values().contains(customPos)) {
|
||||
alignToGrid(customPos, workArea.topLeft(), grid, listView_->spacing());
|
||||
// FIXME: this is very inefficient
|
||||
while(std::find(usedPos.cbegin(), usedPos.cend(), customPos) != usedPos.cend()) {
|
||||
customPos.setY(customPos.y() + grid.height() + listView_->spacing());
|
||||
if(customPos.y() + grid.height() > workArea.bottom() + 1) {
|
||||
customPos.setX(customPos.x() + grid.width() + listView_->spacing());
|
||||
customPos.setY(workArea.top());
|
||||
}
|
||||
}
|
||||
customItemPos_[name.toUtf8()] = customPos;
|
||||
customItemPos_[name.toStdString()] = customPos;
|
||||
usedPos.push_back(customPos);
|
||||
}
|
||||
}
|
||||
file.endGroup();
|
||||
@ -677,39 +877,40 @@ void DesktopWindow::saveItemPositions() {
|
||||
file.clear(); // remove all existing entries
|
||||
|
||||
// FIXME: we have to remove dead entries not associated to any files?
|
||||
QHash<QByteArray, QPoint>::iterator it;
|
||||
for(it = customItemPos_.begin(); it != customItemPos_.end(); ++it) {
|
||||
const QByteArray& name = it.key();
|
||||
QPoint pos = it.value();
|
||||
file.beginGroup(QString::fromUtf8(name, name.length()));
|
||||
for(auto it = customItemPos_.cbegin(); it != customItemPos_.cend(); ++it) {
|
||||
auto& name = it->first;
|
||||
auto& pos = it->second;
|
||||
file.beginGroup(QString::fromStdString(name));
|
||||
file.setValue("pos", pos);
|
||||
file.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::onStickToCurrentPos(bool toggled) {
|
||||
QAction* action = static_cast<QAction*>(sender());
|
||||
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(action->parent());
|
||||
|
||||
QModelIndexList indexes = listView_->selectionModel()->selectedIndexes();
|
||||
if(!indexes.isEmpty()) {
|
||||
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);
|
||||
bool relayout(false);
|
||||
QModelIndexList::const_iterator it;
|
||||
for(it = indexes.constBegin(); it != indexes.constEnd(); ++it) {
|
||||
auto file = proxyModel_->fileInfoFromIndex(*it);
|
||||
auto name = file->name();
|
||||
if(toggled) { // remember the current custom position
|
||||
QRect itemRect = listView_->rectForIndex(*it);
|
||||
customItemPos_[name] = itemRect.topLeft();
|
||||
saveItemPositions();
|
||||
}
|
||||
else { // cancel custom position and perform relayout
|
||||
QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name);
|
||||
if(it != customItemPos_.end()) {
|
||||
customItemPos_.erase(it);
|
||||
saveItemPositions();
|
||||
relayoutItems();
|
||||
auto item = customItemPos_.find(name);
|
||||
if(item != customItemPos_.end()) {
|
||||
customItemPos_.erase(item);
|
||||
relayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
saveItemPositions();
|
||||
if(relayout) {
|
||||
relayoutItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::queueRelayout(int delay) {
|
||||
@ -726,15 +927,15 @@ void DesktopWindow::queueRelayout(int delay) {
|
||||
// slots for file operations
|
||||
|
||||
void DesktopWindow::onCutActivated() {
|
||||
Fm::PathList paths = selectedFilePaths();
|
||||
if(!paths.isNull()) {
|
||||
auto paths = selectedFilePaths();
|
||||
if(!paths.empty()) {
|
||||
Fm::cutFilesToClipboard(paths);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::onCopyActivated() {
|
||||
Fm::PathList paths = selectedFilePaths();
|
||||
if(!paths.isNull()) {
|
||||
auto paths = selectedFilePaths();
|
||||
if(!paths.empty()) {
|
||||
Fm::copyFilesToClipboard(paths);
|
||||
}
|
||||
}
|
||||
@ -744,31 +945,41 @@ void DesktopWindow::onPasteActivated() {
|
||||
}
|
||||
|
||||
void DesktopWindow::onDeleteActivated() {
|
||||
Fm::PathList paths = selectedFilePaths();
|
||||
if(!paths.isNull()) {
|
||||
auto paths = selectedFilePaths();
|
||||
if(!paths.empty()) {
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
bool shiftPressed = (qApp->keyboardModifiers() & Qt::ShiftModifier ? true : false);
|
||||
if(settings.useTrash() && !shiftPressed)
|
||||
if(settings.useTrash() && !shiftPressed) {
|
||||
Fm::FileOperation::trashFiles(paths, settings.confirmTrash());
|
||||
else
|
||||
}
|
||||
else {
|
||||
Fm::FileOperation::deleteFiles(paths, settings.confirmDelete());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::onRenameActivated() {
|
||||
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);
|
||||
// do inline renaming if only one item is selected,
|
||||
// otherwise use the renaming dialog
|
||||
if(selectedIndexes().size() == 1) {
|
||||
QModelIndex cur = listView_->currentIndex();
|
||||
if (cur.isValid()) {
|
||||
listView_->edit(cur);
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto files = selectedFiles();
|
||||
if(!files.empty()) {
|
||||
for(auto& info: files) {
|
||||
Fm::renameFile(info, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::onFilePropertiesActivated() {
|
||||
Fm::FileInfoList files = selectedFiles();
|
||||
if(!files.isNull()) {
|
||||
Fm::FilePropsDialog::showForFiles(files);
|
||||
auto files = selectedFiles();
|
||||
if(!files.empty()) {
|
||||
Fm::FilePropsDialog::showForFiles(std::move(files));
|
||||
}
|
||||
}
|
||||
|
||||
@ -810,12 +1021,15 @@ static void forwardMouseEventToRoot(QMouseEvent* event) {
|
||||
}
|
||||
|
||||
// convert Qt modifiers to XCB states
|
||||
if(event->modifiers() & Qt::ShiftModifier)
|
||||
if(event->modifiers() & Qt::ShiftModifier) {
|
||||
xcb_event.state |= XCB_MOD_MASK_SHIFT;
|
||||
if(event->modifiers() & Qt::ControlModifier)
|
||||
}
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
xcb_event.state |= XCB_MOD_MASK_SHIFT;
|
||||
if(event->modifiers() & Qt::AltModifier)
|
||||
}
|
||||
if(event->modifiers() & Qt::AltModifier) {
|
||||
xcb_event.state |= XCB_MOD_MASK_1;
|
||||
}
|
||||
|
||||
xcb_event.sequence = 0;
|
||||
xcb_event.time = event->timestamp();
|
||||
@ -835,20 +1049,20 @@ static void forwardMouseEventToRoot(QMouseEvent* event) {
|
||||
xcb_flush(QX11Info::connection());
|
||||
}
|
||||
|
||||
bool DesktopWindow::event(QEvent* event)
|
||||
{
|
||||
bool DesktopWindow::event(QEvent* event) {
|
||||
switch(event->type()) {
|
||||
case QEvent::WinIdChange: {
|
||||
qDebug() << "winid change:" << effectiveWinId();
|
||||
if(effectiveWinId() == 0)
|
||||
if(effectiveWinId() == 0) {
|
||||
break;
|
||||
}
|
||||
// set freedesktop.org EWMH hints properly
|
||||
if(QX11Info::isPlatformX11() && QX11Info::connection()) {
|
||||
xcb_connection_t* con = QX11Info::connection();
|
||||
const char* atom_name = "_NET_WM_WINDOW_TYPE_DESKTOP";
|
||||
xcb_atom_t atom = xcb_intern_atom_reply(con, xcb_intern_atom(con, 0, strlen(atom_name), atom_name), NULL)->atom;
|
||||
xcb_atom_t atom = xcb_intern_atom_reply(con, xcb_intern_atom(con, 0, strlen(atom_name), atom_name), nullptr)->atom;
|
||||
const char* prop_atom_name = "_NET_WM_WINDOW_TYPE";
|
||||
xcb_atom_t prop_atom = xcb_intern_atom_reply(con, xcb_intern_atom(con, 0, strlen(prop_atom_name), prop_atom_name), NULL)->atom;
|
||||
xcb_atom_t prop_atom = xcb_intern_atom_reply(con, xcb_intern_atom(con, 0, strlen(prop_atom_name), prop_atom_name), nullptr)->atom;
|
||||
xcb_atom_t XA_ATOM = 4;
|
||||
xcb_change_property(con, XCB_PROP_MODE_REPLACE, effectiveWinId(), prop_atom, XA_ATOM, 32, 1, &atom);
|
||||
}
|
||||
@ -869,13 +1083,14 @@ bool DesktopWindow::event(QEvent* event)
|
||||
|
||||
#undef FontChange // this seems to be defined in Xlib headers as a macro, undef it!
|
||||
|
||||
bool DesktopWindow::eventFilter(QObject * watched, QEvent * event) {
|
||||
bool DesktopWindow::eventFilter(QObject* watched, QEvent* event) {
|
||||
if(watched == listView_) {
|
||||
switch(event->type()) {
|
||||
case QEvent::StyleChange:
|
||||
case QEvent::FontChange:
|
||||
if(model_)
|
||||
if(model_) {
|
||||
queueRelayout();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -883,10 +1098,6 @@ bool DesktopWindow::eventFilter(QObject * watched, QEvent * event) {
|
||||
}
|
||||
else if(watched == listView_->viewport()) {
|
||||
switch(event->type()) {
|
||||
case QEvent::Paint: {
|
||||
paintBackground(static_cast<QPaintEvent*>(event));
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
if(showWmMenu_) {
|
||||
@ -904,15 +1115,15 @@ bool DesktopWindow::eventFilter(QObject * watched, QEvent * event) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return Fm::FolderView::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void DesktopWindow::childDropEvent(QDropEvent* e) {
|
||||
const QMimeData* mimeData = e->mimeData();
|
||||
bool moveItem = false;
|
||||
if(e->source() == listView_ && e->keyboardModifiers() == Qt::NoModifier) {
|
||||
// drag source is our list view, and no other modifier keys are pressed
|
||||
// => we're dragging desktop items
|
||||
const QMimeData *mimeData = e->mimeData();
|
||||
if(mimeData->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||
QModelIndex dropIndex = listView_->indexAt(e->pos());
|
||||
if(dropIndex.isValid()) { // drop on an item
|
||||
@ -926,17 +1137,62 @@ void DesktopWindow::childDropEvent(QDropEvent* e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(moveItem)
|
||||
if(moveItem) {
|
||||
e->accept();
|
||||
else
|
||||
}
|
||||
else {
|
||||
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
|
||||
auto grid = delegate->itemSize();
|
||||
Fm::FolderView::childDropEvent(e);
|
||||
// position dropped items successively, starting with the drop rectangle
|
||||
if(mimeData->hasUrls()
|
||||
&& (e->dropAction() == Qt::CopyAction
|
||||
|| e->dropAction() == Qt::MoveAction
|
||||
|| e->dropAction() == Qt::LinkAction)) {
|
||||
QList<QUrl> urlList = mimeData->urls();
|
||||
for(int i = 0; i < urlList.count(); ++i) {
|
||||
std::string name = urlList.at(i).fileName().toUtf8().constData();
|
||||
if(!name.empty()) { // respect the positions of existing files
|
||||
QString desktopDir = XdgDir::readDesktopDir() + QString(QLatin1String("/"));
|
||||
if(!QFile::exists(desktopDir + QString::fromStdString(name))) {
|
||||
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
|
||||
workArea.adjust(12, 12, -12, -12);
|
||||
QPoint pos = mapFromGlobal(e->pos());
|
||||
alignToGrid(pos, workArea.topLeft(), grid, listView_->spacing());
|
||||
if(i > 0)
|
||||
pos.setY(pos.y() + grid.height() + listView_->spacing());
|
||||
if(pos.y() + grid.height() > workArea.bottom() + 1) {
|
||||
pos.setX(pos.x() + grid.width() + listView_->spacing());
|
||||
pos.setY(workArea.top());
|
||||
}
|
||||
customItemPos_[name] = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
saveItemPositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWindow::closeEvent(QCloseEvent *event) {
|
||||
void DesktopWindow::alignToGrid(QPoint& pos, const QPoint& topLeft, const QSize& grid, const int spacing) {
|
||||
qreal w = qAbs((qreal)pos.x() - (qreal)topLeft.x())
|
||||
/ (qreal)(grid.width() + spacing);
|
||||
qreal h = qAbs(pos.y() - (qreal)topLeft.y())
|
||||
/ (qreal)(grid.height() + spacing);
|
||||
pos.setX(topLeft.x() + qRound(w) * (grid.width() + spacing));
|
||||
pos.setY(topLeft.y() + qRound(h) * (grid.height() + spacing));
|
||||
}
|
||||
|
||||
void DesktopWindow::closeEvent(QCloseEvent* event) {
|
||||
// prevent the desktop window from being closed.
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void DesktopWindow::paintEvent(QPaintEvent *event) {
|
||||
paintBackground(event);
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void DesktopWindow::setScreenNum(int num) {
|
||||
if(screenNum_ != num) {
|
||||
screenNum_ = num;
|
||||
|
@ -23,25 +23,27 @@
|
||||
|
||||
#include "view.h"
|
||||
#include "launcher.h"
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
#include <QHash>
|
||||
#include <QPoint>
|
||||
#include <QByteArray>
|
||||
#include <xcb/xcb.h>
|
||||
#include <libfm-qt/folder.h>
|
||||
#include <libfm-qt/core/folder.h>
|
||||
|
||||
namespace Fm {
|
||||
class CachedFolderModel;
|
||||
class ProxyFolderModel;
|
||||
class FolderViewListView;
|
||||
class CachedFolderModel;
|
||||
class ProxyFolderModel;
|
||||
class FolderViewListView;
|
||||
}
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
class DesktopItemDelegate;
|
||||
class Settings;
|
||||
|
||||
class DesktopWindow : public View {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class Application;
|
||||
|
||||
@ -63,10 +65,16 @@ public:
|
||||
void setDesktopFolder();
|
||||
void setWallpaperFile(QString filename);
|
||||
void setWallpaperMode(WallpaperMode mode = WallpaperStretch);
|
||||
void setLastSlide(QString filename);
|
||||
void setWallpaperDir(QString dirname);
|
||||
void setSlideShowInterval(int interval);
|
||||
void setWallpaperRandomize(bool randomize);
|
||||
|
||||
// void setWallpaperAlpha(qreal alpha);
|
||||
void updateWallpaper();
|
||||
void updateFromSettings(Settings& settings);
|
||||
bool pickWallpaper();
|
||||
void nextWallpaper();
|
||||
void updateFromSettings(Settings& settings, bool changeSlide = true);
|
||||
|
||||
void queueRelayout(int delay = 0);
|
||||
|
||||
@ -77,24 +85,25 @@ public:
|
||||
void setScreenNum(int num);
|
||||
|
||||
protected:
|
||||
virtual void prepareFolderMenu(Fm::FolderMenu* menu);
|
||||
virtual void prepareFileMenu(Fm::FileMenu* menu);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void onFileClicked(int type, FmFileInfo* fileInfo);
|
||||
virtual void prepareFolderMenu(Fm::FolderMenu* menu) override;
|
||||
virtual void prepareFileMenu(Fm::FileMenu* menu) override;
|
||||
virtual void resizeEvent(QResizeEvent* event) override;
|
||||
virtual void onFileClicked(int type, const std::shared_ptr<const Fm::FileInfo>& fileInfo) override;
|
||||
|
||||
void loadItemPositions();
|
||||
void saveItemPositions();
|
||||
|
||||
QImage loadWallpaperFile(QSize requiredSize);
|
||||
|
||||
virtual bool event(QEvent* event);
|
||||
virtual bool eventFilter(QObject * watched, QEvent * event);
|
||||
virtual bool event(QEvent* event) override;
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
virtual void childDropEvent(QDropEvent* e);
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
virtual void childDropEvent(QDropEvent* e) override;
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onOpenDirRequested(FmPath* path, int target);
|
||||
void onOpenDirRequested(const Fm::FilePath& path, int target);
|
||||
void onDesktopPreferences();
|
||||
|
||||
void onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
|
||||
@ -120,11 +129,12 @@ protected Q_SLOTS:
|
||||
private:
|
||||
void removeBottomGap();
|
||||
void paintBackground(QPaintEvent* event);
|
||||
static void alignToGrid(QPoint& pos, const QPoint& topLeft, const QSize& grid, const int spacing);
|
||||
|
||||
private:
|
||||
Fm::ProxyFolderModel* proxyModel_;
|
||||
Fm::CachedFolderModel* model_;
|
||||
Fm::Folder folder_;
|
||||
std::shared_ptr<Fm::Folder> folder_;
|
||||
Fm::FolderViewListView* listView_;
|
||||
|
||||
QColor fgColor_;
|
||||
@ -132,13 +142,17 @@ private:
|
||||
QColor shadowColor_;
|
||||
QString wallpaperFile_;
|
||||
WallpaperMode wallpaperMode_;
|
||||
QString lastSlide_;
|
||||
QString wallpaperDir_;
|
||||
int slideShowInterval_;
|
||||
QTimer* wallpaperTimer_;
|
||||
bool wallpaperRandomize_;
|
||||
QPixmap wallpaperPixmap_;
|
||||
DesktopItemDelegate* delegate_;
|
||||
Launcher fileLauncher_;
|
||||
bool showWmMenu_;
|
||||
|
||||
int screenNum_;
|
||||
QHash<QByteArray, QPoint> customItemPos_;
|
||||
std::unordered_map<std::string, QPoint> customItemPos_;
|
||||
QHash<QModelIndex, QString> displayNames_; // only for desktop entries and shortcuts
|
||||
QTimer* relayoutTimer_;
|
||||
};
|
||||
|
@ -1,517 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindFilesDialog</class>
|
||||
<widget class="QDialog" name="FindFilesDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Find Files</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Name/Location</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>File name patterns</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Pattern:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Case insensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="text">
|
||||
<string>Use regular expression</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Places to search</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="list-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="list-remove">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_3">
|
||||
<property name="text">
|
||||
<string>Search in sub directories</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_4">
|
||||
<property name="text">
|
||||
<string>Search hidden files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>File Type</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>File Type</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Only search for files of following types:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_5">
|
||||
<property name="text">
|
||||
<string>Text files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_6">
|
||||
<property name="text">
|
||||
<string>Image files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_7">
|
||||
<property name="text">
|
||||
<string>Audio files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_8">
|
||||
<property name="text">
|
||||
<string>Video files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_9">
|
||||
<property name="text">
|
||||
<string>Documents</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
<string>Content</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>File contains</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_10">
|
||||
<property name="text">
|
||||
<string>Case insensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_11">
|
||||
<property name="text">
|
||||
<string>Use regular expression</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Properties</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="title">
|
||||
<string>File Size</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_12">
|
||||
<property name="text">
|
||||
<string>Bigger than:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_13">
|
||||
<property name="text">
|
||||
<string>Smaller than:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Last Modified Time</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_14">
|
||||
<property name="text">
|
||||
<string>Earlier than:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDateTimeEdit" name="dateTimeEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_15">
|
||||
<property name="text">
|
||||
<string>Later than:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDateTimeEdit" name="dateTimeEdit_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>FindFilesDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>222</x>
|
||||
<y>344</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FindFilesDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>290</x>
|
||||
<y>350</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_14</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>dateTimeEdit</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>129</x>
|
||||
<y>166</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>294</x>
|
||||
<y>170</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_15</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>dateTimeEdit_2</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>91</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>302</x>
|
||||
<y>195</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_12</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>102</x>
|
||||
<y>73</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>184</x>
|
||||
<y>77</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_12</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>comboBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>49</x>
|
||||
<y>72</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>357</x>
|
||||
<y>76</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_13</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinBox_2</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>123</x>
|
||||
<y>101</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>186</x>
|
||||
<y>104</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_13</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>comboBox_2</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>53</x>
|
||||
<y>98</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>339</x>
|
||||
<y>108</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -21,6 +21,7 @@
|
||||
#include "launcher.h"
|
||||
#include "mainwindow.h"
|
||||
#include "application.h"
|
||||
#include <libfm-qt/core/filepath.h>
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
@ -38,23 +39,26 @@ Launcher::~Launcher() {
|
||||
|
||||
bool Launcher::openFolder(GAppLaunchContext* ctx, GList* folder_infos, GError** err) {
|
||||
GList* l = folder_infos;
|
||||
Fm::FileInfo fi = FM_FILE_INFO(l->data);
|
||||
FmFileInfo* fi = FM_FILE_INFO(l->data);
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
MainWindow* mainWindow = mainWindow_;
|
||||
Fm::FilePath path{fm_path_to_gfile(fm_file_info_get_path(fi)), false};
|
||||
if(!mainWindow) {
|
||||
mainWindow = new MainWindow(fi.getPath());
|
||||
mainWindow = new MainWindow(std::move(path));
|
||||
mainWindow->resize(app->settings().windowWidth(), app->settings().windowHeight());
|
||||
|
||||
if(app->settings().windowMaximized()) {
|
||||
mainWindow->setWindowState(mainWindow->windowState() | Qt::WindowMaximized);
|
||||
}
|
||||
}
|
||||
else
|
||||
mainWindow->chdir(fi.getPath());
|
||||
else {
|
||||
mainWindow->chdir(std::move(path));
|
||||
}
|
||||
l = l->next;
|
||||
for(; l; l = l->next) {
|
||||
fi = FM_FILE_INFO(l->data);
|
||||
mainWindow->addTab(fi.getPath());
|
||||
path = Fm::FilePath{fm_path_to_gfile(fm_file_info_get_path(fi)), false};
|
||||
mainWindow->addTab(std::move(path));
|
||||
}
|
||||
mainWindow->show();
|
||||
mainWindow->raise();
|
||||
|
@ -29,7 +29,7 @@ class MainWindow;
|
||||
|
||||
class Launcher : public Fm::FileLauncher {
|
||||
public:
|
||||
Launcher(MainWindow* mainWindow = NULL);
|
||||
Launcher(MainWindow* mainWindow = nullptr);
|
||||
~Launcher();
|
||||
|
||||
protected:
|
||||
|
@ -197,7 +197,7 @@
|
||||
<addaction name="menuToolbars"/>
|
||||
<addaction name="menuPathBarStyle"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Editw">
|
||||
<widget class="QMenu" name="menu_Edit">
|
||||
<property name="title">
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
@ -245,14 +245,14 @@
|
||||
<addaction name="actionFindFiles"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menu_Editw"/>
|
||||
<addaction name="menu_Edit"/>
|
||||
<addaction name="menu_View"/>
|
||||
<addaction name="menu_Go"/>
|
||||
<addaction name="menu_Bookmarks"/>
|
||||
<addaction name="menu_Tool"/>
|
||||
<addaction name="menu_Help"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="PCManFM::StatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::PreventContextMenu</enum>
|
||||
@ -836,6 +836,12 @@
|
||||
<header>tabbar.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PCManFM::StatusBar</class>
|
||||
<extends>QStatusBar</extends>
|
||||
<header>statusbar.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Fm::SidePane</class>
|
||||
<extends>QWidget</extends>
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <QToolButton>
|
||||
#include <QShortcut>
|
||||
#include <QKeySequence>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QDebug>
|
||||
|
||||
#include "tabpage.h"
|
||||
@ -42,9 +42,7 @@
|
||||
#include <libfm-qt/filepropsdialog.h>
|
||||
#include <libfm-qt/pathedit.h>
|
||||
#include <libfm-qt/pathbar.h>
|
||||
#include <libfm-qt/path.h>
|
||||
#include <libfm-qt/fileinfo.h>
|
||||
#include <libfm-qt/folder.h>
|
||||
#include <libfm-qt/core/fileinfo.h>
|
||||
#include "ui_about.h"
|
||||
#include "application.h"
|
||||
|
||||
@ -55,13 +53,14 @@ namespace PCManFM {
|
||||
// static
|
||||
MainWindow* MainWindow::lastActive_ = nullptr;
|
||||
|
||||
MainWindow::MainWindow(Path path):
|
||||
MainWindow::MainWindow(Fm::FilePath path):
|
||||
QMainWindow(),
|
||||
pathEntry_(nullptr),
|
||||
pathBar_(nullptr),
|
||||
fileLauncher_(this),
|
||||
rightClickIndex_(-1),
|
||||
updatingViewMenu_(false) {
|
||||
updatingViewMenu_(false),
|
||||
bookmarks_{Fm::Bookmarks::globalInstance()} {
|
||||
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
@ -71,8 +70,9 @@ MainWindow::MainWindow(Path path):
|
||||
// hide menu items that are not usable
|
||||
//if(!uriExists("computer:///"))
|
||||
// ui.actionComputer->setVisible(false);
|
||||
if(!settings.supportTrash())
|
||||
if(!settings.supportTrash()) {
|
||||
ui.actionTrash->setVisible(false);
|
||||
}
|
||||
|
||||
// FIXME: add an option to hide network:///
|
||||
// We cannot use uriExists() here since calling this on "network:///"
|
||||
@ -136,10 +136,12 @@ MainWindow::MainWindow(Path path):
|
||||
|
||||
// path bar
|
||||
createPathBar(settings.pathBarButtons());
|
||||
if(settings.pathBarButtons())
|
||||
if(settings.pathBarButtons()) {
|
||||
ui.actionPathButtons->setChecked(true);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.actionLocationBar->setChecked(true);
|
||||
}
|
||||
|
||||
// add filesystem info to status bar
|
||||
fsInfoLabel_ = new QLabel(ui.statusbar);
|
||||
@ -153,8 +155,7 @@ MainWindow::MainWindow(Path path):
|
||||
ui.splitter->setSizes(sizes);
|
||||
|
||||
// load bookmark menu
|
||||
bookmarks_ = Fm::Bookmarks::dup();
|
||||
g_signal_connect(bookmarks_, "changed", G_CALLBACK(onBookmarksChanged), this);
|
||||
connect(bookmarks_.get(), &Fm::Bookmarks::changed, this, &MainWindow::onBookmarksChanged);
|
||||
loadBookmarksMenu();
|
||||
|
||||
// Fix the menu groups which is not done by Qt designer
|
||||
@ -189,17 +190,18 @@ MainWindow::MainWindow(Path path):
|
||||
addActions(ui.menubar->actions());
|
||||
|
||||
// Show or hide the menu bar
|
||||
QMenu *menu = new QMenu(ui.toolBar);
|
||||
QMenu* menu = new QMenu(ui.toolBar);
|
||||
menu->addMenu(ui.menu_File);
|
||||
menu->addMenu(ui.menu_Editw);
|
||||
menu->addMenu(ui.menu_Edit);
|
||||
menu->addMenu(ui.menu_View);
|
||||
menu->addMenu(ui.menu_Go);
|
||||
menu->addMenu(ui.menu_Bookmarks);
|
||||
menu->addMenu(ui.menu_Tool);
|
||||
menu->addMenu(ui.menu_Help);
|
||||
ui.actionMenu->setMenu(menu);
|
||||
if(ui.actionMenu->icon().isNull())
|
||||
if(ui.actionMenu->icon().isNull()) {
|
||||
ui.actionMenu->setIcon(QIcon::fromTheme("applications-system"));
|
||||
}
|
||||
QToolButton* menuBtn = static_cast<QToolButton*>(ui.toolBar->widgetForAction(ui.actionMenu));
|
||||
menuBtn->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
@ -264,29 +266,28 @@ MainWindow::MainWindow(Path path):
|
||||
connect(shortcut, &QShortcut::activated, ui.filterBar, &QLineEdit::clear);
|
||||
}
|
||||
|
||||
if(!path.isNull())
|
||||
if(path) {
|
||||
addTab(path);
|
||||
}
|
||||
|
||||
// size from settings
|
||||
if(settings.rememberWindowSize()) {
|
||||
resize(settings.windowWidth(), settings.windowHeight());
|
||||
if(settings.windowMaximized())
|
||||
if(settings.windowMaximized()) {
|
||||
setWindowState(windowState() | Qt::WindowMaximized);
|
||||
}
|
||||
}
|
||||
|
||||
if(QApplication::layoutDirection() == Qt::RightToLeft)
|
||||
if(QApplication::layoutDirection() == Qt::RightToLeft) {
|
||||
setRTLIcons(true);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
if(!bookmarks_.isNull()) {
|
||||
g_signal_handlers_disconnect_by_func(bookmarks_, (gpointer)G_CALLBACK(onBookmarksChanged), this);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::chdir(Path path) {
|
||||
void MainWindow::chdir(Fm::FilePath path) {
|
||||
TabPage* page = currentPage();
|
||||
|
||||
if(page) {
|
||||
ui.filterBar->clear();
|
||||
page->chdir(path, true);
|
||||
@ -305,17 +306,16 @@ void MainWindow::createPathBar(bool usePathButtons) {
|
||||
else {
|
||||
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, bar);
|
||||
ui.actionGo->setVisible(!usePathButtons);
|
||||
}
|
||||
|
||||
// add a new tab
|
||||
int MainWindow::addTab(Path path) {
|
||||
int MainWindow::addTab(Fm::FilePath path) {
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
|
||||
TabPage* newPage = new TabPage(path, this);
|
||||
TabPage* newPage = new TabPage(this);
|
||||
newPage->setFileLauncher(&fileLauncher_);
|
||||
int index = ui.stackedWidget->addWidget(newPage);
|
||||
connect(newPage, &TabPage::titleChanged, this, &MainWindow::onTabPageTitleChanged);
|
||||
@ -325,12 +325,12 @@ int MainWindow::addTab(Path path) {
|
||||
connect(newPage, &TabPage::backwardRequested, this, &MainWindow::on_actionGoBack_triggered);
|
||||
connect(newPage, &TabPage::forwardRequested, this, &MainWindow::on_actionGoForward_triggered);
|
||||
|
||||
ui.tabBar->insertTab(index, newPage->title());
|
||||
newPage->chdir(path, true);
|
||||
ui.tabBar->insertTab(index, newPage->windowTitle());
|
||||
|
||||
if(!settings.alwaysShowTabs()) {
|
||||
ui.tabBar->setVisible(ui.tabBar->count() > 1);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -338,8 +338,8 @@ void MainWindow::toggleMenuBar(bool checked) {
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
bool showMenuBar = !settings.showMenuBar();
|
||||
|
||||
if (!showMenuBar) {
|
||||
if (QMessageBox::Cancel == QMessageBox::warning(this,
|
||||
if(!showMenuBar) {
|
||||
if(QMessageBox::Cancel == QMessageBox::warning(this,
|
||||
tr("Hide menu bar"),
|
||||
tr("This will hide the menu bar completely, use Ctrl+M to show it again."),
|
||||
QMessageBox::Ok | QMessageBox::Cancel)) {
|
||||
@ -357,27 +357,20 @@ void MainWindow::toggleMenuBar(bool checked) {
|
||||
|
||||
void MainWindow::onPathEntryReturnPressed() {
|
||||
QString text = pathEntry_->text();
|
||||
QByteArray utext = text.toUtf8();
|
||||
chdir(Fm::Path::newForDisplayName(utext));
|
||||
QByteArray utext = text.toLocal8Bit();
|
||||
chdir(Fm::FilePath::fromPathStr(utext.constData()));
|
||||
}
|
||||
|
||||
void MainWindow::onPathEntryEdited(const QString& text) {
|
||||
QString realText(text);
|
||||
if(realText == "~" || realText.startsWith("~/")) {
|
||||
realText.replace(0, 1, QDir::homePath());
|
||||
pathEntry_->setText(realText);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onPathBarChdir(FmPath* dirPath) {
|
||||
void MainWindow::onPathBarChdir(const Fm::FilePath& dirPath) {
|
||||
// call chdir() only when needed because otherwise
|
||||
// filter bar will be cleard on changing current tab
|
||||
TabPage* page = currentPage();
|
||||
if(page && dirPath != page->path())
|
||||
if(page && dirPath != page->path()) {
|
||||
chdir(dirPath);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onPathBarMiddleClickChdir(FmPath* dirPath) {
|
||||
void MainWindow::onPathBarMiddleClickChdir(const Fm::FilePath& dirPath) {
|
||||
addTab(dirPath);
|
||||
}
|
||||
|
||||
@ -412,13 +405,14 @@ void MainWindow::on_actionGoForward_triggered() {
|
||||
}
|
||||
|
||||
void MainWindow::on_actionHome_triggered() {
|
||||
chdir(Fm::Path::getHome());
|
||||
chdir(Fm::FilePath::homeDir());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionReload_triggered() {
|
||||
currentPage()->reload();
|
||||
if(pathEntry_ != nullptr)
|
||||
if(pathEntry_ != nullptr) {
|
||||
pathEntry_->setText(currentPage()->pathName());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionConnectToServer_triggered() {
|
||||
@ -431,32 +425,32 @@ void MainWindow::on_actionGo_triggered() {
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNewTab_triggered() {
|
||||
Fm::Path path = currentPage()->path();
|
||||
auto path = currentPage()->path();
|
||||
int index = addTab(path);
|
||||
ui.tabBar->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNewWin_triggered() {
|
||||
Fm::Path path = currentPage()->path();
|
||||
auto path = currentPage()->path();
|
||||
(new MainWindow(path))->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNewFolder_triggered() {
|
||||
if(TabPage* tabPage = currentPage()) {
|
||||
Fm::Path dirPath = tabPage->folderView()->path();
|
||||
|
||||
if(dirPath)
|
||||
auto dirPath = tabPage->folderView()->path();
|
||||
if(dirPath) {
|
||||
createFileOrFolder(CreateNewFolder, dirPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNewBlankFile_triggered() {
|
||||
if(TabPage* tabPage = currentPage()) {
|
||||
Fm::Path dirPath = tabPage->folderView()->path();
|
||||
|
||||
if(dirPath)
|
||||
auto dirPath = tabPage->folderView()->path();
|
||||
if(dirPath) {
|
||||
createFileOrFolder(CreateNewTextFile, dirPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCloseTab_triggered() {
|
||||
@ -472,8 +466,8 @@ void MainWindow::on_actionCloseWindow_triggered() {
|
||||
void MainWindow::on_actionFileProperties_triggered() {
|
||||
TabPage* page = currentPage();
|
||||
if(page) {
|
||||
Fm::FileInfoList files = page->selectedFiles();
|
||||
if(!files.isNull()) {
|
||||
auto files = page->selectedFiles();
|
||||
if(!files.empty()) {
|
||||
Fm::FilePropsDialog::showForFiles(files);
|
||||
}
|
||||
}
|
||||
@ -481,20 +475,23 @@ void MainWindow::on_actionFileProperties_triggered() {
|
||||
|
||||
void MainWindow::on_actionFolderProperties_triggered() {
|
||||
TabPage* page = currentPage();
|
||||
|
||||
if(page) {
|
||||
Fm::Folder folder = page->folder();
|
||||
if(!folder.isNull()) {
|
||||
Fm::FileInfo info = folder.getInfo();
|
||||
if(!info.isNull())
|
||||
auto folder = page->folder();
|
||||
if(folder) {
|
||||
auto info = folder->info();
|
||||
if(info) {
|
||||
Fm::FilePropsDialog::showForFile(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionShowHidden_triggered(bool checked) {
|
||||
currentPage()->setShowHidden(checked);
|
||||
ui.sidePane->setShowHidden(checked);
|
||||
if(!currentPage()->hasCustomizedView()) {
|
||||
static_cast<Application*>(qApp)->settings().setShowHidden(checked); // remember globally
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionByFileName_triggered(bool checked) {
|
||||
@ -540,8 +537,9 @@ void MainWindow::on_actionPreserveView_triggered(bool checked) {
|
||||
|
||||
void MainWindow::on_actionFilter_triggered(bool checked) {
|
||||
ui.filterBar->setVisible(checked);
|
||||
if(checked)
|
||||
if(checked) {
|
||||
ui.filterBar->setFocus();
|
||||
}
|
||||
else if(TabPage* tabPage = currentPage()) {
|
||||
ui.filterBar->clear();
|
||||
tabPage->folderView()->childView()->setFocus();
|
||||
@ -585,33 +583,33 @@ void MainWindow::on_actionPathButtons_triggered(bool checked) {
|
||||
}
|
||||
|
||||
void MainWindow::on_actionComputer_triggered() {
|
||||
chdir(Fm::Path::newForUri("computer:///"));
|
||||
chdir(Fm::FilePath::fromUri("computer:///"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionApplications_triggered() {
|
||||
chdir(Fm::Path::getAppsMenu());
|
||||
chdir(Fm::FilePath::fromUri("menu://applications/"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionTrash_triggered() {
|
||||
chdir(Fm::Path::getTrash());
|
||||
chdir(Fm::FilePath::fromUri("trash:///"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNetwork_triggered() {
|
||||
chdir(Fm::Path::newForUri("network:///"));
|
||||
chdir(Fm::FilePath::fromUri("network:///"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDesktop_triggered() {
|
||||
chdir(Fm::Path::getDesktop());
|
||||
auto desktop = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toLocal8Bit();
|
||||
chdir(Fm::FilePath::fromLocalPath(desktop.constData()));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAddToBookmarks_triggered() {
|
||||
TabPage* page = currentPage();
|
||||
if(page) {
|
||||
Fm::Path cwd = page->path();
|
||||
if(!cwd.isNull()) {
|
||||
char* dispName = cwd.displayBasename();
|
||||
bookmarks_.insert(cwd, dispName, -1);
|
||||
g_free(dispName);
|
||||
auto cwd = page->path();
|
||||
if(cwd) {
|
||||
auto dispName = cwd.baseName();
|
||||
bookmarks_->insert(cwd, dispName.get(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -679,10 +677,12 @@ void MainWindow::onTabBarTabMoved(int from, int to) {
|
||||
}
|
||||
|
||||
void MainWindow::focusFilterBar() {
|
||||
if(!ui.filterBar->isVisible())
|
||||
if(!ui.filterBar->isVisible()) {
|
||||
ui.actionFilter->trigger();
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.filterBar->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onFilterStringChanged(QString str) {
|
||||
@ -705,7 +705,7 @@ void MainWindow::closeTab(int index) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *event) {
|
||||
void MainWindow::resizeEvent(QResizeEvent* event) {
|
||||
QMainWindow::resizeEvent(event);
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
if(settings.rememberWindowSize()) {
|
||||
@ -718,10 +718,10 @@ void MainWindow::resizeEvent(QResizeEvent *event) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(lastActive_ == this)
|
||||
void MainWindow::closeEvent(QCloseEvent* event) {
|
||||
if(lastActive_ == this) {
|
||||
lastActive_ = nullptr;
|
||||
}
|
||||
|
||||
QWidget::closeEvent(event);
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
@ -737,16 +737,18 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
void MainWindow::onTabBarCurrentChanged(int index) {
|
||||
ui.stackedWidget->setCurrentIndex(index);
|
||||
if(TabPage* page = static_cast<TabPage*>(ui.stackedWidget->widget(index)))
|
||||
if(TabPage* page = static_cast<TabPage*>(ui.stackedWidget->widget(index))) {
|
||||
ui.filterBar->setText(page->getFilterStr());
|
||||
}
|
||||
updateUIForCurrentPage();
|
||||
}
|
||||
|
||||
void MainWindow::updateStatusBarForCurrentPage() {
|
||||
TabPage* tabPage = currentPage();
|
||||
QString text = tabPage->statusText(TabPage::StatusTextSelectedFiles);
|
||||
if(text.isEmpty())
|
||||
if(text.isEmpty()) {
|
||||
text = tabPage->statusText(TabPage::StatusTextNormal);
|
||||
}
|
||||
ui.statusbar->showMessage(text);
|
||||
|
||||
text = tabPage->statusText(TabPage::StatusTextFSInfo);
|
||||
@ -755,8 +757,9 @@ void MainWindow::updateStatusBarForCurrentPage() {
|
||||
}
|
||||
|
||||
void MainWindow::updateViewMenuForCurrentPage() {
|
||||
if(updatingViewMenu_) // prevent recursive calls
|
||||
if(updatingViewMenu_) { // prevent recursive calls
|
||||
return;
|
||||
}
|
||||
updatingViewMenu_ = true;
|
||||
TabPage* tabPage = currentPage();
|
||||
if(tabPage) {
|
||||
@ -765,7 +768,7 @@ void MainWindow::updateViewMenuForCurrentPage() {
|
||||
ui.actionPreserveView->setChecked(tabPage->hasCustomizedView());
|
||||
|
||||
// view mode
|
||||
QAction* modeAction = NULL;
|
||||
QAction* modeAction = nullptr;
|
||||
|
||||
switch(tabPage->viewMode()) {
|
||||
case Fm::FolderView::IconMode:
|
||||
@ -785,7 +788,7 @@ void MainWindow::updateViewMenuForCurrentPage() {
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT(modeAction != NULL);
|
||||
Q_ASSERT(modeAction != nullptr);
|
||||
modeAction->setChecked(true);
|
||||
|
||||
// sort menu
|
||||
@ -797,21 +800,51 @@ void MainWindow::updateViewMenuForCurrentPage() {
|
||||
sortActions[Fm::FolderModel::ColumnFileOwner] = ui.actionByOwner;
|
||||
sortActions[tabPage->sortColumn()]->setChecked(true);
|
||||
|
||||
if(tabPage->sortOrder() == Qt::AscendingOrder)
|
||||
if(tabPage->sortOrder() == Qt::AscendingOrder) {
|
||||
ui.actionAscending->setChecked(true);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.actionDescending->setChecked(true);
|
||||
}
|
||||
ui.actionCaseSensitive->setChecked(tabPage->sortCaseSensitive());
|
||||
ui.actionFolderFirst->setChecked(tabPage->sortFolderFirst());
|
||||
}
|
||||
updatingViewMenu_ = false;
|
||||
}
|
||||
|
||||
// Update the enabled state of Edit actions for selected files
|
||||
void MainWindow::updateEditSelectedActions() {
|
||||
bool hasAccessible(false);
|
||||
bool hasDeletable(false);
|
||||
bool hasRenamable(false);
|
||||
if(TabPage* page = currentPage()) {
|
||||
auto files = page->selectedFiles();
|
||||
for(auto& file: files) {
|
||||
if(file->isAccessible()) {
|
||||
hasAccessible = true;
|
||||
}
|
||||
if(file->isDeletable()) {
|
||||
hasDeletable = true;
|
||||
}
|
||||
if(file->canSetName()) {
|
||||
hasRenamable = true;
|
||||
}
|
||||
if (hasAccessible && hasDeletable && hasRenamable) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ui.actionCopy->setEnabled(hasAccessible);
|
||||
ui.actionCut->setEnabled(hasDeletable);
|
||||
ui.actionDelete->setEnabled(hasDeletable);
|
||||
ui.actionRename->setEnabled(hasRenamable);
|
||||
}
|
||||
|
||||
void MainWindow::updateUIForCurrentPage() {
|
||||
TabPage* tabPage = currentPage();
|
||||
|
||||
if(tabPage) {
|
||||
setWindowTitle(tabPage->title());
|
||||
setWindowTitle(tabPage->windowTitle());
|
||||
if(pathEntry_ != nullptr) {
|
||||
pathEntry_->setText(tabPage->pathName());
|
||||
}
|
||||
@ -834,6 +867,16 @@ void MainWindow::updateUIForCurrentPage() {
|
||||
updateViewMenuForCurrentPage();
|
||||
updateStatusBarForCurrentPage();
|
||||
}
|
||||
|
||||
// also update the enabled state of Edit actions
|
||||
updateEditSelectedActions();
|
||||
bool isWritable(false);
|
||||
if(tabPage && tabPage->folder()) {
|
||||
if(auto info = tabPage->folder()->info()) {
|
||||
isWritable = info->isWritable();
|
||||
}
|
||||
}
|
||||
ui.actionPaste->setEnabled(isWritable);
|
||||
}
|
||||
|
||||
void MainWindow::onStackedWidgetWidgetRemoved(int index) {
|
||||
@ -855,12 +898,23 @@ void MainWindow::onStackedWidgetWidgetRemoved(int index) {
|
||||
void MainWindow::onTabPageTitleChanged(QString title) {
|
||||
TabPage* tabPage = static_cast<TabPage*>(sender());
|
||||
int index = ui.stackedWidget->indexOf(tabPage);
|
||||
|
||||
if(index >= 0)
|
||||
if(index >= 0) {
|
||||
ui.tabBar->setTabText(index, title);
|
||||
}
|
||||
|
||||
if(tabPage == currentPage())
|
||||
if(tabPage == currentPage()) {
|
||||
setWindowTitle(title);
|
||||
|
||||
// Since TabPage::titleChanged is emitted on changing directory,
|
||||
// the enabled state of Paste action should be updated here
|
||||
bool isWritable(false);
|
||||
if(tabPage && tabPage->folder()) {
|
||||
if(auto info = tabPage->folder()->info()) {
|
||||
isWritable = info->isWritable();
|
||||
}
|
||||
}
|
||||
ui.actionPaste->setEnabled(isWritable);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onTabPageStatusChanged(int type, QString statusText) {
|
||||
@ -869,12 +923,15 @@ void MainWindow::onTabPageStatusChanged(int type, QString statusText) {
|
||||
switch(type) {
|
||||
case TabPage::StatusTextNormal:
|
||||
case TabPage::StatusTextSelectedFiles: {
|
||||
// FIXME: updating the status text so frequently is a little bit ineffiecient
|
||||
QString text = statusText = tabPage->statusText(TabPage::StatusTextSelectedFiles);
|
||||
if(text.isEmpty())
|
||||
// although the status text may change very frequently,
|
||||
// the text of PCManFM::StatusBar is updated with a delay
|
||||
QString text = tabPage->statusText(TabPage::StatusTextSelectedFiles);
|
||||
if(text.isEmpty()) {
|
||||
ui.statusbar->showMessage(tabPage->statusText(TabPage::StatusTextNormal));
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.statusbar->showMessage(text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TabPage::StatusTextFSInfo:
|
||||
@ -883,9 +940,13 @@ void MainWindow::onTabPageStatusChanged(int type, QString statusText) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Since TabPage::statusChanged is always emitted after View::selChanged,
|
||||
// there is no need to connect a separate slot to the latter signal
|
||||
updateEditSelectedActions();
|
||||
}
|
||||
|
||||
void MainWindow::onTabPageOpenDirRequested(FmPath* path, int target) {
|
||||
void MainWindow::onTabPageOpenDirRequested(const Fm::FilePath& path, int target) {
|
||||
switch(target) {
|
||||
case OpenInCurrentTab:
|
||||
chdir(path);
|
||||
@ -911,35 +972,40 @@ void MainWindow::onTabPageSortFilterChanged() {
|
||||
settings.setSortOrder(tabPage->sortOrder());
|
||||
settings.setSortFolderFirst(tabPage->sortFolderFirst());
|
||||
settings.setSortCaseSensitive(tabPage->sortCaseSensitive());
|
||||
settings.setShowHidden(tabPage->showHidden()); // remember globally , as in on_actionShowHidden_triggered()
|
||||
}
|
||||
tabPage->setShowHidden(tabPage->showHidden()); // change status text and perfolder setting
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onSidePaneChdirRequested(int type, FmPath* path) {
|
||||
void MainWindow::onSidePaneChdirRequested(int type, const Fm::FilePath &path) {
|
||||
// FIXME: use enum for type value or change it to button.
|
||||
if(type == 0) // left button (default)
|
||||
if(type == 0) { // left button (default)
|
||||
chdir(path);
|
||||
else if(type == 1) // middle button
|
||||
}
|
||||
else if(type == 1) { // middle button
|
||||
addTab(path);
|
||||
else if(type == 2) // new window
|
||||
}
|
||||
else if(type == 2) { // new window
|
||||
(new MainWindow(path))->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSidePaneOpenFolderInNewWindowRequested(const Fm::FilePath &path) {
|
||||
(new MainWindow(path))->show();
|
||||
}
|
||||
|
||||
void MainWindow::onSidePaneOpenFolderInNewWindowRequested(FmPath* path) {
|
||||
(new MainWindow(path))->show();
|
||||
}
|
||||
|
||||
void MainWindow::onSidePaneOpenFolderInNewTabRequested(FmPath* path) {
|
||||
void MainWindow::onSidePaneOpenFolderInNewTabRequested(const Fm::FilePath &path) {
|
||||
addTab(path);
|
||||
}
|
||||
|
||||
void MainWindow::onSidePaneOpenFolderInTerminalRequested(FmPath* path) {
|
||||
void MainWindow::onSidePaneOpenFolderInTerminalRequested(const Fm::FilePath &path) {
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
app->openFolderInTerminal(path);
|
||||
}
|
||||
|
||||
void MainWindow::onSidePaneCreateNewFolderRequested(FmPath* path) {
|
||||
void MainWindow::onSidePaneCreateNewFolderRequested(const Fm::FilePath &path) {
|
||||
createFileOrFolder(CreateNewFolder, path);
|
||||
}
|
||||
|
||||
@ -953,38 +1019,34 @@ void MainWindow::onSplitterMoved(int pos, int index) {
|
||||
}
|
||||
|
||||
void MainWindow::loadBookmarksMenu() {
|
||||
GList* allBookmarks = bookmarks_.getAll();
|
||||
QAction* before = ui.actionAddToBookmarks;
|
||||
|
||||
for(GList* l = allBookmarks; l; l = l->next) {
|
||||
FmBookmarkItem* item = reinterpret_cast<FmBookmarkItem*>(l->data);
|
||||
for(auto& item: bookmarks_->items()) {
|
||||
BookmarkAction* action = new BookmarkAction(item, ui.menu_Bookmarks);
|
||||
connect(action, &QAction::triggered, this, &MainWindow::onBookmarkActionTriggered);
|
||||
ui.menu_Bookmarks->insertAction(before, action);
|
||||
}
|
||||
|
||||
ui.menu_Bookmarks->insertSeparator(before);
|
||||
g_list_free_full(allBookmarks, (GDestroyNotify)fm_bookmark_item_unref);
|
||||
}
|
||||
|
||||
void MainWindow::onBookmarksChanged(FmBookmarks* bookmarks, MainWindow* pThis) {
|
||||
void MainWindow::onBookmarksChanged() {
|
||||
// delete existing items
|
||||
QList<QAction*> actions = pThis->ui.menu_Bookmarks->actions();
|
||||
QList<QAction*>::const_iterator it = actions.begin();
|
||||
QList<QAction*>::const_iterator last_it = actions.end() - 2;
|
||||
QList<QAction*> actions = ui.menu_Bookmarks->actions();
|
||||
QList<QAction*>::const_iterator it = actions.constBegin();
|
||||
QList<QAction*>::const_iterator last_it = actions.constEnd() - 2;
|
||||
|
||||
while(it != last_it) {
|
||||
QAction* action = *it;
|
||||
++it;
|
||||
pThis->ui.menu_Bookmarks->removeAction(action);
|
||||
ui.menu_Bookmarks->removeAction(action);
|
||||
}
|
||||
|
||||
pThis->loadBookmarksMenu();
|
||||
loadBookmarksMenu();
|
||||
}
|
||||
|
||||
void MainWindow::onBookmarkActionTriggered() {
|
||||
BookmarkAction* action = static_cast<BookmarkAction*>(sender());
|
||||
Fm::Path path = action->path();
|
||||
auto path = action->path();
|
||||
if(path) {
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
Settings& settings = app->settings();
|
||||
@ -1005,13 +1067,13 @@ void MainWindow::onBookmarkActionTriggered() {
|
||||
|
||||
void MainWindow::on_actionCopy_triggered() {
|
||||
TabPage* page = currentPage();
|
||||
Fm::PathList paths = page->selectedFilePaths();
|
||||
auto paths = page->selectedFilePaths();
|
||||
copyFilesToClipboard(paths);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCut_triggered() {
|
||||
TabPage* page = currentPage();
|
||||
Fm::PathList paths = page->selectedFilePaths();
|
||||
auto paths = page->selectedFilePaths();
|
||||
cutFilesToClipboard(paths);
|
||||
}
|
||||
|
||||
@ -1023,21 +1085,39 @@ void MainWindow::on_actionDelete_triggered() {
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
Settings& settings = app->settings();
|
||||
TabPage* page = currentPage();
|
||||
Fm::PathList paths = page->selectedFilePaths();
|
||||
auto paths = page->selectedFilePaths();
|
||||
|
||||
bool shiftPressed = (qApp->keyboardModifiers() & Qt::ShiftModifier ? true : false);
|
||||
if(settings.useTrash() && !shiftPressed)
|
||||
if(settings.useTrash() && !shiftPressed) {
|
||||
FileOperation::trashFiles(paths, settings.confirmTrash(), this);
|
||||
else
|
||||
}
|
||||
else {
|
||||
FileOperation::deleteFiles(paths, settings.confirmDelete(), this);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRename_triggered() {
|
||||
// do inline renaming if only one item is selected,
|
||||
// otherwise use the renaming dialog
|
||||
TabPage* page = currentPage();
|
||||
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);
|
||||
auto files = page->selectedFiles();
|
||||
if(files.size() == 1) {
|
||||
QAbstractItemView* view = page->folderView()->childView();
|
||||
QModelIndexList selIndexes = view->selectionModel()->selectedIndexes();
|
||||
if(selIndexes.size() > 1) { // in the detailed list mode, only the first index is editable
|
||||
view->setCurrentIndex(selIndexes.at(0));
|
||||
}
|
||||
QModelIndex cur = view->currentIndex();
|
||||
if (cur.isValid()) {
|
||||
view->scrollTo(cur);
|
||||
view->edit(cur);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!files.empty()) {
|
||||
for(auto& file: files) {
|
||||
Fm::renameFile(file, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1083,7 +1163,7 @@ bool MainWindow::event(QEvent* event) {
|
||||
return QMainWindow::event(event);
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *event) {
|
||||
void MainWindow::changeEvent(QEvent* event) {
|
||||
switch(event->type()) {
|
||||
case QEvent::LayoutDirectionChange:
|
||||
setRTLIcons(QApplication::layoutDirection() == Qt::RightToLeft);
|
||||
@ -1103,10 +1183,9 @@ void MainWindow::onBackForwardContextMenu(QPoint pos) {
|
||||
QMenu menu;
|
||||
for(int i = 0; i < history.size(); ++i) {
|
||||
const BrowseHistoryItem& item = history.at(i);
|
||||
Fm::Path path = item.path();
|
||||
char* name = path.displayName(true);
|
||||
QAction* action = menu.addAction(QString::fromUtf8(name));
|
||||
g_free(name);
|
||||
auto path = item.path();
|
||||
auto name = path.displayName();
|
||||
QAction* action = menu.addAction(name.get());
|
||||
if(i == current) {
|
||||
// make the current path bold and checked
|
||||
action->setCheckable(true);
|
||||
@ -1127,14 +1206,19 @@ void MainWindow::onBackForwardContextMenu(QPoint pos) {
|
||||
|
||||
void MainWindow::tabContextMenu(const QPoint& pos) {
|
||||
int tabNum = ui.tabBar->count();
|
||||
if(tabNum <= 1) return;
|
||||
if(tabNum <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
rightClickIndex_ = ui.tabBar->tabAt(pos);
|
||||
if(rightClickIndex_ < 0) return;
|
||||
if(rightClickIndex_ < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu menu;
|
||||
if(rightClickIndex_ > 0)
|
||||
if(rightClickIndex_ > 0) {
|
||||
menu.addAction(ui.actionCloseLeft);
|
||||
}
|
||||
if(rightClickIndex_ < tabNum - 1) {
|
||||
menu.addAction(ui.actionCloseRight);
|
||||
if(rightClickIndex_ > 0) {
|
||||
@ -1153,9 +1237,12 @@ void MainWindow::closeLeftTabs() {
|
||||
}
|
||||
|
||||
void MainWindow::closeRightTabs() {
|
||||
if(rightClickIndex_ < 0) return;
|
||||
while(rightClickIndex_ < ui.tabBar->count() - 1)
|
||||
if(rightClickIndex_ < 0) {
|
||||
return;
|
||||
}
|
||||
while(rightClickIndex_ < ui.tabBar->count() - 1) {
|
||||
closeTab(rightClickIndex_ + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::focusPathEntry() {
|
||||
@ -1164,7 +1251,7 @@ void MainWindow::focusPathEntry() {
|
||||
pathEntry_->setFocus();
|
||||
pathEntry_->selectAll();
|
||||
}
|
||||
else if (pathBar_ != nullptr) { // use button-style path bar
|
||||
else if(pathBar_ != nullptr) { // use button-style path bar
|
||||
pathBar_->openEditor();
|
||||
}
|
||||
}
|
||||
@ -1188,7 +1275,7 @@ void MainWindow::updateFromSettings(Settings& settings) {
|
||||
ui.verticalLayout_2->insertWidget(0, ui.tabBar);
|
||||
}
|
||||
}
|
||||
else if (ui.verticalLayout_2->indexOf(ui.tabBar) > -1 && settings.fullWidthTabBar()) {
|
||||
else if(ui.verticalLayout_2->indexOf(ui.tabBar) > -1 && settings.fullWidthTabBar()) {
|
||||
ui.verticalLayout_2->removeWidget(ui.tabBar);
|
||||
ui.verticalLayout->insertWidget(0, ui.tabBar);
|
||||
}
|
||||
@ -1208,7 +1295,7 @@ static const char* su_cmd_subst(char opt, gpointer user_data) {
|
||||
|
||||
static FmAppCommandParseOption su_cmd_opts[] = {
|
||||
{ 's', su_cmd_subst },
|
||||
{ 0, NULL }
|
||||
{ 0, nullptr }
|
||||
};
|
||||
|
||||
void MainWindow::on_actionOpenAsRoot_triggered() {
|
||||
@ -1222,33 +1309,30 @@ void MainWindow::on_actionOpenAsRoot_triggered() {
|
||||
// run the su command
|
||||
// FIXME: it's better to get the filename of the current process rather than hard-code pcmanfm-qt here.
|
||||
QByteArray suCommand = settings.suCommand().toLocal8Bit();
|
||||
char* cmd = NULL;
|
||||
char* cmd = nullptr;
|
||||
QByteArray programCommand = app->applicationFilePath().toLocal8Bit();
|
||||
programCommand += " %U";
|
||||
|
||||
if(fm_app_command_parse(suCommand.constData(), su_cmd_opts, &cmd, gpointer(programCommand.constData())) == 0) {
|
||||
/* no %s found so just append to it */
|
||||
g_free(cmd);
|
||||
cmd = g_strconcat(suCommand.constData(), programCommand.constData(), NULL);
|
||||
cmd = g_strconcat(suCommand.constData(), programCommand.constData(), nullptr);
|
||||
}
|
||||
|
||||
GAppInfo* appInfo = g_app_info_create_from_commandline(cmd, NULL, GAppInfoCreateFlags(0), NULL);
|
||||
Fm::GAppInfoPtr appInfo{g_app_info_create_from_commandline(cmd, nullptr, GAppInfoCreateFlags(0), nullptr), false};
|
||||
g_free(cmd);
|
||||
|
||||
if(appInfo) {
|
||||
Fm::Path cwd = page->path();
|
||||
GError* err = NULL;
|
||||
char* uri = cwd.toUri();
|
||||
GList* uris = g_list_prepend(NULL, uri);
|
||||
auto cwd = page->path();
|
||||
Fm::GErrorPtr err;
|
||||
auto uri = cwd.uri();
|
||||
GList* uris = g_list_prepend(nullptr, uri.get());
|
||||
|
||||
if(!g_app_info_launch_uris(appInfo, uris, NULL, &err)) {
|
||||
if(!g_app_info_launch_uris(appInfo.get(), uris, nullptr, &err)) {
|
||||
QMessageBox::critical(this, tr("Error"), QString::fromUtf8(err->message));
|
||||
g_error_free(err);
|
||||
}
|
||||
|
||||
g_list_free(uris);
|
||||
g_free(uri);
|
||||
g_object_unref(appInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1261,14 +1345,13 @@ void MainWindow::on_actionOpenAsRoot_triggered() {
|
||||
|
||||
void MainWindow::on_actionFindFiles_triggered() {
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
Fm::PathList selectedPaths = currentPage()->selectedFilePaths();
|
||||
auto selectedPaths = currentPage()->selectedFilePaths();
|
||||
QStringList paths;
|
||||
if(!selectedPaths.isNull()) {
|
||||
for(GList* l = fm_path_list_peek_head_link(selectedPaths); l; l = l->next) {
|
||||
if(!selectedPaths.empty()) {
|
||||
for(auto& path: selectedPaths) {
|
||||
// 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));
|
||||
paths.append(path.displayName().get());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1287,18 +1370,22 @@ void MainWindow::on_actionOpenTerminal_triggered() {
|
||||
|
||||
void MainWindow::onShortcutNextTab() {
|
||||
int current = ui.tabBar->currentIndex();
|
||||
if(current < ui.tabBar->count() - 1)
|
||||
if(current < ui.tabBar->count() - 1) {
|
||||
ui.tabBar->setCurrentIndex(current + 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.tabBar->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShortcutPrevTab() {
|
||||
int current = ui.tabBar->currentIndex();
|
||||
if(current > 0)
|
||||
if(current > 0) {
|
||||
ui.tabBar->setCurrentIndex(current - 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.tabBar->setCurrentIndex(ui.tabBar->count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to nth tab when Alt+n or Ctrl+n is pressed
|
||||
@ -1311,19 +1398,24 @@ void MainWindow::onShortcutJumpToTab() {
|
||||
// Then we know how to test if a key sequence contains a modifier.
|
||||
// It's a shame that Qt has no API for this task.
|
||||
|
||||
if((keyValue & Qt::ALT) == Qt::ALT) // test if we have Alt key pressed
|
||||
if((keyValue & Qt::ALT) == Qt::ALT) { // test if we have Alt key pressed
|
||||
keyValue -= Qt::ALT;
|
||||
else if((keyValue & Qt::CTRL) == Qt::CTRL) // test if we have Ctrl key pressed
|
||||
}
|
||||
else if((keyValue & Qt::CTRL) == Qt::CTRL) { // test if we have Ctrl key pressed
|
||||
keyValue -= Qt::CTRL;
|
||||
}
|
||||
|
||||
// now keyValue should contains '0' - '9' only
|
||||
int index;
|
||||
if(keyValue == '0')
|
||||
if(keyValue == '0') {
|
||||
index = 9;
|
||||
else
|
||||
}
|
||||
else {
|
||||
index = keyValue - '1';
|
||||
if(index < ui.tabBar->count())
|
||||
}
|
||||
if(index < ui.tabBar->count()) {
|
||||
ui.tabBar->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,12 +32,13 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QSplitter>
|
||||
#include "launcher.h"
|
||||
#include <libfm-qt/bookmarks.h>
|
||||
#include <libfm-qt/path.h>
|
||||
#include <libfm-qt/core/filepath.h>
|
||||
#include <libfm-qt/core/bookmarks.h>
|
||||
|
||||
namespace Fm {
|
||||
class PathEdit;
|
||||
class PathBar;
|
||||
class PathEdit;
|
||||
class PathBar;
|
||||
}
|
||||
|
||||
namespace PCManFM {
|
||||
@ -46,13 +47,13 @@ class TabPage;
|
||||
class Settings;
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(Fm::Path path = Fm::Path());
|
||||
MainWindow(Fm::FilePath path = Fm::FilePath());
|
||||
virtual ~MainWindow();
|
||||
|
||||
void chdir(Fm::Path path);
|
||||
int addTab(Fm::Path path);
|
||||
void chdir(Fm::FilePath path);
|
||||
int addTab(Fm::FilePath path);
|
||||
|
||||
TabPage* currentPage() {
|
||||
return reinterpret_cast<TabPage*>(ui.stackedWidget->currentWidget());
|
||||
@ -67,9 +68,8 @@ public:
|
||||
protected Q_SLOTS:
|
||||
|
||||
void onPathEntryReturnPressed();
|
||||
void onPathEntryEdited(const QString& text);
|
||||
void onPathBarChdir(FmPath* dirPath);
|
||||
void onPathBarMiddleClickChdir(FmPath* dirPath);
|
||||
void onPathBarChdir(const Fm::FilePath& dirPath);
|
||||
void onPathBarMiddleClickChdir(const Fm::FilePath &dirPath);
|
||||
|
||||
void on_actionNewTab_triggered();
|
||||
void on_actionNewWin_triggered();
|
||||
@ -150,14 +150,14 @@ protected Q_SLOTS:
|
||||
|
||||
void onTabPageTitleChanged(QString title);
|
||||
void onTabPageStatusChanged(int type, QString statusText);
|
||||
void onTabPageOpenDirRequested(FmPath* path, int target);
|
||||
void onTabPageOpenDirRequested(const Fm::FilePath &path, int target);
|
||||
void onTabPageSortFilterChanged();
|
||||
|
||||
void onSidePaneChdirRequested(int type, FmPath* path);
|
||||
void onSidePaneOpenFolderInNewWindowRequested(FmPath* path);
|
||||
void onSidePaneOpenFolderInNewTabRequested(FmPath* path);
|
||||
void onSidePaneOpenFolderInTerminalRequested(FmPath* path);
|
||||
void onSidePaneCreateNewFolderRequested(FmPath* path);
|
||||
void onSidePaneChdirRequested(int type, const Fm::FilePath &path);
|
||||
void onSidePaneOpenFolderInNewWindowRequested(const Fm::FilePath &path);
|
||||
void onSidePaneOpenFolderInNewTabRequested(const Fm::FilePath &path);
|
||||
void onSidePaneOpenFolderInTerminalRequested(const Fm::FilePath &path);
|
||||
void onSidePaneCreateNewFolderRequested(const Fm::FilePath &path);
|
||||
void onSidePaneModeChanged(Fm::SidePane::Mode mode);
|
||||
void onSplitterMoved(int pos, int index);
|
||||
void onResetFocus();
|
||||
@ -174,18 +174,20 @@ protected Q_SLOTS:
|
||||
void focusPathEntry();
|
||||
void toggleMenuBar(bool checked);
|
||||
|
||||
void onBookmarksChanged();
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event) override;
|
||||
void changeEvent(QEvent *event) override;
|
||||
void changeEvent(QEvent* event) override;
|
||||
void closeTab(int index);
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual void resizeEvent(QResizeEvent* event) override;
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
private:
|
||||
static void onBookmarksChanged(FmBookmarks* bookmarks_, MainWindow* pThis);
|
||||
void loadBookmarksMenu();
|
||||
void updateUIForCurrentPage();
|
||||
void updateViewMenuForCurrentPage();
|
||||
void updateEditSelectedActions();
|
||||
void updateStatusBarForCurrentPage();
|
||||
void setRTLIcons(bool isRTL);
|
||||
void createPathBar(bool usePathButtons);
|
||||
@ -195,7 +197,7 @@ private:
|
||||
Fm::PathEdit* pathEntry_;
|
||||
Fm::PathBar* pathBar_;
|
||||
QLabel* fsInfoLabel_;
|
||||
Fm::Bookmarks bookmarks_;
|
||||
std::shared_ptr<Fm::Bookmarks> bookmarks_;
|
||||
Launcher fileLauncher_;
|
||||
int rightClickIndex_;
|
||||
bool updatingViewMenu_;
|
||||
|
@ -8,6 +8,8 @@ int main(int argc, char** argv) {
|
||||
qunsetenv("QT_NO_GLIB");
|
||||
|
||||
PCManFM::Application app(argc, argv);
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
|
||||
app.init();
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -27,15 +27,12 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include <libfm-qt/folderview.h>
|
||||
#include <libfm-qt/core/terminal.h>
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
static int bigIconSizes[] = {96, 72, 64, 48, 36, 32, 24, 20};
|
||||
static int smallIconSizes[] = {48, 36, 32, 24, 20, 16, 12};
|
||||
static int thumbnailIconSizes[] = {256, 224, 192, 160, 128, 96, 64};
|
||||
|
||||
PreferencesDialog::PreferencesDialog (QString activePage, QWidget* parent):
|
||||
QDialog (parent) {
|
||||
PreferencesDialog::PreferencesDialog(QString activePage, QWidget* parent):
|
||||
QDialog(parent) {
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
@ -59,13 +56,13 @@ static void findIconThemesInDir(QHash<QString, QString>& iconThemes, QString dir
|
||||
GKeyFile* kf = g_key_file_new();
|
||||
Q_FOREACH(QString subDir, subDirs) {
|
||||
QString indexFile = dirName % '/' % subDir % "/index.theme";
|
||||
if(g_key_file_load_from_file(kf, indexFile.toLocal8Bit().constData(), GKeyFileFlags(0), NULL)) {
|
||||
if(g_key_file_load_from_file(kf, indexFile.toLocal8Bit().constData(), GKeyFileFlags(0), nullptr)) {
|
||||
// FIXME: skip hidden ones
|
||||
// icon theme must have this key, so it has icons if it has this key
|
||||
// otherwise, it might be a cursor theme or any other kind of theme.
|
||||
if(g_key_file_has_key(kf, "Icon Theme", "Directories", NULL)) {
|
||||
char* dispName = g_key_file_get_locale_string(kf, "Icon Theme", "Name", NULL, NULL);
|
||||
// char* comment = g_key_file_get_locale_string(kf, "Icon Theme", "Comment", NULL, NULL);
|
||||
if(g_key_file_has_key(kf, "Icon Theme", "Directories", nullptr)) {
|
||||
char* dispName = g_key_file_get_locale_string(kf, "Icon Theme", "Name", nullptr, nullptr);
|
||||
// char* comment = g_key_file_get_locale_string(kf, "Icon Theme", "Comment", nullptr, nullptr);
|
||||
iconThemes[subDir] = dispName;
|
||||
g_free(dispName);
|
||||
}
|
||||
@ -90,7 +87,7 @@ void PreferencesDialog::initIconThemes(Settings& settings) {
|
||||
|
||||
iconThemes.remove("hicolor"); // remove hicolor, which is only a fallback
|
||||
QHash<QString, QString>::const_iterator it;
|
||||
for(it = iconThemes.begin(); it != iconThemes.end(); ++it) {
|
||||
for(it = iconThemes.constBegin(); it != iconThemes.constEnd(); ++it) {
|
||||
ui.iconTheme->addItem(it.value(), it.key());
|
||||
}
|
||||
ui.iconTheme->model()->sort(0); // sort the list of icon theme names
|
||||
@ -104,8 +101,9 @@ void PreferencesDialog::initIconThemes(Settings& settings) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i >= n)
|
||||
if(i >= n) {
|
||||
i = 0;
|
||||
}
|
||||
ui.iconTheme->setCurrentIndex(i);
|
||||
}
|
||||
else { // auto-detection of icon theme works, hide the fallback icon theme combo box.
|
||||
@ -124,37 +122,45 @@ void PreferencesDialog::initArchivers(Settings& settings) {
|
||||
for(const GList* l = allArchivers; l; l = l->next, ++i) {
|
||||
FmArchiver* archiver = reinterpret_cast<FmArchiver*>(l->data);
|
||||
ui.archiver->addItem(archiver->program, QString(archiver->program));
|
||||
if(archiver->program == settings.archiver())
|
||||
if(archiver->program == settings.archiver()) {
|
||||
ui.archiver->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::initDisplayPage(Settings& settings) {
|
||||
initIconThemes(settings);
|
||||
// icon sizes
|
||||
for(std::size_t i = 0; i < G_N_ELEMENTS(bigIconSizes); ++i) {
|
||||
int size = bigIconSizes[i];
|
||||
int i = 0;
|
||||
for (const auto & size : Settings::iconSizes(Settings::Big)) {
|
||||
ui.bigIconSize->addItem(QString("%1 x %1").arg(size), size);
|
||||
if(settings.bigIconSize() == size)
|
||||
if(settings.bigIconSize() == size) {
|
||||
ui.bigIconSize->setCurrentIndex(i);
|
||||
}
|
||||
for(std::size_t i = 0; i < G_N_ELEMENTS(smallIconSizes); ++i) {
|
||||
int size = smallIconSizes[i];
|
||||
++i;
|
||||
}
|
||||
i = 0;
|
||||
for (const auto & size : Settings::iconSizes(Settings::Small)) {
|
||||
QString text = QString("%1 x %1").arg(size);
|
||||
ui.smallIconSize->addItem(text, size);
|
||||
if(settings.smallIconSize() == size)
|
||||
if(settings.smallIconSize() == size) {
|
||||
ui.smallIconSize->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
ui.sidePaneIconSize->addItem(text, size);
|
||||
if(settings.sidePaneIconSize() == size)
|
||||
if(settings.sidePaneIconSize() == size) {
|
||||
ui.sidePaneIconSize->setCurrentIndex(i);
|
||||
}
|
||||
for(std::size_t i = 0; i < G_N_ELEMENTS(thumbnailIconSizes); ++i) {
|
||||
int size = thumbnailIconSizes[i];
|
||||
++i;
|
||||
}
|
||||
i = 0;
|
||||
for (const auto & size : Settings::iconSizes(Settings::Thumbnail)) {
|
||||
ui.thumbnailIconSize->addItem(QString("%1 x %1").arg(size), size);
|
||||
if(settings.thumbnailIconSize() == size)
|
||||
if(settings.thumbnailIconSize() == size) {
|
||||
ui.thumbnailIconSize->setCurrentIndex(i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
ui.siUnit->setChecked(settings.siUnit());
|
||||
ui.backupAsHidden->setChecked(settings.backupAsHidden());
|
||||
@ -204,8 +210,9 @@ void PreferencesDialog::initBehaviorPage(Settings& settings) {
|
||||
|
||||
ui.configmDelete->setChecked(settings.confirmDelete());
|
||||
|
||||
if(settings.supportTrash())
|
||||
if(settings.supportTrash()) {
|
||||
ui.useTrash->setChecked(settings.useTrash());
|
||||
}
|
||||
else {
|
||||
ui.useTrash->hide();
|
||||
}
|
||||
@ -225,16 +232,19 @@ void PreferencesDialog::initVolumePage(Settings& settings) {
|
||||
ui.mountOnStartup->setChecked(settings.mountOnStartup());
|
||||
ui.mountRemovable->setChecked(settings.mountRemovable());
|
||||
ui.autoRun->setChecked(settings.autoRun());
|
||||
if(settings.closeOnUnmount())
|
||||
if(settings.closeOnUnmount()) {
|
||||
ui.closeOnUnmount->setChecked(true);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui.goHomeOnUnmount->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::initTerminals(Settings& settings) {
|
||||
// load the known terminal list from the terminal.list file of libfm
|
||||
QSettings termlist(LIBFM_DATA_DIR "/terminals.list", QSettings::IniFormat);
|
||||
ui.terminal->addItems(termlist.childGroups());
|
||||
for(auto& terminal: Fm::allKnownTerminals()) {
|
||||
ui.terminal->addItem(terminal.get());
|
||||
}
|
||||
ui.terminal->setEditText(settings.terminal());
|
||||
}
|
||||
|
||||
@ -271,7 +281,7 @@ void PreferencesDialog::applyDisplayPage(Settings& settings) {
|
||||
settings.setFallbackIconThemeName(newIconTheme);
|
||||
QIcon::setThemeName(settings.fallbackIconThemeName());
|
||||
// update the UI by emitting a style change event
|
||||
Q_FOREACH(QWidget *widget, QApplication::allWidgets()) {
|
||||
Q_FOREACH(QWidget* widget, QApplication::allWidgets()) {
|
||||
QEvent event(QEvent::StyleChange);
|
||||
QApplication::sendEvent(widget, &event);
|
||||
}
|
||||
@ -310,8 +320,9 @@ void PreferencesDialog::applyBehaviorPage(Settings& settings) {
|
||||
settings.setViewMode(mode);
|
||||
settings.setConfirmDelete(ui.configmDelete->isChecked());
|
||||
|
||||
if(settings.supportTrash())
|
||||
if(settings.supportTrash()) {
|
||||
settings.setUseTrash(ui.useTrash->isChecked());
|
||||
}
|
||||
|
||||
settings.setNoUsbTrash(ui.noUsbTrash->isChecked());
|
||||
settings.setConfirmTrash(ui.confirmTrash->isChecked());
|
||||
@ -378,8 +389,9 @@ void PreferencesDialog::lockMargins(bool lock) {
|
||||
ui.vMargin->setValue(ui.hMargin->value());
|
||||
connect(ui.hMargin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui.vMargin, &QSpinBox::setValue);
|
||||
}
|
||||
else
|
||||
else {
|
||||
disconnect(ui.hMargin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui.vMargin, &QSpinBox::setValue);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace PCManFM
|
||||
|
@ -25,13 +25,12 @@
|
||||
#include "ui_preferences.h"
|
||||
#include <QString>
|
||||
|
||||
namespace PCManFM
|
||||
{
|
||||
namespace PCManFM {
|
||||
|
||||
class Settings;
|
||||
|
||||
class PreferencesDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// activePage is the name of page to select (general, display, advanced...)
|
||||
|
@ -63,6 +63,10 @@ Settings::Settings():
|
||||
closeOnUnmount_(false),
|
||||
wallpaperMode_(0),
|
||||
wallpaper_(),
|
||||
lastSlide_(),
|
||||
wallpaperDir_(),
|
||||
slideShowInterval_(0),
|
||||
wallpaperRandomize_(false),
|
||||
desktopBgColor_(),
|
||||
desktopFgColor_(),
|
||||
desktopShadowColor_(),
|
||||
@ -115,7 +119,13 @@ Settings::Settings():
|
||||
sidePaneIconSize_(24),
|
||||
thumbnailIconSize_(128),
|
||||
folderViewCellMargins_(QSize(3, 3)),
|
||||
desktopCellMargins_(QSize(3, 1)) {
|
||||
desktopCellMargins_(QSize(3, 1)),
|
||||
searchNameCaseInsensitive_(false),
|
||||
searchContentCaseInsensitive_(false),
|
||||
searchNameRegexp_(true),
|
||||
searchContentRegexp_(true),
|
||||
searchRecursive_(false),
|
||||
searchhHidden_(false) {
|
||||
}
|
||||
|
||||
Settings::~Settings() {
|
||||
@ -126,10 +136,12 @@ 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() != 0) // non-root user
|
||||
if(geteuid() != 0) { // non-root user
|
||||
dirName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||
if (dirName.isEmpty())
|
||||
}
|
||||
if(dirName.isEmpty()) {
|
||||
dirName = QDir::homePath() % QLatin1String("/.config");
|
||||
}
|
||||
return dirName;
|
||||
}
|
||||
|
||||
@ -202,13 +214,19 @@ bool Settings::loadFile(QString filePath) {
|
||||
settings.beginGroup("Desktop");
|
||||
wallpaperMode_ = wallpaperModeFromString(settings.value("WallpaperMode").toString());
|
||||
wallpaper_ = settings.value("Wallpaper").toString();
|
||||
lastSlide_ = settings.value("LastSlide").toString();
|
||||
wallpaperDir_ = settings.value("WallpaperDirectory").toString();
|
||||
slideShowInterval_ = settings.value("SlideShowInterval", 0).toInt();
|
||||
wallpaperRandomize_ = settings.value("WallpaperRandomize").toBool();
|
||||
desktopBgColor_.setNamedColor(settings.value("BgColor", "#000000").toString());
|
||||
desktopFgColor_.setNamedColor(settings.value("FgColor", "#ffffff").toString());
|
||||
desktopShadowColor_.setNamedColor(settings.value("ShadowColor", "#000000").toString());
|
||||
if(settings.contains("Font"))
|
||||
if(settings.contains("Font")) {
|
||||
desktopFont_.fromString(settings.value("Font").toString());
|
||||
else
|
||||
}
|
||||
else {
|
||||
desktopFont_ = QApplication::font();
|
||||
}
|
||||
desktopIconSize_ = settings.value("DesktopIconSize", 48).toInt();
|
||||
showWmMenu_ = settings.value("ShowWmMenu", false).toBool();
|
||||
desktopShowHidden_ = settings.value("ShowHidden", false).toBool();
|
||||
@ -248,10 +266,10 @@ bool Settings::loadFile(QString filePath) {
|
||||
shadowHidden_ = settings.value("ShadowHidden", false).toBool();
|
||||
|
||||
// override config in libfm's FmConfig
|
||||
bigIconSize_ = settings.value("BigIconSize", 48).toInt();
|
||||
smallIconSize_ = settings.value("SmallIconSize", 24).toInt();
|
||||
sidePaneIconSize_ = settings.value("SidePaneIconSize", 24).toInt();
|
||||
thumbnailIconSize_ = settings.value("ThumbnailIconSize", 128).toInt();
|
||||
bigIconSize_ = toIconSize(settings.value("BigIconSize", 48).toInt(), Big);
|
||||
smallIconSize_ = toIconSize(settings.value("SmallIconSize", 24).toInt(), Small);
|
||||
sidePaneIconSize_ = toIconSize(settings.value("SidePaneIconSize", 24).toInt(), Small);
|
||||
thumbnailIconSize_ = toIconSize(settings.value("ThumbnailIconSize", 128).toInt(), Thumbnail);
|
||||
|
||||
folderViewCellMargins_ = (settings.value("FolderViewCellMargins", QSize(3, 3)).toSize()
|
||||
.expandedTo(QSize(0, 0))).boundedTo(QSize(48, 48));
|
||||
@ -283,6 +301,15 @@ bool Settings::loadFile(QString filePath) {
|
||||
pathBarButtons_ = settings.value("PathBarButtons", true).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("Search");
|
||||
searchNameCaseInsensitive_ = settings.value("searchNameCaseInsensitive", false).toBool();
|
||||
searchContentCaseInsensitive_ = settings.value("searchContentCaseInsensitive", false).toBool();
|
||||
searchNameRegexp_ = settings.value("searchNameRegexp", true).toBool();
|
||||
searchContentRegexp_ = settings.value("searchContentRegexp", true).toBool();
|
||||
searchRecursive_ = settings.value("searchRecursive", false).toBool();
|
||||
searchhHidden_ = settings.value("searchhHidden", false).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -319,6 +346,10 @@ bool Settings::saveFile(QString filePath) {
|
||||
settings.beginGroup("Desktop");
|
||||
settings.setValue("WallpaperMode", wallpaperModeToString(wallpaperMode_));
|
||||
settings.setValue("Wallpaper", wallpaper_);
|
||||
settings.setValue("LastSlide", lastSlide_);
|
||||
settings.setValue("WallpaperDirectory", wallpaperDir_);
|
||||
settings.setValue("SlideShowInterval", slideShowInterval_);
|
||||
settings.setValue("WallpaperRandomize", wallpaperRandomize_);
|
||||
settings.setValue("BgColor", desktopBgColor_.name());
|
||||
settings.setValue("FgColor", desktopFgColor_.name());
|
||||
settings.setValue("ShadowColor", desktopShadowColor_.name());
|
||||
@ -396,9 +427,46 @@ bool Settings::saveFile(QString filePath) {
|
||||
// save per-folder settings
|
||||
Fm::FolderConfig::saveCache();
|
||||
|
||||
settings.beginGroup("Search");
|
||||
settings.setValue("searchNameCaseInsensitive", searchNameCaseInsensitive_);
|
||||
settings.setValue("searchContentCaseInsensitive", searchContentCaseInsensitive_);
|
||||
settings.setValue("searchNameRegexp", searchNameRegexp_);
|
||||
settings.setValue("searchContentRegexp", searchContentRegexp_);
|
||||
settings.setValue("searchRecursive", searchRecursive_);
|
||||
settings.setValue("searchhHidden", searchhHidden_);
|
||||
settings.endGroup();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const QList<int> & Settings::iconSizes(IconType type) {
|
||||
static const QList<int> sizes_big = {96, 72, 64, 48, 32};
|
||||
static const QList<int> sizes_thumbnail = {256, 224, 192, 160, 128, 96, 64};
|
||||
static const QList<int> sizes_small = {48, 32, 24, 22, 16};
|
||||
switch(type) {
|
||||
case Big:
|
||||
return sizes_big;
|
||||
break;
|
||||
case Thumbnail:
|
||||
return sizes_thumbnail;
|
||||
break;
|
||||
case Small:
|
||||
default:
|
||||
return sizes_small;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int Settings::toIconSize(int size, IconType type) const {
|
||||
const QList<int> & sizes = iconSizes(type);
|
||||
for (const auto & s : sizes) {
|
||||
if(size >= s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return sizes.back();
|
||||
}
|
||||
|
||||
static const char* bookmarkOpenMethodToString(OpenDirTargetType value) {
|
||||
switch(value) {
|
||||
case OpenInCurrentTab:
|
||||
@ -416,12 +484,15 @@ static const char* bookmarkOpenMethodToString(OpenDirTargetType value) {
|
||||
|
||||
static OpenDirTargetType bookmarkOpenMethodFromString(const QString str) {
|
||||
|
||||
if(str == QStringLiteral("new_tab"))
|
||||
if(str == QStringLiteral("new_tab")) {
|
||||
return OpenInNewTab;
|
||||
else if(str == QStringLiteral("new_window"))
|
||||
}
|
||||
else if(str == QStringLiteral("new_window")) {
|
||||
return OpenInNewWindow;
|
||||
else if(str == QStringLiteral("last_window"))
|
||||
}
|
||||
else if(str == QStringLiteral("last_window")) {
|
||||
return OpenInLastActiveWindow;
|
||||
}
|
||||
return OpenInCurrentTab;
|
||||
}
|
||||
|
||||
@ -447,16 +518,21 @@ static const char* viewModeToString(Fm::FolderView::ViewMode value) {
|
||||
|
||||
Fm::FolderView::ViewMode viewModeFromString(const QString str) {
|
||||
Fm::FolderView::ViewMode ret;
|
||||
if(str == "icon")
|
||||
if(str == "icon") {
|
||||
ret = Fm::FolderView::IconMode;
|
||||
else if(str == "compact")
|
||||
}
|
||||
else if(str == "compact") {
|
||||
ret = Fm::FolderView::CompactMode;
|
||||
else if(str == "detailed")
|
||||
}
|
||||
else if(str == "detailed") {
|
||||
ret = Fm::FolderView::DetailedListMode;
|
||||
else if(str == "thumbnail")
|
||||
}
|
||||
else if(str == "thumbnail") {
|
||||
ret = Fm::FolderView::ThumbnailMode;
|
||||
else
|
||||
}
|
||||
else {
|
||||
ret = Fm::FolderView::IconMode;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -493,18 +569,24 @@ static const char* sortColumnToString(Fm::FolderModel::ColumnId value) {
|
||||
|
||||
static Fm::FolderModel::ColumnId sortColumnFromString(const QString str) {
|
||||
Fm::FolderModel::ColumnId ret;
|
||||
if(str == "name")
|
||||
if(str == "name") {
|
||||
ret = Fm::FolderModel::ColumnFileName;
|
||||
else if(str == "type")
|
||||
}
|
||||
else if(str == "type") {
|
||||
ret = Fm::FolderModel::ColumnFileType;
|
||||
else if(str == "size")
|
||||
}
|
||||
else if(str == "size") {
|
||||
ret = Fm::FolderModel::ColumnFileSize;
|
||||
else if(str == "mtime")
|
||||
}
|
||||
else if(str == "mtime") {
|
||||
ret = Fm::FolderModel::ColumnFileMTime;
|
||||
else if(str == "owner")
|
||||
}
|
||||
else if(str == "owner") {
|
||||
ret = Fm::FolderModel::ColumnFileOwner;
|
||||
else
|
||||
}
|
||||
else {
|
||||
ret = Fm::FolderModel::ColumnFileName;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -536,18 +618,24 @@ static const char* wallpaperModeToString(int value) {
|
||||
|
||||
static int wallpaperModeFromString(const QString str) {
|
||||
int ret;
|
||||
if(str == "stretch")
|
||||
if(str == "stretch") {
|
||||
ret = DesktopWindow::WallpaperStretch;
|
||||
else if(str == "fit")
|
||||
}
|
||||
else if(str == "fit") {
|
||||
ret = DesktopWindow::WallpaperFit;
|
||||
else if(str == "center")
|
||||
}
|
||||
else if(str == "center") {
|
||||
ret = DesktopWindow::WallpaperCenter;
|
||||
else if(str == "tile")
|
||||
}
|
||||
else if(str == "tile") {
|
||||
ret = DesktopWindow::WallpaperTile;
|
||||
else if(str == "zoom")
|
||||
}
|
||||
else if(str == "zoom") {
|
||||
ret = DesktopWindow::WallpaperZoom;
|
||||
else
|
||||
}
|
||||
else {
|
||||
ret = DesktopWindow::WallpaperNone;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -570,12 +658,15 @@ static const char* sidePaneModeToString(Fm::SidePane::Mode value) {
|
||||
|
||||
static Fm::SidePane::Mode sidePaneModeFromString(const QString& str) {
|
||||
Fm::SidePane::Mode ret;
|
||||
if(str == "none")
|
||||
if(str == "none") {
|
||||
ret = Fm::SidePane::ModeNone;
|
||||
else if(str == "dirtree")
|
||||
}
|
||||
else if(str == "dirtree") {
|
||||
ret = Fm::SidePane::ModeDirTree;
|
||||
else
|
||||
}
|
||||
else {
|
||||
ret = Fm::SidePane::ModePlaces;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -589,7 +680,7 @@ void Settings::setTerminal(QString terminalCommand) {
|
||||
|
||||
|
||||
// per-folder settings
|
||||
FolderSettings Settings::loadFolderSettings(Fm::Path path) const {
|
||||
FolderSettings Settings::loadFolderSettings(const Fm::FilePath& path) const {
|
||||
FolderSettings settings;
|
||||
Fm::FolderConfig cfg(path);
|
||||
// set defaults
|
||||
@ -643,8 +734,8 @@ FolderSettings Settings::loadFolderSettings(Fm::Path path) const {
|
||||
return settings;
|
||||
}
|
||||
|
||||
void Settings::saveFolderSettings(Fm::Path path, const FolderSettings& settings) {
|
||||
if(!path.isNull()) {
|
||||
void Settings::saveFolderSettings(const Fm::FilePath& path, const FolderSettings& settings) {
|
||||
if(path) {
|
||||
// ensure that we have the libfm dir
|
||||
QString dirName = xdgUserConfigDir() % QStringLiteral("/libfm");
|
||||
QDir().mkpath(dirName); // if libfm config dir does not exist, create it
|
||||
@ -659,8 +750,8 @@ void Settings::saveFolderSettings(Fm::Path path, const FolderSettings& settings)
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::clearFolderSettings(Fm::Path path) const {
|
||||
if(!path.isNull()) {
|
||||
void Settings::clearFolderSettings(const Fm::FilePath& path) const {
|
||||
if(path) {
|
||||
Fm::FolderConfig cfg(path);
|
||||
cfg.purge();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <libfm-qt/foldermodel.h>
|
||||
#include "desktopwindow.h"
|
||||
#include <libfm-qt/sidepane.h>
|
||||
#include <libfm-qt/thumbnailloader.h>
|
||||
#include <libfm-qt/core/thumbnailjob.h>
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
@ -121,6 +121,12 @@ private:
|
||||
class Settings : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum IconType {
|
||||
Small,
|
||||
Big,
|
||||
Thumbnail
|
||||
};
|
||||
|
||||
Settings();
|
||||
virtual ~Settings();
|
||||
|
||||
@ -131,6 +137,7 @@ public:
|
||||
bool saveFile(QString filePath);
|
||||
|
||||
static QString xdgUserConfigDir();
|
||||
static const QList<int> & iconSizes(IconType type);
|
||||
|
||||
QString profileDir(QString profile, bool useFallback = false);
|
||||
|
||||
@ -235,6 +242,38 @@ public:
|
||||
wallpaper_ = wallpaper;
|
||||
}
|
||||
|
||||
QString wallpaperDir() const {
|
||||
return wallpaperDir_;
|
||||
}
|
||||
|
||||
void setLastSlide(QString wallpaper) {
|
||||
lastSlide_ = wallpaper;
|
||||
}
|
||||
|
||||
QString lastSlide() const {
|
||||
return lastSlide_;
|
||||
}
|
||||
|
||||
void setWallpaperDir(QString dir) {
|
||||
wallpaperDir_ = dir;
|
||||
}
|
||||
|
||||
int slideShowInterval() const {
|
||||
return slideShowInterval_;
|
||||
}
|
||||
|
||||
void setSlideShowInterval(int interval) {
|
||||
slideShowInterval_ = interval;
|
||||
}
|
||||
|
||||
bool wallpaperRandomize() const {
|
||||
return wallpaperRandomize_;
|
||||
}
|
||||
|
||||
void setWallpaperRandomize(bool randomize) {
|
||||
wallpaperRandomize_ = randomize;
|
||||
}
|
||||
|
||||
const QColor& desktopBgColor() const {
|
||||
return desktopBgColor_;
|
||||
}
|
||||
@ -340,25 +379,31 @@ public:
|
||||
}
|
||||
|
||||
int windowWidth() const {
|
||||
if(rememberWindowSize_)
|
||||
if(rememberWindowSize_) {
|
||||
return lastWindowWidth_;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return fixedWindowWidth_;
|
||||
}
|
||||
}
|
||||
|
||||
int windowHeight() const {
|
||||
if(rememberWindowSize_)
|
||||
if(rememberWindowSize_) {
|
||||
return lastWindowHeight_;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return fixedWindowHeight_;
|
||||
}
|
||||
}
|
||||
|
||||
bool windowMaximized() const {
|
||||
if(rememberWindowSize_)
|
||||
if(rememberWindowSize_) {
|
||||
return lastWindowMaximized_;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int fixedWindowWidth() const {
|
||||
return fixedWindowWidth_;
|
||||
@ -560,8 +605,9 @@ public:
|
||||
}
|
||||
|
||||
bool useTrash() const {
|
||||
if(!supportTrash_)
|
||||
if(!supportTrash_) {
|
||||
return false;
|
||||
}
|
||||
return useTrash_;
|
||||
}
|
||||
|
||||
@ -660,19 +706,19 @@ public:
|
||||
}
|
||||
|
||||
void setThumbnailLocalFilesOnly(bool value) {
|
||||
Fm::ThumbnailLoader::setLocalFilesOnly(value);
|
||||
Fm::ThumbnailJob::setLocalFilesOnly(value);
|
||||
}
|
||||
|
||||
bool thumbnailLocalFilesOnly() {
|
||||
return Fm::ThumbnailLoader::localFilesOnly();
|
||||
bool thumbnailLocalFilesOnly() const {
|
||||
return Fm::ThumbnailJob::localFilesOnly();
|
||||
}
|
||||
|
||||
int maxThumbnailFileSize() {
|
||||
return Fm::ThumbnailLoader::maxThumbnailFileSize();
|
||||
int maxThumbnailFileSize() const {
|
||||
return Fm::ThumbnailJob::maxThumbnailFileSize();
|
||||
}
|
||||
|
||||
void setMaxThumbnailFileSize(int size) {
|
||||
Fm::ThumbnailLoader::setMaxThumbnailFileSize(size);
|
||||
Fm::ThumbnailJob::setMaxThumbnailFileSize(size);
|
||||
}
|
||||
|
||||
void setThumbnailIconSize(int thumbnailIconSize) {
|
||||
@ -742,13 +788,63 @@ public:
|
||||
}
|
||||
|
||||
// per-folder settings
|
||||
FolderSettings loadFolderSettings(Fm::Path path) const;
|
||||
FolderSettings loadFolderSettings(const Fm::FilePath& path) const;
|
||||
|
||||
void saveFolderSettings(Fm::Path path, const FolderSettings &settings);
|
||||
void saveFolderSettings(const Fm::FilePath& path, const FolderSettings& settings);
|
||||
|
||||
void clearFolderSettings(Fm::Path path) const;
|
||||
void clearFolderSettings(const Fm::FilePath& path) const;
|
||||
|
||||
bool searchNameCaseInsensitive() const {
|
||||
return searchNameCaseInsensitive_;
|
||||
}
|
||||
|
||||
void setSearchNameCaseInsensitive(bool caseInsensitive) {
|
||||
searchNameCaseInsensitive_ = caseInsensitive;
|
||||
}
|
||||
|
||||
bool searchContentCaseInsensitive() const {
|
||||
return searchContentCaseInsensitive_;
|
||||
}
|
||||
|
||||
void setsearchContentCaseInsensitive(bool caseInsensitive) {
|
||||
searchContentCaseInsensitive_ = caseInsensitive;
|
||||
}
|
||||
|
||||
bool searchNameRegexp() const {
|
||||
return searchNameRegexp_;
|
||||
}
|
||||
|
||||
void setSearchNameRegexp(bool reg) {
|
||||
searchNameRegexp_ = reg;
|
||||
}
|
||||
|
||||
bool searchContentRegexp() const {
|
||||
return searchContentRegexp_;
|
||||
}
|
||||
|
||||
void setSearchContentRegexp(bool reg) {
|
||||
searchContentRegexp_ = reg;
|
||||
}
|
||||
|
||||
bool searchRecursive() const {
|
||||
return searchRecursive_;
|
||||
}
|
||||
|
||||
void setSearchRecursive(bool rec) {
|
||||
searchRecursive_ = rec;
|
||||
}
|
||||
|
||||
bool searchhHidden() const {
|
||||
return searchhHidden_;
|
||||
}
|
||||
|
||||
void setSearchhHidden(bool hidden) {
|
||||
searchhHidden_ = hidden;
|
||||
}
|
||||
|
||||
private:
|
||||
int toIconSize(int size, IconType type) const;
|
||||
|
||||
QString profileName_;
|
||||
bool supportTrash_;
|
||||
|
||||
@ -766,6 +862,10 @@ private:
|
||||
|
||||
int wallpaperMode_;
|
||||
QString wallpaper_;
|
||||
QString lastSlide_;
|
||||
QString wallpaperDir_;
|
||||
int slideShowInterval_;
|
||||
bool wallpaperRandomize_;
|
||||
QColor desktopBgColor_;
|
||||
QColor desktopFgColor_;
|
||||
QColor desktopShadowColor_;
|
||||
@ -836,6 +936,14 @@ private:
|
||||
|
||||
QSize folderViewCellMargins_;
|
||||
QSize desktopCellMargins_;
|
||||
|
||||
// search settings
|
||||
bool searchNameCaseInsensitive_;
|
||||
bool searchContentCaseInsensitive_;
|
||||
bool searchNameRegexp_;
|
||||
bool searchContentRegexp_;
|
||||
bool searchRecursive_;
|
||||
bool searchhHidden_;
|
||||
};
|
||||
|
||||
}
|
||||
|
96
pcmanfm/statusbar.cpp
Normal file
96
pcmanfm/statusbar.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "statusbar.h"
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#define MESSAGE_DELAY 250
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
Label::Label(QWidget* parent, Qt::WindowFlags f):
|
||||
QLabel(parent, f),
|
||||
lastWidth_(0) {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
// set a min width to prevent the window from widening with long texts
|
||||
setMinimumWidth(fontMetrics().averageCharWidth() * 10);
|
||||
}
|
||||
|
||||
// A simplified version of QLabel::paintEvent()
|
||||
// without pixmap or shortcut but with eliding.
|
||||
void Label::paintEvent(QPaintEvent* /*event*/) {
|
||||
QRect cr = contentsRect().adjusted(margin(), margin(), -margin(), -margin());
|
||||
QString txt = text();
|
||||
// if the text is changed or its rect is resized (due to window resizing),
|
||||
// find whether it needs to be elided...
|
||||
if (txt != lastText_ || cr.width() != lastWidth_) {
|
||||
lastText_ = txt;
|
||||
lastWidth_ = cr.width();
|
||||
elidedText_ = fontMetrics().elidedText(txt, Qt::ElideMiddle, cr.width());
|
||||
}
|
||||
// ... then, draw the (elided) text
|
||||
if(!elidedText_.isEmpty()) {
|
||||
QPainter painter(this);
|
||||
QStyleOption opt;
|
||||
opt.initFrom(this);
|
||||
style()->drawItemText(&painter, cr, alignment(), opt.palette, isEnabled(), elidedText_, foregroundRole());
|
||||
}
|
||||
}
|
||||
|
||||
StatusBar::StatusBar(QWidget *parent):
|
||||
QStatusBar(parent),
|
||||
lastTimeOut_(0) {
|
||||
statusLabel_ = new Label();
|
||||
statusLabel_->setFrameShape(QFrame::NoFrame);
|
||||
// 4px space on both sides (not to be mixed with the permanent widget)
|
||||
statusLabel_->setContentsMargins(4, 0, 4, 0);
|
||||
addWidget(statusLabel_);
|
||||
|
||||
messageTimer_ = new QTimer (this);
|
||||
messageTimer_->setSingleShot(true);
|
||||
messageTimer_->setInterval(MESSAGE_DELAY);
|
||||
connect(messageTimer_, &QTimer::timeout, this, &StatusBar::reallyShowMessage);
|
||||
}
|
||||
|
||||
StatusBar::~StatusBar() {
|
||||
if(messageTimer_) {
|
||||
messageTimer_->stop();
|
||||
delete messageTimer_;
|
||||
}
|
||||
}
|
||||
|
||||
void StatusBar::showMessage(const QString &message, int timeout) {
|
||||
// don't show the message immediately
|
||||
lastMessage_ = message;
|
||||
lastTimeOut_ = timeout;
|
||||
if(!messageTimer_->isActive()) {
|
||||
messageTimer_->start();
|
||||
}
|
||||
}
|
||||
|
||||
void StatusBar::reallyShowMessage() {
|
||||
if(lastTimeOut_ == 0) {
|
||||
// set the text on the label to prevent its disappearance on focusing menubar items
|
||||
// and also ensure that it contsains no newline (because file names may contain it)
|
||||
statusLabel_->setText(lastMessage_.replace(QLatin1Char('\n'), QLatin1Char(' ')));
|
||||
}
|
||||
else {
|
||||
QStatusBar::showMessage(lastMessage_, lastTimeOut_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
63
pcmanfm/statusbar.h
Normal file
63
pcmanfm/statusbar.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef FM_STATUSBAR_H
|
||||
#define FM_STATUSBAR_H
|
||||
|
||||
#include <QStatusBar>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
class Label : public QLabel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Label(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
QString elidedText_;
|
||||
QString lastText_;
|
||||
int lastWidth_;
|
||||
};
|
||||
|
||||
class StatusBar : public QStatusBar {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StatusBar(QWidget *parent = 0);
|
||||
~StatusBar();
|
||||
|
||||
public Q_SLOTS:
|
||||
void showMessage(const QString &message, int timeout = 0);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void reallyShowMessage();
|
||||
|
||||
private:
|
||||
Label* statusLabel_; // for a stable (elided) text
|
||||
QTimer* messageTimer_;
|
||||
QString lastMessage_;
|
||||
int lastTimeOut_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FM_STATUSBAR_H
|
@ -24,11 +24,13 @@
|
||||
#include <libfm-qt/mountoperation.h>
|
||||
#include <libfm-qt/proxyfoldermodel.h>
|
||||
#include <libfm-qt/cachedfoldermodel.h>
|
||||
#include <libfm-qt/fileinfo.h>
|
||||
#include <libfm-qt/core/fileinfo.h>
|
||||
#include <libfm-qt/utilities.h>
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QDir>
|
||||
#include "settings.h"
|
||||
#include "application.h"
|
||||
#include <QTimer>
|
||||
@ -39,42 +41,50 @@ using namespace Fm;
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
bool ProxyFilter::filterAcceptsRow(const Fm::ProxyFolderModel* model, FmFileInfo* info) const {
|
||||
if(!model || !info)
|
||||
bool ProxyFilter::filterAcceptsRow(const Fm::ProxyFolderModel* model, const std::shared_ptr<const Fm::FileInfo>& info) const {
|
||||
if(!model || !info) {
|
||||
return true;
|
||||
QString baseName(fm_file_info_get_name(info));
|
||||
if(!virtHiddenList_.isEmpty() && !model->showHidden() && virtHiddenList_.contains(baseName))
|
||||
}
|
||||
QString baseName = QString::fromStdString(info->name());
|
||||
if(!virtHiddenList_.isEmpty() && !model->showHidden() && virtHiddenList_.contains(baseName)) {
|
||||
return false;
|
||||
if(!filterStr_.isEmpty() && !baseName.contains(filterStr_, Qt::CaseInsensitive))
|
||||
}
|
||||
if(!filterStr_.isEmpty() && !baseName.contains(filterStr_, Qt::CaseInsensitive)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProxyFilter::setVirtHidden(Fm::Folder folder) {
|
||||
void ProxyFilter::setVirtHidden(const std::shared_ptr<Fm::Folder> &folder) {
|
||||
virtHiddenList_ = QStringList(); // reset the list
|
||||
if(folder.isNull())
|
||||
if(!folder) {
|
||||
return;
|
||||
Fm::Path path = folder.getPath();
|
||||
if(!path.isNull()) {
|
||||
char* pathStr = path.toStr();
|
||||
}
|
||||
auto path = folder->path();
|
||||
if(path) {
|
||||
auto pathStr = path.localPath();
|
||||
if(pathStr) {
|
||||
QString dotHidden = QString::fromUtf8(pathStr) + QString("/.hidden");
|
||||
g_free(pathStr);
|
||||
QString dotHidden = QString::fromUtf8(pathStr.get()) + QString("/.hidden");
|
||||
// FIXME: this does not work for non-local filesystems
|
||||
QFile file(dotHidden);
|
||||
if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&file);
|
||||
while(!in.atEnd())
|
||||
while(!in.atEnd()) {
|
||||
virtHiddenList_.append(in.readLine());
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TabPage::TabPage(Fm::Path path, QWidget* parent):
|
||||
TabPage::TabPage(QWidget* parent):
|
||||
QWidget(parent),
|
||||
folderModel_(NULL),
|
||||
folderView_{nullptr},
|
||||
folderModel_{nullptr},
|
||||
proxyModel_{nullptr},
|
||||
proxyFilter_{nullptr},
|
||||
verticalLayout{nullptr},
|
||||
overrideCursor_(false) {
|
||||
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
@ -91,7 +101,7 @@ TabPage::TabPage(Fm::Path path, QWidget* parent):
|
||||
folderView_ = new View(settings.viewMode(), this);
|
||||
folderView_->setMargins(settings.folderViewCellMargins());
|
||||
// newView->setColumnWidth(Fm::FolderModel::ColumnName, 200);
|
||||
connect(folderView_, &View::openDirRequested, this, &TabPage::onOpenDirRequested);
|
||||
connect(folderView_, &View::openDirRequested, this, &TabPage::openDirRequested);
|
||||
connect(folderView_, &View::selChanged, this, &TabPage::onSelChanged);
|
||||
connect(folderView_, &View::clickedBack, this, &TabPage::backwardRequested);
|
||||
connect(folderView_, &View::clickedForward, this, &TabPage::forwardRequested);
|
||||
@ -102,18 +112,20 @@ TabPage::TabPage(Fm::Path path, QWidget* parent):
|
||||
// FIXME: this is very dirty
|
||||
folderView_->setModel(proxyModel_);
|
||||
verticalLayout->addWidget(folderView_);
|
||||
|
||||
chdir(path, true);
|
||||
}
|
||||
|
||||
TabPage::~TabPage() {
|
||||
freeFolder();
|
||||
if(proxyFilter_)
|
||||
if(proxyFilter_) {
|
||||
delete proxyFilter_;
|
||||
if(proxyModel_)
|
||||
}
|
||||
if(proxyModel_) {
|
||||
delete proxyModel_;
|
||||
if(folderModel_)
|
||||
}
|
||||
disconnect(folderModel_, &Fm::FolderModel::fileSizeChanged, this, &TabPage::onFileSizeChanged);
|
||||
if(folderModel_) {
|
||||
folderModel_->unref();
|
||||
}
|
||||
|
||||
if(overrideCursor_) {
|
||||
QApplication::restoreOverrideCursor(); // remove busy cursor
|
||||
@ -121,30 +133,24 @@ TabPage::~TabPage() {
|
||||
}
|
||||
|
||||
void TabPage::freeFolder() {
|
||||
if(!folder_.isNull()) {
|
||||
if(folder_) {
|
||||
if(folderSettings_.isCustomized()) {
|
||||
// save custom view settings for this folder
|
||||
static_cast<Application*>(qApp)->settings().saveFolderSettings(folder_.getPath(), folderSettings_);
|
||||
static_cast<Application*>(qApp)->settings().saveFolderSettings(folder_->path(), 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);
|
||||
g_signal_handlers_disconnect_by_func(folder_, (gpointer)onFolderFsInfo, this);
|
||||
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);
|
||||
disconnect(folder_.get(), nullptr, this, nullptr); // disconnect from all signals
|
||||
folder_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void TabPage::onFolderStartLoading(FmFolder* _folder, TabPage* pThis) {
|
||||
if(!pThis->overrideCursor_) {
|
||||
void TabPage::onFolderStartLoading() {
|
||||
if(!overrideCursor_) {
|
||||
// FIXME: sometimes FmFolder of libfm generates unpaired "start-loading" and
|
||||
// "finish-loading" signals of uncertain reasons. This should be a bug in libfm.
|
||||
// Until it's fixed in libfm, we need to workaround the problem here, not to
|
||||
// override the cursor twice.
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
pThis->overrideCursor_ = true;
|
||||
overrideCursor_ = true;
|
||||
}
|
||||
#if 0
|
||||
#if FM_CHECK_VERSION(1, 0, 2) && 0 // disabled
|
||||
@ -161,35 +167,44 @@ void TabPage::freeFolder() {
|
||||
}
|
||||
else
|
||||
#endif
|
||||
fm_folder_view_set_model(fv, NULL);
|
||||
fm_folder_view_set_model(fv, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
// slot
|
||||
void TabPage::restoreScrollPos() {
|
||||
void TabPage::onUiUpdated() {
|
||||
// scroll to recorded position
|
||||
folderView_->childView()->verticalScrollBar()->setValue(browseHistory().currentScrollPos());
|
||||
|
||||
// if the current folder is the parent folder of the last browsed folder,
|
||||
// select the folder item in current view.
|
||||
if(!lastFolderPath_.isNull() && lastFolderPath_.getParent() == path()) {
|
||||
if(lastFolderPath_ && lastFolderPath_.parent() == path()) {
|
||||
QModelIndex index = folderView_->indexFromFolderPath(lastFolderPath_);
|
||||
if(index.isValid()) {
|
||||
folderView_->childView()->scrollTo(index, QAbstractItemView::EnsureVisible);
|
||||
folderView_->childView()->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
// update selection statusbar info when needed
|
||||
connect(folderModel_, &Fm::FolderModel::fileSizeChanged, this, &TabPage::onFileSizeChanged);
|
||||
}
|
||||
|
||||
/*static*/ void TabPage::onFolderFinishLoading(FmFolder* _folder, TabPage* pThis) {
|
||||
// FIXME: is this needed?
|
||||
FmFileInfo* fi = fm_folder_get_info(_folder);
|
||||
void TabPage::onFileSizeChanged(const QModelIndex& index) {
|
||||
if(folderView_->hasSelection()) {
|
||||
QModelIndexList indexes = folderView_->selectionModel()->selectedIndexes();
|
||||
if(indexes.contains(proxyModel_->mapFromSource(index))) {
|
||||
onSelChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabPage::onFolderFinishLoading() {
|
||||
auto fi = folder_->info();
|
||||
if(fi) { // if loading of the folder fails, it's possible that we don't have FmFileInfo.
|
||||
pThis->title_ = QString::fromUtf8(fm_file_info_get_disp_name(fi));
|
||||
Q_EMIT pThis->titleChanged(pThis->title_);
|
||||
setWindowTitle(fi->displayName());
|
||||
Q_EMIT titleChanged(fi->displayName());
|
||||
}
|
||||
|
||||
fm_folder_query_filesystem_info(_folder); // FIXME: is this needed?
|
||||
folder_->queryFilesystemInfo(); // FIXME: is this needed?
|
||||
#if 0
|
||||
FmFolderView* fv = folder_view;
|
||||
const FmNavHistoryItem* item;
|
||||
@ -202,7 +217,7 @@ void TabPage::restoreScrollPos() {
|
||||
* and create the model again when it's fully loaded.
|
||||
* This optimization, however, is not used for FmFolder objects
|
||||
* with incremental loading (search://) */
|
||||
if(fm_folder_view_get_model(fv) == NULL) {
|
||||
if(fm_folder_view_get_model(fv) == nullptr) {
|
||||
/* create a model for the folder and set it to the view */
|
||||
FmFolderModel* model = fm_folder_model_new(folder, app_config->show_hidden);
|
||||
fm_folder_view_set_model(fv, model);
|
||||
@ -218,26 +233,26 @@ void TabPage::restoreScrollPos() {
|
||||
#endif
|
||||
|
||||
// update status text
|
||||
QString& text = pThis->statusText_[StatusTextNormal];
|
||||
text = pThis->formatStatusText();
|
||||
Q_EMIT pThis->statusChanged(StatusTextNormal, text);
|
||||
QString& text = statusText_[StatusTextNormal];
|
||||
text = formatStatusText();
|
||||
Q_EMIT statusChanged(StatusTextNormal, text);
|
||||
|
||||
if(pThis->overrideCursor_) {
|
||||
if(overrideCursor_) {
|
||||
QApplication::restoreOverrideCursor(); // remove busy cursor
|
||||
pThis->overrideCursor_ = false;
|
||||
overrideCursor_ = false;
|
||||
}
|
||||
|
||||
// After finishing loading the folder, the model is updated, but Qt delays the UI update
|
||||
// for performance reasons. Therefore at this point the UI is not up to date.
|
||||
// Of course, the scrollbar ranges are not updated yet. We solve this by installing an Qt timeout handler.
|
||||
QTimer::singleShot(10, pThis, SLOT(restoreScrollPos()));
|
||||
// For example, the scrollbar ranges are not updated yet. We solve this by installing an Qt timeout handler.
|
||||
QTimer::singleShot(10, this, SLOT(onUiUpdated()));
|
||||
}
|
||||
|
||||
/*static*/ FmJobErrorAction TabPage::onFolderError(FmFolder* _folder, GError* err, FmJobErrorSeverity severity, TabPage* pThis) {
|
||||
if(err->domain == G_IO_ERROR) {
|
||||
if(err->code == G_IO_ERROR_NOT_MOUNTED && severity < FM_JOB_ERROR_CRITICAL) {
|
||||
FmPath* path = fm_folder_get_path(_folder);
|
||||
MountOperation* op = new MountOperation(pThis);
|
||||
void TabPage::onFolderError(const Fm::GErrorPtr& err, Fm::Job::ErrorSeverity severity, Fm::Job::ErrorAction& response) {
|
||||
if(err.domain() == G_IO_ERROR) {
|
||||
if(err.code() == G_IO_ERROR_NOT_MOUNTED && severity < Fm::Job::ErrorSeverity::CRITICAL) {
|
||||
auto& path = folder_->path();
|
||||
MountOperation* op = new MountOperation(this);
|
||||
op->mount(path);
|
||||
if(op->wait()) { // blocking event loop, wait for mount operation to finish.
|
||||
// This will reload the folder, which generates a new "start-loading"
|
||||
@ -246,12 +261,13 @@ void TabPage::restoreScrollPos() {
|
||||
// Because the two signals are not correctly paired, we need to
|
||||
// remove busy cursor here since "finish-loading" is not emitted.
|
||||
QApplication::restoreOverrideCursor(); // remove busy cursor
|
||||
pThis->overrideCursor_ = false;
|
||||
return FM_JOB_RETRY;
|
||||
overrideCursor_ = false;
|
||||
response = Fm::Job::ErrorAction::RETRY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(severity >= FM_JOB_ERROR_MODERATE) {
|
||||
if(severity >= Fm::Job::ErrorSeverity::MODERATE) {
|
||||
/* Only show more severe errors to the users and
|
||||
* ignore milder errors. Otherwise too many error
|
||||
* message boxes can be annoying.
|
||||
@ -260,15 +276,15 @@ void TabPage::restoreScrollPos() {
|
||||
* */
|
||||
|
||||
// FIXME: consider replacing this modal dialog with an info bar to improve usability
|
||||
QMessageBox::critical(pThis, tr("Error"), QString::fromUtf8(err->message));
|
||||
QMessageBox::critical(this, tr("Error"), err.message());
|
||||
}
|
||||
return FM_JOB_CONTINUE;
|
||||
response = Fm::Job::ErrorAction::CONTINUE;
|
||||
}
|
||||
|
||||
/*static*/ void TabPage::onFolderFsInfo(FmFolder* _folder, TabPage* pThis) {
|
||||
void TabPage::onFolderFsInfo() {
|
||||
guint64 free, total;
|
||||
QString& msg = pThis->statusText_[StatusTextFSInfo];
|
||||
if(fm_folder_get_filesystem_info(_folder, &total, &free)) {
|
||||
QString& msg = statusText_[StatusTextFSInfo];
|
||||
if(folder_->getFilesystemInfo(&total, &free)) {
|
||||
char total_str[64];
|
||||
char free_str[64];
|
||||
fm_file_size_to_str(free_str, sizeof(free_str), free, fm_config->si_unit);
|
||||
@ -277,78 +293,90 @@ void TabPage::restoreScrollPos() {
|
||||
.arg(QString::fromUtf8(free_str))
|
||||
.arg(QString::fromUtf8(total_str));
|
||||
}
|
||||
else
|
||||
else {
|
||||
msg.clear();
|
||||
Q_EMIT pThis->statusChanged(StatusTextFSInfo, msg);
|
||||
}
|
||||
Q_EMIT statusChanged(StatusTextFSInfo, msg);
|
||||
}
|
||||
|
||||
QString TabPage::formatStatusText() {
|
||||
if(proxyModel_ && !folder_.isNull()) {
|
||||
Fm::FileInfoList files = folder_.getFiles();
|
||||
int total_files = fm_file_info_list_get_length(files);
|
||||
if(proxyModel_ && folder_) {
|
||||
// FIXME: this is very inefficient
|
||||
auto files = folder_->files();
|
||||
int total_files = files.size();
|
||||
int shown_files = proxyModel_->rowCount();
|
||||
int hidden_files = total_files - shown_files;
|
||||
QString text = tr("%n item(s)", "", shown_files);
|
||||
if(hidden_files > 0)
|
||||
if(hidden_files > 0) {
|
||||
text += tr(" (%n hidden)", "", hidden_files);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*static*/ void TabPage::onFolderRemoved(FmFolder* _folder, TabPage* pThis) {
|
||||
void TabPage::onFolderRemoved() {
|
||||
// the folder we're showing is removed, destroy the widget
|
||||
qDebug("folder removed");
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
// NOTE: call pThis->deleteLater() directly from this GObject signal handler
|
||||
// NOTE: call deleteLater() directly from this GObject signal handler
|
||||
// does not work but I don't know why.
|
||||
// Maybe it's the problem of glib mainloop integration?
|
||||
// Call it when idle works, though.
|
||||
if(settings.closeOnUnmount())
|
||||
QTimer::singleShot(0, pThis, SLOT(deleteLater()));
|
||||
else
|
||||
pThis->chdir(Fm::Path::getHome());
|
||||
if(settings.closeOnUnmount()) {
|
||||
QTimer::singleShot(0, this, SLOT(deleteLater()));
|
||||
}
|
||||
else {
|
||||
chdir(Fm::FilePath::homeDir());
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void TabPage::onFolderUnmount(FmFolder* _folder, TabPage* pThis) {
|
||||
void TabPage::onFolderUnmount() {
|
||||
// the folder we're showing is unmounted, destroy the widget
|
||||
qDebug("folder unmount");
|
||||
// NOTE: call pThis->deleteLater() directly from this GObject signal handler
|
||||
// NOTE: call deleteLater() directly from this GObject signal handler
|
||||
// does not work but I don't know why.
|
||||
// Maybe it's the problem of glib mainloop integration?
|
||||
// Call it when idle works, though.
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
// NOTE: call pThis->deleteLater() directly from this GObject signal handler
|
||||
// NOTE: call deleteLater() directly from this GObject signal handler
|
||||
// does not work but I don't know why.
|
||||
// Maybe it's the problem of glib mainloop integration?
|
||||
// Call it when idle works, though.
|
||||
if(settings.closeOnUnmount())
|
||||
QTimer::singleShot(0, pThis, SLOT(deleteLater()));
|
||||
else
|
||||
pThis->chdir(Fm::Path::getHome());
|
||||
if(settings.closeOnUnmount()) {
|
||||
QTimer::singleShot(0, this, SLOT(deleteLater()));
|
||||
}
|
||||
else {
|
||||
chdir(Fm::FilePath::homeDir());
|
||||
}
|
||||
}
|
||||
|
||||
/*static */ void TabPage::onFolderContentChanged(FmFolder* _folder, TabPage* pThis) {
|
||||
void TabPage::onFolderContentChanged() {
|
||||
/* update status text */
|
||||
pThis->statusText_[StatusTextNormal] = pThis->formatStatusText();
|
||||
Q_EMIT pThis->statusChanged(StatusTextNormal, pThis->statusText_[StatusTextNormal]);
|
||||
statusText_[StatusTextNormal] = formatStatusText();
|
||||
Q_EMIT statusChanged(StatusTextNormal, statusText_[StatusTextNormal]);
|
||||
}
|
||||
|
||||
QString TabPage::pathName() {
|
||||
char* disp_path = path().displayName(true);
|
||||
QString ret = QString::fromUtf8(disp_path);
|
||||
g_free(disp_path);
|
||||
return ret;
|
||||
// auto disp_path = path().displayName();
|
||||
// FIXME: displayName() returns invalid path sometimes.
|
||||
auto disp_path = path().toString();
|
||||
return QString::fromUtf8(disp_path.get());
|
||||
}
|
||||
|
||||
void TabPage::chdir(Path newPath, bool addHistory) {
|
||||
if(!folder_.isNull()) {
|
||||
void TabPage::chdir(Fm::FilePath newPath, bool addHistory) {
|
||||
// qDebug() << "TABPAGE CHDIR:" << newPath.toString().get();
|
||||
if(folder_) {
|
||||
// we're already in the specified dir
|
||||
if(newPath == fm_folder_get_path(folder_))
|
||||
if(newPath == folder_->path()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reset the status selected text
|
||||
statusText_[StatusTextSelectedFiles] = QString();
|
||||
|
||||
// remember the previous folder path that we have browsed.
|
||||
lastFolderPath_ = folder_.getPath();
|
||||
lastFolderPath_ = folder_->path();
|
||||
|
||||
if(addHistory) {
|
||||
// store current scroll pos in the browse history
|
||||
@ -359,18 +387,16 @@ void TabPage::chdir(Path newPath, bool addHistory) {
|
||||
|
||||
// free the previous model
|
||||
if(folderModel_) {
|
||||
proxyModel_->setSourceModel(NULL);
|
||||
disconnect(folderModel_, &Fm::FolderModel::fileSizeChanged, this, &TabPage::onFileSizeChanged);
|
||||
proxyModel_->setSourceModel(nullptr);
|
||||
folderModel_->unref(); // unref the cached model
|
||||
folderModel_ = NULL;
|
||||
folderModel_ = nullptr;
|
||||
}
|
||||
|
||||
freeFolder();
|
||||
}
|
||||
|
||||
char* disp_name = newPath.displayBasename();
|
||||
title_ = QString::fromUtf8(disp_name);
|
||||
Q_EMIT titleChanged(title_);
|
||||
g_free(disp_name);
|
||||
Q_EMIT titleChanged(newPath.baseName().get()); // FIXME: display name
|
||||
|
||||
folder_ = Fm::Folder::fromPath(newPath);
|
||||
proxyFilter_->setVirtHidden(folder_);
|
||||
@ -378,14 +404,16 @@ void TabPage::chdir(Path newPath, bool addHistory) {
|
||||
// add current path to browse history
|
||||
history_.add(path());
|
||||
}
|
||||
g_signal_connect(folder_, "start-loading", G_CALLBACK(onFolderStartLoading), this);
|
||||
g_signal_connect(folder_, "finish-loading", G_CALLBACK(onFolderFinishLoading), this);
|
||||
g_signal_connect(folder_, "error", G_CALLBACK(onFolderError), this);
|
||||
g_signal_connect(folder_, "fs-info", G_CALLBACK(onFolderFsInfo), this);
|
||||
connect(folder_.get(), &Fm::Folder::startLoading, this, &TabPage::onFolderStartLoading);
|
||||
connect(folder_.get(), &Fm::Folder::finishLoading, this, &TabPage::onFolderFinishLoading);
|
||||
|
||||
// FIXME: Fm::Folder::error() is a bad design and might be removed in the future.
|
||||
connect(folder_.get(), &Fm::Folder::error, this, &TabPage::onFolderError);
|
||||
connect(folder_.get(), &Fm::Folder::fileSystemChanged, this, &TabPage::onFolderFsInfo);
|
||||
/* destroy the page when the folder is unmounted or deleted. */
|
||||
g_signal_connect(folder_, "removed", G_CALLBACK(onFolderRemoved), this);
|
||||
g_signal_connect(folder_, "unmount", G_CALLBACK(onFolderUnmount), this);
|
||||
g_signal_connect(folder_, "content-changed", G_CALLBACK(onFolderContentChanged), this);
|
||||
connect(folder_.get(), &Fm::Folder::removed, this, &TabPage::onFolderRemoved);
|
||||
connect(folder_.get(), &Fm::Folder::unmount, this, &TabPage::onFolderUnmount);
|
||||
connect(folder_.get(), &Fm::Folder::contentChanged, this, &TabPage::onFolderContentChanged);
|
||||
|
||||
folderModel_ = CachedFolderModel::modelFromFolder(folder_);
|
||||
|
||||
@ -400,13 +428,14 @@ void TabPage::chdir(Path newPath, bool addHistory) {
|
||||
|
||||
folderView_->setViewMode(folderSettings_.viewMode());
|
||||
|
||||
if(folder_.isLoaded()) {
|
||||
onFolderStartLoading(folder_, this);
|
||||
onFolderFinishLoading(folder_, this);
|
||||
onFolderFsInfo(folder_, this);
|
||||
if(folder_->isLoaded()) {
|
||||
onFolderStartLoading();
|
||||
onFolderFinishLoading();
|
||||
onFolderFsInfo();
|
||||
}
|
||||
else {
|
||||
onFolderStartLoading();
|
||||
}
|
||||
else
|
||||
onFolderStartLoading(folder_, this);
|
||||
}
|
||||
|
||||
void TabPage::selectAll() {
|
||||
@ -417,34 +446,42 @@ void TabPage::invertSelection() {
|
||||
folderView_->invertSelection();
|
||||
}
|
||||
|
||||
void TabPage::onOpenDirRequested(FmPath* path, int target) {
|
||||
Q_EMIT openDirRequested(path, target);
|
||||
void TabPage::reload() {
|
||||
if(folder_) {
|
||||
proxyFilter_->setVirtHidden(folder_); // reread ".hidden"
|
||||
// don't select or scroll to the previous folder after reload
|
||||
lastFolderPath_ = Fm::FilePath();
|
||||
// but remember the current scroll position
|
||||
BrowseHistoryItem& item = history_.currentItem();
|
||||
QAbstractItemView* childView = folderView_->childView();
|
||||
item.setScrollPos(childView->verticalScrollBar()->value());
|
||||
|
||||
folder_->reload();
|
||||
}
|
||||
}
|
||||
|
||||
// when the current selection in the folder view is changed
|
||||
void TabPage::onSelChanged(int numSel) {
|
||||
void TabPage::onSelChanged() {
|
||||
QString msg;
|
||||
if(numSel > 0) {
|
||||
if(folderView_->hasSelection()) {
|
||||
auto files = folderView_->selectedFiles();
|
||||
int numSel = files.size();
|
||||
/* FIXME: display total size of all selected files. */
|
||||
if(numSel == 1) { /* only one file is selected */
|
||||
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) {
|
||||
auto& fi = files.front();
|
||||
if(!fi->isDir()) {
|
||||
msg = QString("\"%1\" (%2) %3")
|
||||
.arg(QString::fromUtf8(fi.getDispName()))
|
||||
.arg(QString::fromUtf8(size_str))
|
||||
.arg(QString::fromUtf8(fi.getDesc()));
|
||||
.arg(fi->displayName())
|
||||
.arg(Fm::formatFileSize(fi->size(), fm_config->si_unit)) // FIXME: deprecate fm_config
|
||||
.arg(fi->mimeType()->desc());
|
||||
}
|
||||
else {
|
||||
msg = QString("\"%1\" %2")
|
||||
.arg(QString::fromUtf8(fi.getDispName()))
|
||||
.arg(QString::fromUtf8(fi.getDesc()));
|
||||
.arg(fi->displayName())
|
||||
.arg(fi->mimeType()->desc());
|
||||
}
|
||||
/* FIXME: should we support statusbar plugins as in the gtk+ version? */
|
||||
}
|
||||
}
|
||||
else {
|
||||
goffset sum;
|
||||
GList* l;
|
||||
@ -452,24 +489,17 @@ void TabPage::onSelChanged(int numSel) {
|
||||
/* don't count if too many files are selected, that isn't lightweight */
|
||||
if(numSel < 1000) {
|
||||
sum = 0;
|
||||
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()) {
|
||||
for(auto& fi: files) {
|
||||
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 += fi->size();
|
||||
}
|
||||
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(Fm::formatFileSize(sum, fm_config->si_unit)); // FIXME: deprecate fm_config
|
||||
}
|
||||
/* FIXME: should we support statusbar plugins as in the gtk+ version? */
|
||||
}
|
||||
@ -502,9 +532,8 @@ void TabPage::forward() {
|
||||
chdir(history_.currentPath(), false);
|
||||
}
|
||||
|
||||
void TabPage::jumpToHistory(int index)
|
||||
{
|
||||
if(index >=0 && index < history_.size()) {
|
||||
void TabPage::jumpToHistory(int index) {
|
||||
if(index >= 0 && index < history_.size()) {
|
||||
// remember current scroll position
|
||||
BrowseHistoryItem& item = history_.currentItem();
|
||||
QAbstractItemView* childView = folderView_->childView();
|
||||
@ -516,15 +545,15 @@ void TabPage::jumpToHistory(int index)
|
||||
}
|
||||
|
||||
bool TabPage::canUp() {
|
||||
Fm::Path _path = path();
|
||||
return (!_path.isNull() && !_path.getParent().isNull());
|
||||
auto _path = path();
|
||||
return (_path && _path.hasParent());
|
||||
}
|
||||
|
||||
void TabPage::up() {
|
||||
Fm::Path _path = path();
|
||||
if(!_path.isNull()) {
|
||||
Fm::Path parent = _path.getParent();
|
||||
if(!parent.isNull()) {
|
||||
auto _path = path();
|
||||
if(_path) {
|
||||
auto parent = _path.parent();
|
||||
if(parent) {
|
||||
chdir(parent, true);
|
||||
}
|
||||
}
|
||||
@ -552,8 +581,9 @@ void TabPage::sort(int col, Qt::SortOrder order) {
|
||||
static_cast<Application*>(qApp)->settings().saveFolderSettings(path(), folderSettings_);
|
||||
}
|
||||
}
|
||||
if(proxyModel_)
|
||||
if(proxyModel_) {
|
||||
proxyModel_->sort(col, order);
|
||||
}
|
||||
}
|
||||
|
||||
void TabPage::setSortFolderFirst(bool value) {
|
||||
@ -584,24 +614,30 @@ void TabPage::setShowHidden(bool showHidden) {
|
||||
static_cast<Application*>(qApp)->settings().saveFolderSettings(path(), folderSettings_);
|
||||
}
|
||||
}
|
||||
if(!proxyModel_ || showHidden == proxyModel_->showHidden())
|
||||
if(!proxyModel_) {
|
||||
return;
|
||||
}
|
||||
if(showHidden != proxyModel_->showHidden()) {
|
||||
proxyModel_->setShowHidden(showHidden);
|
||||
}
|
||||
// this may also be called by MainWindow::onTabPageSortFilterChanged to set status message
|
||||
statusText_[StatusTextNormal] = formatStatusText();
|
||||
Q_EMIT statusChanged(StatusTextNormal, statusText_[StatusTextNormal]);
|
||||
}
|
||||
|
||||
void TabPage::applyFilter() {
|
||||
if(!proxyModel_)
|
||||
if(!proxyModel_) {
|
||||
return;
|
||||
}
|
||||
proxyModel_->updateFilters();
|
||||
statusText_[StatusTextNormal] = formatStatusText();
|
||||
Q_EMIT statusChanged(StatusTextNormal, statusText_[StatusTextNormal]);
|
||||
}
|
||||
|
||||
void TabPage::setCustomizedView(bool value) {
|
||||
if(folderSettings_.isCustomized() == value)
|
||||
if(folderSettings_.isCustomized() == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
Settings& settings = static_cast<Application*>(qApp)->settings();
|
||||
folderSettings_.setCustomized(value);
|
||||
|
@ -27,16 +27,18 @@
|
||||
#include <libfm-qt/browsehistory.h>
|
||||
#include "view.h"
|
||||
#include <libfm-qt/path.h>
|
||||
#include <libfm-qt/folder.h>
|
||||
#include <libfm-qt/fileinfo.h>
|
||||
#include "settings.h"
|
||||
|
||||
#include <libfm-qt/core/fileinfo.h>
|
||||
#include <libfm-qt/core/filepath.h>
|
||||
#include <libfm-qt/core/folder.h>
|
||||
|
||||
namespace Fm {
|
||||
class FileLauncher;
|
||||
class FolderModel;
|
||||
class ProxyFolderModel;
|
||||
class CachedFolderModel;
|
||||
};
|
||||
class FileLauncher;
|
||||
class FolderModel;
|
||||
class ProxyFolderModel;
|
||||
class CachedFolderModel;
|
||||
}
|
||||
|
||||
namespace PCManFM {
|
||||
|
||||
@ -44,9 +46,9 @@ class Launcher;
|
||||
|
||||
class ProxyFilter : public Fm::ProxyFolderModelFilter {
|
||||
public:
|
||||
bool filterAcceptsRow(const Fm::ProxyFolderModel* model, FmFileInfo* info) const;
|
||||
bool filterAcceptsRow(const Fm::ProxyFolderModel* model, const std::shared_ptr<const Fm::FileInfo>& info) const;
|
||||
virtual ~ProxyFilter() {}
|
||||
void setVirtHidden(Fm::Folder folder);
|
||||
void setVirtHidden(const std::shared_ptr<Fm::Folder>& folder);
|
||||
QString getFilterStr() {
|
||||
return filterStr_;
|
||||
}
|
||||
@ -60,7 +62,7 @@ private:
|
||||
};
|
||||
|
||||
class TabPage : public QWidget {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum StatusTextType {
|
||||
@ -71,10 +73,10 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
explicit TabPage(Fm::Path path, QWidget* parent = nullptr);
|
||||
explicit TabPage(QWidget* parent = nullptr);
|
||||
virtual ~TabPage();
|
||||
|
||||
void chdir(Fm::Path newPath, bool addHistory = true);
|
||||
void chdir(Fm::FilePath newPath, bool addHistory = true);
|
||||
|
||||
Fm::FolderView::ViewMode viewMode() {
|
||||
return folderSettings_.viewMode();
|
||||
@ -104,18 +106,18 @@ public:
|
||||
void setSortCaseSensitive(bool value);
|
||||
|
||||
bool showHidden() {
|
||||
return folderSettings_.showHidden();
|
||||
return proxyModel_->showHidden();
|
||||
}
|
||||
|
||||
void setShowHidden(bool showHidden);
|
||||
|
||||
Fm::Path path() {
|
||||
return Fm::Path(!folder_.isNull() ? folder_.getPath() : nullptr);
|
||||
Fm::FilePath path() {
|
||||
return folder_ ? folder_->path() : Fm::FilePath();
|
||||
}
|
||||
|
||||
QString pathName();
|
||||
|
||||
Fm::Folder& folder() {
|
||||
const std::shared_ptr<Fm::Folder>& folder() {
|
||||
return folder_;
|
||||
}
|
||||
|
||||
@ -135,7 +137,7 @@ public:
|
||||
return folderView_->selectedFiles();
|
||||
}
|
||||
|
||||
Fm::PathList selectedFilePaths() {
|
||||
Fm::FilePathList selectedFilePaths() {
|
||||
return folderView_->selectedFilePaths();
|
||||
}
|
||||
|
||||
@ -143,16 +145,7 @@ public:
|
||||
|
||||
void invertSelection();
|
||||
|
||||
void reload() {
|
||||
if(!folder_.isNull()) {
|
||||
proxyFilter_->setVirtHidden(folder_); // reread ".hidden"
|
||||
folder_.reload();
|
||||
}
|
||||
}
|
||||
|
||||
QString title() const {
|
||||
return title_;
|
||||
}
|
||||
void reload();
|
||||
|
||||
QString statusText(StatusTextType type = StatusTextNormal) const {
|
||||
return statusText_[type];
|
||||
@ -187,15 +180,17 @@ public:
|
||||
}
|
||||
|
||||
QString getFilterStr() {
|
||||
if(proxyFilter_)
|
||||
if(proxyFilter_) {
|
||||
return proxyFilter_->getFilterStr();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void setFilterStr(QString str) {
|
||||
if(proxyFilter_)
|
||||
if(proxyFilter_) {
|
||||
proxyFilter_->setFilterStr(str);
|
||||
}
|
||||
}
|
||||
|
||||
void applyFilter();
|
||||
|
||||
@ -208,27 +203,30 @@ public:
|
||||
Q_SIGNALS:
|
||||
void statusChanged(int type, QString statusText);
|
||||
void titleChanged(QString title);
|
||||
void openDirRequested(FmPath* path, int target);
|
||||
void openDirRequested(const Fm::FilePath& path, int target);
|
||||
void sortFilterChanged();
|
||||
void forwardRequested();
|
||||
void backwardRequested();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onOpenDirRequested(FmPath* path, int target);
|
||||
void onSelChanged(int numSel);
|
||||
void restoreScrollPos();
|
||||
void onSelChanged();
|
||||
void onUiUpdated();
|
||||
void onFileSizeChanged(const QModelIndex& index);
|
||||
|
||||
private:
|
||||
void freeFolder();
|
||||
QString formatStatusText();
|
||||
|
||||
static void onFolderStartLoading(FmFolder* _folder, TabPage* pThis);
|
||||
static void onFolderFinishLoading(FmFolder* _folder, TabPage* pThis);
|
||||
static FmJobErrorAction onFolderError(FmFolder* _folder, GError* err, FmJobErrorSeverity severity, TabPage* pThis);
|
||||
static void onFolderFsInfo(FmFolder* _folder, TabPage* pThis);
|
||||
static void onFolderRemoved(FmFolder* _folder, TabPage* pThis);
|
||||
static void onFolderUnmount(FmFolder* _folder, TabPage* pThis);
|
||||
static void onFolderContentChanged(FmFolder* _folder, TabPage* pThis);
|
||||
void onFolderStartLoading();
|
||||
void onFolderFinishLoading();
|
||||
|
||||
// FIXME: this API design is bad and might be removed later
|
||||
void onFolderError(const Fm::GErrorPtr& err, Fm::Job::ErrorSeverity severity, Fm::Job::ErrorAction& response);
|
||||
|
||||
void onFolderFsInfo();
|
||||
void onFolderRemoved();
|
||||
void onFolderUnmount();
|
||||
void onFolderContentChanged();
|
||||
|
||||
private:
|
||||
View* folderView_;
|
||||
@ -236,11 +234,10 @@ private:
|
||||
Fm::ProxyFolderModel* proxyModel_;
|
||||
ProxyFilter* proxyFilter_;
|
||||
QVBoxLayout* verticalLayout;
|
||||
Fm::Folder folder_;
|
||||
QString title_;
|
||||
std::shared_ptr<Fm::Folder> folder_;
|
||||
QString statusText_[StatusTextNum];
|
||||
Fm::BrowseHistory history_; // browsing history
|
||||
Fm::Path lastFolderPath_; // last browsed folder
|
||||
Fm::FilePath lastFolderPath_; // last browsed folder
|
||||
bool overrideCursor_;
|
||||
FolderSettings folderSettings_;
|
||||
};
|
||||
|
4
pcmanfm/translations/pcmanfm-qt-desktop-pref_lt.desktop
Normal file
4
pcmanfm/translations/pcmanfm-qt-desktop-pref_lt.desktop
Normal file
@ -0,0 +1,4 @@
|
||||
#Translations
|
||||
Name[lt]=Darbalaukis
|
||||
GenericName[lt]=Darbalaukio nustatymai
|
||||
Comment[lt]=Keisti darbalaukio tvarkytuvės darbalaukio foną ir elgseną
|
4
pcmanfm/translations/pcmanfm-qt_lt.desktop
Normal file
4
pcmanfm/translations/pcmanfm-qt_lt.desktop
Normal file
@ -0,0 +1,4 @@
|
||||
#Translations
|
||||
Name[lt]=PCManFM failų tvarkytuvė
|
||||
GenericName[lt]=Failų tvarkytuvė
|
||||
Comment[lt]=Naršyti failų sistemą ir tvarkyti failus
|
@ -40,10 +40,10 @@ View::View(Fm::FolderView::ViewMode _mode, QWidget* parent):
|
||||
View::~View() {
|
||||
}
|
||||
|
||||
void View::onFileClicked(int type, FmFileInfo* fileInfo) {
|
||||
void View::onFileClicked(int type, const std::shared_ptr<const Fm::FileInfo>& fileInfo) {
|
||||
if(type == MiddleClick) {
|
||||
if(fm_file_info_is_dir(fileInfo)) {
|
||||
Q_EMIT openDirRequested(fm_file_info_get_path(fileInfo), OpenInNewTab);
|
||||
if(fileInfo->isDir()) {
|
||||
Q_EMIT openDirRequested(fileInfo->path(), OpenInNewTab);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -60,18 +60,18 @@ void View::onNewWindow() {
|
||||
|
||||
void View::onNewTab() {
|
||||
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
|
||||
for(GList* l = fm_file_info_list_peek_head_link(menu->files()); l; l = l->next) {
|
||||
FmFileInfo* file = FM_FILE_INFO(l->data);
|
||||
Q_EMIT openDirRequested(fm_file_info_get_path(file), OpenInNewTab);
|
||||
auto files = menu->files();
|
||||
for(auto& file: files) {
|
||||
Q_EMIT openDirRequested(file->path(), OpenInNewTab);
|
||||
}
|
||||
}
|
||||
|
||||
void View::onOpenInTerminal() {
|
||||
Application* app = static_cast<Application*>(qApp);
|
||||
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
|
||||
for(GList* l = fm_file_info_list_peek_head_link(menu->files()); l; l = l->next) {
|
||||
Fm::FileInfo file = FM_FILE_INFO(l->data);
|
||||
app->openFolderInTerminal(file.getPath());
|
||||
auto files = menu->files();
|
||||
for(auto& file: files) {
|
||||
app->openFolderInTerminal(file->path());
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,17 +88,17 @@ void View::prepareFileMenu(Fm::FileMenu* menu) {
|
||||
// add some more menu items for dirs
|
||||
bool all_native = true;
|
||||
bool all_directory = true;
|
||||
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())
|
||||
auto files = menu->files();
|
||||
for(auto& fi: files) {
|
||||
if(!fi->isDir()) {
|
||||
all_directory = false;
|
||||
else if(fi.isDir() && !fi.isNative())
|
||||
}
|
||||
else if(fi->isDir() && !fi->isNative()) {
|
||||
all_native = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (all_directory)
|
||||
{
|
||||
if(all_directory) {
|
||||
QAction* action = new QAction(QIcon::fromTheme("window-new"), tr("Open in New T&ab"), menu);
|
||||
connect(action, &QAction::triggered, this, &View::onNewTab);
|
||||
menu->insertAction(menu->separator1(), action);
|
||||
@ -110,19 +110,20 @@ void View::prepareFileMenu(Fm::FileMenu* menu) {
|
||||
// TODO: add search
|
||||
// action = menu->addAction(_("Search"));
|
||||
|
||||
if(all_native)
|
||||
{
|
||||
if(all_native) {
|
||||
action = new QAction(QIcon::fromTheme("utilities-terminal"), tr("Open in Termina&l"), menu);
|
||||
connect(action, &QAction::triggered, this, &View::onOpenInTerminal);
|
||||
menu->insertAction(menu->separator1(), action);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(menu->pasteAction()) // NULL for trash
|
||||
if(menu->pasteAction()) { // nullptr for trash
|
||||
menu->pasteAction()->setVisible(false);
|
||||
if(menu->createAction())
|
||||
}
|
||||
if(menu->createAction()) {
|
||||
menu->createAction()->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::prepareFolderMenu(Fm::FolderMenu* menu) {
|
||||
|
@ -22,10 +22,12 @@
|
||||
#define PCMANFM_FOLDERVIEW_H
|
||||
|
||||
#include <libfm-qt/folderview.h>
|
||||
#include <libfm-qt/core/filepath.h>
|
||||
|
||||
|
||||
namespace Fm {
|
||||
class FileMenu;
|
||||
class FolderMenu;
|
||||
class FileMenu;
|
||||
class FolderMenu;
|
||||
}
|
||||
|
||||
namespace PCManFM {
|
||||
@ -33,7 +35,7 @@ namespace PCManFM {
|
||||
class Settings;
|
||||
|
||||
class View : public Fm::FolderView {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit View(Fm::FolderView::ViewMode _mode = IconMode, QWidget* parent = 0);
|
||||
@ -49,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void openDirRequested(FmPath* path, int target);
|
||||
void openDirRequested(const Fm::FilePath& path, int target);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onNewWindow();
|
||||
@ -58,7 +60,7 @@ protected Q_SLOTS:
|
||||
void onSearch();
|
||||
|
||||
protected:
|
||||
virtual void onFileClicked(int type, FmFileInfo* fileInfo);
|
||||
virtual void onFileClicked(int type, const std::shared_ptr<const Fm::FileInfo>& fileInfo);
|
||||
virtual void prepareFileMenu(Fm::FileMenu* menu);
|
||||
virtual void prepareFolderMenu(Fm::FolderMenu* menu);
|
||||
|
||||
@ -66,5 +68,5 @@ private:
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // PCMANFM_FOLDERVIEW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user