Cherry-picking upstream version 0.12.0.

ubuntu/cosmic
Alf Gaida 7 years ago
parent 307faf782b
commit 49eb8afa56

@ -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)

@ -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
)

@ -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

@ -0,0 +1,2 @@
# Translations
Name[ar]=سطح المكتب

@ -0,0 +1,2 @@
# Translations
Name[cs]=Plocha

@ -0,0 +1,2 @@
# Translations
Name[cs_CZ]=Plocha

@ -0,0 +1,2 @@
# Translations
Name[da]=Skrivebord

@ -0,0 +1,2 @@
# Translations
Name[de]=Arbeitsfläche

@ -0,0 +1,2 @@
# Translations
Name[el]=Επιφάνεια εργασίας

@ -0,0 +1,2 @@
# Translations
Name[eo]=Labortablo

@ -0,0 +1,2 @@
# Translations
Name[es]=Escritorio

@ -0,0 +1,2 @@
# Translations
Name[es_VE]=Escritorio

@ -0,0 +1,2 @@
# Translations
Name[eu]=Mahaigaina

@ -0,0 +1,2 @@
# Translations
Name[fi]=Työpöytä

@ -0,0 +1,2 @@
# Translations
Name[fr]=Bureau

@ -0,0 +1,2 @@
# Translations
Name[hu]=Asztal

@ -0,0 +1,2 @@
# Translations
Name[ia]=Scriptorio

@ -0,0 +1,2 @@
# Translations
Name[it_IT]=Desktop

@ -0,0 +1,2 @@
# Translations
Name[ja]=デスクトップ

@ -0,0 +1,2 @@
# Translations
Name[lt]=Darbalaukis

@ -0,0 +1,2 @@
# Translations
Name[nl]=Bureaublad

@ -0,0 +1,2 @@
# Translations
Name[pl_PL]=Pulpit

@ -0,0 +1,2 @@
# Translations
Name[pt]=Área de trabalho

@ -0,0 +1,2 @@
# Translations
Name[pt_BR]=Área de trabalho

@ -0,0 +1,2 @@
# Translations
Name[ro_RO]=Desktop

@ -0,0 +1,2 @@
# Translations
Name[ru]=Pабочий стол

@ -0,0 +1,2 @@
# Translations
Name[ru_RU]=Рабочий стол

@ -0,0 +1,2 @@
# Translations
Name[sl]=Namizje

@ -0,0 +1,2 @@
# Translations
Name[th_TH]=เดสก์ท็อป

@ -0,0 +1,2 @@
# Translations
Name[tr]=Masaüstü

@ -0,0 +1,2 @@
# Translations
Name[uk]=Стільниця

@ -0,0 +1,2 @@
# Translations
Name[zh_CN]=桌面

@ -0,0 +1,2 @@
# Translations
Name[zh_TW]=桌面

@ -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
)

@ -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

File diff suppressed because it is too large Load Diff

@ -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;
@ -43,110 +46,110 @@ class PreferencesDialog;
class DesktopPreferencesDialog;
class ProxyStyle: public QProxyStyle {
Q_OBJECT
Q_OBJECT
public:
ProxyStyle() : QProxyStyle() {}
virtual ~ProxyStyle() {}
virtual int styleHint(StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0) const;
ProxyStyle() : QProxyStyle() {}
virtual ~ProxyStyle() {}
virtual int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
};
class Application : public QApplication {
Q_OBJECT
Q_PROPERTY(bool desktopManagerEnabled READ desktopManagerEnabled)
Q_OBJECT
Q_PROPERTY(bool desktopManagerEnabled READ desktopManagerEnabled)
public:
Application(int& argc, char** argv);
virtual ~Application();
Application(int& argc, char** argv);
virtual ~Application();
void init();
int exec();
void init();
int exec();
Settings& settings() {
return settings_;
}
Settings& settings() {
return settings_;
}
Fm::LibFmQt& libFm() {
return libFm_;
}
Fm::LibFmQt& libFm() {
return libFm_;
}
// public interface exported via dbus
void launchFiles(QString cwd, QStringList paths, bool inNewWindow);
void setWallpaper(QString path, QString modeString);
void preferences(QString page);
void desktopPrefrences(QString page);
void editBookmarks();
void desktopManager(bool enabled);
void findFiles(QStringList paths = QStringList());
void connectToServer();
// public interface exported via dbus
void launchFiles(QString cwd, QStringList paths, bool inNewWindow);
void setWallpaper(QString path, QString modeString);
void preferences(QString page);
void desktopPrefrences(QString page);
void editBookmarks();
void desktopManager(bool enabled);
void findFiles(QStringList paths = QStringList());
void connectToServer();
bool desktopManagerEnabled() {
return enableDesktopManager_;
}
bool desktopManagerEnabled() {
return enableDesktopManager_;
}
void updateFromSettings();
void updateDesktopsFromSettings();
void updateFromSettings();
void updateDesktopsFromSettings(bool changeSlide = true);
void openFolderInTerminal(Fm::Path path);
void openFolders(Fm::FileInfoList files);
void openFolderInTerminal(Fm::FilePath path);
void openFolders(Fm::FileInfoList files);
QString profileName() {
return profileName_;
}
QString profileName() {
return profileName_;
}
protected Q_SLOTS:
void onAboutToQuit();
void onSigtermNotified();
void onAboutToQuit();
void onSigtermNotified();
void onLastWindowClosed();
void onSaveStateRequest(QSessionManager & manager);
void onScreenResized(int num);
void onScreenCountChanged(int newCount);
void initVolumeManager();
void onLastWindowClosed();
void onSaveStateRequest(QSessionManager& manager);
void onScreenResized(int num);
void onScreenCountChanged(int newCount);
void initVolumeManager();
void onVirtualGeometryChanged(const QRect& rect);
void onScreenDestroyed(QObject* screenObj);
void onScreenAdded(QScreen* newScreen);
void reloadDesktopsAsNeeded();
void onVirtualGeometryChanged(const QRect& rect);
void onScreenDestroyed(QObject* screenObj);
void onScreenAdded(QScreen* newScreen);
void reloadDesktopsAsNeeded();
void onFindFileAccepted();
void onConnectToServerAccepted();
void onFindFileAccepted();
void onConnectToServerAccepted();
protected:
virtual bool eventFilter(QObject* watched, QEvent* event);
bool parseCommandLineArgs();
DesktopWindow* createDesktopWindow(int screenNum);
bool autoMountVolume(GVolume* volume, bool interactive = true);
virtual bool eventFilter(QObject* watched, QEvent* event);
bool parseCommandLineArgs();
DesktopWindow* createDesktopWindow(int screenNum);
bool autoMountVolume(GVolume* volume, bool interactive = true);
static void onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis);
static void onVolumeAdded(GVolumeMonitor* monitor, GVolume* volume, Application* pThis);
private Q_SLOTS:
void onUserDirsChanged();
void onUserDirsChanged();
private:
void initWatch();
void installSigtermHandler();
bool isPrimaryInstance;
Fm::LibFmQt libFm_;
Settings settings_;
QString profileName_;
bool daemonMode_;
bool enableDesktopManager_;
QVector<DesktopWindow*> desktopWindows_;
QPointer<PreferencesDialog> preferencesDialog_;
QPointer<DesktopPreferencesDialog> desktopPreferencesDialog_;
QPointer<Fm::EditBookmarksDialog> editBookmarksialog_;
QTranslator translator;
QTranslator qtTranslator;
GVolumeMonitor* volumeMonitor_;
QFileSystemWatcher *userDirsWatcher_;
QString userDirsFile_;
QString userDesktopFolder_;
bool lxqtRunning_;
int argc_;
char** argv_;
void initWatch();
void installSigtermHandler();
bool isPrimaryInstance;
Fm::LibFmQt libFm_;
Settings settings_;
QString profileName_;
bool daemonMode_;
bool enableDesktopManager_;
QVector<DesktopWindow*> desktopWindows_;
QPointer<PreferencesDialog> preferencesDialog_;
QPointer<DesktopPreferencesDialog> desktopPreferencesDialog_;
QPointer<Fm::EditBookmarksDialog> editBookmarksialog_;
QTranslator translator;
QTranslator qtTranslator;
GVolumeMonitor* volumeMonitor_;
QFileSystemWatcher* userDirsWatcher_;
QString userDirsFile_;
QString userDesktopFolder_;
bool lxqtRunning_;
int argc_;
char** argv_;
};
}

@ -23,116 +23,121 @@
#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),
mount_(G_MOUNT(g_object_ref(mount))) {
QDialog(parent, f),
cancellable(g_cancellable_new()),
applications(nullptr),
mount_(G_MOUNT(g_object_ref(mount))) {
setAttribute(Qt::WA_DeleteOnClose);
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
ui.setupUi(this);
GIcon* gicon = g_volume_get_icon(volume);
QIcon icon = Fm::IconTheme::icon(gicon);
ui.icon->setPixmap(icon.pixmap(QSize(48, 48)));
GIcon* gicon = g_volume_get_icon(volume);
QIcon icon = Fm::IconInfo::fromGIcon(gicon)->qicon();
ui.icon->setPixmap(icon.pixmap(QSize(48, 48)));
// add actions
QListWidgetItem* item = new QListWidgetItem(QIcon::fromTheme("system-file-manager"), tr("Open in file manager"));
ui.listWidget->addItem(item);
// add actions
QListWidgetItem* item = new QListWidgetItem(QIcon::fromTheme("system-file-manager"), tr("Open in file manager"));
ui.listWidget->addItem(item);
g_mount_guess_content_type(mount, TRUE, cancellable, (GAsyncReadyCallback)onContentTypeFinished, this);
g_mount_guess_content_type(mount, TRUE, cancellable, (GAsyncReadyCallback)onContentTypeFinished, this);
}
AutoRunDialog::~AutoRunDialog() {
g_list_foreach(applications, (GFunc)g_object_unref, NULL);
g_list_free(applications);
g_list_foreach(applications, (GFunc)g_object_unref, nullptr);
g_list_free(applications);
if(mount_)
g_object_unref(mount_);
if(mount_) {
g_object_unref(mount_);
}
if(cancellable) {
g_cancellable_cancel(cancellable);
g_object_unref(cancellable);
}
if(cancellable) {
g_cancellable_cancel(cancellable);
g_object_unref(cancellable);
}
}
void AutoRunDialog::accept() {
QListWidgetItem* item = ui.listWidget->selectedItems().first();
if(item) {
GFile* gf = g_mount_get_root(mount_);
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);
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);
// 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);
win->resize(settings.windowWidth(), settings.windowHeight());
if(settings.windowMaximized()) {
win->setWindowState(win->windowState() | Qt::WindowMaximized);
}
win->show();
QListWidgetItem* item = ui.listWidget->selectedItems().first();
if(item) {
GFile* gf = g_mount_get_root(mount_);
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(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::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);
win->resize(settings.windowWidth(), settings.windowHeight());
if(settings.windowMaximized()) {
win->setWindowState(win->windowState() | Qt::WindowMaximized);
}
win->show();
}
g_object_unref(gf);
}
g_object_unref(gf);
}
QDialog::accept();
QDialog::accept();
}
// static
void AutoRunDialog::onContentTypeFinished(GMount* mount, GAsyncResult* res, AutoRunDialog* pThis) {
if(pThis->cancellable) {
g_object_unref(pThis->cancellable);
pThis->cancellable = NULL;
}
char** types = g_mount_guess_content_type_finish(mount, res, NULL);
char* desc = NULL;
if(types) {
if(types[0]) {
for(char** type = types; *type; ++type) {
GList* l = g_app_info_get_all_for_type(*type);
if(l)
pThis->applications = g_list_concat(pThis->applications, l);
}
desc = g_content_type_get_description(types[0]);
if(pThis->cancellable) {
g_object_unref(pThis->cancellable);
pThis->cancellable = nullptr;
}
g_strfreev(types);
if(pThis->applications) {
int pos = 0;
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);
QString text = QString::fromUtf8(g_app_info_get_name(app));
QListWidgetItem* item = new QListWidgetItem(icon, text);
item->setData(Qt::UserRole, qVariantFromValue<void*>(app));
pThis->ui.listWidget->insertItem(pos, item);
}
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) {
pThis->applications = g_list_concat(pThis->applications, l);
}
}
desc = g_content_type_get_description(types[0]);
}
g_strfreev(types);
if(pThis->applications) {
int pos = 0;
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::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));
pThis->ui.listWidget->insertItem(pos, item);
}
}
}
}
if(desc) {
pThis->ui.mediumType->setText(QString::fromUtf8(desc));
g_free(desc);
}
else
pThis->ui.mediumType->setText(tr("Removable Disk"));
if(desc) {
pThis->ui.mediumType->setText(QString::fromUtf8(desc));
g_free(desc);
}
else {
pThis->ui.mediumType->setText(tr("Removable Disk"));
}
// select the first item
pThis->ui.listWidget->item(0)->setSelected(true);
// select the first item
pThis->ui.listWidget->item(0)->setSelected(true);
}
} // namespace PCManFM

@ -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);

File diff suppressed because it is too large Load Diff

@ -23,124 +23,138 @@
#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;
enum WallpaperMode {
WallpaperNone,
WallpaperStretch,
WallpaperFit,
WallpaperCenter,
WallpaperTile,
WallpaperZoom
};
explicit DesktopWindow(int screenNum);
virtual ~DesktopWindow();
void setForeground(const QColor& color);
void setShadow(const QColor& color);
void setBackground(const QColor& color);
void setDesktopFolder();
void setWallpaperFile(QString filename);
void setWallpaperMode(WallpaperMode mode = WallpaperStretch);
// void setWallpaperAlpha(qreal alpha);
void updateWallpaper();
void updateFromSettings(Settings& settings);
void queueRelayout(int delay = 0);
int screenNum() const {
return screenNum_;
}
void setScreenNum(int num);
friend class Application;
enum WallpaperMode {
WallpaperNone,
WallpaperStretch,
WallpaperFit,
WallpaperCenter,
WallpaperTile,
WallpaperZoom
};
explicit DesktopWindow(int screenNum);
virtual ~DesktopWindow();
void setForeground(const QColor& color);
void setShadow(const QColor& color);
void setBackground(const QColor& color);
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();
bool pickWallpaper();
void nextWallpaper();
void updateFromSettings(Settings& settings, bool changeSlide = true);
void queueRelayout(int delay = 0);
int screenNum() const {
return screenNum_;
}
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();
void loadItemPositions();
void saveItemPositions();
QImage loadWallpaperFile(QSize requiredSize);
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 onDesktopPreferences();
void onOpenDirRequested(const Fm::FilePath& path, int target);
void onDesktopPreferences();
void onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
void onRowsInserted(const QModelIndex& parent, int start, int end);
void onLayoutChanged();
void onModelSortFilterChanged();
void onIndexesMoved(const QModelIndexList& indexes);
void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
void onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
void onRowsInserted(const QModelIndex& parent, int start, int end);
void onLayoutChanged();
void onModelSortFilterChanged();
void onIndexesMoved(const QModelIndexList& indexes);
void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
void relayoutItems();
void onStickToCurrentPos(bool toggled);
void relayoutItems();
void onStickToCurrentPos(bool toggled);
// void updateWorkArea();
// void updateWorkArea();
// file operations
void onCutActivated();
void onCopyActivated();
void onPasteActivated();
void onRenameActivated();
void onDeleteActivated();
void onFilePropertiesActivated();
// file operations
void onCutActivated();
void onCopyActivated();
void onPasteActivated();
void onRenameActivated();
void onDeleteActivated();
void onFilePropertiesActivated();
private:
void removeBottomGap();
void paintBackground(QPaintEvent* event);
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_;
Fm::FolderViewListView* listView_;
QColor fgColor_;
QColor bgColor_;
QColor shadowColor_;
QString wallpaperFile_;
WallpaperMode wallpaperMode_;
QPixmap wallpaperPixmap_;
DesktopItemDelegate* delegate_;
Launcher fileLauncher_;
bool showWmMenu_;
int screenNum_;
QHash<QByteArray, QPoint> customItemPos_;
QHash<QModelIndex, QString> displayNames_; // only for desktop entries and shortcuts
QTimer* relayoutTimer_;
Fm::ProxyFolderModel* proxyModel_;
Fm::CachedFolderModel* model_;
std::shared_ptr<Fm::Folder> folder_;
Fm::FolderViewListView* listView_;
QColor fgColor_;
QColor bgColor_;
QColor shadowColor_;
QString wallpaperFile_;
WallpaperMode wallpaperMode_;
QString lastSlide_;
QString wallpaperDir_;
int slideShowInterval_;
QTimer* wallpaperTimer_;
bool wallpaperRandomize_;
QPixmap wallpaperPixmap_;
Launcher fileLauncher_;
bool showWmMenu_;
int screenNum_;
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,15 +21,16 @@
#include "launcher.h"
#include "mainwindow.h"
#include "application.h"
#include <libfm-qt/core/filepath.h>
namespace PCManFM {
Launcher::Launcher(PCManFM::MainWindow* mainWindow):
Fm::FileLauncher(),
mainWindow_(mainWindow) {
Fm::FileLauncher(),
mainWindow_(mainWindow) {
Application* app = static_cast<Application*>(qApp);
setQuickExec(app->settings().quickExec());
Application* app = static_cast<Application*>(qApp);
setQuickExec(app->settings().quickExec());
}
Launcher::~Launcher() {
@ -37,28 +38,31 @@ Launcher::~Launcher() {
}
bool Launcher::openFolder(GAppLaunchContext* ctx, GList* folder_infos, GError** err) {
GList* l = folder_infos;
Fm::FileInfo fi = FM_FILE_INFO(l->data);
Application* app = static_cast<Application*>(qApp);
MainWindow* mainWindow = mainWindow_;
if(!mainWindow) {
mainWindow = new MainWindow(fi.getPath());
mainWindow->resize(app->settings().windowWidth(), app->settings().windowHeight());
GList* l = folder_infos;
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(std::move(path));
mainWindow->resize(app->settings().windowWidth(), app->settings().windowHeight());
if(app->settings().windowMaximized()) {
mainWindow->setWindowState(mainWindow->windowState() | Qt::WindowMaximized);
if(app->settings().windowMaximized()) {
mainWindow->setWindowState(mainWindow->windowState() | Qt::WindowMaximized);
}
}
}
else
mainWindow->chdir(fi.getPath());
l = l->next;
for(; l; l = l->next) {
fi = FM_FILE_INFO(l->data);
mainWindow->addTab(fi.getPath());
}
mainWindow->show();
mainWindow->raise();
return true;
else {
mainWindow->chdir(std::move(path));
}
l = l->next;
for(; l; l = l->next) {
fi = FM_FILE_INFO(l->data);
path = Fm::FilePath{fm_path_to_gfile(fm_file_info_get_path(fi)), false};
mainWindow->addTab(std::move(path));
}
mainWindow->show();
mainWindow->raise();
return true;
}
} //namespace PCManFM

@ -29,14 +29,14 @@ class MainWindow;
class Launcher : public Fm::FileLauncher {
public:
Launcher(MainWindow* mainWindow = NULL);
~Launcher();
Launcher(MainWindow* mainWindow = nullptr);
~Launcher();
protected:
virtual bool openFolder(GAppLaunchContext* ctx, GList* folder_infos, GError** err);
virtual bool openFolder(GAppLaunchContext* ctx, GList* folder_infos, GError** err);
private:
MainWindow* mainWindow_;
MainWindow* mainWindow_;
};
}

@ -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>&amp;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>

File diff suppressed because it is too large Load Diff

@ -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,162 +47,163 @@ class TabPage;
class Settings;
class MainWindow : public QMainWindow {
Q_OBJECT
Q_OBJECT
public:
MainWindow(Fm::Path path = Fm::Path());
virtual ~MainWindow();
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());
}
TabPage* currentPage() {
return reinterpret_cast<TabPage*>(ui.stackedWidget->currentWidget());
}
void updateFromSettings(Settings& settings);
void updateFromSettings(Settings& settings);
static MainWindow* lastActive() {
return lastActive_;
}
static MainWindow* lastActive() {
return lastActive_;
}
protected Q_SLOTS:
void onPathEntryReturnPressed();
void onPathEntryEdited(const QString& text);
void onPathBarChdir(FmPath* dirPath);
void onPathBarMiddleClickChdir(FmPath* dirPath);
void on_actionNewTab_triggered();
void on_actionNewWin_triggered();
void on_actionNewFolder_triggered();
void on_actionNewBlankFile_triggered();
void on_actionCloseTab_triggered();
void on_actionCloseWindow_triggered();
void on_actionFileProperties_triggered();
void on_actionFolderProperties_triggered();
void on_actionCut_triggered();
void on_actionCopy_triggered();
void on_actionPaste_triggered();
void on_actionDelete_triggered();
void on_actionRename_triggered();
void on_actionSelectAll_triggered();
void on_actionInvertSelection_triggered();
void on_actionPreferences_triggered();
void on_actionGoBack_triggered();
void on_actionGoForward_triggered();
void on_actionGoUp_triggered();
void on_actionHome_triggered();
void on_actionReload_triggered();
void on_actionConnectToServer_triggered();
void on_actionIconView_triggered();
void on_actionCompactView_triggered();
void on_actionDetailedList_triggered();
void on_actionThumbnailView_triggered();
void on_actionGo_triggered();
void on_actionShowHidden_triggered(bool check);
void on_actionPreserveView_triggered(bool checked);
void on_actionByFileName_triggered(bool checked);
void on_actionByMTime_triggered(bool checked);
void on_actionByOwner_triggered(bool checked);
void on_actionByFileType_triggered(bool checked);
void on_actionByFileSize_triggered(bool checked);
void on_actionAscending_triggered(bool checked);
void on_actionDescending_triggered(bool checked);
void on_actionFolderFirst_triggered(bool checked);
void on_actionCaseSensitive_triggered(bool checked);
void on_actionFilter_triggered(bool checked);
void on_actionLocationBar_triggered(bool checked);
void on_actionPathButtons_triggered(bool checked);
void on_actionApplications_triggered();
void on_actionComputer_triggered();
void on_actionTrash_triggered();
void on_actionNetwork_triggered();
void on_actionDesktop_triggered();
void on_actionAddToBookmarks_triggered();
void on_actionEditBookmarks_triggered();
void on_actionOpenTerminal_triggered();
void on_actionOpenAsRoot_triggered();
void on_actionFindFiles_triggered();
void on_actionAbout_triggered();
void onBookmarkActionTriggered();
void onTabBarCloseRequested(int index);
void onTabBarCurrentChanged(int index);
void onTabBarTabMoved(int from, int to);
void focusFilterBar();
void onFilterStringChanged(QString str);
void onShortcutPrevTab();
void onShortcutNextTab();
void onShortcutJumpToTab();
void onStackedWidgetWidgetRemoved(int index);
void onTabPageTitleChanged(QString title);
void onTabPageStatusChanged(int type, QString statusText);
void onTabPageOpenDirRequested(FmPath* 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 onSidePaneModeChanged(Fm::SidePane::Mode mode);
void onSplitterMoved(int pos, int index);
void onResetFocus();
void onBackForwardContextMenu(QPoint pos);
void tabContextMenu(const QPoint& pos);
void closeLeftTabs();
void closeRightTabs();
void closeOtherTabs() {
closeLeftTabs();
closeRightTabs();
}
void focusPathEntry();
void toggleMenuBar(bool checked);
void onPathEntryReturnPressed();
void onPathBarChdir(const Fm::FilePath& dirPath);
void onPathBarMiddleClickChdir(const Fm::FilePath &dirPath);
void on_actionNewTab_triggered();
void on_actionNewWin_triggered();
void on_actionNewFolder_triggered();
void on_actionNewBlankFile_triggered();
void on_actionCloseTab_triggered();
void on_actionCloseWindow_triggered();
void on_actionFileProperties_triggered();
void on_actionFolderProperties_triggered();
void on_actionCut_triggered();
void on_actionCopy_triggered();
void on_actionPaste_triggered();
void on_actionDelete_triggered();
void on_actionRename_triggered();
void on_actionSelectAll_triggered();
void on_actionInvertSelection_triggered();
void on_actionPreferences_triggered();
void on_actionGoBack_triggered();
void on_actionGoForward_triggered();
void on_actionGoUp_triggered();
void on_actionHome_triggered();
void on_actionReload_triggered();
void on_actionConnectToServer_triggered();
void on_actionIconView_triggered();
void on_actionCompactView_triggered();
void on_actionDetailedList_triggered();
void on_actionThumbnailView_triggered();
void on_actionGo_triggered();
void on_actionShowHidden_triggered(bool check);
void on_actionPreserveView_triggered(bool checked);
void on_actionByFileName_triggered(bool checked);
void on_actionByMTime_triggered(bool checked);
void on_actionByOwner_triggered(bool checked);
void on_actionByFileType_triggered(bool checked);
void on_actionByFileSize_triggered(bool checked);
void on_actionAscending_triggered(bool checked);
void on_actionDescending_triggered(bool checked);
void on_actionFolderFirst_triggered(bool checked);
void on_actionCaseSensitive_triggered(bool checked);
void on_actionFilter_triggered(bool checked);
void on_actionLocationBar_triggered(bool checked);
void on_actionPathButtons_triggered(bool checked);
void on_actionApplications_triggered();
void on_actionComputer_triggered();
void on_actionTrash_triggered();
void on_actionNetwork_triggered();
void on_actionDesktop_triggered();
void on_actionAddToBookmarks_triggered();
void on_actionEditBookmarks_triggered();
void on_actionOpenTerminal_triggered();
void on_actionOpenAsRoot_triggered();
void on_actionFindFiles_triggered();
void on_actionAbout_triggered();
void onBookmarkActionTriggered();
void onTabBarCloseRequested(int index);
void onTabBarCurrentChanged(int index);
void onTabBarTabMoved(int from, int to);
void focusFilterBar();
void onFilterStringChanged(QString str);
void onShortcutPrevTab();
void onShortcutNextTab();
void onShortcutJumpToTab();
void onStackedWidgetWidgetRemoved(int index);
void onTabPageTitleChanged(QString title);
void onTabPageStatusChanged(int type, QString statusText);
void onTabPageOpenDirRequested(const Fm::FilePath &path, int target);
void onTabPageSortFilterChanged();
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();
void onBackForwardContextMenu(QPoint pos);
void tabContextMenu(const QPoint& pos);
void closeLeftTabs();
void closeRightTabs();
void closeOtherTabs() {
closeLeftTabs();
closeRightTabs();
}
void focusPathEntry();
void toggleMenuBar(bool checked);
void onBookmarksChanged();
protected:
bool event(QEvent* event) override;
void changeEvent(QEvent *event) override;
void closeTab(int index);
virtual void resizeEvent(QResizeEvent *event) override;
virtual void closeEvent(QCloseEvent *event) override;
bool event(QEvent* event) override;
void changeEvent(QEvent* event) override;
void closeTab(int index);
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 updateStatusBarForCurrentPage();
void setRTLIcons(bool isRTL);
void createPathBar(bool usePathButtons);
void loadBookmarksMenu();
void updateUIForCurrentPage();
void updateViewMenuForCurrentPage();
void updateEditSelectedActions();
void updateStatusBarForCurrentPage();
void setRTLIcons(bool isRTL);
void createPathBar(bool usePathButtons);
private:
Ui::MainWindow ui;
Fm::PathEdit* pathEntry_;
Fm::PathBar* pathBar_;
QLabel* fsInfoLabel_;
Fm::Bookmarks bookmarks_;
Launcher fileLauncher_;
int rightClickIndex_;
bool updatingViewMenu_;
QAction* menuSep_;
static MainWindow* lastActive_;
Ui::MainWindow ui;
Fm::PathEdit* pathEntry_;
Fm::PathBar* pathBar_;
QLabel* fsInfoLabel_;
std::shared_ptr<Fm::Bookmarks> bookmarks_;
Launcher fileLauncher_;
int rightClickIndex_;
bool updatingViewMenu_;
QAction* menuSep_;
static MainWindow* lastActive_;
};
}

@ -3,11 +3,13 @@
#include <libfm-qt/libfmqt.h>
int main(int argc, char** argv) {
// ensure that glib integration of Qt is not turned off
// This fixes #168: https://github.com/lxde/pcmanfm-qt/issues/168
qunsetenv("QT_NO_GLIB");
// ensure that glib integration of Qt is not turned off
// This fixes #168: https://github.com/lxde/pcmanfm-qt/issues/168
qunsetenv("QT_NO_GLIB");
PCManFM::Application app(argc, argv);
app.init();
return app.exec();
PCManFM::Application app(argc, argv);
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
app.init();
return app.exec();
}

@ -27,26 +27,23 @@
#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) {
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
PreferencesDialog::PreferencesDialog (QString activePage, QWidget* parent):
QDialog (parent) {
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// resize the list widget according to the width of its content.
ui.listWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
ui.listWidget->setMaximumWidth(ui.listWidget->sizeHintForColumn(0) + ui.listWidget->frameWidth() * 2 + 4);
// resize the list widget according to the width of its content.
ui.listWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
ui.listWidget->setMaximumWidth(ui.listWidget->sizeHintForColumn(0) + ui.listWidget->frameWidth() * 2 + 4);
initFromSettings();
initFromSettings();
selectPage(activePage);
adjustSize();
selectPage(activePage);
adjustSize();
}
PreferencesDialog::~PreferencesDialog() {
@ -54,106 +51,115 @@ PreferencesDialog::~PreferencesDialog() {
}
static void findIconThemesInDir(QHash<QString, QString>& iconThemes, QString dirName) {
QDir dir(dirName);
QStringList subDirs = dir.entryList(QDir::AllDirs);
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)) {
// 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);
iconThemes[subDir] = dispName;
g_free(dispName);
}
QDir dir(dirName);
QStringList subDirs = dir.entryList(QDir::AllDirs);
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), 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", 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);
}
}
}
}
g_key_file_free(kf);
g_key_file_free(kf);
}
void PreferencesDialog::initIconThemes(Settings& settings) {
// check if auto-detection is done (for example, from xsettings)
if(settings.useFallbackIconTheme()) { // auto-detection failed
// load xdg icon themes and select the current one
QHash<QString, QString> iconThemes;
// user customed icon themes
findIconThemesInDir(iconThemes, QString(g_get_home_dir()) % "/.icons");
// search for icons in system data dir
const char* const* dataDirs = g_get_system_data_dirs();
for(const char* const* dataDir = dataDirs; *dataDir; ++dataDir) {
findIconThemesInDir(iconThemes, QString(*dataDir) % "/icons");
}
iconThemes.remove("hicolor"); // remove hicolor, which is only a fallback
QHash<QString, QString>::const_iterator it;
for(it = iconThemes.begin(); it != iconThemes.end(); ++it) {
ui.iconTheme->addItem(it.value(), it.key());
// check if auto-detection is done (for example, from xsettings)
if(settings.useFallbackIconTheme()) { // auto-detection failed
// load xdg icon themes and select the current one
QHash<QString, QString> iconThemes;
// user customed icon themes
findIconThemesInDir(iconThemes, QString(g_get_home_dir()) % "/.icons");
// search for icons in system data dir
const char* const* dataDirs = g_get_system_data_dirs();
for(const char* const* dataDir = dataDirs; *dataDir; ++dataDir) {
findIconThemesInDir(iconThemes, QString(*dataDir) % "/icons");
}
iconThemes.remove("hicolor"); // remove hicolor, which is only a fallback
QHash<QString, QString>::const_iterator 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
// select current theme name
int n = ui.iconTheme->count();
int i;
for(i = 0; i < n; ++i) {
QVariant itemData = ui.iconTheme->itemData(i);
if(itemData == settings.fallbackIconThemeName()) {
break;
}
}
if(i >= n) {
i = 0;
}
ui.iconTheme->setCurrentIndex(i);
}
ui.iconTheme->model()->sort(0); // sort the list of icon theme names
// select current theme name
int n = ui.iconTheme->count();
int i;
for(i = 0; i < n; ++i) {
QVariant itemData = ui.iconTheme->itemData(i);
if(itemData == settings.fallbackIconThemeName()) {
break;
}
else { // auto-detection of icon theme works, hide the fallback icon theme combo box.
ui.iconThemeLabel->hide();
ui.iconTheme->hide();
}
if(i >= n)
i = 0;
ui.iconTheme->setCurrentIndex(i);
}
else { // auto-detection of icon theme works, hide the fallback icon theme combo box.
ui.iconThemeLabel->hide();
ui.iconTheme->hide();
}
ui.hMargin->setValue(settings.folderViewCellMargins().width());
ui.vMargin->setValue(settings.folderViewCellMargins().height());
connect(ui.lockMargins, &QAbstractButton::clicked, this, &PreferencesDialog::lockMargins);
ui.hMargin->setValue(settings.folderViewCellMargins().width());
ui.vMargin->setValue(settings.folderViewCellMargins().height());
connect(ui.lockMargins, &QAbstractButton::clicked, this, &PreferencesDialog::lockMargins);
}
void PreferencesDialog::initArchivers(Settings& settings) {
const GList* allArchivers = fm_archiver_get_all();
int i = 0;
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())
ui.archiver->setCurrentIndex(i);
}
const GList* allArchivers = fm_archiver_get_all();
int i = 0;
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()) {
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];
ui.bigIconSize->addItem(QString("%1 x %1").arg(size), size);
if(settings.bigIconSize() == size)
ui.bigIconSize->setCurrentIndex(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) {
ui.bigIconSize->setCurrentIndex(i);
}
++i;
}
for(std::size_t i = 0; i < G_N_ELEMENTS(smallIconSizes); ++i) {
int size = smallIconSizes[i];
QString text = QString("%1 x %1").arg(size);
ui.smallIconSize->addItem(text, size);
if(settings.smallIconSize() == size)
ui.smallIconSize->setCurrentIndex(i);
ui.sidePaneIconSize->addItem(text, size);
if(settings.sidePaneIconSize() == size)
ui.sidePaneIconSize->setCurrentIndex(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) {
ui.smallIconSize->setCurrentIndex(i);
}
ui.sidePaneIconSize->addItem(text, size);
if(settings.sidePaneIconSize() == size) {
ui.sidePaneIconSize->setCurrentIndex(i);
}
++i;
}
for(std::size_t i = 0; i < G_N_ELEMENTS(thumbnailIconSizes); ++i) {
int size = thumbnailIconSizes[i];
ui.thumbnailIconSize->addItem(QString("%1 x %1").arg(size), size);
if(settings.thumbnailIconSize() == size)
ui.thumbnailIconSize->setCurrentIndex(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) {
ui.thumbnailIconSize->setCurrentIndex(i);
}
++i;
}
ui.siUnit->setChecked(settings.siUnit());
@ -168,218 +174,224 @@ void PreferencesDialog::initDisplayPage(Settings& settings) {
}
void PreferencesDialog::initUiPage(Settings& settings) {
ui.alwaysShowTabs->setChecked(settings.alwaysShowTabs());
ui.fullWidthTabbar->setChecked(settings.fullWidthTabBar());
ui.showTabClose->setChecked(settings.showTabClose());
ui.rememberWindowSize->setChecked(settings.rememberWindowSize());
ui.fixedWindowWidth->setValue(settings.fixedWindowWidth());
ui.fixedWindowHeight->setValue(settings.fixedWindowHeight());
// FIXME: Hide options that we don't support yet.
ui.showInPlaces->parentWidget()->hide();
ui.alwaysShowTabs->setChecked(settings.alwaysShowTabs());
ui.fullWidthTabbar->setChecked(settings.fullWidthTabBar());
ui.showTabClose->setChecked(settings.showTabClose());
ui.rememberWindowSize->setChecked(settings.rememberWindowSize());
ui.fixedWindowWidth->setValue(settings.fixedWindowWidth());
ui.fixedWindowHeight->setValue(settings.fixedWindowHeight());
// FIXME: Hide options that we don't support yet.
ui.showInPlaces->parentWidget()->hide();
}
void PreferencesDialog::initBehaviorPage(Settings& settings) {
ui.singleClick->setChecked(settings.singleClick());
ui.autoSelectionDelay->setValue(double(settings.autoSelectionDelay()) / 1000);
ui.bookmarkOpenMethod->setCurrentIndex(settings.bookmarkOpenMethod());
ui.viewMode->addItem(tr("Icon View"), (int)Fm::FolderView::IconMode);
ui.viewMode->addItem(tr("Compact View"), (int)Fm::FolderView::CompactMode);
ui.viewMode->addItem(tr("Thumbnail View"), (int)Fm::FolderView::ThumbnailMode);
ui.viewMode->addItem(tr("Detailed List View"), (int)Fm::FolderView::DetailedListMode);
const Fm::FolderView::ViewMode modes[] = {
Fm::FolderView::IconMode,
Fm::FolderView::CompactMode,
Fm::FolderView::ThumbnailMode,
Fm::FolderView::DetailedListMode
};
for(std::size_t i = 0; i < G_N_ELEMENTS(modes); ++i) {
if(modes[i] == settings.viewMode()) {
ui.viewMode->setCurrentIndex(i);
break;
ui.singleClick->setChecked(settings.singleClick());
ui.autoSelectionDelay->setValue(double(settings.autoSelectionDelay()) / 1000);
ui.bookmarkOpenMethod->setCurrentIndex(settings.bookmarkOpenMethod());
ui.viewMode->addItem(tr("Icon View"), (int)Fm::FolderView::IconMode);
ui.viewMode->addItem(tr("Compact View"), (int)Fm::FolderView::CompactMode);
ui.viewMode->addItem(tr("Thumbnail View"), (int)Fm::FolderView::ThumbnailMode);
ui.viewMode->addItem(tr("Detailed List View"), (int)Fm::FolderView::DetailedListMode);
const Fm::FolderView::ViewMode modes[] = {
Fm::FolderView::IconMode,
Fm::FolderView::CompactMode,
Fm::FolderView::ThumbnailMode,
Fm::FolderView::DetailedListMode
};
for(std::size_t i = 0; i < G_N_ELEMENTS(modes); ++i) {
if(modes[i] == settings.viewMode()) {
ui.viewMode->setCurrentIndex(i);
break;
}
}
}
ui.configmDelete->setChecked(settings.confirmDelete());
ui.configmDelete->setChecked(settings.confirmDelete());
if(settings.supportTrash())
ui.useTrash->setChecked(settings.useTrash());
else {
ui.useTrash->hide();
}
if(settings.supportTrash()) {
ui.useTrash->setChecked(settings.useTrash());
}
else {
ui.useTrash->hide();
}
ui.noUsbTrash->setChecked(settings.noUsbTrash());
ui.confirmTrash->setChecked(settings.confirmTrash());
ui.quickExec->setChecked(settings.quickExec());
ui.noUsbTrash->setChecked(settings.noUsbTrash());
ui.confirmTrash->setChecked(settings.confirmTrash());
ui.quickExec->setChecked(settings.quickExec());
}
void PreferencesDialog::initThumbnailPage(Settings& settings) {
ui.showThumbnails->setChecked(settings.showThumbnails());
ui.thumbnailLocal->setChecked(settings.thumbnailLocalFilesOnly());
ui.maxThumbnailFileSize->setValue(settings.maxThumbnailFileSize());
ui.showThumbnails->setChecked(settings.showThumbnails());
ui.thumbnailLocal->setChecked(settings.thumbnailLocalFilesOnly());
ui.maxThumbnailFileSize->setValue(settings.maxThumbnailFileSize());
}
void PreferencesDialog::initVolumePage(Settings& settings) {
ui.mountOnStartup->setChecked(settings.mountOnStartup());
ui.mountRemovable->setChecked(settings.mountRemovable());
ui.autoRun->setChecked(settings.autoRun());
if(settings.closeOnUnmount())
ui.closeOnUnmount->setChecked(true);
else
ui.goHomeOnUnmount->setChecked(true);
ui.mountOnStartup->setChecked(settings.mountOnStartup());
ui.mountRemovable->setChecked(settings.mountRemovable());
ui.autoRun->setChecked(settings.autoRun());
if(settings.closeOnUnmount()) {
ui.closeOnUnmount->setChecked(true);
}
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());
ui.terminal->setEditText(settings.terminal());
// load the known terminal list from the terminal.list file of libfm
for(auto& terminal: Fm::allKnownTerminals()) {
ui.terminal->addItem(terminal.get());
}
ui.terminal->setEditText(settings.terminal());
}
void PreferencesDialog::initAdvancedPage(Settings& settings) {
initArchivers(settings);
initTerminals(settings);
ui.suCommand->setText(settings.suCommand());
initArchivers(settings);
initTerminals(settings);
ui.suCommand->setText(settings.suCommand());
ui.onlyUserTemplates->setChecked(settings.onlyUserTemplates());
ui.templateTypeOnce->setChecked(settings.templateTypeOnce());
ui.onlyUserTemplates->setChecked(settings.onlyUserTemplates());
ui.templateTypeOnce->setChecked(settings.templateTypeOnce());
ui.templateRunApp->setChecked(settings.templateRunApp());
ui.templateRunApp->setChecked(settings.templateRunApp());
// FIXME: Hide options that we don't support yet.
ui.templateRunApp->hide();
// FIXME: Hide options that we don't support yet.
ui.templateRunApp->hide();
}
void PreferencesDialog::initFromSettings() {
Settings& settings = static_cast<Application*>(qApp)->settings();
initDisplayPage(settings);
initUiPage(settings);
initBehaviorPage(settings);
initThumbnailPage(settings);
initVolumePage(settings);
initAdvancedPage(settings);
Settings& settings = static_cast<Application*>(qApp)->settings();
initDisplayPage(settings);
initUiPage(settings);
initBehaviorPage(settings);
initThumbnailPage(settings);
initVolumePage(settings);
initAdvancedPage(settings);
}
void PreferencesDialog::applyDisplayPage(Settings& settings) {
if(settings.useFallbackIconTheme()) {
// only apply the value if icon theme combo box is in use
// the combo box is hidden when auto-detection of icon theme from xsettings works.
QString newIconTheme = ui.iconTheme->itemData(ui.iconTheme->currentIndex()).toString();
if(newIconTheme != settings.fallbackIconThemeName()) {
settings.setFallbackIconThemeName(newIconTheme);
QIcon::setThemeName(settings.fallbackIconThemeName());
// update the UI by emitting a style change event
Q_FOREACH(QWidget *widget, QApplication::allWidgets()) {
QEvent event(QEvent::StyleChange);
QApplication::sendEvent(widget, &event);
}
if(settings.useFallbackIconTheme()) {
// only apply the value if icon theme combo box is in use
// the combo box is hidden when auto-detection of icon theme from xsettings works.
QString newIconTheme = ui.iconTheme->itemData(ui.iconTheme->currentIndex()).toString();
if(newIconTheme != settings.fallbackIconThemeName()) {
settings.setFallbackIconThemeName(newIconTheme);
QIcon::setThemeName(settings.fallbackIconThemeName());
// update the UI by emitting a style change event
Q_FOREACH(QWidget* widget, QApplication::allWidgets()) {
QEvent event(QEvent::StyleChange);
QApplication::sendEvent(widget, &event);
}
}
}
}
settings.setBigIconSize(ui.bigIconSize->itemData(ui.bigIconSize->currentIndex()).toInt());
settings.setSmallIconSize(ui.smallIconSize->itemData(ui.smallIconSize->currentIndex()).toInt());
settings.setThumbnailIconSize(ui.thumbnailIconSize->itemData(ui.thumbnailIconSize->currentIndex()).toInt());
settings.setSidePaneIconSize(ui.sidePaneIconSize->itemData(ui.sidePaneIconSize->currentIndex()).toInt());
settings.setSiUnit(ui.siUnit->isChecked());
settings.setBackupAsHidden(ui.backupAsHidden->isChecked());
settings.setShowFullNames(ui.showFullNames->isChecked());
settings.setShadowHidden(ui.shadowHidden->isChecked());
settings.setFolderViewCellMargins(QSize(ui.hMargin->value(), ui.vMargin->value()));
settings.setBigIconSize(ui.bigIconSize->itemData(ui.bigIconSize->currentIndex()).toInt());
settings.setSmallIconSize(ui.smallIconSize->itemData(ui.smallIconSize->currentIndex()).toInt());
settings.setThumbnailIconSize(ui.thumbnailIconSize->itemData(ui.thumbnailIconSize->currentIndex()).toInt());
settings.setSidePaneIconSize(ui.sidePaneIconSize->itemData(ui.sidePaneIconSize->currentIndex()).toInt());
settings.setSiUnit(ui.siUnit->isChecked());
settings.setBackupAsHidden(ui.backupAsHidden->isChecked());
settings.setShowFullNames(ui.showFullNames->isChecked());
settings.setShadowHidden(ui.shadowHidden->isChecked());
settings.setFolderViewCellMargins(QSize(ui.hMargin->value(), ui.vMargin->value()));
}
void PreferencesDialog::applyUiPage(Settings& settings) {
settings.setAlwaysShowTabs(ui.alwaysShowTabs->isChecked());
settings.setFullWidthTabBar(ui.fullWidthTabbar->isChecked());
settings.setShowTabClose(ui.showTabClose->isChecked());
settings.setRememberWindowSize(ui.rememberWindowSize->isChecked());
settings.setFixedWindowWidth(ui.fixedWindowWidth->value());
settings.setFixedWindowHeight(ui.fixedWindowHeight->value());
settings.setAlwaysShowTabs(ui.alwaysShowTabs->isChecked());
settings.setFullWidthTabBar(ui.fullWidthTabbar->isChecked());
settings.setShowTabClose(ui.showTabClose->isChecked());
settings.setRememberWindowSize(ui.rememberWindowSize->isChecked());
settings.setFixedWindowWidth(ui.fixedWindowWidth->value());
settings.setFixedWindowHeight(ui.fixedWindowHeight->value());
}
void PreferencesDialog::applyBehaviorPage(Settings& settings) {
settings.setSingleClick(ui.singleClick->isChecked());
settings.setAutoSelectionDelay(int(ui.autoSelectionDelay->value() * 1000));
settings.setSingleClick(ui.singleClick->isChecked());
settings.setAutoSelectionDelay(int(ui.autoSelectionDelay->value() * 1000));
settings.setBookmarkOpenMethod(OpenDirTargetType(ui.bookmarkOpenMethod->currentIndex()));
settings.setBookmarkOpenMethod(OpenDirTargetType(ui.bookmarkOpenMethod->currentIndex()));
// FIXME: bug here?
Fm::FolderView::ViewMode mode = Fm::FolderView::ViewMode(ui.viewMode->itemData(ui.viewMode->currentIndex()).toInt());
settings.setViewMode(mode);
settings.setConfirmDelete(ui.configmDelete->isChecked());
// FIXME: bug here?
Fm::FolderView::ViewMode mode = Fm::FolderView::ViewMode(ui.viewMode->itemData(ui.viewMode->currentIndex()).toInt());
settings.setViewMode(mode);
settings.setConfirmDelete(ui.configmDelete->isChecked());
if(settings.supportTrash())
settings.setUseTrash(ui.useTrash->isChecked());
if(settings.supportTrash()) {
settings.setUseTrash(ui.useTrash->isChecked());
}
settings.setNoUsbTrash(ui.noUsbTrash->isChecked());
settings.setConfirmTrash(ui.confirmTrash->isChecked());
settings.setQuickExec(ui.quickExec->isChecked());
settings.setNoUsbTrash(ui.noUsbTrash->isChecked());
settings.setConfirmTrash(ui.confirmTrash->isChecked());
settings.setQuickExec(ui.quickExec->isChecked());
}
void PreferencesDialog::applyThumbnailPage(Settings& settings) {
settings.setShowThumbnails(ui.showThumbnails->isChecked());
settings.setThumbnailLocalFilesOnly(ui.thumbnailLocal->isChecked());
settings.setMaxThumbnailFileSize(ui.maxThumbnailFileSize->value());
settings.setShowThumbnails(ui.showThumbnails->isChecked());
settings.setThumbnailLocalFilesOnly(ui.thumbnailLocal->isChecked());
settings.setMaxThumbnailFileSize(ui.maxThumbnailFileSize->value());
}
void PreferencesDialog::applyVolumePage(Settings& settings) {
settings.setAutoRun(ui.autoRun->isChecked());
settings.setMountOnStartup(ui.mountOnStartup->isChecked());
settings.setMountRemovable(ui.mountRemovable->isChecked());
settings.setCloseOnUnmount(ui.closeOnUnmount->isChecked());
settings.setAutoRun(ui.autoRun->isChecked());
settings.setMountOnStartup(ui.mountOnStartup->isChecked());
settings.setMountRemovable(ui.mountRemovable->isChecked());
settings.setCloseOnUnmount(ui.closeOnUnmount->isChecked());
}
void PreferencesDialog::applyAdvancedPage(Settings& settings) {
settings.setTerminal(ui.terminal->currentText());
settings.setSuCommand(ui.suCommand->text());
settings.setArchiver(ui.archiver->itemData(ui.archiver->currentIndex()).toString());
settings.setTerminal(ui.terminal->currentText());
settings.setSuCommand(ui.suCommand->text());
settings.setArchiver(ui.archiver->itemData(ui.archiver->currentIndex()).toString());
settings.setOnlyUserTemplates(ui.onlyUserTemplates->isChecked());
settings.setTemplateTypeOnce(ui.templateTypeOnce->isChecked());
settings.setTemplateRunApp(ui.templateRunApp->isChecked());
settings.setOnlyUserTemplates(ui.onlyUserTemplates->isChecked());
settings.setTemplateTypeOnce(ui.templateTypeOnce->isChecked());
settings.setTemplateRunApp(ui.templateRunApp->isChecked());
}
void PreferencesDialog::applySettings() {
Settings& settings = static_cast<Application*>(qApp)->settings();
applyDisplayPage(settings);
applyUiPage(settings);
applyBehaviorPage(settings);
applyThumbnailPage(settings);
applyVolumePage(settings);
applyAdvancedPage(settings);
settings.save();
Application* app = static_cast<Application*>(qApp);
app->updateFromSettings();
Settings& settings = static_cast<Application*>(qApp)->settings();
applyDisplayPage(settings);
applyUiPage(settings);
applyBehaviorPage(settings);
applyThumbnailPage(settings);
applyVolumePage(settings);
applyAdvancedPage(settings);
settings.save();
Application* app = static_cast<Application*>(qApp);
app->updateFromSettings();
}
void PreferencesDialog::accept() {
applySettings();
QDialog::accept();
applySettings();
QDialog::accept();
}
void PreferencesDialog::selectPage(QString name) {
if(!name.isEmpty()) {
QWidget* page = findChild<QWidget*>(name + "Page");
if(page) {
int index = ui.stackedWidget->indexOf(page);
ui.listWidget->setCurrentRow(index);
if(!name.isEmpty()) {
QWidget* page = findChild<QWidget*>(name + "Page");
if(page) {
int index = ui.stackedWidget->indexOf(page);
ui.listWidget->setCurrentRow(index);
}
}
}
}
void PreferencesDialog::lockMargins(bool lock) {
ui.vMargin->setDisabled(lock);
if(lock) {
ui.vMargin->setValue(ui.hMargin->value());
connect(ui.hMargin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui.vMargin, &QSpinBox::setValue);
}
else
disconnect(ui.hMargin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui.vMargin, &QSpinBox::setValue);
ui.vMargin->setDisabled(lock);
if(lock) {
ui.vMargin->setValue(ui.hMargin->value());
connect(ui.hMargin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui.vMargin, &QSpinBox::setValue);
}
else {
disconnect(ui.hMargin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui.vMargin, &QSpinBox::setValue);
}
}
} // namespace PCManFM

@ -25,49 +25,48 @@
#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...)
explicit PreferencesDialog(QString activePage = QString(), QWidget* parent = 0);
virtual ~PreferencesDialog();
// activePage is the name of page to select (general, display, advanced...)
explicit PreferencesDialog(QString activePage = QString(), QWidget* parent = 0);
virtual ~PreferencesDialog();
virtual void accept();
virtual void accept();
void selectPage(QString name);
void selectPage(QString name);
protected Q_SLOTS:
void lockMargins(bool lock);
void lockMargins(bool lock);
private:
void initIconThemes(Settings& settings);
void initArchivers(Settings& settings);
void initDisplayPage(Settings& settings);
void initUiPage(Settings& settings);
void initBehaviorPage(Settings& settings);
void initThumbnailPage(Settings& settings);
void initVolumePage(Settings& settings);
void initAdvancedPage(Settings& settings);
void initTerminals(Settings& settings);
void applyUiPage(Settings& settings);
void applyDisplayPage(Settings& settings);
void applyBehaviorPage(Settings& settings);
void applyThumbnailPage(Settings& settings);
void applyVolumePage(Settings& settings);
void applyAdvancedPage(Settings& settings);
void initFromSettings();
void applySettings();
void initIconThemes(Settings& settings);
void initArchivers(Settings& settings);
void initDisplayPage(Settings& settings);
void initUiPage(Settings& settings);
void initBehaviorPage(Settings& settings);
void initThumbnailPage(Settings& settings);
void initVolumePage(Settings& settings);
void initAdvancedPage(Settings& settings);
void initTerminals(Settings& settings);
void applyUiPage(Settings& settings);
void applyDisplayPage(Settings& settings);
void applyBehaviorPage(Settings& settings);
void applyThumbnailPage(Settings& settings);
void applyVolumePage(Settings& settings);
void applyAdvancedPage(Settings& settings);
void initFromSettings();
void applySettings();
private:
Ui::PreferencesDialog ui;
Ui::PreferencesDialog ui;
};
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -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_);
}
}
}

@ -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

File diff suppressed because it is too large Load Diff

@ -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,205 +46,200 @@ class Launcher;
class ProxyFilter : public Fm::ProxyFolderModelFilter {
public:
bool filterAcceptsRow(const Fm::ProxyFolderModel* model, FmFileInfo* info) const;
virtual ~ProxyFilter() {}
void setVirtHidden(Fm::Folder folder);
QString getFilterStr() {
return filterStr_;
}
void setFilterStr(QString str) {
filterStr_ = str;
}
bool filterAcceptsRow(const Fm::ProxyFolderModel* model, const std::shared_ptr<const Fm::FileInfo>& info) const;
virtual ~ProxyFilter() {}
void setVirtHidden(const std::shared_ptr<Fm::Folder>& folder);
QString getFilterStr() {
return filterStr_;
}
void setFilterStr(QString str) {
filterStr_ = str;
}
private:
QString filterStr_;
QStringList virtHiddenList_;
QString filterStr_;
QStringList virtHiddenList_;
};
class TabPage : public QWidget {
Q_OBJECT
Q_OBJECT
public:
enum StatusTextType {
StatusTextNormal,
StatusTextSelectedFiles,
StatusTextFSInfo,
StatusTextNum
};
enum StatusTextType {
StatusTextNormal,
StatusTextSelectedFiles,
StatusTextFSInfo,
StatusTextNum
};
public:
explicit TabPage(Fm::Path path, QWidget* parent = nullptr);
virtual ~TabPage();
void chdir(Fm::Path newPath, bool addHistory = true);
explicit TabPage(QWidget* parent = nullptr);
virtual ~TabPage();
Fm::FolderView::ViewMode viewMode() {
return folderSettings_.viewMode();
}
void chdir(Fm::FilePath newPath, bool addHistory = true);
void setViewMode(Fm::FolderView::ViewMode mode);
Fm::FolderView::ViewMode viewMode() {
return folderSettings_.viewMode();
}
void sort(int col, Qt::SortOrder order = Qt::AscendingOrder);
void setViewMode(Fm::FolderView::ViewMode mode);
int sortColumn() {
return folderSettings_.sortColumn();
}
void sort(int col, Qt::SortOrder order = Qt::AscendingOrder);
Qt::SortOrder sortOrder() {
return folderSettings_.sortOrder();
}
int sortColumn() {
return folderSettings_.sortColumn();
}
bool sortFolderFirst() {
return folderSettings_.sortFolderFirst();
}
void setSortFolderFirst(bool value);
Qt::SortOrder sortOrder() {
return folderSettings_.sortOrder();
}
bool sortCaseSensitive() {
return folderSettings_.sortCaseSensitive();
}
bool sortFolderFirst() {
return folderSettings_.sortFolderFirst();
}
void setSortFolderFirst(bool value);
void setSortCaseSensitive(bool value);
bool sortCaseSensitive() {
return folderSettings_.sortCaseSensitive();
}
bool showHidden() {
return folderSettings_.showHidden();
}
void setSortCaseSensitive(bool value);
void setShowHidden(bool showHidden);
bool showHidden() {
return proxyModel_->showHidden();
}
Fm::Path path() {
return Fm::Path(!folder_.isNull() ? folder_.getPath() : nullptr);
}
void setShowHidden(bool showHidden);
QString pathName();
Fm::FilePath path() {
return folder_ ? folder_->path() : Fm::FilePath();
}
Fm::Folder& folder() {
return folder_;
}
QString pathName();
Fm::FolderModel* folderModel() {
return reinterpret_cast<Fm::FolderModel*>(folderModel_);
}
const std::shared_ptr<Fm::Folder>& folder() {
return folder_;
}
View* folderView() {
return folderView_;
}
Fm::FolderModel* folderModel() {
return reinterpret_cast<Fm::FolderModel*>(folderModel_);
}
Fm::BrowseHistory& browseHistory() {
return history_;
}
View* folderView() {
return folderView_;
}
Fm::FileInfoList selectedFiles() {
return folderView_->selectedFiles();
}
Fm::BrowseHistory& browseHistory() {
return history_;
}
Fm::PathList selectedFilePaths() {
return folderView_->selectedFilePaths();
}
Fm::FileInfoList selectedFiles() {
return folderView_->selectedFiles();
}
void selectAll();
Fm::FilePathList selectedFilePaths() {
return folderView_->selectedFilePaths();
}
void invertSelection();
void selectAll();
void reload() {
if(!folder_.isNull()) {
proxyFilter_->setVirtHidden(folder_); // reread ".hidden"
folder_.reload();
}
}
void invertSelection();
QString title() const {
return title_;
}
void reload();
QString statusText(StatusTextType type = StatusTextNormal) const {
return statusText_[type];
}
QString statusText(StatusTextType type = StatusTextNormal) const {
return statusText_[type];
}
bool canBackward() {
return history_.canBackward();
}
bool canBackward() {
return history_.canBackward();
}
void backward();
void backward();
bool canForward() {
return history_.canForward();
}
bool canForward() {
return history_.canForward();
}
void forward();
void forward();
void jumpToHistory(int index);
void jumpToHistory(int index);
bool canUp();
bool canUp();
void up();
void up();
void updateFromSettings(Settings& settings);
void updateFromSettings(Settings& settings);
void setFileLauncher(Fm::FileLauncher* launcher) {
folderView_->setFileLauncher(launcher);
}
void setFileLauncher(Fm::FileLauncher* launcher) {
folderView_->setFileLauncher(launcher);
}
Fm::FileLauncher* fileLauncher() {
return folderView_->fileLauncher();
}
Fm::FileLauncher* fileLauncher() {
return folderView_->fileLauncher();
}
QString getFilterStr() {
if(proxyFilter_)
return proxyFilter_->getFilterStr();
return QString();
}
QString getFilterStr() {
if(proxyFilter_) {
return proxyFilter_->getFilterStr();
}
return QString();
}
void setFilterStr(QString str) {
if(proxyFilter_)
proxyFilter_->setFilterStr(str);
}
void setFilterStr(QString str) {
if(proxyFilter_) {
proxyFilter_->setFilterStr(str);
}
}
void applyFilter();
void applyFilter();
bool hasCustomizedView() {
return folderSettings_.isCustomized();
}
bool hasCustomizedView() {
return folderSettings_.isCustomized();
}
void setCustomizedView(bool value);
void setCustomizedView(bool value);
Q_SIGNALS:
void statusChanged(int type, QString statusText);
void titleChanged(QString title);
void openDirRequested(FmPath* path, int target);
void sortFilterChanged();
void forwardRequested();
void backwardRequested();
void statusChanged(int type, QString statusText);
void titleChanged(QString title);
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();
void freeFolder();
QString formatStatusText();
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);
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 onFolderFsInfo();
void onFolderRemoved();
void onFolderUnmount();
void onFolderContentChanged();
private:
View* folderView_;
Fm::CachedFolderModel* folderModel_;
Fm::ProxyFolderModel* proxyModel_;
ProxyFilter* proxyFilter_;
QVBoxLayout* verticalLayout;
Fm::Folder folder_;
QString title_;
QString statusText_[StatusTextNum];
Fm::BrowseHistory history_; // browsing history
Fm::Path lastFolderPath_; // last browsed folder
bool overrideCursor_;
FolderSettings folderSettings_;
View* folderView_;
Fm::CachedFolderModel* folderModel_;
Fm::ProxyFolderModel* proxyModel_;
ProxyFilter* proxyFilter_;
QVBoxLayout* verticalLayout;
std::shared_ptr<Fm::Folder> folder_;
QString statusText_[StatusTextNum];
Fm::BrowseHistory history_; // browsing history
Fm::FilePath lastFolderPath_; // last browsed folder
bool overrideCursor_;
FolderSettings folderSettings_;
};
}

@ -0,0 +1,4 @@
#Translations
Name[lt]=Darbalaukis
GenericName[lt]=Darbalaukio nustatymai
Comment[lt]=Keisti darbalaukio tvarkytuvės darbalaukio foną ir elgseną

@ -0,0 +1,4 @@
#Translations
Name[lt]=PCManFM failų tvarkytuvė
GenericName[lt]=Failų tvarkytuvė
Comment[lt]=Naršyti failų sistemą ir tvarkyti failus

@ -31,48 +31,48 @@
namespace PCManFM {
View::View(Fm::FolderView::ViewMode _mode, QWidget* parent):
Fm::FolderView(_mode, parent) {
Fm::FolderView(_mode, parent) {
Settings& settings = static_cast<Application*>(qApp)->settings();
updateFromSettings(settings);
Settings& settings = static_cast<Application*>(qApp)->settings();
updateFromSettings(settings);
}
View::~View() {
}
void View::onFileClicked(int type, FmFileInfo* fileInfo) {
if(type == MiddleClick) {
if(fm_file_info_is_dir(fileInfo)) {
Q_EMIT openDirRequested(fm_file_info_get_path(fileInfo), OpenInNewTab);
void View::onFileClicked(int type, const std::shared_ptr<const Fm::FileInfo>& fileInfo) {
if(type == MiddleClick) {
if(fileInfo->isDir()) {
Q_EMIT openDirRequested(fileInfo->path(), OpenInNewTab);
}
}
else {
Fm::FolderView::onFileClicked(type, fileInfo);
}
}
else {
Fm::FolderView::onFileClicked(type, fileInfo);
}
}
void View::onNewWindow() {
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
// FIXME: open the files in a new window
Application* app = static_cast<Application*>(qApp);
app->openFolders(menu->files());
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
// FIXME: open the files in a new window
Application* app = static_cast<Application*>(qApp);
app->openFolders(menu->files());
}
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);
}
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
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());
}
Application* app = static_cast<Application*>(qApp);
Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(sender()->parent());
auto files = menu->files();
for(auto& file: files) {
app->openFolderInTerminal(file->path());
}
}
void View::onSearch() {
@ -80,49 +80,50 @@ void View::onSearch() {
}
void View::prepareFileMenu(Fm::FileMenu* menu) {
Application* app = static_cast<Application*>(qApp);
menu->setConfirmDelete(app->settings().confirmDelete());
menu->setConfirmTrash(app->settings().confirmTrash());
menu->setUseTrash(app->settings().useTrash());
// 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())
all_directory = false;
else if(fi.isDir() && !fi.isNative())
all_native = false;
}
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);
action = new QAction(QIcon::fromTheme("window-new"), tr("Open in New Win&dow"), menu);
connect(action, &QAction::triggered, this, &View::onNewWindow);
menu->insertAction(menu->separator1(), action);
// TODO: add search
// action = menu->addAction(_("Search"));
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);
Application* app = static_cast<Application*>(qApp);
menu->setConfirmDelete(app->settings().confirmDelete());
menu->setConfirmTrash(app->settings().confirmTrash());
menu->setUseTrash(app->settings().useTrash());
// add some more menu items for dirs
bool all_native = true;
bool all_directory = true;
auto files = menu->files();
for(auto& fi: files) {
if(!fi->isDir()) {
all_directory = false;
}
else if(fi->isDir() && !fi->isNative()) {
all_native = false;
}
}
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);
action = new QAction(QIcon::fromTheme("window-new"), tr("Open in New Win&dow"), menu);
connect(action, &QAction::triggered, this, &View::onNewWindow);
menu->insertAction(menu->separator1(), action);
// TODO: add search
// action = menu->addAction(_("Search"));
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()) { // nullptr for trash
menu->pasteAction()->setVisible(false);
}
if(menu->createAction()) {
menu->createAction()->setVisible(false);
}
}
}
else {
if(menu->pasteAction()) // NULL for trash
menu->pasteAction()->setVisible(false);
if(menu->createAction())
menu->createAction()->setVisible(false);
}
}
void View::prepareFolderMenu(Fm::FolderMenu* menu) {
@ -130,19 +131,19 @@ void View::prepareFolderMenu(Fm::FolderMenu* menu) {
void View::updateFromSettings(Settings& settings) {
setIconSize(Fm::FolderView::IconMode, QSize(settings.bigIconSize(), settings.bigIconSize()));
setIconSize(Fm::FolderView::CompactMode, QSize(settings.smallIconSize(), settings.smallIconSize()));
setIconSize(Fm::FolderView::ThumbnailMode, QSize(settings.thumbnailIconSize(), settings.thumbnailIconSize()));
setIconSize(Fm::FolderView::DetailedListMode, QSize(settings.smallIconSize(), settings.smallIconSize()));
setIconSize(Fm::FolderView::IconMode, QSize(settings.bigIconSize(), settings.bigIconSize()));
setIconSize(Fm::FolderView::CompactMode, QSize(settings.smallIconSize(), settings.smallIconSize()));
setIconSize(Fm::FolderView::ThumbnailMode, QSize(settings.thumbnailIconSize(), settings.thumbnailIconSize()));
setIconSize(Fm::FolderView::DetailedListMode, QSize(settings.smallIconSize(), settings.smallIconSize()));
setMargins(settings.folderViewCellMargins());
setMargins(settings.folderViewCellMargins());
setAutoSelectionDelay(settings.autoSelectionDelay());
setAutoSelectionDelay(settings.autoSelectionDelay());
Fm::ProxyFolderModel* proxyModel = model();
if(proxyModel) {
proxyModel->setShowThumbnails(settings.showThumbnails());
}
Fm::ProxyFolderModel* proxyModel = model();
if(proxyModel) {
proxyModel->setShowThumbnails(settings.showThumbnails());
}
}
} // namespace PCManFM

@ -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,38 +35,38 @@ namespace PCManFM {
class Settings;
class View : public Fm::FolderView {
Q_OBJECT
Q_OBJECT
public:
explicit View(Fm::FolderView::ViewMode _mode = IconMode, QWidget* parent = 0);
virtual ~View();
explicit View(Fm::FolderView::ViewMode _mode = IconMode, QWidget* parent = 0);
virtual ~View();
void updateFromSettings(Settings& settings);
void updateFromSettings(Settings& settings);
QSize getMargins() const {
return Fm::FolderView::getMargins();
}
void setMargins(QSize size) {
Fm::FolderView::setMargins(size);
}
QSize getMargins() const {
return Fm::FolderView::getMargins();
}
void setMargins(QSize size) {
Fm::FolderView::setMargins(size);
}
Q_SIGNALS:
void openDirRequested(FmPath* path, int target);
void openDirRequested(const Fm::FilePath& path, int target);
protected Q_SLOTS:
void onNewWindow();
void onNewTab();
void onOpenInTerminal();
void onSearch();
void onNewWindow();
void onNewTab();
void onOpenInTerminal();
void onSearch();
protected:
virtual void onFileClicked(int type, FmFileInfo* fileInfo);
virtual void prepareFileMenu(Fm::FileMenu* menu);
virtual void prepareFolderMenu(Fm::FolderMenu* menu);
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);
private:
};
};
}
#endif // PCMANFM_FOLDERVIEW_H

Loading…
Cancel
Save