mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
[solid-device-automounter] Port to KF5
CHANGELOG: Automatic mounting of external storage is now possible again REVIEW: 124730 BUG: 351003 FIXED-IN: 5.5.0
This commit is contained in:
parent
9a59617dbc
commit
e8a571f095
22 changed files with 1903 additions and 1 deletions
|
|
@ -151,6 +151,6 @@ add_subdirectory(kcms)
|
|||
add_subdirectory(knetattach)
|
||||
add_subdirectory(attica-kde)
|
||||
add_subdirectory(imports/activitymanager/)
|
||||
|
||||
add_subdirectory(solid-device-automounter)
|
||||
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
|
|
|||
8
solid-device-automounter/CMakeLists.txt
Normal file
8
solid-device-automounter/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
project(device_automounter)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
||||
|
||||
set(device_automounter_lib_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/lib/AutomounterSettings.cpp)
|
||||
|
||||
add_subdirectory(kcm)
|
||||
add_subdirectory(kded)
|
||||
346
solid-device-automounter/COPYING
Normal file
346
solid-device-automounter/COPYING
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
NOTE! The GPL below is copyrighted by the Free Software Foundation, but
|
||||
the instance of code that it refers to (the kde programs) are copyrighted
|
||||
by the authors who actually wrote it.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
23
solid-device-automounter/SETTINGS
Normal file
23
solid-device-automounter/SETTINGS
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
This document describes the kded_device_automounterrc settings and how they affect behavior.
|
||||
|
||||
General/AutomountUnknownDevices:If true, all devices get mounted regardles of
|
||||
the other conditions.
|
||||
|
||||
General/AutomountOnPlugin: When this is set to true, devices might get
|
||||
mounted when they are inserted.
|
||||
|
||||
General/AutomountOnLogin: When true, devices might get mounted when
|
||||
the module is loaded.
|
||||
|
||||
General/AutomountEnabled: Determines if automounting is globally enabled.
|
||||
|
||||
Devices/<dev>/EverMounted: Used to determine if a device is 'known'. A device
|
||||
is known if it has ever been mounted.
|
||||
|
||||
Devices/<dev>/LastSeenMounted: Saves the 'mounted' state between desktop
|
||||
sessions. Devices with this set to true are
|
||||
automagically remounted when the module loads.
|
||||
|
||||
Devices/<dev>/ForceAutomount: Determines if this device should get
|
||||
automounted regardless of anything else,
|
||||
including AutomountEnabled.
|
||||
23
solid-device-automounter/kcm/CMakeLists.txt
Normal file
23
solid-device-automounter/kcm/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
add_definitions(-DTRANSLATION_DOMAIN=\"kcm_device_automounter\")
|
||||
|
||||
set(kcm_device_automounter_SRCS DeviceAutomounterKCM.cpp DeviceModel.cpp)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
ki18n_wrap_ui(kcm_device_automounter_SRCS DeviceAutomounterKCM.ui)
|
||||
|
||||
kconfig_add_kcfg_files(kcm_device_automounter_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../lib/AutomounterSettingsBase.kcfgc ${CMAKE_CURRENT_SOURCE_DIR}/LayoutSettings.kcfgc)
|
||||
|
||||
add_library(kcm_device_automounter ${kcm_device_automounter_SRCS} ${device_automounter_lib_SRCS})
|
||||
|
||||
target_link_libraries(kcm_device_automounter
|
||||
KF5::CoreAddons
|
||||
KF5::KCMUtils
|
||||
KF5::ConfigWidgets
|
||||
KF5::Service
|
||||
KF5::I18n
|
||||
KF5::Solid)
|
||||
|
||||
install(TARGETS kcm_device_automounter DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
||||
install(FILES device_automounter_kcm.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
214
solid-device-automounter/kcm/DeviceAutomounterKCM.cpp
Normal file
214
solid-device-automounter/kcm/DeviceAutomounterKCM.cpp
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
/**************************************************************************
|
||||
* Copyright (C) 2009-2010 Trever Fischer <tdfischer@fedoraproject.org> *
|
||||
* Copyright (C) 2015 Kai UWe Broulik <kde@privat.broulik.de> *
|
||||
* *
|
||||
* 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 "DeviceAutomounterKCM.h"
|
||||
|
||||
#include <QStandardItem>
|
||||
#include <QStandardItemModel>
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KConfigGroup>
|
||||
#include <Solid/DeviceNotifier>
|
||||
#include <Solid/StorageVolume>
|
||||
|
||||
#include <KPluginFactory>
|
||||
|
||||
#include "AutomounterSettings.h"
|
||||
#include "LayoutSettings.h"
|
||||
#include "DeviceModel.h"
|
||||
|
||||
K_PLUGIN_FACTORY(DeviceAutomounterKCMFactory, registerPlugin<DeviceAutomounterKCM>();)
|
||||
K_EXPORT_PLUGIN(DeviceAutomounterKCMFactory("kcm_device_automounter"))
|
||||
|
||||
DeviceAutomounterKCM::DeviceAutomounterKCM(QWidget *parent, const QVariantList &args)
|
||||
: KCModule(parent, args)//DeviceAutomounterKCMFactory::componentData(), parent)
|
||||
{
|
||||
KAboutData *about = new KAboutData("kcm_device_automounter",
|
||||
i18n("Device Automounter"),
|
||||
"2.0",
|
||||
QString(),
|
||||
KAboutLicense::GPL_V2,
|
||||
i18n("(c) 2009 Trever Fischer, (c) 2015 Kai Uwe Broulik"));
|
||||
about->addAuthor(i18n("Trever Fischer"), i18n("Original Author"));
|
||||
about->addAuthor(i18n("Kai Uwe Broulik"), i18n("Plasma 5 Port"), "kde@privat.broulik.de");
|
||||
|
||||
setAboutData(about);
|
||||
setupUi(this);
|
||||
|
||||
m_devices = new DeviceModel(this);
|
||||
deviceView->setModel(m_devices);
|
||||
|
||||
auto emitChanged = [this] {
|
||||
emit changed();
|
||||
};
|
||||
|
||||
connect(automountOnLogin, &QCheckBox::stateChanged, this, emitChanged);
|
||||
connect(automountOnPlugin, &QCheckBox::stateChanged, this, emitChanged);
|
||||
connect(automountEnabled, &QCheckBox::stateChanged, this, emitChanged);
|
||||
connect(automountUnknownDevices, &QCheckBox::stateChanged, this, emitChanged);
|
||||
connect(m_devices, &DeviceModel::dataChanged, this, emitChanged);
|
||||
|
||||
connect(automountEnabled, SIGNAL(stateChanged(int)), this, SLOT(enabledChanged()));
|
||||
|
||||
connect(deviceView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection, const QItemSelection)), this, SLOT(updateForgetDeviceButton()));
|
||||
|
||||
connect(forgetDevice, SIGNAL(clicked(bool)), this, SLOT(forgetSelectedDevices()));
|
||||
|
||||
forgetDevice->setEnabled(false);
|
||||
}
|
||||
|
||||
DeviceAutomounterKCM::~DeviceAutomounterKCM()
|
||||
{
|
||||
saveLayout();
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::updateForgetDeviceButton()
|
||||
{
|
||||
foreach (const QModelIndex &idx, deviceView->selectionModel()->selectedIndexes()) {
|
||||
if (idx.data(DeviceModel::TypeRole) == DeviceModel::Detatched) {
|
||||
forgetDevice->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
forgetDevice->setEnabled(false);
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::forgetSelectedDevices()
|
||||
{
|
||||
QItemSelectionModel *selected = deviceView->selectionModel();
|
||||
int offset = 0;
|
||||
while (!selected->selectedIndexes().isEmpty() && selected->selectedIndexes().size() > offset) {
|
||||
if (selected->selectedIndexes()[offset].data(DeviceModel::TypeRole) == DeviceModel::Attached) {
|
||||
offset++;
|
||||
} else {
|
||||
m_devices->forgetDevice(selected->selectedIndexes()[offset].data(DeviceModel::UdiRole).toString());
|
||||
}
|
||||
}
|
||||
changed();
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::enabledChanged()
|
||||
{
|
||||
if (automountEnabled->isChecked()) {
|
||||
automountOnLogin->setEnabled(false);
|
||||
automountOnPlugin->setEnabled(false);
|
||||
automountUnknownDevices->setEnabled(false);
|
||||
deviceView->setEnabled(false);
|
||||
} else {
|
||||
automountOnLogin->setEnabled(true);
|
||||
automountOnPlugin->setEnabled(true);
|
||||
automountUnknownDevices->setEnabled(true);
|
||||
deviceView->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::load()
|
||||
{
|
||||
automountEnabled->setChecked(AutomounterSettings::automountEnabled());
|
||||
automountUnknownDevices->setChecked(AutomounterSettings::automountUnknownDevices());
|
||||
automountOnLogin->setChecked(AutomounterSettings::automountOnLogin());
|
||||
automountOnPlugin->setChecked(AutomounterSettings::automountOnPlugin());
|
||||
|
||||
m_devices->reload();
|
||||
enabledChanged();
|
||||
loadLayout();
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::save()
|
||||
{
|
||||
saveLayout();
|
||||
|
||||
AutomounterSettings::setAutomountEnabled(automountEnabled->isChecked());
|
||||
AutomounterSettings::setAutomountUnknownDevices(automountUnknownDevices->isChecked());
|
||||
AutomounterSettings::setAutomountOnLogin(automountOnLogin->isChecked());
|
||||
AutomounterSettings::setAutomountOnPlugin(automountOnPlugin->isChecked());
|
||||
|
||||
QStringList validDevices;
|
||||
for (int i = 0; i < m_devices->rowCount(); ++i) {
|
||||
const QModelIndex &idx = m_devices->index(i, 0);
|
||||
|
||||
for (int j = 0; j < m_devices->rowCount(idx); ++j) {
|
||||
QModelIndex dev = m_devices->index(j, 1, idx);
|
||||
const QString device = dev.data(DeviceModel::UdiRole).toString();
|
||||
validDevices << device;
|
||||
|
||||
if (dev.data(Qt::CheckStateRole).toInt() == Qt::Checked) {
|
||||
AutomounterSettings::deviceSettings(device).writeEntry("ForceLoginAutomount", true);
|
||||
} else {
|
||||
AutomounterSettings::deviceSettings(device).writeEntry("ForceLoginAutomount", false);
|
||||
}
|
||||
|
||||
dev = dev.sibling(j, 2);
|
||||
|
||||
if (dev.data(Qt::CheckStateRole).toInt() == Qt::Checked) {
|
||||
AutomounterSettings::deviceSettings(device).writeEntry("ForceAttachAutomount", true);
|
||||
} else {
|
||||
AutomounterSettings::deviceSettings(device).writeEntry("ForceAttachAutomount", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QString &possibleDevice, AutomounterSettings::knownDevices()) {
|
||||
if (!validDevices.contains(possibleDevice)) {
|
||||
AutomounterSettings::deviceSettings(possibleDevice).deleteGroup();
|
||||
}
|
||||
}
|
||||
|
||||
AutomounterSettings::self()->save();
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::saveLayout()
|
||||
{
|
||||
QList<int> widths;
|
||||
const int nbColumn = m_devices->columnCount();
|
||||
widths.reserve(nbColumn);
|
||||
|
||||
for (int i = 0; i < nbColumn; ++i) {
|
||||
widths << deviceView->columnWidth(i);
|
||||
}
|
||||
|
||||
LayoutSettings::setHeaderWidths(widths);
|
||||
//Check DeviceModel.cpp, thats where the magic row numbers come from.
|
||||
LayoutSettings::setAttachedExpanded(deviceView->isExpanded(m_devices->index(0,0)));
|
||||
LayoutSettings::setDetatchedExpanded(deviceView->isExpanded(m_devices->index(1,0)));
|
||||
LayoutSettings::self()->save();
|
||||
}
|
||||
|
||||
void DeviceAutomounterKCM::loadLayout()
|
||||
{
|
||||
LayoutSettings::self()->load();
|
||||
//Reset it first, just in case there isn't any layout saved for a particular column.
|
||||
int nbColumn = m_devices->columnCount();
|
||||
for (int i = 0; i < nbColumn; ++i) {
|
||||
deviceView->resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
QList<int> widths = LayoutSettings::headerWidths();
|
||||
nbColumn = m_devices->columnCount();
|
||||
for (int i = 0; i < nbColumn && i < widths.size(); ++i) {
|
||||
deviceView->setColumnWidth(i, widths[i]);
|
||||
}
|
||||
|
||||
deviceView->setExpanded(m_devices->index(0,0), LayoutSettings::attachedExpanded());
|
||||
deviceView->setExpanded(m_devices->index(1,0), LayoutSettings::detatchedExpanded());
|
||||
}
|
||||
|
||||
#include "DeviceAutomounterKCM.moc"
|
||||
57
solid-device-automounter/kcm/DeviceAutomounterKCM.h
Normal file
57
solid-device-automounter/kcm/DeviceAutomounterKCM.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/**************************************************************************
|
||||
* Copyright (C) 2009-2010 Trever Fischer <tdfischer@fedoraproject.org> *
|
||||
* Copyright (C) 2015 Kai Uwe Broulik <kde@privat.broulik.de> *
|
||||
* *
|
||||
* 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 DEVICEAUTOMOUNTERKCM_H
|
||||
#define DEVICEAUTOMOUNTERKCM_H
|
||||
|
||||
#include <KCModule>
|
||||
|
||||
#include "ui_DeviceAutomounterKCM.h"
|
||||
|
||||
class QStandardItemModel;
|
||||
class QStandardItem;
|
||||
class DeviceModel;
|
||||
|
||||
class DeviceAutomounterKCM : public KCModule, public Ui::DeviceAutomounterKCM
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeviceAutomounterKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
|
||||
virtual ~DeviceAutomounterKCM();
|
||||
|
||||
public slots:
|
||||
void load();
|
||||
void save();
|
||||
|
||||
private slots:
|
||||
void enabledChanged();
|
||||
void updateForgetDeviceButton();
|
||||
void forgetSelectedDevices();
|
||||
|
||||
private:
|
||||
void saveLayout();
|
||||
void loadLayout();
|
||||
|
||||
DeviceModel *m_devices;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
150
solid-device-automounter/kcm/DeviceAutomounterKCM.ui
Normal file
150
solid-device-automounter/kcm/DeviceAutomounterKCM.ui
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DeviceAutomounterKCM</class>
|
||||
<widget class="QWidget" name="DeviceAutomounterKCM">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>615</width>
|
||||
<height>380</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="automountEnabled">
|
||||
<property name="whatsThis">
|
||||
<string>When this is unchecked, no device automounting of any kind will happen, regardless of anything selected in the "Device Overrides" section.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable automatic mounting of removable media</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="automountUnknownDevices">
|
||||
<property name="whatsThis">
|
||||
<string>When this is checked, only remembered devices will be automatically mounted. A device is 'remembered' if it has ever been mounted before. For instance, plugging in a USB media player to charge is not sufficient to 'remember' it - if the files are not accessed, it will not be automatically mounted the next time it is seen. Once they have been accessed, however, the device's contents will be automatically made available to the system.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Only automatically mount removable media that has been manually mounted before</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="automountOnLogin">
|
||||
<property name="whatsThis">
|
||||
<string>If any removable storage devices are connected to your system when you login to your desktop, their contents will automatically be made available to your system for other programs to read.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mount all removable media at login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="automountOnPlugin">
|
||||
<property name="whatsThis">
|
||||
<string>When this is checked, the contents of any storage device will automatically be made available to the system when it is plugged in or attached.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically mount removable media when attached</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Device Overrides</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="deviceView">
|
||||
<property name="whatsThis">
|
||||
<string>This list contains the storage devices known to the system. If "Automount on Login" is checked, the device will be automatically mounted even though "Mount all removable media at login" is unchecked. The same applies for "Automount on Attach".
|
||||
|
||||
If "Enable automatic mounting of removable media" is unchecked, the overrides do not apply and no devices will be automatically mounted.</string>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="forgetDevice">
|
||||
<property name="whatsThis">
|
||||
<string>Clicking this button causes the selected devices to be 'forgotten'. This is only useful if "Only automatically mount removable media that has been manually mounted before" is checked. Once a device is forgotten and the system is set to only automatically mount familiar devices, the device will not be automatically mounted.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Forget Device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
310
solid-device-automounter/kcm/DeviceModel.cpp
Normal file
310
solid-device-automounter/kcm/DeviceModel.cpp
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
#include "DeviceModel.h"
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <Solid/DeviceNotifier>
|
||||
#include <Solid/Device>
|
||||
#include <Solid/StorageVolume>
|
||||
|
||||
#include "AutomounterSettings.h"
|
||||
|
||||
DeviceModel::DeviceModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
reload();
|
||||
|
||||
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(const QString)), this, SLOT(deviceAttached(const QString)));
|
||||
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(const QString)), this, SLOT(deviceRemoved(const QString)));
|
||||
}
|
||||
|
||||
void DeviceModel::forgetDevice(const QString &udi)
|
||||
{
|
||||
if (m_disconnected.contains(udi)) {
|
||||
const int deviceIndex = m_disconnected.indexOf(udi);
|
||||
beginRemoveRows(index(1, 0), deviceIndex, deviceIndex);
|
||||
m_disconnected.removeOne(udi);
|
||||
endRemoveRows();
|
||||
} else if (m_attached.contains(udi)) {
|
||||
const int deviceIndex = m_attached.indexOf(udi);
|
||||
beginRemoveRows(index(0, 0), deviceIndex, deviceIndex);
|
||||
m_attached.removeOne(udi);
|
||||
endRemoveRows();
|
||||
}
|
||||
m_loginForced.remove(udi);
|
||||
m_attachedForced.remove(udi);
|
||||
}
|
||||
|
||||
QVariant DeviceModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
switch(section) {
|
||||
case 0: return i18n("Device");
|
||||
case 1: return i18n("Automount on Login");
|
||||
case 2: return i18n("Automount on Attach");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void DeviceModel::deviceAttached(const QString &udi)
|
||||
{
|
||||
const Solid::Device devive(udi);
|
||||
auto volume = devive.as<Solid::StorageVolume>();
|
||||
|
||||
if (volume && !volume->isIgnored()) {
|
||||
if (m_disconnected.contains(udi)) {
|
||||
const int deviceIndex = m_disconnected.indexOf(udi);
|
||||
beginRemoveRows(index(1, 0), deviceIndex, deviceIndex);
|
||||
m_disconnected.removeOne(udi);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
addNewDevice(udi);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceModel::deviceRemoved(const QString &udi)
|
||||
{
|
||||
if (m_attached.contains(udi)) {
|
||||
const int deviceIndex = m_attached.indexOf(udi);
|
||||
|
||||
beginRemoveRows(index(0, 0), deviceIndex, deviceIndex);
|
||||
m_attached.removeOne(udi);
|
||||
endRemoveRows();
|
||||
|
||||
// NOTE the device is not moved to the "Disconnected" section
|
||||
// when removing it while the KCM is opened because we need to check
|
||||
// whether the device that just got detached is ignored
|
||||
// (don't show partition tables and other garbage) but this information
|
||||
// is no longer available when the device is gone
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceModel::addNewDevice(const QString &udi)
|
||||
{
|
||||
AutomounterSettings::self()->load();
|
||||
|
||||
if (!m_loginForced.contains(udi)) {
|
||||
m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login);
|
||||
}
|
||||
if (!m_attachedForced.contains(udi)) {
|
||||
m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach);
|
||||
}
|
||||
|
||||
const Solid::Device dev(udi);
|
||||
if (dev.isValid()) {
|
||||
beginInsertRows(index(0, 0), m_attached.size(), m_attached.size());
|
||||
m_attached << udi;
|
||||
} else {
|
||||
beginInsertRows(index(1, 0), m_disconnected.size(), m_disconnected.size());
|
||||
m_disconnected << udi;
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void DeviceModel::reload()
|
||||
{
|
||||
beginResetModel();
|
||||
m_loginForced.clear();
|
||||
m_attachedForced.clear();
|
||||
m_attached.clear();
|
||||
m_disconnected.clear();
|
||||
|
||||
foreach (const QString &dev, AutomounterSettings::knownDevices()) {
|
||||
addNewDevice(dev);
|
||||
}
|
||||
foreach (const QString &udi, m_loginForced.keys()) {
|
||||
m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login);
|
||||
m_attachedForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach);
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QModelIndex DeviceModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
if (parent.column() > 0) {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
if (parent.row() == 0) {
|
||||
if (row >= 0 && row < m_attached.size() && column >= 0 && column <= 2) {
|
||||
return createIndex(row, column, static_cast<quintptr>(0));
|
||||
}
|
||||
} else if (parent.row() == 1) {
|
||||
if (row >= 0 && row < m_disconnected.size() && column >= 0 && column <= 2) {
|
||||
return createIndex(row, column, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((row == 0 || row == 1) && column >= 0 && column <= 2) {
|
||||
return createIndex(row, column, 3);
|
||||
}
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex DeviceModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
if (index.internalId() == 3)
|
||||
return QModelIndex();
|
||||
return createIndex(index.internalId(), 0, 3);
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
Qt::ItemFlags DeviceModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
if (index.parent().isValid()) {
|
||||
if (index.column() > 0) {
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
|
||||
} else if (index.column() == 0) {
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
}
|
||||
} else {
|
||||
return Qt::ItemIsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
|
||||
bool DeviceModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (index.isValid() && role == Qt::CheckStateRole && index.column() > 0) {
|
||||
const QString &udi = index.data(Qt::UserRole).toString();
|
||||
switch(index.column()) {
|
||||
case 1:
|
||||
m_loginForced[udi] = (value.toInt() == Qt::Checked) ? true : false;
|
||||
break;
|
||||
case 2:
|
||||
m_attachedForced[udi] = (value.toInt() == Qt::Checked) ? true : false;
|
||||
break;
|
||||
}
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant DeviceModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.isValid() && index.parent().isValid()) {
|
||||
if (index.parent().row() == 0) {
|
||||
if (role == TypeRole) {
|
||||
return Attached;
|
||||
}
|
||||
|
||||
const QString &udi = m_attached.at(index.row());
|
||||
Solid::Device dev(udi);
|
||||
|
||||
if (role == Qt::UserRole) {
|
||||
return udi;
|
||||
}
|
||||
|
||||
if (index.column() == 0) {
|
||||
switch(role) {
|
||||
case Qt::DisplayRole:
|
||||
return dev.description();
|
||||
case Qt::ToolTipRole:
|
||||
return i18n("UDI: %1", udi);
|
||||
case Qt::DecorationRole:
|
||||
return QIcon::fromTheme(dev.icon());
|
||||
}
|
||||
} else if (index.column() == 1) {
|
||||
switch(role) {
|
||||
case Qt::CheckStateRole:
|
||||
return m_loginForced[udi] ? Qt::Checked : Qt::Unchecked;
|
||||
case Qt::ToolTipRole:
|
||||
if (m_loginForced[udi] || AutomounterSettings::shouldAutomountDevice(udi, AutomounterSettings::Login))
|
||||
return i18n("This device will be automatically mounted at login.");
|
||||
return i18n("This device will not be automatically mounted at login.");
|
||||
}
|
||||
} else if (index.column() == 2) {
|
||||
switch(role) {
|
||||
case Qt::CheckStateRole:
|
||||
return m_attachedForced[udi] ? Qt::Checked : Qt::Unchecked;
|
||||
case Qt::ToolTipRole:
|
||||
if (m_attachedForced[udi] || AutomounterSettings::shouldAutomountDevice(udi, AutomounterSettings::Attach))
|
||||
return i18n("This device will be automatically mounted when attached.");
|
||||
return i18n("This device will not be automatically mounted when attached.");
|
||||
}
|
||||
}
|
||||
} else if (index.parent().row() == 1) {
|
||||
if (role == TypeRole) {
|
||||
return Detatched;
|
||||
}
|
||||
|
||||
const QString &udi = m_disconnected[index.row()];
|
||||
|
||||
if (role == Qt::UserRole) {
|
||||
return udi;
|
||||
}
|
||||
|
||||
if (index.column() == 0) {
|
||||
switch(role) {
|
||||
case Qt::DisplayRole:
|
||||
return AutomounterSettings::getDeviceName(udi);
|
||||
case Qt::ToolTipRole:
|
||||
return i18n("UDI: %1", udi);
|
||||
case Qt::DecorationRole:
|
||||
return QIcon::fromTheme(AutomounterSettings::getDeviceIcon(udi));
|
||||
}
|
||||
} else if (index.column() == 1) {
|
||||
switch(role) {
|
||||
case Qt::CheckStateRole:
|
||||
return m_loginForced[udi] ? Qt::Checked : Qt::Unchecked;
|
||||
case Qt::ToolTipRole:
|
||||
if (m_loginForced[udi] || AutomounterSettings::shouldAutomountDevice(udi, AutomounterSettings::Login))
|
||||
return i18n("This device will be automatically mounted at login.");
|
||||
return i18n("This device will not be automatically mounted at login.");
|
||||
}
|
||||
} else if (index.column() == 2) {
|
||||
switch(role) {
|
||||
case Qt::CheckStateRole:
|
||||
return m_attachedForced[udi] ? Qt::Checked : Qt::Unchecked;
|
||||
case Qt::ToolTipRole:
|
||||
if (m_attachedForced[udi] || AutomounterSettings::shouldAutomountDevice(udi, AutomounterSettings::Attach))
|
||||
return i18n("This device will be automatically mounted when attached.");
|
||||
return i18n("This device will not be automatically mounted when attached.");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (index.isValid()) {
|
||||
if (role == Qt::DisplayRole && index.column() == 0) {
|
||||
if (index.row() == 0) {
|
||||
return i18n("Attached Devices");
|
||||
} else if (index.row() == 1) {
|
||||
return i18n("Disconnected Devices");
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int DeviceModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
if (parent.internalId() < 3 || parent.column() > 0) {
|
||||
return 0;
|
||||
}
|
||||
if (parent.row() == 0) {
|
||||
return m_attached.size();
|
||||
}
|
||||
|
||||
return m_disconnected.size();
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int DeviceModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return 3;
|
||||
}
|
||||
57
solid-device-automounter/kcm/DeviceModel.h
Normal file
57
solid-device-automounter/kcm/DeviceModel.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef DEVICEMODEL_H
|
||||
#define DEVICEMODEL_H
|
||||
|
||||
#include <QtCore/QAbstractItemModel>
|
||||
#include <QtCore/QModelIndex>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QHash>
|
||||
|
||||
class DeviceModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeviceModel(QObject *parent = nullptr);
|
||||
virtual ~DeviceModel() = default;
|
||||
|
||||
enum DeviceType {
|
||||
Attached,
|
||||
Detatched
|
||||
};
|
||||
|
||||
enum {
|
||||
UdiRole = Qt::UserRole,
|
||||
TypeRole
|
||||
};
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
|
||||
public slots:
|
||||
void forgetDevice(const QString &udi);
|
||||
void reload();
|
||||
|
||||
private slots:
|
||||
void deviceAttached(const QString &udi);
|
||||
void deviceRemoved(const QString &udi);
|
||||
|
||||
private:
|
||||
void addNewDevice(const QString &udi);
|
||||
|
||||
QList<QString> m_attached;
|
||||
QList<QString> m_disconnected;
|
||||
QHash<QString, bool> m_loginForced;
|
||||
QHash<QString, bool> m_attachedForced;
|
||||
};
|
||||
|
||||
#endif
|
||||
16
solid-device-automounter/kcm/LayoutSettings.kcfg
Normal file
16
solid-device-automounter/kcm/LayoutSettings.kcfg
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||
<kcfgfile name="device_automounter_kcmrc"/>
|
||||
<group name="Layout">
|
||||
<entry name="HeaderWidths" type="IntList"/>
|
||||
<entry name="AttachedExpanded" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="DetatchedExpanded" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
4
solid-device-automounter/kcm/LayoutSettings.kcfgc
Normal file
4
solid-device-automounter/kcm/LayoutSettings.kcfgc
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ClassName=LayoutSettings
|
||||
File=LayoutSettings.kcfg
|
||||
Mutators=true
|
||||
Singleton=true
|
||||
3
solid-device-automounter/kcm/Messages.sh
Normal file
3
solid-device-automounter/kcm/Messages.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#! /bin/sh
|
||||
$EXTRACTRC *.ui *.kcfg >> rc.cpp
|
||||
$XGETTEXT *.cpp -o $podir/kcm_device_automounter.pot
|
||||
212
solid-device-automounter/kcm/device_automounter_kcm.desktop
Normal file
212
solid-device-automounter/kcm/device_automounter_kcm.desktop
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
[Desktop Entry]
|
||||
Exec=kcmshell4 device_automounter_kcm
|
||||
Icon=drive-removable-media
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
X-KDE-Library=kcm_device_automounter
|
||||
X-KDE-ParentApp=kcontrol
|
||||
X-KDE-System-Settings-Parent-Category=hardware
|
||||
X-KDE-Keywords=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[ar]=ضم,قابل للإزالة,أجهزة,تلقائي
|
||||
X-KDE-Keywords[ast]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[bg]=Mount,Removable,Devices,Automatic,Монтиране,Устройства,Автоматично
|
||||
X-KDE-Keywords[bn]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[bs]=Mount,Removable,Devices,Automatic,montiranje,uklonjivi,uređaji,automatski
|
||||
X-KDE-Keywords[ca]=Muntatge,Extraïble,Dispositius,Automàtic
|
||||
X-KDE-Keywords[ca@valencia]=Muntatge,Extraïble,Dispositius,Automàtic
|
||||
X-KDE-Keywords[cs]=Připojení,Odpojitelné,Zařízení,Automatické
|
||||
X-KDE-Keywords[da]=Montering,flytbare,enheder,automatisk
|
||||
X-KDE-Keywords[de]=Automatische Wechselmedieneinbindung,Wechselmedien,Speichermedien
|
||||
X-KDE-Keywords[el]=Προσάρτηση,αφαιρούμενες,συσκευές,αυτόματη
|
||||
X-KDE-Keywords[en_GB]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[eo]=Munti,Demeteblaj,Aparatoj,Aŭtomate
|
||||
X-KDE-Keywords[es]=Montar,Extraíble,Dispositivos,Automático
|
||||
X-KDE-Keywords[et]=Eemaldatavad seadmed,seadmed,automaatne,ühendamine
|
||||
X-KDE-Keywords[eu]=Muntatu,Aldagarria,Gailuak,Automatikoa
|
||||
X-KDE-Keywords[fa]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[fi]=Liitä,Liittäminen,Irrotettava,Laitteet,Automaattinen
|
||||
X-KDE-Keywords[fr]=Attacher, amovible, périphériques, automatique
|
||||
X-KDE-Keywords[ga]=Feistigh,Inbhainte,Gléasanna,Uathoibríoch
|
||||
X-KDE-Keywords[gl]=Montar,Extraíbel,Dispositivo,Automático
|
||||
X-KDE-Keywords[gu]=માઉન્ટ,દૂર કરી શકાય તેવું,ઉપકરણો,આપમેળે
|
||||
X-KDE-Keywords[he]=Mount,Removable,Devices,Automatic,מעגן,אוטומטית,חיבור,נייד
|
||||
X-KDE-Keywords[hi]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[hu]=Csatolás,Eltávolítható,Eszközök,Automatikus
|
||||
X-KDE-Keywords[ia]=Montar,Removibile,Dispositivos,Automatic
|
||||
X-KDE-Keywords[id]=Kait,Dapat Dilepas,Divais,Otomatis
|
||||
X-KDE-Keywords[is]=Tengja,Fjarlægjanleg,Tæki,Sjálfvirk
|
||||
X-KDE-Keywords[it]=Montaggio,removibile,dispositivo,automatico
|
||||
X-KDE-Keywords[ja]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[kk]=Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[km]=ម៉ោន អាចយកចេញបាន ឧបករណ៍ ស្វ័យប្រវត្តិ
|
||||
X-KDE-Keywords[ko]=Mount,Removable,Devices,Automatic,마운트,자동,이동식,장치
|
||||
X-KDE-Keywords[lt]=Prijungti,Keičiamieji,Įrenginiai,Automatiškai
|
||||
X-KDE-Keywords[lv]=Montēt,noņemams,ierīces,automātiski
|
||||
X-KDE-Keywords[mr]=जोड, काढता येणारी, साधने, स्वयंचलित
|
||||
X-KDE-Keywords[nb]=Monter,Flyttbare,Enheter,Automatisk
|
||||
X-KDE-Keywords[nds]=Inhangen,tuuschbor,Reedschappen,automaatsch
|
||||
X-KDE-Keywords[nl]=Aankoppelen,verwijderbaar,apparaten,automatisch
|
||||
X-KDE-Keywords[nn]=Montering,Flyttbar,Minnepinne,Einingar,Automatisk
|
||||
X-KDE-Keywords[pa]=ਮਾਊਂਟ,ਹਟਾਉਣਯੋਗ,ਜੰਤਰ,ਆਟੋਮੈਟਿਕ
|
||||
X-KDE-Keywords[pl]=Montowanie,Wymienne,Urządzenia,Automatycznie
|
||||
X-KDE-Keywords[pt]=Montagem,Removível,Automática,Dispositivos
|
||||
X-KDE-Keywords[pt_BR]=Montagem,Removível,Automática,Dispositivos
|
||||
X-KDE-Keywords[ro]=Montare,Amoviabil,Dispozitive,Automat
|
||||
X-KDE-Keywords[ru]=Mount,Removable,Devices,Automatic,подключение,внешние,носители,автоматическое,переносные,съёмные,съемные,устройства,монтирование
|
||||
X-KDE-Keywords[sk]=Pripojiť,Vymeniteľný,Zariadenia,Automaticky
|
||||
X-KDE-Keywords[sl]=priklapljanje,priklop,odstranljivo,odstranljive,naprave,samodejno,avtomatično
|
||||
X-KDE-Keywords[sr]=Mount,Removable,Devices,Automatic,монтирање,монтирна,уклоњив,уређај,аутоматски
|
||||
X-KDE-Keywords[sr@ijekavian]=Mount,Removable,Devices,Automatic,монтирање,монтирна,уклоњив,уређај,аутоматски
|
||||
X-KDE-Keywords[sr@ijekavianlatin]=Mount,Removable,Devices,Automatic,montiranje,montirna,uklonjiv,uređaj,automatski
|
||||
X-KDE-Keywords[sr@latin]=Mount,Removable,Devices,Automatic,montiranje,montirna,uklonjiv,uređaj,automatski
|
||||
X-KDE-Keywords[sv]=Montera,Flyttbar,Enheter,Automatisk
|
||||
X-KDE-Keywords[tg]=Васлкунӣ,Ҷудошаванда,Дастгоҳҳо,Худкор
|
||||
X-KDE-Keywords[tr]=Bağla,Çıkarılabilir,Aygıtlar,Otomatik
|
||||
X-KDE-Keywords[ug]=ئېگەرلەش، يۆتكىلىشچان، ئۈسكۈنىلەر، ئاپتوماتىك
|
||||
X-KDE-Keywords[uk]=Mount,Removable,Devices,Automatic,монтування,портативний,змінний,пристрій,пристрої,автоматично,автоматичне
|
||||
X-KDE-Keywords[vi]=Gắn,tháo gỡ được,thiết bị,tự động,Mount,Removable,Devices,Automatic
|
||||
X-KDE-Keywords[wa]=Monter,Oiståve,bodjåve,Éndjins,Otomatike
|
||||
X-KDE-Keywords[x-test]=xxMountxx,xxRemovablexx,xxDevicesxx,xxAutomaticxx
|
||||
X-KDE-Keywords[zh_CN]=Mount,Removable,Devices,Automatic,挂载,自动,可移动,设备
|
||||
X-KDE-Keywords[zh_TW]=Mount,Removable,Devices,Automatic
|
||||
X-DocPath=kcontrol/solid-device-automounter/index.html
|
||||
Name=Removable Devices
|
||||
Name[ar]=أجهزة قابلة للإزالة
|
||||
Name[ast]=Preseos estrayibles
|
||||
Name[bg]=Преносими устройства
|
||||
Name[bn]=অপসারণযোগ্য ডিভাইস
|
||||
Name[bs]=Uklonjivi uređaji
|
||||
Name[ca]=Dispositius extraïbles
|
||||
Name[ca@valencia]=Dispositius extraïbles
|
||||
Name[cs]=Odpojitelná zařízení
|
||||
Name[csb]=Przenosné ùrządzenia
|
||||
Name[da]=Flytbare enheder
|
||||
Name[de]=Wechselmedien
|
||||
Name[el]=Αφαιρούμενες συσκευές
|
||||
Name[en_GB]=Removable Devices
|
||||
Name[eo]=Demeteblaj aparatoj
|
||||
Name[es]=Dispositivos extraíbles
|
||||
Name[et]=Eemaldatavad seadmed
|
||||
Name[eu]=Gailu aldagarriak
|
||||
Name[fa]=دستگاههای جداشدنی
|
||||
Name[fi]=Irrotettavat laitteet
|
||||
Name[fr]=Périphériques amovibles
|
||||
Name[fy]=Utnimbere apparaten
|
||||
Name[ga]=Gléasanna Inbhainte
|
||||
Name[gl]=Dispositivos extraíbeis
|
||||
Name[gu]=દૂર કરી શકાય તેવાં ઉપકરણો
|
||||
Name[he]=התקנים נשלפים
|
||||
Name[hi]=हटाने लायक औज़ार
|
||||
Name[hr]=Uklonjivi uređaji
|
||||
Name[hu]=Cserélhető eszközök
|
||||
Name[ia]=Dispositivos removibile
|
||||
Name[id]=Divais Dapat Dilepaskan
|
||||
Name[is]=Útskiptanleg tæki
|
||||
Name[it]=Dispositivi rimovibili
|
||||
Name[ja]=リムーバブルデバイス
|
||||
Name[kk]=Ауыстырмалы құрылғылар
|
||||
Name[km]=ឧបករណ៍ចល័ត
|
||||
Name[kn]=ತೆಗೆದೆಹಾಕಬಹುದಾದ ಸಾಧನಗಳು
|
||||
Name[ko]=이동식 장치
|
||||
Name[lt]=Keičiamieji įrenginiai
|
||||
Name[lv]=Noņemamās iekārtas
|
||||
Name[mk]=Подвижни уреди
|
||||
Name[ml]=നീക്കം ചെയ്യാവുന്ന ഉപകരണങ്ങള്
|
||||
Name[mr]=काढता येणारी साधने
|
||||
Name[nb]=Flyttbar
|
||||
Name[nds]=Tuuschbor Reedschappen
|
||||
Name[nl]=Verwijderbare apparaten
|
||||
Name[nn]=Flyttbare einingar
|
||||
Name[pa]=ਹਟਾਉਣਯੋਗ ਜੰਤਰ
|
||||
Name[pl]=Urządzenia wymienne
|
||||
Name[pt]=Dispositivos Removíveis
|
||||
Name[pt_BR]=Dispositivos removíveis
|
||||
Name[ro]=Dispozitive amovibile
|
||||
Name[ru]=Внешние носители
|
||||
Name[si]=ඉවත් කල හැකි මෙවලම්
|
||||
Name[sk]=Vymeniteľné zariadenia
|
||||
Name[sl]=Odstranljive naprave
|
||||
Name[sr]=Уклоњиви уређаји
|
||||
Name[sr@ijekavian]=Уклоњиви уређаји
|
||||
Name[sr@ijekavianlatin]=Uklonjivi uređaji
|
||||
Name[sr@latin]=Uklonjivi uređaji
|
||||
Name[sv]=Flyttbara enheter
|
||||
Name[tg]=Дастгоҳҳои ҷудошаванда
|
||||
Name[th]=อุปกรณ์ที่สามารถถอด/เสียบได้
|
||||
Name[tr]=Çıkarılabilir Aygıtlar
|
||||
Name[ug]=چىقىرىۋېتىشكە بولىدىغان ئۈسكۈنىلەر
|
||||
Name[uk]=Портативні пристрої
|
||||
Name[vi]=Thiết bị tháo gỡ được
|
||||
Name[wa]=Éndjins bodjåves
|
||||
Name[x-test]=xxRemovable Devicesxx
|
||||
Name[zh_CN]=移动设备
|
||||
Name[zh_TW]=可移除裝置
|
||||
Comment=Configure automatic handling of removable storage media
|
||||
Comment[ar]=اضبط المعالجة التلقائية لوسائط التخزين القابلة للإزالة
|
||||
Comment[ast]=Configurar la xestión automática de medios d'atroxamientu estrayibles
|
||||
Comment[bg]=Настройки на автоматични действия за преносими устройства за съхранение на данни
|
||||
Comment[bs]=Podešavanje automatskog rukovanja uklonjivim skladišnim medijumima
|
||||
Comment[ca]=Configura la gestió automàtica dels suports d'emmagatzematge extraïbles
|
||||
Comment[ca@valencia]=Configura la gestió automàtica dels suports d'emmagatzematge extraïbles
|
||||
Comment[cs]=Nastavit automatické zacházení s odpojitelnými médii
|
||||
Comment[csb]=Ùsôdzanié aùtomamtny robòtë z przenosnyma mediama
|
||||
Comment[da]=Indstil automatisk håndtering af flytbare lagringsmedier
|
||||
Comment[de]=Automatischen Umgang mit Wechselmedien einrichten
|
||||
Comment[el]=Διαμόρφωση αυτόματης διαχείρισης των αφαιρούμενων μέσων αποθήκευσης
|
||||
Comment[en_GB]=Configure automatic handling of removable storage media
|
||||
Comment[eo]=Agordi aŭtomatan traktadon de demeteblaj datumprotiloj
|
||||
Comment[es]=Configurar la gestión automática de medios de almacenamiento extraíbles
|
||||
Comment[et]=Eemaldatavate andmekandjate automaatse käitlemise seadistamine
|
||||
Comment[eu]=Biltegiratze-euskarri aldagarrien maneiu automatikoa konfiguratzea
|
||||
Comment[fi]=Irrotettavan tallennusmedian automaattisen käsittelyn asetukset
|
||||
Comment[fr]=Configure la prise en charge automatique des média amovibles de stockage
|
||||
Comment[fy]=IT automatysk ôfhanneljen fan útnimbere opslach media ynstelle
|
||||
Comment[ga]=Cumraigh láimhseáil uathoibríoch meán inbhainte stórála
|
||||
Comment[gl]=Configura a xestión automática dos medios extraíbeis de almacenaxe
|
||||
Comment[gu]=દૂર કરી શકાય તેવા સંગ્રહ ઉપકરણોની દેખરેખ રુપરેખાંકિત કરો
|
||||
Comment[he]=הגדרת תפעול אוטומטי להתקני אחסון נשלפים.
|
||||
Comment[hi]=हटाने योग्य भंडारण मीडिया का स्वत: हैंडलिंग कॉन्फ़िगर करें
|
||||
Comment[hr]=Podesi automatsko korištenje uklonjivih medija za pohranu
|
||||
Comment[hu]=Cserélhető eszközök automatikus kezelésének beállítása
|
||||
Comment[ia]=Il configura le tractamento automatic de media de immagazinage removibile
|
||||
Comment[id]=Mengatur penanganan otomatis dari media penyimpanan dapat dilepas
|
||||
Comment[is]=Stilla sjálfvirka meðhöndlun á fjarlægjanlegum geymslumiðlum
|
||||
Comment[it]=Configura la gestione automatica dei supporti rimovibili
|
||||
Comment[ja]=リムーバブルストレージメディアの自動処理を設定
|
||||
Comment[kk]=Ауыстырмалы сақтағыш тасушылармен автоматты түрде айналысуды баптау
|
||||
Comment[km]=កំណត់រចនាសម្ព័ន្ធការគ្រប់គ្រងដោយស្វ័យប្រវត្តិរបស់មេឌៀផ្ទុកចល័ត
|
||||
Comment[ko]=이동식 저장소 미디어 자동 처리 설정
|
||||
Comment[lt]=Konfigūruoti automatinį keičiamųjų įrenginių tvarkymą
|
||||
Comment[lv]=Konfigurēt noņemamo datu nesēju automātisku apstrādi
|
||||
Comment[mk]=Го конфигурира автоматското ракување со подвижните носачи
|
||||
Comment[ml]=നീക്കം ചെയ്യാവുന്ന സംഭരണ മാധ്യമത്തിനെ സ്വയം കൈകാര്യം ചെയ്യുന്നതു് ക്രമീകരിയ്ക്കുക.
|
||||
Comment[mr]=काढता येणाऱ्या संचयन साधनांची स्वयंचलितरित्या हाताळणी संयोजीत करा
|
||||
Comment[nb]=Sett opp automatisk håndtering av flyttbare lagringsmedium
|
||||
Comment[nds]=Dat automaatsche Hanteren vun tuuschbor Spiekerreedschappen instellen
|
||||
Comment[nl]=Automatische behandeling van verwijderbare opslagmedia configureren
|
||||
Comment[nn]=Set opp automatisk handtering av flyttbare lagringsmedium
|
||||
Comment[pa]=ਹਟਾਉਣਯੋਗ ਸਟੋਰੇਜ਼ ਮੀਡਿਆ ਨੂੰ ਆਟੋਮੈਟਿਕ ਹੈਂਡਲ ਕਰਨ ਲਈ ਸੰਰਚਨਾ
|
||||
Comment[pl]=Ustawienia samoczynnej obsługi urządzeń wymiennych
|
||||
Comment[pt]=Configurar o tratamento automático dos dispositivos removíveis de armazenamento
|
||||
Comment[pt_BR]=Configura o funcionamento automático de mídias removíveis
|
||||
Comment[ro]=Configurează manipularea automată a mediilor de stocare amovibile
|
||||
Comment[ru]=Настройка автоматического подключения внешних носителей информации
|
||||
Comment[si]=ඉවත් කල හැකි ගබඩා මෙවලම් වල ස්වයංක්රීය හැසිරවීම වින්යාසගත කරයි
|
||||
Comment[sk]=Nastavenie automatického zaobchádzania s vymeniteľnými médiami
|
||||
Comment[sl]=Nastavi samodejno rokovanje z odstranljivimi nosilci za shranjevanje
|
||||
Comment[sr]=Подешавање аутоматског руковања уклоњивим складишним медијумима
|
||||
Comment[sr@ijekavian]=Подешавање аутоматског руковања уклоњивим складишним медијумима
|
||||
Comment[sr@ijekavianlatin]=Podešavanje automatskog rukovanja uklonjivim skladišnim medijumima
|
||||
Comment[sr@latin]=Podešavanje automatskog rukovanja uklonjivim skladišnim medijumima
|
||||
Comment[sv]=Anpassa automatisk hantering av flyttbara lagringsmedia
|
||||
Comment[tg]=Танзимоти коркарди худкор барои дастгоҳҳои ҷудошавандаи медиа
|
||||
Comment[th]=ปรับแต่งการจัดการอัตโนมัติให้กับสื่อจัดเก็บข้อมูลแบบถอด/เสียบได้
|
||||
Comment[tr]=Çıkarılabilir depolama ortamlarının otomatik yönetimini yapılandır
|
||||
Comment[ug]=يۆتكىلىشچان ساقلاش ۋاسىتىسىنىڭ ئۆزلۈكىدىن بىر تەرەپ قىلىش سەپلىمىسى
|
||||
Comment[uk]=Налаштувати автоматичну обробку портативних носіїв даних
|
||||
Comment[vi]=Cấu hình xử lý tự động các phương tiện lưu trữ tháo gỡ được
|
||||
Comment[wa]=Apontyî l' apougnaedje otomatike di sopoirts di stocaedje di masse
|
||||
Comment[x-test]=xxConfigure automatic handling of removable storage mediaxx
|
||||
Comment[zh_CN]=配置对移动存储设备的自动处理
|
||||
Comment[zh_TW]=設定可移除儲存裝置的自動處理
|
||||
Categories=Qt;KDE;Filesystem;System;X-KDE-settings-components;
|
||||
11
solid-device-automounter/kded/CMakeLists.txt
Normal file
11
solid-device-automounter/kded/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
set(kded_device_automounter_SRCS DeviceAutomounter.cpp)
|
||||
|
||||
kconfig_add_kcfg_files(kded_device_automounter_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../lib/AutomounterSettingsBase.kcfgc)
|
||||
|
||||
add_library(kded_device_automounter MODULE ${device_automounter_lib_SRCS} ${kded_device_automounter_SRCS})
|
||||
|
||||
target_link_libraries(kded_device_automounter KF5::CoreAddons KF5::Service KF5::ConfigCore KF5::ConfigGui KF5::DBusAddons KF5::Solid)
|
||||
|
||||
install(TARGETS kded_device_automounter DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
||||
install(FILES device_automounter.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
|
||||
101
solid-device-automounter/kded/DeviceAutomounter.cpp
Normal file
101
solid-device-automounter/kded/DeviceAutomounter.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Trever Fischer <wm161@wm161.net> *
|
||||
* *
|
||||
* 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 "DeviceAutomounter.h"
|
||||
|
||||
#include <KPluginFactory>
|
||||
|
||||
#include <Solid/Device>
|
||||
#include <Solid/DeviceNotifier>
|
||||
#include <Solid/StorageAccess>
|
||||
#include <Solid/StorageVolume>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
K_PLUGIN_FACTORY(DeviceAutomounterFactory, registerPlugin<DeviceAutomounter>();)
|
||||
K_EXPORT_PLUGIN(DeviceAutomounterFactory("kded_device_automounter"))
|
||||
|
||||
DeviceAutomounter::DeviceAutomounter(QObject *parent, const QVariantList &args)
|
||||
: KDEDModule(parent)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
QTimer::singleShot(0, this, SLOT(init()));
|
||||
}
|
||||
|
||||
DeviceAutomounter::~DeviceAutomounter()
|
||||
{
|
||||
}
|
||||
|
||||
void DeviceAutomounter::init()
|
||||
{
|
||||
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(const QString&)), this, SLOT(deviceAdded(const QString&)));
|
||||
QList<Solid::Device> volumes = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume);
|
||||
foreach(Solid::Device volume, volumes) {
|
||||
// sa can be 0 (e.g. for the swap partition)
|
||||
if (Solid::StorageAccess *sa = volume.as<Solid::StorageAccess>()) {
|
||||
connect(sa, &Solid::StorageAccess::accessibilityChanged, this, &DeviceAutomounter::deviceMountChanged);
|
||||
}
|
||||
automountDevice(volume, AutomounterSettings::Login);
|
||||
}
|
||||
AutomounterSettings::self()->save();
|
||||
}
|
||||
|
||||
void DeviceAutomounter::deviceMountChanged(bool accessible, const QString &udi)
|
||||
{
|
||||
AutomounterSettings::setDeviceLastSeenMounted(udi, accessible);
|
||||
AutomounterSettings::self()->save();
|
||||
}
|
||||
|
||||
void DeviceAutomounter::automountDevice(Solid::Device &dev, AutomounterSettings::AutomountType type)
|
||||
{
|
||||
if (dev.is<Solid::StorageVolume>() && dev.is<Solid::StorageAccess>()) {
|
||||
Solid::StorageAccess *sa = dev.as<Solid::StorageAccess>();
|
||||
if (sa->isIgnored()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutomounterSettings::setDeviceLastSeenMounted(dev.udi(), sa->isAccessible());
|
||||
AutomounterSettings::saveDevice(dev);
|
||||
|
||||
if (AutomounterSettings::shouldAutomountDevice(dev.udi(), type)) {
|
||||
Solid::StorageVolume *sv = dev.as<Solid::StorageVolume>();
|
||||
if (!sv->isIgnored()) {
|
||||
sa->setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceAutomounter::deviceAdded(const QString &udi)
|
||||
{
|
||||
AutomounterSettings::self()->load();
|
||||
|
||||
Solid::Device dev(udi);
|
||||
automountDevice(dev, AutomounterSettings::Attach);
|
||||
AutomounterSettings::self()->save();
|
||||
|
||||
if (dev.is<Solid::StorageAccess>()) {
|
||||
Solid::StorageAccess *sa = dev.as<Solid::StorageAccess>();
|
||||
if (sa) {
|
||||
connect(sa, &Solid::StorageAccess::accessibilityChanged, this, &DeviceAutomounter::deviceMountChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "DeviceAutomounter.moc"
|
||||
43
solid-device-automounter/kded/DeviceAutomounter.h
Normal file
43
solid-device-automounter/kded/DeviceAutomounter.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Trever Fischer <wm161@wm161.net> *
|
||||
* *
|
||||
* 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 DEVICEAUTOMOUNTER_H
|
||||
#define DEVICEAUTOMOUNTER_H
|
||||
|
||||
#include <kdedmodule.h>
|
||||
#include <Solid/Device>
|
||||
#include "AutomounterSettings.h"
|
||||
|
||||
class DeviceAutomounter : public KDEDModule
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceAutomounter(QObject *parent = nullptr, const QVariantList &args = QVariantList());
|
||||
virtual ~DeviceAutomounter();
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
void deviceAdded(const QString &udi);
|
||||
void deviceMountChanged(bool accessible, const QString &udi);
|
||||
|
||||
private:
|
||||
void automountDevice(Solid::Device &dev, AutomounterSettings::AutomountType type);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
146
solid-device-automounter/kded/device_automounter.desktop
Normal file
146
solid-device-automounter/kded/device_automounter.desktop
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KDEDModule
|
||||
X-KDE-Kded-autoload=true
|
||||
X-KDE-Kded-load-on-demand=false
|
||||
X-KDE-Kded-phase=1
|
||||
X-KDE-Library=device_automounter
|
||||
X-KDE-DBus-ModuleName=device_automounter
|
||||
Name=Removable Device Automounter
|
||||
Name[ar]=المركب الآلي لأجهزة التخزين القابلة للإزالة
|
||||
Name[ast]=Automontaxe de preseos estrayibles
|
||||
Name[bg]=Автоматично монтиране на преносими устройства
|
||||
Name[bn]=অপসারণযোগ্য ডিভাইস অটো-মাউন্টার
|
||||
Name[bs]=Automonter uklonjivih uređaja
|
||||
Name[ca]=Muntador automàtic de dispositius extraïbles
|
||||
Name[ca@valencia]=Muntador automàtic de dispositius extraïbles
|
||||
Name[cs]=Automatické připojování odpojitelných zařízení
|
||||
Name[csb]=Aùtomatné dodôwanié przenosnych mediów
|
||||
Name[da]=Automontering af flytbare enheder
|
||||
Name[de]=Automatische Wechselmedieneinbindung
|
||||
Name[el]=Αυτόματη προσάρτηση αφαιρούμενων συσκευών
|
||||
Name[en_GB]=Removable Device Automounter
|
||||
Name[eo]=Aŭtomata muntilo de demeteblaj aparatoj
|
||||
Name[es]=Automontaje de dispositivos extraíbles
|
||||
Name[et]=Eemaldatavate seadmete automaatne ühendaja
|
||||
Name[eu]=Gailu aldagarrien muntaketa automatikoa
|
||||
Name[fa]=سوارساز خوذکار دستگاههای جداشدنی
|
||||
Name[fi]=Irrotettavan laitteen automaattiasentaja
|
||||
Name[fr]=Auto-monteur de périphérique amovible
|
||||
Name[fy]=Utnimber apparaat autokeppelder
|
||||
Name[ga]=Feisteoir Uathoibríoch Do Ghléasanna Inbhainte
|
||||
Name[gl]=Montador automático de dispositivos extraíbeis
|
||||
Name[gu]=દૂર કરી શકાય તેવા ઉપકરણોને આપમેળે માઉન્ટ કરનાર
|
||||
Name[he]=מעגן אוטומטי של התקנים
|
||||
Name[hi]=हटाने योग्य युक्ति स्वतःमाउन्टर
|
||||
Name[hr]=Automatski monter uklonjivih uređaja
|
||||
Name[hu]=Automatikus cserélhetőeszköz-csatoló
|
||||
Name[ia]=Removable Device Automounter (Montator automatic de Dispositivo Removibile)
|
||||
Name[id]=Pengait Otomatis Divais Dapat Dilepas
|
||||
Name[is]=Sjálfvirk tenging fjarlægjanlegra geymslumiðla
|
||||
Name[it]=Montaggio automatico dei dispositivi rimovibili
|
||||
Name[ja]=リムーバブルデバイスの自動マウント
|
||||
Name[kk]=Ауыстырмалы құрылғының автоттіркегіші
|
||||
Name[km]=កម្មវិធីម៉ោនឧបករណ៍ចល័តដោយស្វ័យប្រវត្តិ
|
||||
Name[ko]=이동식 장치 자동 마운터
|
||||
Name[lt]=Keičiamųjų įrenginių automatinis prijungimas
|
||||
Name[lv]=Noņemamo iekārtu automontētājs
|
||||
Name[mk]=Автом. монтирање на подвижните уреди
|
||||
Name[ml]=നീക്കം ചെയ്യാവുന്ന ഉപകരണങ്ങളുടെ ഔട്ടോമൌണ്ടര്
|
||||
Name[mr]=काढता येणारे साधन स्वयंचलित जुळवणीकार
|
||||
Name[nb]=Automatisk montering av flyttbare enheter
|
||||
Name[nds]=Autom. Inhangdeenst för tuuschbor Reedschappen
|
||||
Name[nl]=Automatische aankoppelaar voor verwijderbare apparaten
|
||||
Name[nn]=Automontering av flyttbare einingar
|
||||
Name[pa]=ਹਟਾਉਣਯੋਗ ਜੰਤਰ ਆਟੋ-ਮਾਊਂਟਰ
|
||||
Name[pl]=Samoczynne montowanie urządzeń wymiennych
|
||||
Name[pt]=Montagem Automática dos Dispositivos Removíveis
|
||||
Name[pt_BR]=Montagem automática de dispositivos removíveis
|
||||
Name[ro]=Montator automat de dispozitive amovibile
|
||||
Name[ru]=Подключение внешних носителей
|
||||
Name[si]=ඉවත්කල හැකි මෙවලම ස්වයංව සවිකරනය
|
||||
Name[sk]=Automatické pripájanie vymeniteľných zariadení
|
||||
Name[sl]=Samodejno priklapljanje odstranljivih naprav
|
||||
Name[sr]=Аутомонтер уклоњивих уређаја
|
||||
Name[sr@ijekavian]=Аутомонтер уклоњивих уређаја
|
||||
Name[sr@ijekavianlatin]=Automonter uklonjivih uređaja
|
||||
Name[sr@latin]=Automonter uklonjivih uređaja
|
||||
Name[sv]=Automatisk montering av flyttbara enheter
|
||||
Name[tg]=Худваслкунандаи дасгоҳи ҷудошаванда
|
||||
Name[th]=ตัวเมานท์อัตโนมัติให้กับอุปกรณ์ถอด/เสียบได้
|
||||
Name[tr]=Otomatik Çıkarılabilir Aygıt Bağlayıcı
|
||||
Name[ug]=يۆتكىلىشچان ئۈسكۈنىنى ئۆزلۈكىدىن ئېگەرلىگۈچ
|
||||
Name[uk]=Автоматичне монтування портативних пристроїв
|
||||
Name[vi]=Trình tự động gắn thiết bị tháo gỡ được
|
||||
Name[wa]=Oto-monteu d' éndjin bodjåve
|
||||
Name[x-test]=xxRemovable Device Automounterxx
|
||||
Name[zh_CN]=移动设备自动挂载程序
|
||||
Name[zh_TW]=可移除裝置自動掛載器
|
||||
Comment=Automatically mounts devices as needed
|
||||
Comment[ar]=وصْل الأجهزة تلقائياً عند الحاجة
|
||||
Comment[ast]=Monta automáticamente preseos cuando se necesiten
|
||||
Comment[bg]=Автоматично монтиране на устройства при нужда
|
||||
Comment[bn]=প্রয়োজনমত ডিভাইস নিজে থেকে মাউন্ট করে
|
||||
Comment[bs]=Automatsko montiranje uređaja po potrebi
|
||||
Comment[ca]=Munta automàticament els dispositius quan es necessita
|
||||
Comment[ca@valencia]=Munta automàticament els dispositius quan es necessita
|
||||
Comment[cs]=Automaticky připojí zařízení dle potřeby
|
||||
Comment[da]=Monterer automatisk enheder efter behov
|
||||
Comment[de]=Bindet Geräte bei Bedarf automatisch ein
|
||||
Comment[el]=Αυτόματη προσάρτηση συσκευών όταν χρειάζεται
|
||||
Comment[en_GB]=Automatically mounts devices as needed
|
||||
Comment[eo]=Ĝi aŭtomate muntas la aparatojn kiam necese
|
||||
Comment[es]=Monta automáticamente dispositivos cuando es necesario
|
||||
Comment[et]=Seadmete automaatne ühendamine vajaduse korral
|
||||
Comment[eu]=Gailuak automatikoki muntatzen ditu behar izanez gero
|
||||
Comment[fa]=درصورت نیاز دستگاهها را به صورت خودکار سوار میکند
|
||||
Comment[fi]=Liittää laitteet automaattisesti tarpeen mukaan
|
||||
Comment[fr]=Monte automatiquement les périphériques à la demande
|
||||
Comment[ga]=Feistigh gléasanna go huathoibríoch nuair a bheidh siad de dhíth
|
||||
Comment[gl]=Monta automaticamente os dispositivos cando sexa preciso
|
||||
Comment[gu]=જરુરિયાત મુજબ ઉપકરણો આપમેળે માઉન્ટ કરે છે
|
||||
Comment[he]=מעגן התקנים אוטומטית על־פי הצורך
|
||||
Comment[hi]=जरुरत होने पर उपकरण स्वतः माउन्ट होगा
|
||||
Comment[hr]=Automatski montira uređaje po potrebi
|
||||
Comment[hu]=Eszközök automatikus csatolása amint szükséges
|
||||
Comment[ia]=Il monta automaticamente le dispositivos como il necessita
|
||||
Comment[id]=Secara otomatis mengaitkan divais ketika diperlukan
|
||||
Comment[is]=Tengir tæki sjálfvirkt eftir þörfum inn í skráakerfi
|
||||
Comment[it]=Monta automaticamente i dispositivi secondo necessità
|
||||
Comment[ja]=必要に応じて自動的にデバイスをマウントします
|
||||
Comment[kk]=Құрылғыны керек кезде автоматты түрде тіркеу
|
||||
Comment[km]=ម៉ោនឧបករណ៍ដោយស្វ័យប្រវត្តិ នៅពេលដែលត្រូវការ
|
||||
Comment[kn]=ಅಗತ್ಯವಿದ್ದಾಗ ಸಾಧನಗಳನ್ನು ಸ್ವಯಂಚಾಲಿತವಾಗಿ ಆರೋಹಿಸುತ್ತದೆ
|
||||
Comment[ko]=필요할 때 자동으로 장치를 마운트합니다
|
||||
Comment[lt]=Prireikus automatiškai prijungia įrenginius
|
||||
Comment[lv]=Automātiski piemontē pieslēgtās ierīces
|
||||
Comment[ml]=ഉപകരണങ്ങള് ആവശ്യമുള്ളപ്പോള് അവ സ്വയം മൌണ്ട് ചെയ്യുന്നതാണ്
|
||||
Comment[mr]=जशी गरज असेले तसे स्वयंचलितरित्या साधने जुळवितो
|
||||
Comment[nb]=Monterer enheter automatisk når de trengs
|
||||
Comment[nds]=Hangt bruukt Reedschappen automaatsch in.
|
||||
Comment[nl]=Koppelt automatisch apparaten aan zoals nodig is
|
||||
Comment[nn]=Monter einingar automatisk når dei trengst
|
||||
Comment[pa]=ਜਦੋਂ ਲੋੜ ਹੋਵੇ ਤਾਂ ਜੰਤਰ ਆਟੋਮੈਟਿਕ ਮਾਊਂਟ ਕਰੋ
|
||||
Comment[pl]=Montuje urządzenia, gdy są potrzebne
|
||||
Comment[pt]=Monta automaticamente os dispositivos à medida das necessidades
|
||||
Comment[pt_BR]=Monta automaticamente os dispositivos quando necessário
|
||||
Comment[ro]=Montează automat dispozitivele atunci cînd este necesar
|
||||
Comment[ru]=Автоматически подключает внешние носители информации
|
||||
Comment[si]=අවශ්ය පරිදි මෙවලම් ස්වයංව සවි කරයි
|
||||
Comment[sk]=Automaticky pripojí zariadenia podľa potreby
|
||||
Comment[sl]=Samodejno po potrebi priklopi naprave
|
||||
Comment[sr]=Аутоматско монтирање уређаја по потреби
|
||||
Comment[sr@ijekavian]=Аутоматско монтирање уређаја по потреби
|
||||
Comment[sr@ijekavianlatin]=Automatsko montiranje uređaja po potrebi
|
||||
Comment[sr@latin]=Automatsko montiranje uređaja po potrebi
|
||||
Comment[sv]=Monterar automatiskt enheter efter behov
|
||||
Comment[tg]=Аз рӯи зарурат дастгоҳҳоро ба худкор васл мекунад
|
||||
Comment[th]=ต้องการอุปกรณ์ต่าง ๆ ที่จะให้ทำการเมานท์อัตโนมัติ
|
||||
Comment[tr]=Aygıtları gerektiğinde otomatik olarak bağlar
|
||||
Comment[ug]=زۆرۈر بولغاندا ئۈسكۈنە ئۆزلۈكىدىن ئېگەرلىنىدۇ
|
||||
Comment[uk]=Автоматичне монтування пристроїв за вимогою
|
||||
Comment[vi]=Tự động gắn các thiết bị khi cần thiết
|
||||
Comment[wa]=Monte otomaticmint des éndjins come mezåjhe
|
||||
Comment[x-test]=xxAutomatically mounts devices as neededxx
|
||||
Comment[zh_CN]=按需自动挂载设备
|
||||
Comment[zh_TW]=需要時自動掛載
|
||||
106
solid-device-automounter/lib/AutomounterSettings.cpp
Normal file
106
solid-device-automounter/lib/AutomounterSettings.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Trever Fischer <wm161@wm161.net> *
|
||||
* Copyright (C) 2015 by Kai Uwe Broulik <kde@privat.broulik.de> *
|
||||
* *
|
||||
* 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 "AutomounterSettings.h"
|
||||
|
||||
KConfigGroup AutomounterSettings::deviceSettings(const QString &udi)
|
||||
{
|
||||
return self()->config()->group("Devices").group(udi);
|
||||
}
|
||||
|
||||
QStringList AutomounterSettings::knownDevices()
|
||||
{
|
||||
return self()->config()->group("Devices").groupList();
|
||||
}
|
||||
|
||||
bool AutomounterSettings::deviceIsKnown(const QString &udi)
|
||||
{
|
||||
return self()->config()->group("Devices").group(udi).readEntry("EverMounted", false);
|
||||
}
|
||||
|
||||
bool AutomounterSettings::deviceAutomountIsForced(const QString &udi, AutomountType type)
|
||||
{
|
||||
switch (type) {
|
||||
case Login:
|
||||
return deviceSettings(udi).readEntry("ForceLoginAutomount", false);
|
||||
case Attach:
|
||||
return deviceSettings(udi).readEntry("ForceAttachAutomount", false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutomounterSettings::shouldAutomountDevice(const QString &udi, AutomountType type)
|
||||
{
|
||||
// We auto-mount the device, if:
|
||||
// 1.) auto-mounting is forced, or
|
||||
// 2.) auto-mounting is enabled
|
||||
// and auto-mounting on login/attach is configured
|
||||
// and the device is known, has been seen mounted last, or is unknown to us
|
||||
|
||||
bool known = deviceIsKnown(udi);
|
||||
bool enabled = automountEnabled();
|
||||
bool automountUnknown = automountUnknownDevices();
|
||||
bool deviceAutomount = deviceAutomountIsForced(udi, type);
|
||||
bool lastSeenMounted = deviceSettings(udi).readEntry("LastSeenMounted", false);
|
||||
bool typeCondition = false;
|
||||
switch(type) {
|
||||
case Login:
|
||||
typeCondition = automountOnLogin();
|
||||
break;
|
||||
case Attach:
|
||||
typeCondition = automountOnPlugin();
|
||||
break;
|
||||
}
|
||||
bool shouldAutomount = deviceAutomount || (enabled && typeCondition
|
||||
&& (known || lastSeenMounted || automountUnknown));
|
||||
|
||||
return shouldAutomount;
|
||||
}
|
||||
|
||||
void AutomounterSettings::setDeviceLastSeenMounted(const QString &udi, bool mounted)
|
||||
{
|
||||
if (mounted) {
|
||||
deviceSettings(udi).writeEntry("EverMounted", true);
|
||||
}
|
||||
deviceSettings(udi).writeEntry("LastSeenMounted", mounted);
|
||||
}
|
||||
|
||||
QString AutomounterSettings::getDeviceName(const QString &udi)
|
||||
{
|
||||
return deviceSettings(udi).readEntry("LastNameSeen");
|
||||
}
|
||||
|
||||
void AutomounterSettings::saveDevice(const Solid::Device &dev)
|
||||
{
|
||||
KConfigGroup settings = deviceSettings(dev.udi());
|
||||
settings.writeEntry("LastNameSeen", dev.description());
|
||||
settings.writeEntry("Icon", dev.icon());
|
||||
}
|
||||
|
||||
bool AutomounterSettings::getDeviceForcedAutomount(const QString &udi)
|
||||
{
|
||||
return deviceSettings(udi).readEntry("ForceAutomount", false);
|
||||
}
|
||||
|
||||
QString AutomounterSettings::getDeviceIcon(const QString &udi)
|
||||
{
|
||||
return deviceSettings(udi).readEntry("Icon");
|
||||
}
|
||||
47
solid-device-automounter/lib/AutomounterSettings.h
Normal file
47
solid-device-automounter/lib/AutomounterSettings.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Trever Fischer <wm161@wm161.net> *
|
||||
* *
|
||||
* 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 AUTOMOUNTERSETTINGS_H
|
||||
#define AUTOMOUNTERSETTINGS_H
|
||||
|
||||
#include "AutomounterSettingsBase.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
|
||||
#include <Solid/Device>
|
||||
|
||||
class AutomounterSettings : public AutomounterSettingsBase {
|
||||
public:
|
||||
enum AutomountType {
|
||||
Login,
|
||||
Attach
|
||||
};
|
||||
static KConfigGroup deviceSettings(const QString &udi);
|
||||
static QStringList knownDevices();
|
||||
static bool deviceIsKnown(const QString &udi);
|
||||
static bool shouldAutomountDevice(const QString &udi, AutomountType type);
|
||||
static void setDeviceLastSeenMounted(const QString &udi, bool mounted);
|
||||
static bool deviceAutomountIsForced(const QString &udi, AutomountType type);
|
||||
static QString getDeviceName(const QString &udi);
|
||||
static bool getDeviceForcedAutomount(const QString &udi);
|
||||
static QString getDeviceIcon(const QString &udi);
|
||||
static void saveDevice(const Solid::Device &dev);
|
||||
};
|
||||
|
||||
#endif
|
||||
21
solid-device-automounter/lib/AutomounterSettingsBase.kcfg
Normal file
21
solid-device-automounter/lib/AutomounterSettingsBase.kcfg
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||
<kcfgfile name="kded_device_automounterrc"/>
|
||||
<group name="General">
|
||||
<entry name="AutomountOnLogin" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="AutomountOnPlugin" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="AutomountUnknownDevices" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="AutomountEnabled" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
ClassName=AutomounterSettingsBase
|
||||
File=AutomounterSettingsBase.kcfg
|
||||
Mutators=true
|
||||
Singleton=true
|
||||
Loading…
Reference in a new issue