diff --git a/doc/index.docbook b/doc/index.docbook
index 4a38a157a..3495ee9bc 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1,2155 +1,2155 @@
]>
The &dolphin; HandbookPeterPenzpeter.penz@gmx.atOrvilleBennett
&Orville.Bennett.mail;
MichaelAustintuxedup@users.sourceforge.netDavidEdmundsonkde@davidedmundson.co.ukAlanBlanchflowerFrankReininghausfrank78ac@googlemail.com2006Peter Penz2006&Orville.Bennett;Michael Austin2009Frank Reininghaus&FDLNotice;2019-02-17Applications 19.04
&dolphin; is the default file manager by &kde;, designed with usability as a primary focus.
KDEDolphinFilemanagerfilemanagementIntroduction
&dolphin; is &plasma;'s default file manager. It aims to improve usability at the
user interface level. &dolphin; focuses only on being a file manager whereas
&konqueror;, which was &kde;'s default file manager in &kde; 3 and can still be
used for file management, is a universal viewer for many file types.
This design approach allows the developers to concentrate on optimizing the user
interface for the specific task of file management.
Please report any problems or feature requests to the &dolphin; author via the
bug report dialog. This is accessible either from the Control
button at the right of the toolbar in the default mode without
menubar; or from HelpReport Bug...
menu of the application, if the menubar is shown.
Using &dolphin;&dolphin; User Interface
The screenshot below shows &dolphin;'s default user interface:
Screenshot of &dolphin;'s default user interface&dolphin;'s default user interface.
&dolphin;'s default user interface.
The elements of the default user interface are:
The toolbar, which can be used for quick access to frequently used actions. The
toolbar can be customized by clicking it with the &RMB; and choosing
Configure Toolbars...
from the context menu, with Configure Toolbars...
from the Control button at the
right of the toolbar or via SettingsConfigure Toolbars...
from the main menu.
Screenshot of &dolphin;'s toolbarThe default toolbar.
Toolbar items where the icon is sufficient for knowing the command do not have text
alongside the icons. This can be changed by a &RMB; click and selecting the item text
below Show Text. The Control
button at the right side of the toolbar is only displayed if the menubar is hidden.
The location bar, which always displays the path to the current folder. It can
be switched between two different modes, see the
section on the location bar for details.
The view, which shows all files
and folders in the current folder.
The Places panel, which
provides quick access to bookmarked locations and disks or other media.
If desktop search and file indexing are enabled in the Desktop Search
module in the &systemsettings; the panel provides Recently Saved
items and allows you to search for Documents, Images,
Audio Files and Video.
The status bar. It displays the name, size and type of the file which is
currently hovered over with the mouse, or the number and size of the files which are
selected. At the right, there is a zoom slider that allows you to adjust the size
of the icons in the view.
The menubar (hidden by default), which provides access to all commands and configuration options.
See the Command Reference for a list of
all menu commands. The menubar can be toggled with
Show Menubar (&Ctrl;M)
from the Settings menu or the Control button.
If the menubar is hidden, all its actions are available from the
Control button.
The additional Information, Folders
and Terminal panels are hidden
by default, for more information see Panels.
The &dolphin; ViewUsing the View
The view displays all files and folders in the current folder. These items
can be accessed or manipulated in different ways:
A file or folder can be opened by clicking it with the &LMB; (or
double-clicking, if Double-click to open files and folders
is enabled in the &systemsettings; in the Input DevicesMouse module.
Clicking any item or the white area around the items with the &RMB; opens a
context menu which provides access to many frequently used actions for the item
or the current folder, respectively.
If the &LMB; is pressed on an item, but not immediately released, the item can
be dragged and dropped in another folder in the current view or in another
&dolphin; view (in another &dolphin; window or in the same window if the
view is split, see below) to move or copy it or to create a symbolic link.
Items can even be dropped in another application to open them in that application.
&dolphin; remembers the history of visited folders. To navigate backward or
forward in the history, the corresponding buttons in the toolbar can be used:
Screenshot of &dolphin;'s toolbarThe Back and Forward buttons in the toolbar.
The Back and Forward buttons in
the toolbar can be used to navigate in the history.
If you click with the &MMB; the item in the history is opened in a new tab
thus keeping the current tab with its content.
&dolphin; View Appearance
The toolbar contains buttons to control the appearance of the view:
Screenshot of &dolphin;'s toolbarThe buttons in the toolbar which control the appearance of the view.
The buttons in the toolbar which control the appearance of the view.
All the settings discussed below and other options concerning, ⪚ the
sorting of the files in the current folder, can also be modified in the
View menu and in the
View Properties dialog. By
default, these settings are remembered for each folder separately. This
behavior can be changed in the
General section of the settings.
View Modes
The first three buttons in the above screenshot switch between &dolphin;'s
view modes.
In the Icons view, which is the default, files will be
represented by an icon that visualizes the file type, and a folder icon will be
shown for subfolders. The names of folders and files, and the items enabled in
ViewAdditional Information,
are displayed below the icons.
The Compact view shows the folder contents as icons with
the name beside it and the items enabled in
ViewAdditional Information
below the name. The items are grouped in columns similar to the Short View
in the &kde; file dialog.
In the Details view, the folder contents are displayed
as a detailed list which contains the name, size and last modification time of
each item. Additional columns can be added by clicking a column header with the
&RMB;.
In the context menu of the header line you can choose between custom or automatic
column width. Automatic width adjusts the width of all columns once to display the longest
item in the column completely, except for the Name column where
the extension is replaced by ...The order of columns can be changed by drag and drop of column headers, except for
the Name header, which is always the first column in this view.
The details view allows you to view the current folder
in a tree-like fashion if
Expandable folders are enabled:
Each subfolder of the current folder can be
expanded or collapsed by clicking on the >
or v icon next to it.Grouped ViewGrouped View
All view modes support grouping by the sort type selected
in ViewSort by
Information in the View
In all view modes &dolphin; shows at least an icon and a name for each item.
Using Additional Information in the View
menu or the context menu of the header in Details mode, you can select
more information for each item to be shown:
Size, Date,
Type, Rating,
Tags or Comment.
Depending on the file type, additionally, sorting criteria can be selected:
Document: Number of words and linesImage: Size and orientationAudio: Artist, album, duration and trackThe Other submenu allows you to select
Path, Link Destination,
Copied From,
Permissions, Owner or
User Group.
Preview
If Preview is enabled, the icons are based on the actual
file or folder contents; ⪚ for images a scaled down preview of the image is
shown.
Split
If Split is clicked, two views are shown which can
display the contents of different folders. This can be convenient for moving or
copying files.
Selecting Items in the View
There are several ways to select items in the view. Once a group of items
is selected, all actions, such as
Cut,
Copy,
Move to Trash,
and drag and drop operations, affect all selected items.
Selecting Items Using the Mouse
You can press the &LMB; somewhere in the view and draw a rectangle around
a group of items before releasing the button. This will select all items in the
rectangle and clear the previous selection. If the &Shift; key is pressed during
the selection process, the previous selection is kept.
If the &Ctrl; key is pressed while an item is clicked with the &LMB;, the
selection state of this item is toggled. If the &Ctrl; key is pressed while a
rectangle is drawn around a group of items as described above, the selection
state of all items in the rectangle will be toggled.
If the &Shift; key is pressed while an item is clicked with the &LMB;, all items
between the previous current item and the clicked item will be selected.
If Show selection marker is enabled in the
Behavior
tab of the General section of the settings, a small
+ or - button appears in the top
left corner of the item which is currently hovered over with the mouse. Clicking
this sign selects or deselects the item, respectively.
Selecting Items Using the Keyboard
If an arrow key, Page Up, Page Down,
Home, or End is pressed, the new current item
is selected, and the previous selection is cleared.
If the &Ctrl; key is held while one of the above keys is pressed, the selection
remains unchanged.
If the &Shift; key is held while one of the above keys is pressed, all items
between the previous current item and the new current item will be selected.
If &Ctrl;Space is pressed,
the selection state of the current item is toggled.
&Ctrl;A selects all items
in the view.
&Ctrl;&Shift;A toggles the
selection state of all items in the view.
Select a file or folder by typing the first few letters of its name and the
first matching item is selected.
To clear the selection and cancel the keyboard search press &Esc; or wait longer than
the timeout of 1 second.
Location Bar
The location bar, which can be found above &dolphin;'s view, displays
the path to the current folder. The location bar has two modes.
Bread Crumb Mode
In the bread crumb mode, which is the default, each folder name in
the path to the current folder is a button which can be clicked to quickly open
that folder. Moreover, clicking the > sign to the right of a
folder opens a menu which allows you to quickly open a subfolder of that folder.
Screenshot of the location bar in bread crumb modeLocation bar in bread crumb mode.
Location bar in bread crumb mode.
Editable Mode
When in bread crumb mode, clicking in the gray area to the right of the path
with the &LMB; switches the location bar to editable mode,
in which the path can be edited using the keyboard. To switch back to bread
crumb mode, click the check mark at the right of the location bar with the &LMB;.
Screenshot of the location bar in editable modeLocation bar in editable mode.
Location bar in editable mode.
Using KioslavesIf the location bar is empty in editable mode, a drop down box appears in
front of the bar listing all available kioslaves on your system. Kioslaves are
programs built into &kde; which add support for many different protocols to
&dolphin; and other &kde; applications.For example with the fish kioslave &dolphin; can be
used to manage files and folders on a remote host that is accessible
via SSH. To do this you would type fish://username@remotehost
into the location bar. Similar remote file management can be done on
remote hosts accessible via the &FTP;, NFS, SFTP, SMB (CIFS) or webdav protocols.It is also possible to use the kioslaves drop down list to access
&systemsettings;, fonts, trash, other programs and devices attached to your computer.
See the drop down list for the full list of capabilities available from kioslaves on your system.
Screenshot of the list of kioslavesLocation bar showing list of available kioslaves.
List of available kioslaves.
Places and Context
If the Places panel is hidden; in both modes an additional icon
in front of the path is displayed. This icon can be clicked with the &LMB; to open a
menu which offers quick access to places and storage media. See the
section about the Places Panel for details.
Location bar with Places iconLocation bar with Places iconThe context menu of the location bar offers actions to switch between the modes and
to copy and paste the path using the clipboard. Check the last option in this context menu to
display either the full path starting with the root folder of the file system or to display
the path starting with the current places entry.
Location bar context menuLocation bar context menuPanels
&dolphin; allows a number of panels to be placed next to the view. These can
be enabled in ViewPanels.
By unlocking the panels and clicking and dragging a panel title, the panel can be moved
to a different position, even outside the window.
Places
The Places panel is located at the left of the window by
default. The Places panel shows any locations you have
bookmarked. It also shows any disk or media attached to the computer, recently accessed items
and allows you to search for certain type of files. The order of these entries can be changed by drag and drop.
The easiest way to add a folder to the Places panel is to
drag it and drop it in the panel. Moreover, you can click inside the panel with
the &RMB; and choose Add Entry...
from the context menu. The first procedure creates a system wide bookmark, the second
procedure can be used to add the current path of the location bar or any desired folder or device.
A dialog opens where label, location and icon can be edited and the usage of this entry
can be restricted to &dolphin;.
A &RMB; click opens the context menu to edit, add, hide or remove entries
and change the icon size to one of the predefined values or lock/unlock the panels.
The context menu has an action to open the entry in a new tab.
Devices can be unmounted using the context menu.
Information
The Information panel shows extended information about the
selected items(s) or about the current folder or the file which is currently hovered
over with the mouse, including size, type, and date of last modification. It also
features a large preview of the selected item and allows you to assign a rating,
tags, and comments to it.
Folders
The Folders panel shows a tree view structure of the file
system. It only shows folders. Clicking a folder with the &LMB; opens this folder
in the &dolphin; view.
Use Limit to Home Directory to hide all folders from
the tree view except your Home.
Terminal
This panel contains a terminal. The terminal will open at the folder currently
shown in the &dolphin; view. Changing the folder in the active &dolphin;
view will update the working folder of the terminal. Changing the directory in
the terminal will update the working folder in the &dolphin; view. The
terminal only works with local media.
Quick Tips
The following are a number of tips to save time when using &dolphin;.
Quick Bookmarking
To quickly create a bookmark in the Places panel for the
current folder, &RMB; click in the work space and click
Add to Places in the context menu.
Finding Files and Searching in Files
&dolphin; is capable of searching for files and for content in files. If
&Ctrl;F is pressed or Edit
-Find... is used, the Find
+Search... is used, the Search
bar will open already set up to search for files within the current folder and any sub-folders.
Start to type into the find input box and the search starts immediately.
Search files and for content in filesSearch files and for content in files
&dolphin; searching files and for content in files.
The search is case insensitive, and does not require surrounding wildcards
(*foo* and foo are equivalent),
but you can use wildcards inside the search term. * will match
zero or more characters, ? only one single character.This feature can be used with running Baloo services; without these services
a KIOSlave is launched to provide the search results.The option from Everywhere with activated Baloo
services searches in all indexed folders, without Baloo this option
starts the search from the user's Home folder.Search with More OptionsSearch with More Options
&dolphin; searching with More Options.
-Use the More Options button to extend the Find
+Use the More Options button to extend the Search
bar. This provides a very comfortable way for
the user to shrink the number of search results.To start a search select one or more file types (Documents,
Audio, Video, Images),
a time period and ratingAlternatively you can use these options in the Places panel
together with the Filter bar to find files using Baloo or limit
the search to files matching the filter expression.Use the Save icon to save a search to the Search For
section in the Places panel to quickly access it again in the future.
Mounting Storage Media
A quick way to mount Storage Media is to click on the device in the
Places panel. This will mount and open the device in &dolphin;.
Undo Actions
&dolphin; is capable of undoing changes you have made to files. For example if
you moved a file to the Trash, &dolphin; can undo this and move it back to its
original location. To undo an action, press &Ctrl;Z
or select EditUndo: (action name)
in the menu, ⪚ Undo: Rename.
Renaming A Batch Of Files
&dolphin; is capable of renaming a number of files at the same time. Each file
will have the file name specified, including a number, ⪚, Image1.jpg,
Image2.jpg, Image3.jpg. This can be useful, ⪚, for pictures taken with a digital camera.
If you wish to rename a batch of files, first select the files to be renamed.
This can be done by pressing the &LMB; and drawing a rectangle around the files
to be renamed before releasing it, or by holding &Ctrl; and clicking each file
to be renamed (see Selecting Items in the View
for more details on item selection). Then open the batch-rename dialog by pressing
F2 or via the File menu:
FileRename...
Then enter the name you wish to give the files. The # character must be present
within the name. The files will then be renamed, where the #
character is replaced by a different consecutive number for each file.
If all file extensions in your selection are different, the name of all files
can be changed without using a # placeholder while preserving
the file extensions. This is ⪚ useful to rename a video file and all associated
subtitle files, which have the same filename, but different extensions.
Comparing A Selection Of Files or Folders
If the &kompare; application is installed, you can use it to see the differences
between two files or folders.
First select the two files or folders to be compared. Then launch the &kompare; application
via the Tools menu: ToolsCompare Files.
&kompare; will then open showing the differences between the files or folders.
Filtering Files
&dolphin; is capable of filtering files, &ie; showing only those items in the
view whose name contains a given text. For example, if you wish to show
only the MP3 files within a folder, you could filter for .mp3.
This would then filter out all files whose name does not contain .mp3.
To filter files, first enable the filter bar, either by pressing &Ctrl;I
or via the menu: ToolsShow Filter Bar.
You can then enter the text to be filtered for in the filter bar. The filter bar can
be disabled either by pressing &Esc;, or with a &LMB; click on the
Hide Filter Bar icon.
Configuring &dolphin;
&dolphin; distinguishes two different kinds of settings:
Settings which affect the general behavior of &dolphin;. These can be configured
using the Preferences Dialog.
Settings which determine how the contents of a folder are displayed in &dolphin;.
These settings are called View Properties
and can be controlled with toolbar buttons, via the View menu,
and with the View Properties Dialog.
In the default configuration, the view properties are remembered for each folder,
but &dolphin; can also be configured to use common view properties for all folders
in the General
section of the settings.
The &dolphin; Preferences Dialog
The Preferences Dialog is opened via SettingsConfigure &dolphin;... in the menu in
&dolphin;'s main window. The settings are divided into several groups which can
be accessed by clicking the corresponding icon on the left of the dialog.
All settings except for the Startup page and the Status Bar
tab on the General page are shared with &konqueror; in filemanager mode.
General
This group contains settings which control the general behavior of &dolphin;.
The group is divided further into four subgroups which can be accessed using the
tab bar at the top.
Screenshot of the General settings in &dolphin;'s preferences dialogGeneral Settings.
General Settings in &dolphin;'s Preferences Dialog.
Behavior Tab
In the View section, you can configure whether the
view properties are stored for each
folder or if common view properties are to be used for all folders.
Sorting Mode controls how items are sorted in
the view. If Natural sorting is enabled, the sort order of three example files
will be
File1,File2,File10.
If this option is disabled, the normal alphabetical sorting case sensitive or case insensitive
will be used, which leads to the sort order
File1,File10,File2.
When hovering over a file or folder with the mouse, a small window with relevant
information is shown if Show tooltips is enabled.
Show selection marker shows a small +
or - button above an item's icon if the item is hovered over
with the mouse. These can be used to select or deselect the item.
Enable Rename inline to use this mode if only one item is currently selected.
If this option is disabled or several items are selected, a dialog will be displayed for renaming.
Enabling Switch between split panes with tab key
allows to switch split views with the 	 key.
Disable Turning off split view closes active pane
to close the inactive pane when you are turning off the split view mode, ⪚ pressing F3.
Previews Tab
In this tab, you can configure for which file types previews are shown.
Moreover, the maximum size of remote files for which previews are generated can be chosen.
If previews are enabled for folders, previews of some files in the folder will
be shown inside a folder's icon.
Confirmations Tab
In the ask for confirmation section, you can enable warning dialogs that
are shown before potentially harmful actions .
The confirmation settings for Moving files or folders to trash and
Deleting files or folders affect file operations in &dolphin;, &konqueror;,
Gwenview and all &kde; applications using the default &kde; file dialog,
whereas Closing Dolphin windows
with multiple tabs is a &dolphin; specific setting.Status Bar Tab
In this tab, some additional items can be enabled for the status bar, provided
the status bar is wide enough:
A zoom slider which can be used to change the icon size quickly.
A bar that shows how much space is free on the current drive.
Startup
This group contains settings which control the appearance of &dolphin; on startup.
Screenshot of the Startup settings in &dolphin;'s preferences dialogStartup Settings.
Startup Settings in &dolphin;'s Preferences Dialog.
The Start in folder is the folder which is opened on startup. The
location of the folder can be entered directly or chosen in a dialog which can
be opened by clicking the button showing a folder icon. Moreover,
the current location or the default location (which is the user's home folder)
can be used as the startup folder by clicking the corresponding button.
Split view mode controls if the
&dolphin; view is split on startup
or not.
Editable location bar controls if the location bar is in
editable mode on startup. The bread crumb mode of the location bar is used
otherwise. See the section about the location bar
for details about the two modes.
If Show full path inside location bar is enabled, the full
path of the current location is shown in the bread crumb mode of the location bar.
Otherwise, a shortened version of the path is shown if it begins with the path of
one of the places in the Places panel.
Show filter bar controls if the filter bar is shown on
startup or not. See the section on the filter bar
for details.
Show full path in title bar makes it easy to distinguish
between files or folders with the same name in different folders.
View Modes
This group contains settings which control the behavior of &dolphin;'s view
modes. The three view modes (Icons, Compact, and Details) are accessible via the
tab bar at the top.
Screenshot of the Icons View settings in &dolphin;'s preferences dialogView Modes Settings.
View Modes Settings in &dolphin;'s Preferences Dialog.
Common settings for all view modes
All three view modes have some common settings:
Sliders which control the size of the icons. The Default or
Preview sizes are used if previews are disabled or enabled,
respectively. Note that the icon size can be changed easily with the zoom slider
in the status bar if the corresponding option is enabled in the
General
section of the settings.
A setting for the font used in the view mode: either the system font or a
custom font can be chosen.
The other settings in the Text section which apply to only
one of the view modes are discussed below.
IconsWidth controls the minimum width that is reserved for
the text of a file item.
Maximum lines means maximum number of text lines below the icon.
CompactMaximum width controls the maximum width that is reserved for
the text of a file item.
DetailsExpandable folders determines whether any folders that have subfolders
are displayed in a tree view, where the sub items can be expanded by &LMB; clicking the
> icon and collapsed by clicking the v icon.
Navigation
This group contains settings which control how navigation in the folder
structure and in archives works.
Screenshot of the Navigation settings in &dolphin;'s preferences dialogNavigation Settings.
Navigation Settings in &dolphin;'s Preferences Dialog.
The option to open items with a single or double mouse click is a system wide setting and can be
changed in the &systemsettings; in the Input DevicesMouse module.
Archives will be opened inside &dolphin;, and not in an external application, if
Open Archives as folder is enabled.
If Open folders during drag operations is enabled, dragging
an item with the mouse and hovering over a folder with it for a short time will open
that folder. This allows you to move or copy items quickly to folders which are
several levels deeper in the folder hierarchy.
Services
This group offers a selection of services that can be shown in the
Actions submenu of &dolphin;'s context menu which
appears when clicking a file or folder with the &RMB;.
Screenshot of the Services settings in &dolphin;'s preferences dialogServices Settings.
Services Settings in &dolphin;'s Preferences Dialog.
Using the Download New Services you can fetch additional
services for the context menu.
If you have installed &dolphin;'s plugins for Bazaar,
Mercurial, Git or
Subversion from the kdesdk module these services are shown in the list.
If these plugins are enabled and you enter a folder which is under version control,
the version state (locally changed, up to date &etc;) is indicated by icons
and you have additional entries in the
context menu like commit, update, add, remove &etc;
In the service list you can also choose if the Delete,
Copy To, and Move To
commands are shown in the context menu.
&dolphin; has to be restarted to activate the changes for some of these settings.
Trash
This group contains settings which control the behavior of the trash.
Screenshot of the Trash settings in &dolphin;'s preferences dialogTrash Settings.
Trash Settings in &dolphin;'s Preferences Dialog.
Files which are older than a configurable number of days can be deleted automatically.
The size of the trash can be limited to a configurable percentage of the disk
size. If this limit is reached, a warning can be issued, or the oldest or
largest files can be deleted automatically.
Folder View Properties
The following settings control how the contents of a folder are displayed in the
&dolphin; view, and are stored on a per-folder basis by default:
The view mode (Icons, Compact, Details)
The sorting of items, which is determined by the sort order (ascending,
descending) and the attribute (such as name, size,...) that the items are
sorted by
Sorting of folders and files – are folders shown first or not?
Previews – are they shown instead of icons (based on the settings made in
Previews
tab of &dolphin;'s General settings) or not?
Are items shown in groups in the views?
Are hidden files shown?
What additional information (besides the name) is shown in the Icons or Details view?
The view properties can be configured in the
View menu, some (such as the view
mode) can also be changed using toolbar buttons.
The View Properties DialogScreenshot of the View Properties dialogThe View Properties dialog.
The View Properties Dialog.
The View Properties dialog can be used to quickly modify
several view properties at once. This is done for the current folder, for the
current folder including all subfolders, or even for all folders, depending on
the choice made in the Apply to section.
If Use as default view settings is enabled, the chosen view
properties will also be used for all folders which do not have customized view
properties yet.
Command ReferenceBy default the menubar is not shown. All actions described here either can
be accessed with toolbar buttons or with items in the menu of the
Control toolbar button.The Menubar in &dolphin;'s Main WindowThe File MenuFileCreate NewCreates a new object (such as a folder or a text file) in the current
folder.You will find an explanation of all available objects in &konqueror;'s handbook in the chapter
Create New.&Ctrl;NFileNew WindowOpens a new &dolphin; window.&Ctrl;TFileNew TabOpens a new tab.&Ctrl;WFileClose TabCloses the current tab.&Ctrl;&Shift;TFileUndo close tabReopens the last closed tab.F2FileRenameRenames one currently selected item inline.
Opens the batch rename dialog if several
items are selected.DelFileMove to TrashMoves the currently selected item(s) to the
trash.&Shift;DelFileDeletePermanently deletes the currently selected item(s). The items are not moved
to the trash and cannot be restored.FileShow TargetThis action highlights a link target in a new &dolphin; window.
&Alt;ReturnFilePropertiesShows the properties dialog for the currently selected
item(s).&Ctrl;QFileQuitExits &dolphin;.The Edit Menu&Ctrl;ZEditUndoUndoes the last action performed by &dolphin;.&Ctrl;XEditCutCuts the currently selected item(s).&Ctrl;CEditCopyCopies the currently selected item(s).&Ctrl;VEditPaste Clipboard Contents... or
EditPaste one File or
EditPaste one Folder or
EditPaste x ItemsPastes the currently copied/cut items to the current
folder. If the clipboard does not contain files or folders, the clipboard
contents (such as text or image data) will be pasted into a new file.
The name of this file has to be entered in a dialog.
&Ctrl;FEdit
-Find...
+Search...Opens the find bar. Enter a search term into the edit box and select to search for filename
or in contents of files starting from the current folder or everywhere.&Ctrl;AEditSelect AllSelects all files and folders in the current
folder.&Ctrl;&Shift;AEditInvert Selection
Selects all unselected items and deselects all selected items in the current folder.
The View Menu&Ctrl;+ViewZoom InIncreases the size of icons in the view.&Ctrl;-ViewZoom OutDecreases the size of icons in the view.ViewView ModeChanges the view mode to Icons
(&Ctrl;1), Compact
(&Ctrl;2) or Details
(&Ctrl;3).ViewSort ByChanges whether items are sorted by Name
or other criteria described in Information in the View.Descending reverses the sort order.
Folders First sorts folders before files.
ViewAdditional InformationDisplays additional information
described in Information in the View.
ViewPreviewDisplays a symbolic preview of the file contents in the different
view modes.ViewShow in GroupsDisplays the content of the
current folder grouped by the option selected in Sort By.
&Alt;.ViewHidden FilesShows all the hidden files and sub-folders within the current
folder.There is an alternate shortcut &Ctrl;H
for this action.F3ViewSplitEnables and disables the split view mode.F5ViewReloadReloads the current folder.ViewStopStops loading/reading the contents of the current
folder.ViewPanelsEnables and disables the different panels:
Places (F9), Information
(F11), Folders (F7),
Terminal (F4).
With Lock Panels the panel header with caption and two buttons is
hidden to save space and the panels are immutable, with Unlock Panels
the header is visible and the panel can be moved to the right or left or even
outside the main window.
F6ViewLocation BarEditable LocationChanges the location bar between the two modes; the
bread crumb mode and the
editable mode.
&Ctrl;LViewLocation BarReplace LocationSwitches the location bar to editable mode,
if necessary, and selects the location such that it can be replaced quickly.
ViewAdjust View Properties...Opens the View Properties
Dialog.The Go Menu&Alt;UpGoUpChanges to the folder above the current folder.&Alt;LeftGoBackChanges to the previously viewed folder.&Alt;RightGoForwardUndoes a Go Back action.&Alt;HomeGoHomeChanges to the users home folder, ⪚
/home/Peter/.GoRecently Closed TabsShows a list of recently closed tabs which can
be reopened.The Tools Menu&Ctrl;IToolsShow Filter BarEnables and disables the filter bar.
You can also use the alternate shortcut &Shift;/
for this action.&Shift;F4ToolsOpen TerminalOpens &konsole; within the current folder.ToolsCompare FilesCompare the currently selected files or folders with
&kompare;. This action is only enabled if two files or folders are selected.ToolsSelect Remote CharsetAllows you to choose the charset used by a remote
connection manually.The Settings and Help Menu
&dolphin; has the common &kde; Settings and Help
menu items, for more information read the sections about the Settings Menu and Help Menu
of the &kde; Fundamentals.
Miscellaneous QuestionsHas &dolphin; replaced &konqueror;?
&dolphin; is not intended to be a competitor to &konqueror;: &konqueror; acts as
a universal viewer being able to show &HTML; pages, text documents, folders and a
lot more, whereas &dolphin; focuses on being only a file manager. This approach
allows the optimization of the user interface for the task of file management.
How can I get involved with the development of &dolphin;?
The easiest way to get involved with &dolphin; is to subscribe to the developer
mailing list kfm-devel
and drop an email to the developer mailing list. Email what you can do, how much time
you can devote &etc;, the developers will let you know what you can do in the
project. If you wish to contribute to the documentation please email the
&kde; Documentation Team list.
How can I submit bug reports?
The official channel for submitting bug reports is via the &kde; bug tracking
system. The &kde; bug tracker can be found at
http://bugs.kde.org.
How can I submit feature requests?
The official channel for submitting feature requests is via the &kde; bug
tracking system. The &kde; bug tracker can be found at
http://bugs.kde.org.
Credits and License
&dolphin;
Program copyright 2006–2014 Peter Penz peter.penz@gmx.at,
Frank Reininghaus frank78ac@googlemail.com and Emmanuel Pescosta
emmanuelpescosta099@gmail.com
Contributors:
Cvetoslav Ludmiloff ludmiloff@gmail.comStefan Monov logixoul@gmail.comMichael Austin tuxedup@users.sourceforge.net&Orville.Bennett; &Orville.Bennett.mail;
Documentation copyright 2005 Peter Penz peter.penz@gmx.at
Documentation copyright 2006 &Orville.Bennett; &Orville.Bennett.mail;
Documentation copyright 2006 Michael Austin tuxedup@users.sourceforge.net
Documentation copyright 2009 Frank Reininghaus frank78ac@googlemail.com
&underFDL;
&underGPL;
&documentation.index;
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 7224c8ea9..2775d4285 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1,1685 +1,1690 @@
/***************************************************************************
* Copyright (C) 2006 by Peter Penz *
* Copyright (C) 2006 by Stefan Monov *
* Copyright (C) 2006 by Cvetoslav Ludmiloff *
* *
* 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 "dolphinmainwindow.h"
#include "config-terminal.h"
#include "global.h"
#include "dolphindockwidget.h"
#include "dolphincontextmenu.h"
#include "dolphinnewfilemenu.h"
#include "dolphinrecenttabsmenu.h"
#include "dolphinviewcontainer.h"
#include "dolphintabpage.h"
#include "middleclickactioneventfilter.h"
#include "panels/folders/folderspanel.h"
#include "panels/places/placespanel.h"
#include "panels/information/informationpanel.h"
#include "panels/terminal/terminalpanel.h"
#include "settings/dolphinsettingsdialog.h"
#include "statusbar/dolphinstatusbar.h"
#include "views/dolphinviewactionhandler.h"
#include "views/dolphinremoteencoding.h"
#include "views/draganddrophelper.h"
#include "views/viewproperties.h"
#include "views/dolphinnewfilemenuobserver.h"
#include "dolphin_generalsettings.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace {
// Used for GeneralSettings::version() to determine whether
// an updated version of Dolphin is running.
const int CurrentDolphinVersion = 200;
}
DolphinMainWindow::DolphinMainWindow() :
KXmlGuiWindow(nullptr),
m_newFileMenu(nullptr),
m_tabWidget(nullptr),
m_activeViewContainer(nullptr),
m_actionHandler(nullptr),
m_remoteEncoding(nullptr),
m_settingsDialog(),
m_controlButton(nullptr),
m_updateToolBarTimer(nullptr),
m_lastHandleUrlStatJob(nullptr),
m_terminalPanel(nullptr),
m_placesPanel(nullptr),
m_tearDownFromPlacesRequested(false)
{
Q_INIT_RESOURCE(dolphin);
setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
setObjectName(QStringLiteral("Dolphin#"));
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
this, &DolphinMainWindow::showErrorMessage);
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
undoManager->setUiInterface(new UndoUiInterface());
connect(undoManager, static_cast(&KIO::FileUndoManager::undoAvailable),
this, &DolphinMainWindow::slotUndoAvailable);
connect(undoManager, &KIO::FileUndoManager::undoTextChanged,
this, &DolphinMainWindow::slotUndoTextChanged);
connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted,
this, &DolphinMainWindow::clearStatusBar);
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
this, &DolphinMainWindow::showCommand);
GeneralSettings* generalSettings = GeneralSettings::self();
const bool firstRun = (generalSettings->version() < 200);
if (firstRun) {
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
}
setAcceptDrops(true);
m_tabWidget = new DolphinTabWidget(this);
m_tabWidget->setObjectName("tabWidget");
connect(m_tabWidget, &DolphinTabWidget::activeViewChanged,
this, &DolphinMainWindow::activeViewChanged);
connect(m_tabWidget, &DolphinTabWidget::tabCountChanged,
this, &DolphinMainWindow::tabCountChanged);
connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged,
this, &DolphinMainWindow::updateWindowTitle);
setCentralWidget(m_tabWidget);
setupActions();
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
connect(this, &DolphinMainWindow::urlChanged,
m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
setupDockWidgets();
setupGUI(Keys | Save | Create | ToolBar);
stateChanged(QStringLiteral("new_file"));
QClipboard* clipboard = QApplication::clipboard();
connect(clipboard, &QClipboard::dataChanged,
this, &DolphinMainWindow::updatePasteAction);
QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
showFilterBarAction->setChecked(generalSettings->filterBar());
if (firstRun) {
menuBar()->setVisible(false);
// Assure a proper default size if Dolphin runs the first time
resize(750, 500);
}
const bool showMenu = !menuBar()->isHidden();
QAction* showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
showMenuBarAction->setChecked(showMenu); // workaround for bug #171080
if (!showMenu) {
createControlButton();
}
// enable middle-click on back/forward/up to open in a new tab
auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked);
toolBar()->installEventFilter(middleClickEventFilter);
}
DolphinMainWindow::~DolphinMainWindow()
{
}
void DolphinMainWindow::openDirectories(const QList& dirs, bool splitView)
{
m_tabWidget->openDirectories(dirs, splitView);
}
void DolphinMainWindow::openFiles(const QList& files, bool splitView)
{
m_tabWidget->openFiles(files, splitView);
}
void DolphinMainWindow::showCommand(CommandType command)
{
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
switch (command) {
case KIO::FileUndoManager::Copy:
statusBar->setText(i18nc("@info:status", "Successfully copied."));
break;
case KIO::FileUndoManager::Move:
statusBar->setText(i18nc("@info:status", "Successfully moved."));
break;
case KIO::FileUndoManager::Link:
statusBar->setText(i18nc("@info:status", "Successfully linked."));
break;
case KIO::FileUndoManager::Trash:
statusBar->setText(i18nc("@info:status", "Successfully moved to trash."));
break;
case KIO::FileUndoManager::Rename:
statusBar->setText(i18nc("@info:status", "Successfully renamed."));
break;
case KIO::FileUndoManager::Mkdir:
statusBar->setText(i18nc("@info:status", "Created folder."));
break;
default:
break;
}
}
void DolphinMainWindow::pasteIntoFolder()
{
m_activeViewContainer->view()->pasteIntoFolder();
}
void DolphinMainWindow::changeUrl(const QUrl &url)
{
if (!KProtocolManager::supportsListing(url)) {
// The URL navigator only checks for validity, not
// if the URL can be listed. An error message is
// shown due to DolphinViewContainer::restoreView().
return;
}
m_activeViewContainer->setUrl(url);
updateEditActions();
updatePasteAction();
updateViewActions();
updateGoActions();
emit urlChanged(url);
}
void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
{
if (m_tearDownFromPlacesRequested && url == QUrl::fromLocalFile(QDir::homePath())) {
m_placesPanel->proceedWithTearDown();
m_tearDownFromPlacesRequested = false;
}
m_activeViewContainer->setAutoGrabFocus(false);
changeUrl(url);
m_activeViewContainer->setAutoGrabFocus(true);
}
void DolphinMainWindow::slotEditableStateChanged(bool editable)
{
KToggleAction* editableLocationAction =
static_cast(actionCollection()->action(QStringLiteral("editable_location")));
editableLocationAction->setChecked(editable);
}
void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
{
updateEditActions();
const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount();
QAction* compareFilesAction = actionCollection()->action(QStringLiteral("compare_files"));
if (selectedUrlsCount == 2) {
compareFilesAction->setEnabled(isKompareInstalled());
} else {
compareFilesAction->setEnabled(false);
}
emit selectionChanged(selection);
}
void DolphinMainWindow::updateHistory()
{
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
const int index = urlNavigator->historyIndex();
QAction* backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
if (backAction) {
backAction->setToolTip(i18nc("@info", "Go back"));
backAction->setEnabled(index < urlNavigator->historySize() - 1);
}
QAction* forwardAction = actionCollection()->action(KStandardAction::name(KStandardAction::Forward));
if (forwardAction) {
forwardAction->setToolTip(i18nc("@info", "Go forward"));
forwardAction->setEnabled(index > 0);
}
}
void DolphinMainWindow::updateFilterBarAction(bool show)
{
QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
showFilterBarAction->setChecked(show);
}
void DolphinMainWindow::openNewMainWindow()
{
Dolphin::openNewWindow({m_activeViewContainer->url()}, this);
}
void DolphinMainWindow::openNewActivatedTab()
{
m_tabWidget->openNewActivatedTab();
}
void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement)
{
m_tabWidget->openNewTab(url, QUrl(), tabPlacement);
}
void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url)
{
m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab);
}
void DolphinMainWindow::openNewTabAfterLastTab(const QUrl& url)
{
m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterLastTab);
}
void DolphinMainWindow::openInNewTab()
{
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
bool tabCreated = false;
foreach (const KFileItem& item, list) {
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
if (!url.isEmpty()) {
openNewTabAfterCurrentTab(url);
tabCreated = true;
}
}
// if no new tab has been created from the selection
// open the current directory in a new tab
if (!tabCreated) {
openNewTabAfterCurrentTab(m_activeViewContainer->url());
}
}
void DolphinMainWindow::openInNewWindow()
{
QUrl newWindowUrl;
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
if (list.isEmpty()) {
newWindowUrl = m_activeViewContainer->url();
} else if (list.count() == 1) {
const KFileItem& item = list.first();
newWindowUrl = DolphinView::openItemAsFolderUrl(item);
}
if (!newWindowUrl.isEmpty()) {
Dolphin::openNewWindow({newWindowUrl}, this);
}
}
void DolphinMainWindow::showTarget()
{
const auto link = m_activeViewContainer->view()->selectedItems().at(0);
const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir();
auto linkDestination = link.linkDest();
if (QFileInfo(linkDestination).isRelative()) {
linkDestination = linkLocationDir.filePath(linkDestination);
}
if (QFileInfo::exists(linkDestination)) {
KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)});
} else {
m_activeViewContainer->showMessage(xi18nc("@info", "Could not access %1.", linkDestination),
DolphinViewContainer::Warning);
}
}
void DolphinMainWindow::showEvent(QShowEvent* event)
{
KXmlGuiWindow::showEvent(event);
if (!event->spontaneous()) {
m_activeViewContainer->view()->setFocus();
}
}
void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
// Find out if Dolphin is closed directly by the user or
// by the session manager because the session is closed
bool closedByUser = true;
if (qApp->isSavingSession()) {
closedByUser = false;
}
if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
// Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons:
// QDialogButtonBox::Yes -> Quit
// QDialogButtonBox::No -> Close only the current tab
// QDialogButtonBox::Cancel -> do nothing
QDialog *dialog = new QDialog(this, Qt::Dialog);
dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel);
KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
buttons->button(QDialogButtonBox::Yes)->setDefault(true);
bool doNotAskAgainCheckboxResult = false;
const auto result = KMessageBox::createKMessageBox(dialog,
buttons,
QMessageBox::Warning,
i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
QStringList(),
i18n("Do not ask again"),
&doNotAskAgainCheckboxResult,
KMessageBox::Notify);
if (doNotAskAgainCheckboxResult) {
GeneralSettings::setConfirmClosingMultipleTabs(false);
}
switch (result) {
case QDialogButtonBox::Yes:
// Quit
break;
case QDialogButtonBox::No:
// Close only the current tab
m_tabWidget->closeTab();
Q_FALLTHROUGH();
default:
event->ignore();
return;
}
}
if (m_terminalPanel->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser) {
// Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
// Open a confirmation dialog with 3 buttons:
// QDialogButtonBox::Yes -> Quit
// QDialogButtonBox::No -> Show Terminal Panel
// QDialogButtonBox::Cancel -> do nothing
QDialog *dialog = new QDialog(this, Qt::Dialog);
dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true);
auto standardButtons = QDialogButtonBox::Yes | QDialogButtonBox::Cancel;
if (!m_terminalPanel->isVisible()) {
standardButtons |= QDialogButtonBox::No;
}
QDialogButtonBox *buttons = new QDialogButtonBox(standardButtons);
KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit());
if (!m_terminalPanel->isVisible()) {
KGuiItem::assign(
buttons->button(QDialogButtonBox::No),
KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("utilities-terminal"))));
}
KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
bool doNotAskAgainCheckboxResult = false;
const auto result = KMessageBox::createKMessageBox(
dialog,
buttons,
QMessageBox::Warning,
i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel->runningProgramName()),
QStringList(),
i18n("Do not ask again"),
&doNotAskAgainCheckboxResult,
KMessageBox::Dangerous);
if (doNotAskAgainCheckboxResult) {
GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
}
switch (result) {
case QDialogButtonBox::Yes:
// Quit
break;
case QDialogButtonBox::No:
actionCollection()->action("show_terminal_panel")->trigger();
// Do not quit, ignore quit event
Q_FALLTHROUGH();
default:
event->ignore();
return;
}
}
GeneralSettings::setVersion(CurrentDolphinVersion);
GeneralSettings::self()->save();
KXmlGuiWindow::closeEvent(event);
}
void DolphinMainWindow::saveProperties(KConfigGroup& group)
{
m_tabWidget->saveProperties(group);
}
void DolphinMainWindow::readProperties(const KConfigGroup& group)
{
m_tabWidget->readProperties(group);
}
void DolphinMainWindow::updateNewMenu()
{
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
m_newFileMenu->checkUpToDate();
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
}
void DolphinMainWindow::createDirectory()
{
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
m_newFileMenu->createDirectory();
}
void DolphinMainWindow::quit()
{
close();
}
void DolphinMainWindow::showErrorMessage(const QString& message)
{
m_activeViewContainer->showMessage(message, DolphinViewContainer::Error);
}
void DolphinMainWindow::slotUndoAvailable(bool available)
{
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
if (undoAction) {
undoAction->setEnabled(available);
}
}
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
if (undoAction) {
undoAction->setText(text);
}
}
void DolphinMainWindow::undo()
{
clearStatusBar();
KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
KIO::FileUndoManager::self()->undo();
}
void DolphinMainWindow::cut()
{
m_activeViewContainer->view()->cutSelectedItems();
}
void DolphinMainWindow::copy()
{
m_activeViewContainer->view()->copySelectedItems();
}
void DolphinMainWindow::paste()
{
m_activeViewContainer->view()->paste();
}
void DolphinMainWindow::find()
{
m_activeViewContainer->setSearchModeEnabled(true);
}
void DolphinMainWindow::updatePasteAction()
{
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
QPair pasteInfo = m_activeViewContainer->view()->pasteInfo();
pasteAction->setEnabled(pasteInfo.first);
pasteAction->setText(pasteInfo.second);
}
void DolphinMainWindow::slotDirectoryLoadingCompleted()
{
updatePasteAction();
}
void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
{
if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Back))) {
goBackInNewTab();
} else if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Forward))) {
goForwardInNewTab();
} else if (action == actionCollection()->action(QStringLiteral("go_up"))) {
goUpInNewTab();
} else if (action == actionCollection()->action(QStringLiteral("go_home"))) {
goHomeInNewTab();
}
}
void DolphinMainWindow::selectAll()
{
clearStatusBar();
// if the URL navigator is editable and focused, select the whole
// URL instead of all items of the view
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
QLineEdit* lineEdit = urlNavigator->editor()->lineEdit();
const bool selectUrl = urlNavigator->isUrlEditable() &&
lineEdit->hasFocus();
if (selectUrl) {
lineEdit->selectAll();
} else {
m_activeViewContainer->view()->selectAll();
}
}
void DolphinMainWindow::invertSelection()
{
clearStatusBar();
m_activeViewContainer->view()->invertSelection();
}
void DolphinMainWindow::toggleSplitView()
{
DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled());
updateViewActions();
}
void DolphinMainWindow::toggleSplitStash()
{
DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
tabPage->setSplitViewEnabled(false);
tabPage->setSplitViewEnabled(true, QUrl("stash:/"));
}
void DolphinMainWindow::reloadView()
{
clearStatusBar();
m_activeViewContainer->reload();
m_activeViewContainer->statusBar()->updateSpaceInfo();
}
void DolphinMainWindow::stopLoading()
{
m_activeViewContainer->view()->stopLoading();
}
void DolphinMainWindow::enableStopAction()
{
actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
}
void DolphinMainWindow::disableStopAction()
{
actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
}
void DolphinMainWindow::showFilterBar()
{
m_activeViewContainer->setFilterBarVisible(true);
}
void DolphinMainWindow::toggleEditLocation()
{
clearStatusBar();
QAction* action = actionCollection()->action(QStringLiteral("editable_location"));
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
urlNavigator->setUrlEditable(action->isChecked());
}
void DolphinMainWindow::replaceLocation()
{
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
QLineEdit* lineEdit = navigator->editor()->lineEdit();
// If the text field currently has focus and everything is selected,
// pressing the keyboard shortcut returns the whole thing to breadcrumb mode
if (navigator->isUrlEditable()
&& lineEdit->hasFocus()
&& lineEdit->selectedText() == lineEdit->text() ) {
navigator->setUrlEditable(false);
} else {
navigator->setUrlEditable(true);
navigator->setFocus();
lineEdit->selectAll();
}
}
void DolphinMainWindow::togglePanelLockState()
{
const bool newLockState = !GeneralSettings::lockPanels();
foreach (QObject* child, children()) {
DolphinDockWidget* dock = qobject_cast(child);
if (dock) {
dock->setLocked(newLockState);
}
}
GeneralSettings::setLockPanels(newLockState);
}
void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
{
if (m_terminalPanel->isHiddenInVisibleWindow()) {
m_activeViewContainer->view()->setFocus();
}
}
void DolphinMainWindow::goBack()
{
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
urlNavigator->goBack();
if (urlNavigator->locationState().isEmpty()) {
// An empty location state indicates a redirection URL,
// which must be skipped too
urlNavigator->goBack();
}
}
void DolphinMainWindow::goForward()
{
m_activeViewContainer->urlNavigator()->goForward();
}
void DolphinMainWindow::goUp()
{
m_activeViewContainer->urlNavigator()->goUp();
}
void DolphinMainWindow::goHome()
{
m_activeViewContainer->urlNavigator()->goHome();
}
void DolphinMainWindow::goBackInNewTab()
{
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
const int index = urlNavigator->historyIndex() + 1;
openNewTabAfterCurrentTab(urlNavigator->locationUrl(index));
}
void DolphinMainWindow::goForwardInNewTab()
{
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
const int index = urlNavigator->historyIndex() - 1;
openNewTabAfterCurrentTab(urlNavigator->locationUrl(index));
}
void DolphinMainWindow::goUpInNewTab()
{
const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl();
openNewTabAfterCurrentTab(KIO::upUrl(currentUrl));
}
void DolphinMainWindow::goHomeInNewTab()
{
openNewTabAfterCurrentTab(Dolphin::homeUrl());
}
void DolphinMainWindow::compareFiles()
{
const KFileItemList items = m_tabWidget->currentTabPage()->selectedItems();
if (items.count() != 2) {
// The action is disabled in this case, but it could have been triggered
// via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
return;
}
QUrl urlA = items.at(0).url();
QUrl urlB = items.at(1).url();
QString command(QStringLiteral("kompare -c \""));
command.append(urlA.toDisplayString(QUrl::PreferLocalFile));
command.append("\" \"");
command.append(urlB.toDisplayString(QUrl::PreferLocalFile));
command.append('\"');
KRun::runCommand(command, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
}
void DolphinMainWindow::toggleShowMenuBar()
{
const bool visible = menuBar()->isVisible();
menuBar()->setVisible(!visible);
if (visible) {
createControlButton();
} else {
deleteControlButton();
}
}
void DolphinMainWindow::openTerminal()
{
QString dir(QDir::homePath());
// If the given directory is not local, it can still be the URL of an
// ioslave using UDS_LOCAL_PATH which to be converted first.
KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
KJobWidgets::setWindow(statJob, this);
statJob->exec();
QUrl url = statJob->mostLocalUrl();
//If the URL is local after the above conversion, set the directory.
if (url.isLocalFile()) {
dir = url.toLocalFile();
}
KToolInvocation::invokeTerminal(QString(), dir);
}
void DolphinMainWindow::editSettings()
{
if (!m_settingsDialog) {
DolphinViewContainer* container = activeViewContainer();
container->view()->writeSettings();
const QUrl url = container->url();
DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
settingsDialog->show();
m_settingsDialog = settingsDialog;
} else {
m_settingsDialog.data()->raise();
}
}
void DolphinMainWindow::handleUrl(const QUrl& url)
{
delete m_lastHandleUrlStatJob;
m_lastHandleUrlStatJob = nullptr;
if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
activeViewContainer()->setUrl(url);
} else if (KProtocolManager::supportsListing(url)) {
// stat the URL to see if it is a dir or not
m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
if (m_lastHandleUrlStatJob->uiDelegate()) {
KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
}
connect(m_lastHandleUrlStatJob, &KIO::Job::result,
this, &DolphinMainWindow::slotHandleUrlStatFinished);
} else {
new KRun(url, this); // Automatically deletes itself after being finished
}
}
void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
{
m_lastHandleUrlStatJob = nullptr;
const KIO::UDSEntry entry = static_cast(job)->statResult();
const QUrl url = static_cast(job)->url();
if (entry.isDir()) {
activeViewContainer()->setUrl(url);
} else {
new KRun(url, this); // Automatically deletes itself after being finished
}
}
void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
{
// trash:/ is writable but we don't want to create new items in it.
// TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash"));
}
void DolphinMainWindow::openContextMenu(const QPoint& pos,
const KFileItem& item,
const QUrl& url,
const QList& customActions)
{
QPointer contextMenu = new DolphinContextMenu(this, pos, item, url);
contextMenu.data()->setCustomActions(customActions);
const DolphinContextMenu::Command command = contextMenu.data()->open();
switch (command) {
case DolphinContextMenu::OpenParentFolder:
changeUrl(KIO::upUrl(item.url()));
m_activeViewContainer->view()->markUrlsAsSelected({item.url()});
m_activeViewContainer->view()->markUrlAsCurrent(item.url());
break;
case DolphinContextMenu::OpenParentFolderInNewWindow:
Dolphin::openNewWindow({item.url()}, this, Dolphin::OpenNewWindowFlag::Select);
break;
case DolphinContextMenu::OpenParentFolderInNewTab:
openNewTabAfterLastTab(KIO::upUrl(item.url()));
break;
case DolphinContextMenu::None:
default:
break;
}
// Delete the menu, unless it has been deleted in its own nested event loop already.
if (contextMenu) {
contextMenu->deleteLater();
}
}
void DolphinMainWindow::updateControlMenu()
{
QMenu* menu = qobject_cast(sender());
Q_ASSERT(menu);
// All actions get cleared by QMenu::clear(). This includes the sub-menus
// because 'menu' is their parent.
menu->clear();
KActionCollection* ac = actionCollection();
// Add "Create New" menu
menu->addMenu(m_newFileMenu->menu());
menu->addSeparator();
+ // Overwrite Find action to Search action
+ QAction *searchAction = ac->action(KStandardAction::name(KStandardAction::Find));
+ searchAction->setText(i18n("Search..."));
+
// Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
- addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) |
+ addActionToMenu(searchAction, menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu);
if (added) {
menu->addSeparator();
}
// Add "View" actions
if (!GeneralSettings::showZoomSlider()) {
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
menu->addSeparator();
}
added = addActionToMenu(ac->action(QStringLiteral("sort")), menu) |
addActionToMenu(ac->action(QStringLiteral("view_mode")), menu) |
addActionToMenu(ac->action(QStringLiteral("additional_info")), menu) |
addActionToMenu(ac->action(QStringLiteral("show_preview")), menu) |
addActionToMenu(ac->action(QStringLiteral("show_in_groups")), menu) |
addActionToMenu(ac->action(QStringLiteral("show_hidden_files")), menu);
if (added) {
menu->addSeparator();
}
added = addActionToMenu(ac->action(QStringLiteral("split_view")), menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Redisplay)), menu) |
addActionToMenu(ac->action(QStringLiteral("view_properties")), menu);
if (added) {
menu->addSeparator();
}
addActionToMenu(ac->action(QStringLiteral("panels")), menu);
QMenu* locationBarMenu = new QMenu(i18nc("@action:inmenu", "Location Bar"), menu);
locationBarMenu->addAction(ac->action(QStringLiteral("editable_location")));
locationBarMenu->addAction(ac->action(QStringLiteral("replace_location")));
menu->addMenu(locationBarMenu);
menu->addSeparator();
// Add "Go" menu
QMenu* goMenu = new QMenu(i18nc("@action:inmenu", "Go"), menu);
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Back)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Forward)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Up)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Home)));
goMenu->addAction(ac->action(QStringLiteral("closed_tabs")));
menu->addMenu(goMenu);
// Add "Tool" menu
QMenu* toolsMenu = new QMenu(i18nc("@action:inmenu", "Tools"), menu);
toolsMenu->addAction(ac->action(QStringLiteral("show_filter_bar")));
toolsMenu->addAction(ac->action(QStringLiteral("compare_files")));
toolsMenu->addAction(ac->action(QStringLiteral("open_terminal")));
toolsMenu->addAction(ac->action(QStringLiteral("change_remote_encoding")));
menu->addMenu(toolsMenu);
// Add "Settings" menu entries
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::KeyBindings)), menu);
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ConfigureToolbars)), menu);
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Preferences)), menu);
// Add "Help" menu
auto helpMenu = new KHelpMenu(menu);
menu->addMenu(helpMenu->menu());
menu->addSeparator();
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ShowMenubar)), menu);
}
void DolphinMainWindow::updateToolBar()
{
if (!menuBar()->isVisible()) {
createControlButton();
}
}
void DolphinMainWindow::slotControlButtonDeleted()
{
m_controlButton = nullptr;
m_updateToolBarTimer->start();
}
void DolphinMainWindow::slotPlaceActivated(const QUrl& url)
{
DolphinViewContainer* view = activeViewContainer();
if (view->url() == url) {
// We can end up here if the user clicked a device in the Places Panel
// which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
reloadView();
} else {
changeUrl(url);
}
}
void DolphinMainWindow::closedTabsCountChanged(unsigned int count)
{
actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count > 0);
}
void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
{
DolphinViewContainer* oldViewContainer = m_activeViewContainer;
Q_ASSERT(viewContainer);
m_activeViewContainer = viewContainer;
if (oldViewContainer) {
// Disconnect all signals between the old view container (container,
// view and url navigator) and main window.
oldViewContainer->disconnect(this);
oldViewContainer->view()->disconnect(this);
oldViewContainer->urlNavigator()->disconnect(this);
// except the requestItemInfo so that on hover the information panel can still be updated
connect(oldViewContainer->view(), &DolphinView::requestItemInfo,
this, &DolphinMainWindow::requestItemInfo);
}
connectViewSignals(viewContainer);
m_actionHandler->setCurrentView(viewContainer->view());
updateHistory();
updateEditActions();
updatePasteAction();
updateViewActions();
updateGoActions();
const QUrl url = viewContainer->url();
emit urlChanged(url);
}
void DolphinMainWindow::tabCountChanged(int count)
{
const bool enableTabActions = (count > 1);
actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
}
void DolphinMainWindow::updateWindowTitle()
{
const QString newTitle = m_activeViewContainer->caption();
if (windowTitle() != newTitle) {
setWindowTitle(newTitle);
}
}
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
// m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
} else {
m_placesPanel->proceedWithTearDown();
}
}
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
}
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
QMenu* menu = m_newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
m_newFileMenu->setDelayed(false);
connect(menu, &QMenu::aboutToShow,
this, &DolphinMainWindow::updateNewMenu);
QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N});
connect(newTab, &QAction::triggered, this, static_cast(&DolphinMainWindow::openNewActivatedTab));
QAction* closeTab = KStandardAction::close(
m_tabWidget, static_cast(&DolphinTabWidget::closeTab), actionCollection());
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
// setup 'Edit' menu
KStandardAction::undo(this,
&DolphinMainWindow::undo,
actionCollection());
KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection());
KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection());
QAction* paste = KStandardAction::paste(this, &DolphinMainWindow::paste, actionCollection());
// The text of the paste-action is modified dynamically by Dolphin
// (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
// due to the long text, the text "Paste" is used:
paste->setIconText(i18nc("@action:inmenu Edit", "Paste"));
- KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
+ QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
+ searchAction->setText(i18n("Search..."));
KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
invertSelection->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL + Qt::SHIFT + Qt::Key_A);
connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
// setup 'View' menu
// (note that most of it is set up in DolphinViewActionHandler)
QAction* split = actionCollection()->addAction(QStringLiteral("split_view"));
actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
QAction* stashSplit = actionCollection()->addAction(QStringLiteral("split_stash"));
actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL + Qt::Key_S);
stashSplit->setText(i18nc("@action:intoolbar Stash", "Stash"));
stashSplit->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
stashSplit->setCheckable(false);
stashSplit->setVisible(KProtocolInfo::isKnownProtocol("stash"));
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
QAction* stop = actionCollection()->addAction(QStringLiteral("stop"));
stop->setText(i18nc("@action:inmenu View", "Stop"));
stop->setToolTip(i18nc("@info", "Stop loading"));
stop->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading);
KToggleAction* editableLocation = actionCollection()->add(QStringLiteral("editable_location"));
editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
actionCollection()->setDefaultShortcut(editableLocation, Qt::Key_F6);
connect(editableLocation, &KToggleAction::triggered, this, &DolphinMainWindow::toggleEditLocation);
QAction* replaceLocation = actionCollection()->addAction(QStringLiteral("replace_location"));
replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL + Qt::Key_L);
connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
// setup 'Go' menu
QAction* backAction = KStandardAction::back(this, &DolphinMainWindow::goBack, actionCollection());
auto backShortcuts = backAction->shortcuts();
backShortcuts.append(QKeySequence(Qt::Key_Backspace));
actionCollection()->setDefaultShortcuts(backAction, backShortcuts);
DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this);
actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu);
connect(m_tabWidget, &DolphinTabWidget::rememberClosedTab,
recentTabsMenu, &DolphinRecentTabsMenu::rememberClosedTab);
connect(recentTabsMenu, &DolphinRecentTabsMenu::restoreClosedTab,
m_tabWidget, &DolphinTabWidget::restoreClosedTab);
connect(recentTabsMenu, &DolphinRecentTabsMenu::closedTabsCountChanged,
this, &DolphinMainWindow::closedTabsCountChanged);
QAction* undoCloseTab = actionCollection()->addAction(QStringLiteral("undo_close_tab"));
undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
actionCollection()->setDefaultShortcut(undoCloseTab, Qt::CTRL + Qt::SHIFT + Qt::Key_T);
undoCloseTab->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
undoCloseTab->setEnabled(false);
connect(undoCloseTab, &QAction::triggered, recentTabsMenu, &DolphinRecentTabsMenu::undoCloseTab);
auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
undoAction->setEnabled(false); // undo should be disabled by default
KStandardAction::forward(this, &DolphinMainWindow::goForward, actionCollection());
KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection());
KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection());
// setup 'Tools' menu
QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash});
connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
QAction* compareFiles = actionCollection()->addAction(QStringLiteral("compare_files"));
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
compareFiles->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
compareFiles->setEnabled(false);
connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
#ifdef HAVE_TERMINAL
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
}
#endif
// setup 'Settings' menu
KToggleAction* showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822
this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
KStandardAction::preferences(this, &DolphinMainWindow::editSettings, actionCollection());
// not in menu actions
QList nextTabKeys = KStandardShortcut::tabNext();
nextTabKeys.append(QKeySequence(Qt::CTRL + Qt::Key_Tab));
QList prevTabKeys = KStandardShortcut::tabPrev();
prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
QAction* activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab"));
activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
activateNextTab->setEnabled(false);
connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab);
actionCollection()->setDefaultShortcuts(activateNextTab, nextTabKeys);
QAction* activatePrevTab = actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab"));
activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
activatePrevTab->setEnabled(false);
connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab);
actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys);
// for context menu
QAction* showTarget = actionCollection()->addAction(QStringLiteral("show_target"));
showTarget->setText(i18nc("@action:inmenu", "Show Target"));
showTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
showTarget->setEnabled(false);
connect(showTarget, &QAction::triggered, this, &DolphinMainWindow::showTarget);
QAction* openInNewTab = actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
openInNewTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
QAction* openInNewTabs = actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs"));
openInNewTabs->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
connect(openInNewTabs, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
QAction* openInNewWindow = actionCollection()->addAction(QStringLiteral("open_in_new_window"));
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
}
void DolphinMainWindow::setupDockWidgets()
{
const bool lock = GeneralSettings::lockPanels();
KDualAction* lockLayoutAction = actionCollection()->add(QStringLiteral("lock_panels"));
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
lockLayoutAction->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
lockLayoutAction->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
lockLayoutAction->setActive(lock);
connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState);
// Setup "Information"
DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
infoDock->setLocked(lock);
infoDock->setObjectName(QStringLiteral("infoDock"));
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
#ifdef HAVE_BALOO
InformationPanel* infoPanel = new InformationPanel(infoDock);
infoPanel->setCustomContextMenuActions({lockLayoutAction});
connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
infoDock->setWidget(infoPanel);
QAction* infoAction = infoDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoAction, QStringLiteral("show_information_panel"));
addDockWidget(Qt::RightDockWidgetArea, infoDock);
connect(this, &DolphinMainWindow::urlChanged,
infoPanel, &InformationPanel::setUrl);
connect(this, &DolphinMainWindow::selectionChanged,
infoPanel, &InformationPanel::setSelection);
connect(this, &DolphinMainWindow::requestItemInfo,
infoPanel, &InformationPanel::requestDelayedItemInfo);
#endif
// Setup "Folders"
DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
foldersDock->setLocked(lock);
foldersDock->setObjectName(QStringLiteral("foldersDock"));
foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
foldersPanel->setCustomContextMenuActions({lockLayoutAction});
foldersDock->setWidget(foldersPanel);
QAction* foldersAction = foldersDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersAction, QStringLiteral("show_folders_panel"));
addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
connect(this, &DolphinMainWindow::urlChanged,
foldersPanel, &FoldersPanel::setUrl);
connect(foldersPanel, &FoldersPanel::folderActivated,
this, &DolphinMainWindow::changeUrl);
connect(foldersPanel, &FoldersPanel::folderMiddleClicked,
this, &DolphinMainWindow::openNewTabAfterCurrentTab);
connect(foldersPanel, &FoldersPanel::errorMessage,
this, &DolphinMainWindow::showErrorMessage);
// Setup "Terminal"
#ifdef HAVE_TERMINAL
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
terminalDock->setLocked(lock);
terminalDock->setObjectName(QStringLiteral("terminalDock"));
m_terminalPanel = new TerminalPanel(terminalDock);
m_terminalPanel->setCustomContextMenuActions({lockLayoutAction});
terminalDock->setWidget(m_terminalPanel);
connect(m_terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
connect(terminalDock, &DolphinDockWidget::visibilityChanged,
m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
connect(terminalDock, &DolphinDockWidget::visibilityChanged,
this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
QAction* terminalAction = terminalDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
connect(this, &DolphinMainWindow::urlChanged,
m_terminalPanel, &TerminalPanel::setUrl);
if (GeneralSettings::version() < 200) {
terminalDock->hide();
}
}
#endif
if (GeneralSettings::version() < 200) {
infoDock->hide();
foldersDock->hide();
}
// Setup "Places"
DolphinDockWidget* placesDock = new DolphinDockWidget(i18nc("@title:window", "Places"));
placesDock->setLocked(lock);
placesDock->setObjectName(QStringLiteral("placesDock"));
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
m_placesPanel = new PlacesPanel(placesDock);
m_placesPanel->setCustomContextMenuActions({lockLayoutAction});
placesDock->setWidget(m_placesPanel);
QAction *placesAction = placesDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel"));
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
connect(m_placesPanel, &PlacesPanel::placeActivated,
this, &DolphinMainWindow::slotPlaceActivated);
connect(m_placesPanel, &PlacesPanel::placeMiddleClicked,
this, &DolphinMainWindow::openNewTabAfterCurrentTab);
connect(m_placesPanel, &PlacesPanel::errorMessage,
this, &DolphinMainWindow::showErrorMessage);
connect(this, &DolphinMainWindow::urlChanged,
m_placesPanel, &PlacesPanel::setUrl);
connect(placesDock, &DolphinDockWidget::visibilityChanged,
m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
connect(this, &DolphinMainWindow::settingsChanged,
m_placesPanel, &PlacesPanel::readSettings);
connect(m_placesPanel, &PlacesPanel::storageTearDownRequested,
this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested);
connect(m_placesPanel, &PlacesPanel::storageTearDownExternallyRequested,
this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Show Hidden Places"), this);
actionShowAllPlaces->setCheckable(true);
actionShowAllPlaces->setDisabled(true);
connect(actionShowAllPlaces, &QAction::triggered, this, [actionShowAllPlaces, this](bool checked){
actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint")));
m_placesPanel->showHiddenEntries(checked);
});
connect(m_placesPanel, &PlacesPanel::showHiddenEntriesChanged, this, [actionShowAllPlaces] (bool checked){
actionShowAllPlaces->setChecked(checked);
actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint")));
});
// Add actions into the "Panels" menu
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
actionCollection()->addAction(QStringLiteral("panels"), panelsMenu);
panelsMenu->setDelayed(false);
const KActionCollection* ac = actionCollection();
panelsMenu->addAction(ac->action(QStringLiteral("show_places_panel")));
#ifdef HAVE_BALOO
panelsMenu->addAction(ac->action(QStringLiteral("show_information_panel")));
#endif
panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel")));
panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel")));
panelsMenu->addSeparator();
panelsMenu->addAction(actionShowAllPlaces);
panelsMenu->addAction(lockLayoutAction);
connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{
actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount());
});
}
void DolphinMainWindow::updateEditActions()
{
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
if (list.isEmpty()) {
stateChanged(QStringLiteral("has_no_selection"));
} else {
stateChanged(QStringLiteral("has_selection"));
KActionCollection* col = actionCollection();
QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile));
QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
QAction* showTarget = col->action(QStringLiteral("show_target"));
KFileItemListProperties capabilities(list);
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
renameAction->setEnabled(capabilities.supportsMoving());
moveToTrashAction->setEnabled(enableMoveToTrash);
deleteAction->setEnabled(capabilities.supportsDeleting());
deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
cutAction->setEnabled(capabilities.supportsMoving());
showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
}
}
void DolphinMainWindow::updateViewActions()
{
m_actionHandler->updateViewActions();
QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
updateSplitAction();
QAction* editableLocactionAction = actionCollection()->action(QStringLiteral("editable_location"));
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
}
void DolphinMainWindow::updateGoActions()
{
QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
const QUrl currentUrl = m_activeViewContainer->url();
goUpAction->setEnabled(KIO::upUrl(currentUrl) != currentUrl);
}
void DolphinMainWindow::createControlButton()
{
if (m_controlButton) {
return;
}
Q_ASSERT(!m_controlButton);
m_controlButton = new QToolButton(this);
m_controlButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
m_controlButton->setText(i18nc("@action", "Control"));
m_controlButton->setPopupMode(QToolButton::InstantPopup);
m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
QMenu* controlMenu = new QMenu(m_controlButton);
connect(controlMenu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu);
m_controlButton->setMenu(controlMenu);
toolBar()->addWidget(m_controlButton);
connect(toolBar(), &KToolBar::iconSizeChanged,
m_controlButton, &QToolButton::setIconSize);
connect(toolBar(), &KToolBar::toolButtonStyleChanged,
m_controlButton, &QToolButton::setToolButtonStyle);
// The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
// gets edited. In this case we must add them again. The adding is done asynchronously by
// m_updateToolBarTimer.
connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted);
m_updateToolBarTimer = new QTimer(this);
m_updateToolBarTimer->setInterval(500);
connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar);
}
void DolphinMainWindow::deleteControlButton()
{
delete m_controlButton;
m_controlButton = nullptr;
delete m_updateToolBarTimer;
m_updateToolBarTimer = nullptr;
}
bool DolphinMainWindow::addActionToMenu(QAction* action, QMenu* menu)
{
Q_ASSERT(action);
Q_ASSERT(menu);
const KToolBar* toolBarWidget = toolBar();
foreach (const QWidget* widget, action->associatedWidgets()) {
if (widget == toolBarWidget) {
return false;
}
}
menu->addAction(action);
return true;
}
void DolphinMainWindow::refreshViews()
{
m_tabWidget->refreshViews();
if (GeneralSettings::modifiedStartupSettings()) {
// The startup settings have been changed by the user (see bug #254947).
// Synchronize the split-view setting with the active view:
const bool splitView = GeneralSettings::splitView();
m_tabWidget->currentTabPage()->setSplitViewEnabled(splitView);
updateSplitAction();
updateWindowTitle();
}
emit settingsChanged();
}
void DolphinMainWindow::clearStatusBar()
{
m_activeViewContainer->statusBar()->resetToDefaultText();
}
void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
{
connect(container, &DolphinViewContainer::showFilterBarChanged,
this, &DolphinMainWindow::updateFilterBarAction);
connect(container, &DolphinViewContainer::writeStateChanged,
this, &DolphinMainWindow::slotWriteStateChanged);
const DolphinView* view = container->view();
connect(view, &DolphinView::selectionChanged,
this, &DolphinMainWindow::slotSelectionChanged);
connect(view, &DolphinView::requestItemInfo,
this, &DolphinMainWindow::requestItemInfo);
connect(view, &DolphinView::tabRequested,
this, &DolphinMainWindow::openNewTab);
connect(view, &DolphinView::requestContextMenu,
this, &DolphinMainWindow::openContextMenu);
connect(view, &DolphinView::directoryLoadingStarted,
this, &DolphinMainWindow::enableStopAction);
connect(view, &DolphinView::directoryLoadingCompleted,
this, &DolphinMainWindow::disableStopAction);
connect(view, &DolphinView::directoryLoadingCompleted,
this, &DolphinMainWindow::slotDirectoryLoadingCompleted);
connect(view, &DolphinView::goBackRequested,
this, static_cast(&DolphinMainWindow::goBack));
connect(view, &DolphinView::goForwardRequested,
this, static_cast(&DolphinMainWindow::goForward));
connect(view, &DolphinView::urlActivated,
this, &DolphinMainWindow::handleUrl);
const KUrlNavigator* navigator = container->urlNavigator();
connect(navigator, &KUrlNavigator::urlChanged,
this, &DolphinMainWindow::changeUrl);
connect(navigator, &KUrlNavigator::historyChanged,
this, &DolphinMainWindow::updateHistory);
connect(navigator, &KUrlNavigator::editableStateChanged,
this, &DolphinMainWindow::slotEditableStateChanged);
connect(navigator, &KUrlNavigator::tabRequested,
this, &DolphinMainWindow::openNewTabAfterLastTab);
}
void DolphinMainWindow::updateSplitAction()
{
QAction* splitAction = actionCollection()->action(QStringLiteral("split_view"));
const DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
if (tabPage->splitViewEnabled()) {
if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) {
splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
splitAction->setToolTip(i18nc("@info", "Close left view"));
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
} else {
splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
splitAction->setToolTip(i18nc("@info", "Close right view"));
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
}
} else {
splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
splitAction->setToolTip(i18nc("@info", "Split view"));
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
}
}
bool DolphinMainWindow::isKompareInstalled() const
{
static bool initialized = false;
static bool installed = false;
if (!initialized) {
// TODO: maybe replace this approach later by using a menu
// plugin like kdiff3plugin.cpp
installed = !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
initialized = true;
}
return installed;
}
void DolphinMainWindow::createPanelAction(const QIcon& icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName)
{
QAction* panelAction = actionCollection()->addAction(actionName);
panelAction->setCheckable(true);
panelAction->setChecked(dockAction->isChecked());
panelAction->setText(dockAction->text());
panelAction->setIcon(icon);
actionCollection()->setDefaultShortcut(panelAction, shortcut);
connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked);
}
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
KIO::FileUndoManager::UiInterface()
{
}
DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
{
}
void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
{
DolphinMainWindow* mainWin= qobject_cast(parentWidget());
if (mainWin) {
DolphinViewContainer* container = mainWin->activeViewContainer();
container->showMessage(job->errorString(), DolphinViewContainer::Error);
} else {
KIO::FileUndoManager::UiInterface::jobError(job);
}
}
diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp
index b4fef22a8..68da73a71 100644
--- a/src/filterbar/filterbar.cpp
+++ b/src/filterbar/filterbar.cpp
@@ -1,141 +1,137 @@
/***************************************************************************
* Copyright (C) 2006-2010 by Peter Penz *
* Copyright (C) 2006 by Gregor Kališnik *
* Copyright (C) 2012 by Stuart Citrin *
* *
* 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 "filterbar.h"
#include
#include
#include
#include
#include
#include
FilterBar::FilterBar(QWidget* parent) :
QWidget(parent)
{
// Create close button
QToolButton *closeButton = new QToolButton(this);
closeButton->setAutoRaise(true);
closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
closeButton->setToolTip(i18nc("@info:tooltip", "Hide Filter Bar"));
connect(closeButton, &QToolButton::clicked, this, &FilterBar::closeRequest);
// Create button to lock text when changing folders
m_lockButton = new QToolButton(this);
m_lockButton->setAutoRaise(true);
m_lockButton->setCheckable(true);
m_lockButton->setIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
connect(m_lockButton, &QToolButton::toggled, this, &FilterBar::slotToggleLockButton);
- // Create label
- QLabel* filterLabel = new QLabel(i18nc("@label:textbox", "Filter:"), this);
// Create filter editor
m_filterInput = new QLineEdit(this);
m_filterInput->setLayoutDirection(Qt::LeftToRight);
m_filterInput->setClearButtonEnabled(true);
+ m_filterInput->setPlaceholderText(i18n("Filter..."));
connect(m_filterInput, &QLineEdit::textChanged,
this, &FilterBar::filterChanged);
setFocusProxy(m_filterInput);
// Apply layout
QHBoxLayout* hLayout = new QHBoxLayout(this);
hLayout->setContentsMargins(0, 0, 0, 0);
hLayout->addWidget(closeButton);
- hLayout->addWidget(filterLabel);
hLayout->addWidget(m_filterInput);
hLayout->addWidget(m_lockButton);
-
- filterLabel->setBuddy(m_filterInput);
}
FilterBar::~FilterBar()
{
}
void FilterBar::closeFilterBar()
{
hide();
clear();
if (m_lockButton) {
m_lockButton->setChecked(false);
}
}
void FilterBar::selectAll()
{
m_filterInput->selectAll();
}
void FilterBar::clear()
{
m_filterInput->clear();
}
void FilterBar::slotUrlChanged()
{
if (!m_lockButton || !(m_lockButton->isChecked())) {
clear();
}
}
void FilterBar::slotToggleLockButton(bool checked)
{
if (checked) {
m_lockButton->setIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
} else {
m_lockButton->setIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
clear();
}
}
void FilterBar::showEvent(QShowEvent* event)
{
if (!event->spontaneous()) {
m_filterInput->setFocus();
}
}
void FilterBar::keyReleaseEvent(QKeyEvent* event)
{
QWidget::keyReleaseEvent(event);
switch (event->key()) {
case Qt::Key_Escape:
if (m_filterInput->text().isEmpty()) {
emit closeRequest();
} else {
m_filterInput->clear();
}
break;
case Qt::Key_Enter:
case Qt::Key_Return:
emit focusViewRequest();
break;
default:
break;
}
}
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index 71c277473..d846e5b6c 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -1,568 +1,564 @@
/***************************************************************************
* Copyright (C) 2010 by Peter Penz *
* *
* 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 "dolphinsearchbox.h"
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
#include "panels/places/placesitemmodel.h"
#include
#include
#include
#include
#ifdef HAVE_BALOO
#include
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
QWidget(parent),
m_startedSearching(false),
m_active(true),
m_topLayout(nullptr),
- m_searchLabel(nullptr),
m_searchInput(nullptr),
m_saveSearchAction(nullptr),
m_optionsScrollArea(nullptr),
m_fileNameButton(nullptr),
m_contentButton(nullptr),
m_separator(nullptr),
m_fromHereButton(nullptr),
m_everywhereButton(nullptr),
m_facetsToggleButton(nullptr),
m_facetsWidget(nullptr),
m_searchPath(),
m_startSearchTimer(nullptr)
{
}
DolphinSearchBox::~DolphinSearchBox()
{
saveSettings();
}
void DolphinSearchBox::setText(const QString& text)
{
m_searchInput->setText(text);
}
QString DolphinSearchBox::text() const
{
return m_searchInput->text();
}
void DolphinSearchBox::setSearchPath(const QUrl& url)
{
m_searchPath = url;
QFontMetrics metrics(m_fromHereButton->font());
const int maxWidth = metrics.height() * 8;
const QUrl cleanedUrl = url.adjusted(QUrl::RemoveUserInfo | QUrl::StripTrailingSlash);
QString location = cleanedUrl.fileName();
if (location.isEmpty()) {
location = cleanedUrl.toString(QUrl::PreferLocalFile);
}
if (m_fromHereButton->isChecked() && cleanedUrl.path() == QDir::homePath()) {
m_fromHereButton->setChecked(false);
m_everywhereButton->setChecked(true);
} else {
m_fromHereButton->setChecked(true);
m_everywhereButton->setChecked(false);
}
const QString elidedLocation = metrics.elidedText(location, Qt::ElideMiddle, maxWidth);
m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation));
m_fromHereButton->setToolTip(i18nc("action:button", "Limit search to '%1' and its subfolders", cleanedUrl.toString(QUrl::PreferLocalFile)));
bool hasFacetsSupport = false;
#ifdef HAVE_BALOO
const Baloo::IndexerConfig searchInfo;
hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
#endif
m_facetsWidget->setEnabled(hasFacetsSupport);
}
QUrl DolphinSearchBox::searchPath() const
{
return m_searchPath;
}
QUrl DolphinSearchBox::urlForSearching() const
{
QUrl url;
bool useBalooSearch = false;
#ifdef HAVE_BALOO
const Baloo::IndexerConfig searchInfo;
useBalooSearch = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
#endif
if (useBalooSearch) {
url = balooUrlForSearching();
} else {
url.setScheme(QStringLiteral("filenamesearch"));
QUrlQuery query;
query.addQueryItem(QStringLiteral("search"), m_searchInput->text());
if (m_contentButton->isChecked()) {
query.addQueryItem(QStringLiteral("checkContent"), QStringLiteral("yes"));
}
QString encodedUrl;
if (m_everywhereButton->isChecked()) {
encodedUrl = QDir::homePath();
} else {
encodedUrl = m_searchPath.url();
}
query.addQueryItem(QStringLiteral("url"), encodedUrl);
url.setQuery(query);
}
return url;
}
void DolphinSearchBox::fromSearchUrl(const QUrl& url)
{
if (url.scheme() == QLatin1String("baloosearch")) {
fromBalooSearchUrl(url);
} else if (url.scheme() == QLatin1String("filenamesearch")) {
const QUrlQuery query(url);
setText(query.queryItemValue(QStringLiteral("search")));
setSearchPath(QUrl::fromUserInput(query.queryItemValue(QStringLiteral("url")), QString(), QUrl::AssumeLocalFile));
m_contentButton->setChecked(query.queryItemValue(QStringLiteral("checkContent")) == QLatin1String("yes"));
} else {
setText(QString());
setSearchPath(url);
}
}
void DolphinSearchBox::selectAll()
{
m_searchInput->selectAll();
}
void DolphinSearchBox::setActive(bool active)
{
if (active != m_active) {
m_active = active;
if (active) {
emit activated();
}
}
}
bool DolphinSearchBox::isActive() const
{
return m_active;
}
bool DolphinSearchBox::event(QEvent* event)
{
if (event->type() == QEvent::Polish) {
init();
}
return QWidget::event(event);
}
void DolphinSearchBox::showEvent(QShowEvent* event)
{
if (!event->spontaneous()) {
m_searchInput->setFocus();
m_startedSearching = false;
}
}
void DolphinSearchBox::hideEvent(QHideEvent* event)
{
Q_UNUSED(event);
m_startedSearching = false;
m_startSearchTimer->stop();
}
void DolphinSearchBox::keyReleaseEvent(QKeyEvent* event)
{
QWidget::keyReleaseEvent(event);
if (event->key() == Qt::Key_Escape) {
if (m_searchInput->text().isEmpty()) {
emit closeRequest();
} else {
m_searchInput->clear();
}
}
}
bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event)
{
switch (event->type()) {
case QEvent::FocusIn:
// #379135: we get the FocusIn event when we close a tab but we don't want to emit
// the activated() signal before the removeTab() call in DolphinTabWidget::closeTab() returns.
// To avoid this issue, we delay the activation of the search box.
// We also don't want to schedule the activation process if we are already active,
// otherwise we can enter in a loop of FocusIn/FocusOut events with the searchbox of another tab.
if (!isActive()) {
QTimer::singleShot(0, this, [this] {
setActive(true);
setFocus();
});
}
break;
default:
break;
}
return QObject::eventFilter(obj, event);
}
void DolphinSearchBox::emitSearchRequest()
{
m_startSearchTimer->stop();
m_startedSearching = true;
m_saveSearchAction->setEnabled(true);
emit searchRequest();
}
void DolphinSearchBox::emitCloseRequest()
{
m_startSearchTimer->stop();
m_startedSearching = false;
m_saveSearchAction->setEnabled(false);
emit closeRequest();
}
void DolphinSearchBox::slotConfigurationChanged()
{
saveSettings();
if (m_startedSearching) {
emitSearchRequest();
}
}
void DolphinSearchBox::slotSearchTextChanged(const QString& text)
{
if (text.isEmpty()) {
m_startSearchTimer->stop();
} else {
m_startSearchTimer->start();
}
emit searchTextChanged(text);
}
void DolphinSearchBox::slotReturnPressed()
{
emitSearchRequest();
emit returnPressed();
}
void DolphinSearchBox::slotFacetsButtonToggled()
{
const bool facetsIsVisible = !m_facetsWidget->isVisible();
m_facetsWidget->setVisible(facetsIsVisible);
updateFacetsToggleButton();
}
void DolphinSearchBox::slotFacetChanged()
{
m_startedSearching = true;
m_startSearchTimer->stop();
emit searchRequest();
}
void DolphinSearchBox::slotSearchSaved()
{
const QUrl searchURL = urlForSearching();
if (searchURL.isValid()) {
PlacesItemModel model;
const QString label = i18n("Search for %1 in %2", text(), searchPath().fileName());
model.createPlacesItem(label,
searchURL,
QStringLiteral("folder-saved-search-symbolic"));
}
}
void DolphinSearchBox::initButton(QToolButton* button)
{
button->installEventFilter(this);
button->setAutoExclusive(true);
button->setAutoRaise(true);
button->setCheckable(true);
connect(button, &QToolButton::clicked, this, &DolphinSearchBox::slotConfigurationChanged);
}
void DolphinSearchBox::loadSettings()
{
if (SearchSettings::location() == QLatin1String("Everywhere")) {
m_everywhereButton->setChecked(true);
} else {
m_fromHereButton->setChecked(true);
}
if (SearchSettings::what() == QLatin1String("Content")) {
m_contentButton->setChecked(true);
} else {
m_fileNameButton->setChecked(true);
}
m_facetsWidget->setVisible(SearchSettings::showFacetsWidget());
}
void DolphinSearchBox::saveSettings()
{
SearchSettings::setLocation(m_fromHereButton->isChecked() ? QStringLiteral("FromHere") : QStringLiteral("Everywhere"));
SearchSettings::setWhat(m_fileNameButton->isChecked() ? QStringLiteral("FileName") : QStringLiteral("Content"));
SearchSettings::setShowFacetsWidget(m_facetsToggleButton->isChecked());
SearchSettings::self()->save();
}
void DolphinSearchBox::init()
{
// Create close button
QToolButton* closeButton = new QToolButton(this);
closeButton->setAutoRaise(true);
closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching"));
connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest);
- // Create search label
- m_searchLabel = new QLabel(this);
-
// Create search box
m_searchInput = new QLineEdit(this);
+ m_searchInput->setPlaceholderText(i18n("Search..."));
m_searchInput->installEventFilter(this);
m_searchInput->setClearButtonEnabled(true);
m_searchInput->setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
connect(m_searchInput, &QLineEdit::returnPressed,
this, &DolphinSearchBox::slotReturnPressed);
connect(m_searchInput, &QLineEdit::textChanged,
this, &DolphinSearchBox::slotSearchTextChanged);
setFocusProxy(m_searchInput);
// Add "Save search" button inside search box
m_saveSearchAction = new QAction(this);
m_saveSearchAction->setIcon (QIcon::fromTheme(QStringLiteral("document-save-symbolic")));
m_saveSearchAction->setText(i18nc("action:button", "Save this search to quickly access it again in the future"));
m_saveSearchAction->setEnabled(false);
m_searchInput->addAction(m_saveSearchAction, QLineEdit::TrailingPosition);
connect(m_saveSearchAction, &QAction::triggered, this, &DolphinSearchBox::slotSearchSaved);
// Apply layout for the search input
QHBoxLayout* searchInputLayout = new QHBoxLayout();
searchInputLayout->setContentsMargins(0, 0, 0, 0);
searchInputLayout->addWidget(closeButton);
- searchInputLayout->addWidget(m_searchLabel);
searchInputLayout->addWidget(m_searchInput);
// Create "Filename" and "Content" button
m_fileNameButton = new QToolButton(this);
m_fileNameButton->setText(i18nc("action:button", "Filename"));
initButton(m_fileNameButton);
m_contentButton = new QToolButton();
m_contentButton->setText(i18nc("action:button", "Content"));
initButton(m_contentButton);
QButtonGroup* searchWhatGroup = new QButtonGroup(this);
searchWhatGroup->addButton(m_fileNameButton);
searchWhatGroup->addButton(m_contentButton);
m_separator = new KSeparator(Qt::Vertical, this);
// Create "From Here" and "Your files" buttons
m_fromHereButton = new QToolButton(this);
m_fromHereButton->setText(i18nc("action:button", "From Here"));
initButton(m_fromHereButton);
m_everywhereButton = new QToolButton(this);
m_everywhereButton->setText(i18nc("action:button", "Your files"));
m_everywhereButton->setToolTip(i18nc("action:button", "Search in your home directory"));
m_everywhereButton->setIcon(QIcon::fromTheme(QStringLiteral("user-home")));
m_everywhereButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
initButton(m_everywhereButton);
QButtonGroup* searchLocationGroup = new QButtonGroup(this);
searchLocationGroup->addButton(m_fromHereButton);
searchLocationGroup->addButton(m_everywhereButton);
auto moreSearchToolsButton = new QToolButton(this);
moreSearchToolsButton->setAutoRaise(true);
moreSearchToolsButton->setPopupMode(QToolButton::InstantPopup);
moreSearchToolsButton->setIcon(QIcon::fromTheme("arrow-down-double"));
moreSearchToolsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
moreSearchToolsButton->setText(i18n("More Search Tools"));
moreSearchToolsButton->setMenu(new QMenu(this));
connect(moreSearchToolsButton->menu(), &QMenu::aboutToShow, moreSearchToolsButton->menu(), [this, moreSearchToolsButton]()
{
m_menuFactory.reset(new KMoreToolsMenuFactory("dolphin/search-tools"));
moreSearchToolsButton->menu()->clear();
m_menuFactory->fillMenuFromGroupingNames(moreSearchToolsButton->menu(), { "files-find" }, this->m_searchPath);
} );
// Create "Facets" widgets
m_facetsToggleButton = new QToolButton(this);
m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
initButton(m_facetsToggleButton);
connect(m_facetsToggleButton, &QToolButton::clicked, this, &DolphinSearchBox::slotFacetsButtonToggled);
m_facetsWidget = new DolphinFacetsWidget(this);
m_facetsWidget->installEventFilter(this);
m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged);
// Apply layout for the options
QHBoxLayout* optionsLayout = new QHBoxLayout();
optionsLayout->setContentsMargins(0, 0, 0, 0);
optionsLayout->addWidget(m_fileNameButton);
optionsLayout->addWidget(m_contentButton);
optionsLayout->addWidget(m_separator);
optionsLayout->addWidget(m_fromHereButton);
optionsLayout->addWidget(m_everywhereButton);
optionsLayout->addWidget(new KSeparator(Qt::Vertical, this));
optionsLayout->addWidget(m_facetsToggleButton);
optionsLayout->addWidget(moreSearchToolsButton);
optionsLayout->addStretch(1);
// Put the options into a QScrollArea. This prevents increasing the view width
// in case that not enough width for the options is available.
QWidget* optionsContainer = new QWidget(this);
optionsContainer->setLayout(optionsLayout);
m_optionsScrollArea = new QScrollArea(this);
m_optionsScrollArea->setFrameShape(QFrame::NoFrame);
m_optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_optionsScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_optionsScrollArea->setMaximumHeight(optionsContainer->sizeHint().height());
m_optionsScrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_optionsScrollArea->setWidget(optionsContainer);
m_optionsScrollArea->setWidgetResizable(true);
m_topLayout = new QVBoxLayout(this);
m_topLayout->setContentsMargins(0, 0, 0, 0);
m_topLayout->addLayout(searchInputLayout);
m_topLayout->addWidget(m_optionsScrollArea);
m_topLayout->addWidget(m_facetsWidget);
loadSettings();
// The searching should be started automatically after the user did not change
// the text within one second
m_startSearchTimer = new QTimer(this);
m_startSearchTimer->setSingleShot(true);
m_startSearchTimer->setInterval(1000);
connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
updateFacetsToggleButton();
}
QUrl DolphinSearchBox::balooUrlForSearching() const
{
#ifdef HAVE_BALOO
const QString text = m_searchInput->text();
Baloo::Query query;
query.addType(m_facetsWidget->facetType());
QStringList queryStrings;
QString ratingQuery = m_facetsWidget->ratingTerm();
if (!ratingQuery.isEmpty()) {
queryStrings << ratingQuery;
}
if (m_contentButton->isChecked()) {
queryStrings << text;
} else if (!text.isEmpty()) {
queryStrings << QStringLiteral("filename:\"%1\"").arg(text);
}
if (m_fromHereButton->isChecked()) {
query.setIncludeFolder(m_searchPath.toLocalFile());
}
query.setSearchString(queryStrings.join(QStringLiteral(" ")));
return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
"Query Results from '%1'", text));
#else
return QUrl();
#endif
}
void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url)
{
#ifdef HAVE_BALOO
const Baloo::Query query = Baloo::Query::fromSearchUrl(url);
// Block all signals to avoid unnecessary "searchRequest" signals
// while we adjust the search text and the facet widget.
blockSignals(true);
const QString customDir = query.includeFolder();
if (!customDir.isEmpty()) {
setSearchPath(QUrl::fromLocalFile(customDir));
} else {
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
}
setText(query.searchString());
QStringList types = query.types();
if (!types.isEmpty()) {
m_facetsWidget->setFacetType(types.first());
}
const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts);
foreach (const QString& subTerm, subTerms) {
if (subTerm.startsWith(QLatin1String("filename:"))) {
const QString value = subTerm.mid(9);
setText(value);
} else if (m_facetsWidget->isRatingTerm(subTerm)) {
m_facetsWidget->setRatingTerm(subTerm);
}
}
m_startSearchTimer->stop();
blockSignals(false);
#else
Q_UNUSED(url);
#endif
}
void DolphinSearchBox::updateFacetsToggleButton()
{
const bool facetsIsVisible = SearchSettings::showFacetsWidget();
m_facetsToggleButton->setChecked(facetsIsVisible ? true : false);
m_facetsToggleButton->setIcon(QIcon::fromTheme(facetsIsVisible ? QStringLiteral("arrow-up-double") : QStringLiteral("arrow-down-double")));
m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options"));
}
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index c138cfe7f..bb71049c7 100644
--- a/src/search/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -1,187 +1,186 @@
/***************************************************************************
* Copyright (C) 2010 by Peter Penz *
* *
* 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 DOLPHINSEARCHBOX_H
#define DOLPHINSEARCHBOX_H
#include
#include
class DolphinFacetsWidget;
class QLineEdit;
class KSeparator;
class QToolButton;
class QScrollArea;
class QLabel;
class QVBoxLayout;
class KMoreToolsMenuFactory;
/**
* @brief Input box for searching files with or without Baloo.
*
* The widget allows to specify:
* - Where to search: Everywhere or below the current directory
* - What to search: Filenames or content
*
* If Baloo is available and the current folder is indexed, further
* options are offered.
*/
class DolphinSearchBox : public QWidget {
Q_OBJECT
public:
explicit DolphinSearchBox(QWidget* parent = nullptr);
~DolphinSearchBox() override;
/**
* Sets the text that should be used as input for
* searching.
*/
void setText(const QString& text);
/**
* Returns the text that should be used as input
* for searching.
*/
QString text() const;
/**
* Sets the current path that is used as root for
* searching files, if "From Here" has been selected.
*/
void setSearchPath(const QUrl& url);
QUrl searchPath() const;
/** @return URL that will start the searching of files. */
QUrl urlForSearching() const;
/**
* Extracts information from the given search \a url to
* initialize the search box properly.
*/
void fromSearchUrl(const QUrl& url);
/**
* Selects the whole text of the search box.
*/
void selectAll();
/**
* Set the search box to the active mode, if \a active
* is true. The active mode is default. The inactive mode only differs
* visually from the active mode, no change of the behavior is given.
*
* Using the search box in the inactive mode is useful when having split views,
* where the inactive view is indicated by an search box visually.
*/
void setActive(bool active);
/**
* @return True, if the search box is in the active mode.
* @see DolphinSearchBox::setActive()
*/
bool isActive() const;
protected:
bool event(QEvent* event) override;
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
bool eventFilter(QObject* obj, QEvent* event) override;
signals:
/**
* Is emitted when a searching should be triggered.
*/
void searchRequest();
/**
* Is emitted when the user has changed a character of
* the text that should be used as input for searching.
*/
void searchTextChanged(const QString& text);
void returnPressed();
/**
* Emitted as soon as the search box should get closed.
*/
void closeRequest();
/**
* Is emitted, if the searchbox has been activated by
* an user interaction
* @see DolphinSearchBox::setActive()
*/
void activated();
private slots:
void emitSearchRequest();
void emitCloseRequest();
void slotConfigurationChanged();
void slotSearchTextChanged(const QString& text);
void slotReturnPressed();
void slotFacetsButtonToggled();
void slotFacetChanged();
void slotSearchSaved();
private:
void initButton(QToolButton* button);
void loadSettings();
void saveSettings();
void init();
/**
* @return URL that represents the Baloo query for starting the search.
*/
QUrl balooUrlForSearching() const;
/**
* Extracts information from the given Baloo search \a url to
* initialize the search box properly.
*/
void fromBalooSearchUrl(const QUrl& url);
void updateFacetsToggleButton();
private:
bool m_startedSearching;
bool m_active;
QVBoxLayout* m_topLayout;
- QLabel* m_searchLabel;
QLineEdit* m_searchInput;
QAction* m_saveSearchAction;
QScrollArea* m_optionsScrollArea;
QToolButton* m_fileNameButton;
QToolButton* m_contentButton;
KSeparator* m_separator;
QToolButton* m_fromHereButton;
QToolButton* m_everywhereButton;
QToolButton* m_facetsToggleButton;
DolphinFacetsWidget* m_facetsWidget;
QUrl m_searchPath;
QScopedPointer m_menuFactory;
QTimer* m_startSearchTimer;
};
#endif