parent
e4e632bdb6
commit
102979ed87
@ -1,8 +0,0 @@
|
|||||||
Upstream Authors:
|
|
||||||
LXQt team: http://lxqt.org
|
|
||||||
|
|
||||||
Copyright:
|
|
||||||
Copyright (c) 2014-2017 LXQt team
|
|
||||||
|
|
||||||
License: LGPL-2.1+
|
|
||||||
The full text of the licenses can be found in the 'COPYING' file.
|
|
@ -1,122 +0,0 @@
|
|||||||
|
|
||||||
lxqt-admin-0.12.0 / 2017-10-21
|
|
||||||
==============================
|
|
||||||
|
|
||||||
* Set patch version
|
|
||||||
* Don't export github templates
|
|
||||||
* Added *lt.desktop
|
|
||||||
* lxqt-admin-user: set Qt::AA_UseHighDpiPixmaps to true
|
|
||||||
* lxqt-admin-time: set Qt::AA_UseHighDpiPixmaps to true
|
|
||||||
* Add basic cli to lxqt-admin (#48)
|
|
||||||
* lxqt-admin-user: Check for duplicates from getgrent, getpwent
|
|
||||||
* Fix lxqt-admin-user does not save shell change #1199 (#45)
|
|
||||||
* Bump year
|
|
||||||
|
|
||||||
0.11.1 / 2017-01-01
|
|
||||||
===================
|
|
||||||
|
|
||||||
* Release 0.11.1: Update changelog
|
|
||||||
* lxqt-admin-user: Add FreeBSD support
|
|
||||||
* Added *da.desktop
|
|
||||||
* Add French translation
|
|
||||||
* Remove cpack (#40)
|
|
||||||
|
|
||||||
0.11.0 / 2016-09-24
|
|
||||||
===================
|
|
||||||
|
|
||||||
* Release 0.11.0: Add changelog
|
|
||||||
* user: Add failure message box
|
|
||||||
* user: Provide icon name in polkit policy
|
|
||||||
* Update README.md
|
|
||||||
* Add Catalan translations
|
|
||||||
* Add copyright headers
|
|
||||||
* Add Arabic Translations for Desktop Files
|
|
||||||
* lxqt-admin-user: Fix a change password crash
|
|
||||||
* lxqt-admin-user: Makes the Refresh toolbar button visible
|
|
||||||
* lxqt-admin-time: Adjust dialog size on startup
|
|
||||||
* Update openSUSE section in README
|
|
||||||
* Update README.md
|
|
||||||
* Support NTP and Local RTC settings with timedated provided by systemd. Code cleanup.
|
|
||||||
* Replace calling timedatectl command with calling its dbus interface instead and provide proper error messages.
|
|
||||||
* Use dbus interface of timedate systemd daemon instead of timedatectl command.
|
|
||||||
* Add the ability to update group members.
|
|
||||||
* Support changing of user password.
|
|
||||||
* Show group members.
|
|
||||||
* Try to use a helper script and polkit policy configurations to do user admin.
|
|
||||||
* Remove liboobs dependency from lxqt-admin-time and use timedatectl to handle all time configurations.
|
|
||||||
* Try to handle timezones with timedatectl provided by systemd instead of liboobs.
|
|
||||||
* Add groupmod
|
|
||||||
* Try to remove liboobs dependency.
|
|
||||||
* Add README.md
|
|
||||||
* build: Use external translations
|
|
||||||
* ts-files removal (#32)
|
|
||||||
* Bump years to 2016
|
|
||||||
* Don't track IDE settings
|
|
||||||
* Italian translation update
|
|
||||||
* Russian translations update Remove duplicated ru_RU translations
|
|
||||||
* updated: *_hu.ts
|
|
||||||
|
|
||||||
0.10.0 / 2015-10-31
|
|
||||||
===================
|
|
||||||
|
|
||||||
* Fix license file
|
|
||||||
* Add Greek (el) translation
|
|
||||||
* Rename LxQt to LXQt everywhere
|
|
||||||
* Removed invisible dialog titles. Updated template. Added german translation.
|
|
||||||
* Handles CMake policy CMP0063
|
|
||||||
* Initialize in the same order of declaration in the class definition
|
|
||||||
* Use the LXQtCompilerSettings CMake module
|
|
||||||
* Updates the build system to use the Targets infrastructure
|
|
||||||
* Remove trailing whitespaces
|
|
||||||
* Create lxqt-admin-time_hr.ts
|
|
||||||
* Create lxqt-admin-user_hr.ts
|
|
||||||
* Hungarian translations added
|
|
||||||
* Create lxqt-admin-time_it.desktop
|
|
||||||
* Create lxqt-admin-user_it.desktop
|
|
||||||
* Initial Polish translation
|
|
||||||
* Create lxqt-admin-user_it.desktop
|
|
||||||
* lxqt-admin-user: set minimum default GID value for new group to 1000
|
|
||||||
* Initial Polish translation
|
|
||||||
|
|
||||||
0.9.0 / 2015-01-25
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Create lxqt-admin-user_it.desktop
|
|
||||||
* Create lxqt-admin-user_it.ts
|
|
||||||
* Create lxqt-admin-time_it.ts
|
|
||||||
* Add Portuguese language
|
|
||||||
* Added Japanese translation
|
|
||||||
* Unify naming for a unique lxqt. No more suffixes
|
|
||||||
* Update Russian translation
|
|
||||||
* Updates translations sources
|
|
||||||
* Whole GUI of time/date setup has been rewritten from scratch the app has now style of LXQT config dialogs based on LxQt::ConfigDialog the time and date setting is divided into one configuration widget and timezone selection is divided into second config widget
|
|
||||||
* Add icon to config window
|
|
||||||
* Add .gitignore
|
|
||||||
* Make use of QApplication::exec()
|
|
||||||
* Use the new LxQt::SingleApplication
|
|
||||||
* CMakeLists.txt maintenance.
|
|
||||||
* Update translation a little more
|
|
||||||
* Add Russian translation
|
|
||||||
* updates Translations
|
|
||||||
* Updates the translations infrastructure
|
|
||||||
* Drop Qt4 support in CMakeLists.txt in subfolders
|
|
||||||
* Drop Qt4 support in code
|
|
||||||
* Clean up CMakeLists.txt and drop Qt 4
|
|
||||||
|
|
||||||
0.8.0 / 2014-06-21
|
|
||||||
==================
|
|
||||||
|
|
||||||
* simplify Qt version switching
|
|
||||||
* Support build with Qt5.
|
|
||||||
* Use new LXQt header files.
|
|
||||||
* Update copyright notice.
|
|
||||||
* Support changing group members.
|
|
||||||
* Support adding/removing/editing users and groups.
|
|
||||||
* Redesign the UI.
|
|
||||||
* Add a group configuration dialog.
|
|
||||||
* Improve user dialog.
|
|
||||||
* Add a user config dialog.
|
|
||||||
* Update time every seconds unless it's changed manually by the user.
|
|
||||||
* Add basic skeleton for lxqt-admin-user tool.
|
|
||||||
* Add a very basic time config tool, lxqt-admin-time.
|
|
||||||
* Initial commit.
|
|
@ -1,36 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|
||||||
|
|
||||||
project(lxqt-admin)
|
|
||||||
|
|
||||||
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
|
|
||||||
|
|
||||||
# Set default installation paths
|
|
||||||
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
|
|
||||||
|
|
||||||
find_package(Qt5Widgets REQUIRED)
|
|
||||||
find_package(lxqt REQUIRED)
|
|
||||||
find_package(KF5WindowSystem REQUIRED)
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Patch Version
|
|
||||||
set(LXQT_ADMIN_PATCH_VERSION 0)
|
|
||||||
|
|
||||||
set(LXQT_ADMIN_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_ADMIN_PATCH_VERSION})
|
|
||||||
add_definitions("-DLXQT_ADMIN_VERSION=\"${LXQT_ADMIN_VERSION}\"")
|
|
||||||
|
|
||||||
include(LXQtCompilerSettings NO_POLICY_SCOPE)
|
|
||||||
include(LXQtTranslate)
|
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
|
|
||||||
message(WARNING "${CMAKE_SYSTEM_NAME} is not supported by lxqt-admin-user")
|
|
||||||
message(WARNING "${CMAKE_SYSTEM_NAME} is not supported by lxqt-admin-time")
|
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
||||||
add_subdirectory(lxqt-admin-user)
|
|
||||||
message(WARNING "${CMAKE_SYSTEM_NAME} is not supported by lxqt-admin-time")
|
|
||||||
else()
|
|
||||||
add_subdirectory(lxqt-admin-user)
|
|
||||||
add_subdirectory(lxqt-admin-time)
|
|
||||||
endif()
|
|
@ -1,458 +0,0 @@
|
|||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
Version 2.1, February 1999
|
|
||||||
|
|
||||||
Copyright (C) 1991, 1999 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.
|
|
||||||
|
|
||||||
[This is the first released version of the Lesser GPL. It also counts
|
|
||||||
as the successor of the GNU Library Public License, version 2, hence
|
|
||||||
the version number 2.1.]
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
Licenses are intended to guarantee your freedom to share and change
|
|
||||||
free software--to make sure the software is free for all its users.
|
|
||||||
|
|
||||||
This license, the Lesser General Public License, applies to some
|
|
||||||
specially designated software packages--typically libraries--of the
|
|
||||||
Free Software Foundation and other authors who decide to use it. You
|
|
||||||
can use it too, but we suggest you first think carefully about whether
|
|
||||||
this license or the ordinary General Public License is the better
|
|
||||||
strategy to use in any particular case, based on the explanations below.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom of use,
|
|
||||||
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 and use pieces of
|
|
||||||
it in new free programs; and that you are informed that you can do
|
|
||||||
these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
distributors to deny you these rights or to ask you to surrender these
|
|
||||||
rights. These restrictions translate to certain responsibilities for
|
|
||||||
you if you distribute copies of the library or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of the library, whether gratis
|
|
||||||
or for a fee, you must give the recipients all the rights that we gave
|
|
||||||
you. You must make sure that they, too, receive or can get the source
|
|
||||||
code. If you link other code with the library, you must provide
|
|
||||||
complete object files to the recipients, so that they can relink them
|
|
||||||
with the library after making changes to the library and recompiling
|
|
||||||
it. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
We protect your rights with a two-step method: (1) we copyright the
|
|
||||||
library, and (2) we offer you this license, which gives you legal
|
|
||||||
permission to copy, distribute and/or modify the library.
|
|
||||||
|
|
||||||
To protect each distributor, we want to make it very clear that
|
|
||||||
there is no warranty for the free library. Also, if the library is
|
|
||||||
modified by someone else and passed on, the recipients should know
|
|
||||||
that what they have is not the original version, so that the original
|
|
||||||
author's reputation will not be affected by problems that might be
|
|
||||||
introduced by others.
|
|
||||||
|
|
||||||
Finally, software patents pose a constant threat to the existence of
|
|
||||||
any free program. We wish to make sure that a company cannot
|
|
||||||
effectively restrict the users of a free program by obtaining a
|
|
||||||
restrictive license from a patent holder. Therefore, we insist that
|
|
||||||
any patent license obtained for a version of the library must be
|
|
||||||
consistent with the full freedom of use specified in this license.
|
|
||||||
|
|
||||||
Most GNU software, including some libraries, is covered by the
|
|
||||||
ordinary GNU General Public License. This license, the GNU Lesser
|
|
||||||
General Public License, applies to certain designated libraries, and
|
|
||||||
is quite different from the ordinary General Public License. We use
|
|
||||||
this license for certain libraries in order to permit linking those
|
|
||||||
libraries into non-free programs.
|
|
||||||
|
|
||||||
When a program is linked with a library, whether statically or using
|
|
||||||
a shared library, the combination of the two is legally speaking a
|
|
||||||
combined work, a derivative of the original library. The ordinary
|
|
||||||
General Public License therefore permits such linking only if the
|
|
||||||
entire combination fits its criteria of freedom. The Lesser General
|
|
||||||
Public License permits more lax criteria for linking other code with
|
|
||||||
the library.
|
|
||||||
|
|
||||||
We call this license the "Lesser" General Public License because it
|
|
||||||
does Less to protect the user's freedom than the ordinary General
|
|
||||||
Public License. It also provides other free software developers Less
|
|
||||||
of an advantage over competing non-free programs. These disadvantages
|
|
||||||
are the reason we use the ordinary General Public License for many
|
|
||||||
libraries. However, the Lesser license provides advantages in certain
|
|
||||||
special circumstances.
|
|
||||||
|
|
||||||
For example, on rare occasions, there may be a special need to
|
|
||||||
encourage the widest possible use of a certain library, so that it becomes
|
|
||||||
a de-facto standard. To achieve this, non-free programs must be
|
|
||||||
allowed to use the library. A more frequent case is that a free
|
|
||||||
library does the same job as widely used non-free libraries. In this
|
|
||||||
case, there is little to gain by limiting the free library to free
|
|
||||||
software only, so we use the Lesser General Public License.
|
|
||||||
|
|
||||||
In other cases, permission to use a particular library in non-free
|
|
||||||
programs enables a greater number of people to use a large body of
|
|
||||||
free software. For example, permission to use the GNU C Library in
|
|
||||||
non-free programs enables many more people to use the whole GNU
|
|
||||||
operating system, as well as its variant, the GNU/Linux operating
|
|
||||||
system.
|
|
||||||
|
|
||||||
Although the Lesser General Public License is Less protective of the
|
|
||||||
users' freedom, it does ensure that the user of a program that is
|
|
||||||
linked with the Library has the freedom and the wherewithal to run
|
|
||||||
that program using a modified version of the Library.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow. Pay close attention to the difference between a
|
|
||||||
"work based on the library" and a "work that uses the library". The
|
|
||||||
former contains code derived from the library, whereas the latter must
|
|
||||||
be combined with the library in order to run.
|
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License Agreement applies to any software library or other
|
|
||||||
program which contains a notice placed by the copyright holder or
|
|
||||||
other authorized party saying it may be distributed under the terms of
|
|
||||||
this Lesser General Public License (also called "this License").
|
|
||||||
Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
A "library" means a collection of software functions and/or data
|
|
||||||
prepared so as to be conveniently linked with application programs
|
|
||||||
(which use some of those functions and data) to form executables.
|
|
||||||
|
|
||||||
The "Library", below, refers to any such software library or work
|
|
||||||
which has been distributed under these terms. A "work based on the
|
|
||||||
Library" means either the Library or any derivative work under
|
|
||||||
copyright law: that is to say, a work containing the Library or a
|
|
||||||
portion of it, either verbatim or with modifications and/or translated
|
|
||||||
straightforwardly into another language. (Hereinafter, translation is
|
|
||||||
included without limitation in the term "modification".)
|
|
||||||
|
|
||||||
"Source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For a library, 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 library.
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running a program using the Library is not restricted, and output from
|
|
||||||
such a program is covered only if its contents constitute a work based
|
|
||||||
on the Library (independent of the use of the Library in a tool for
|
|
||||||
writing it). Whether that is true depends on what the Library does
|
|
||||||
and what the program that uses the Library does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Library's
|
|
||||||
complete 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 distribute a copy of this License along with the
|
|
||||||
Library.
|
|
||||||
|
|
||||||
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 Library or any portion
|
|
||||||
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
|
|
||||||
|
|
||||||
b) You must cause the files modified to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
c) You must cause the whole of the work to be licensed at no
|
|
||||||
charge to all third parties under the terms of this License.
|
|
||||||
|
|
||||||
d) If a facility in the modified Library refers to a function or a
|
|
||||||
table of data to be supplied by an application program that uses
|
|
||||||
the facility, other than as an argument passed when the facility
|
|
||||||
is invoked, then you must make a good faith effort to ensure that,
|
|
||||||
in the event an application does not supply such function or
|
|
||||||
table, the facility still operates, and performs whatever part of
|
|
||||||
its purpose remains meaningful.
|
|
||||||
|
|
||||||
(For example, a function in a library to compute square roots has
|
|
||||||
a purpose that is entirely well-defined independent of the
|
|
||||||
application. Therefore, Subsection 2d requires that any
|
|
||||||
application-supplied function or table used by this function must
|
|
||||||
be optional: if the application does not supply it, the square
|
|
||||||
root function must still compute square roots.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Library,
|
|
||||||
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 Library, 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 Library.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Library
|
|
||||||
with the Library (or with a work based on the Library) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
|
||||||
License instead of this License to a given copy of the Library. To do
|
|
||||||
this, you must alter all the notices that refer to this License, so
|
|
||||||
that they refer to the ordinary GNU General Public License, version 2,
|
|
||||||
instead of to this License. (If a newer version than version 2 of the
|
|
||||||
ordinary GNU General Public License has appeared, then you can specify
|
|
||||||
that version instead if you wish.) Do not make any other change in
|
|
||||||
these notices.
|
|
||||||
|
|
||||||
Once this change is made in a given copy, it is irreversible for
|
|
||||||
that copy, so the ordinary GNU General Public License applies to all
|
|
||||||
subsequent copies and derivative works made from that copy.
|
|
||||||
|
|
||||||
This option is useful when you wish to copy part of the code of
|
|
||||||
the Library into a program that is not a library.
|
|
||||||
|
|
||||||
4. You may copy and distribute the Library (or a portion or
|
|
||||||
derivative of it, under Section 2) in object code or executable form
|
|
||||||
under the terms of Sections 1 and 2 above provided that you 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.
|
|
||||||
|
|
||||||
If distribution of 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 satisfies the requirement to
|
|
||||||
distribute the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
5. A program that contains no derivative of any portion of the
|
|
||||||
Library, but is designed to work with the Library by being compiled or
|
|
||||||
linked with it, is called a "work that uses the Library". Such a
|
|
||||||
work, in isolation, is not a derivative work of the Library, and
|
|
||||||
therefore falls outside the scope of this License.
|
|
||||||
|
|
||||||
However, linking a "work that uses the Library" with the Library
|
|
||||||
creates an executable that is a derivative of the Library (because it
|
|
||||||
contains portions of the Library), rather than a "work that uses the
|
|
||||||
library". The executable is therefore covered by this License.
|
|
||||||
Section 6 states terms for distribution of such executables.
|
|
||||||
|
|
||||||
When a "work that uses the Library" uses material from a header file
|
|
||||||
that is part of the Library, the object code for the work may be a
|
|
||||||
derivative work of the Library even though the source code is not.
|
|
||||||
Whether this is true is especially significant if the work can be
|
|
||||||
linked without the Library, or if the work is itself a library. The
|
|
||||||
threshold for this to be true is not precisely defined by law.
|
|
||||||
|
|
||||||
If such an object file uses only numerical parameters, data
|
|
||||||
structure layouts and accessors, and small macros and small inline
|
|
||||||
functions (ten lines or less in length), then the use of the object
|
|
||||||
file is unrestricted, regardless of whether it is legally a derivative
|
|
||||||
work. (Executables containing this object code plus portions of the
|
|
||||||
Library will still fall under Section 6.)
|
|
||||||
|
|
||||||
Otherwise, if the work is a derivative of the Library, you may
|
|
||||||
distribute the object code for the work under the terms of Section 6.
|
|
||||||
Any executables containing that work also fall under Section 6,
|
|
||||||
whether or not they are linked directly with the Library itself.
|
|
||||||
|
|
||||||
6. As an exception to the Sections above, you may also combine or
|
|
||||||
link a "work that uses the Library" with the Library to produce a
|
|
||||||
work containing portions of the Library, and distribute that work
|
|
||||||
under terms of your choice, provided that the terms permit
|
|
||||||
modification of the work for the customer's own use and reverse
|
|
||||||
engineering for debugging such modifications.
|
|
||||||
|
|
||||||
You must give prominent notice with each copy of the work that the
|
|
||||||
Library is used in it and that the Library and its use are covered by
|
|
||||||
this License. You must supply a copy of this License. If the work
|
|
||||||
during execution displays copyright notices, you must include the
|
|
||||||
copyright notice for the Library among them, as well as a reference
|
|
||||||
directing the user to the copy of this License. Also, you must do one
|
|
||||||
of these things:
|
|
||||||
|
|
||||||
a) Accompany the work with the complete corresponding
|
|
||||||
machine-readable source code for the Library including whatever
|
|
||||||
changes were used in the work (which must be distributed under
|
|
||||||
Sections 1 and 2 above); and, if the work is an executable linked
|
|
||||||
with the Library, with the complete machine-readable "work that
|
|
||||||
uses the Library", as object code and/or source code, so that the
|
|
||||||
user can modify the Library and then relink to produce a modified
|
|
||||||
executable containing the modified Library. (It is understood
|
|
||||||
that the user who changes the contents of definitions files in the
|
|
||||||
Library will not necessarily be able to recompile the application
|
|
||||||
to use the modified definitions.)
|
|
||||||
|
|
||||||
b) Use a suitable shared library mechanism for linking with the
|
|
||||||
Library. A suitable mechanism is one that (1) uses at run time a
|
|
||||||
copy of the library already present on the user's computer system,
|
|
||||||
rather than copying library functions into the executable, and (2)
|
|
||||||
will operate properly with a modified version of the library, if
|
|
||||||
the user installs one, as long as the modified version is
|
|
||||||
interface-compatible with the version that the work was made with.
|
|
||||||
|
|
||||||
c) Accompany the work with a written offer, valid for at
|
|
||||||
least three years, to give the same user the materials
|
|
||||||
specified in Subsection 6a, above, for a charge no more
|
|
||||||
than the cost of performing this distribution.
|
|
||||||
|
|
||||||
d) If distribution of the work is made by offering access to copy
|
|
||||||
from a designated place, offer equivalent access to copy the above
|
|
||||||
specified materials from the same place.
|
|
||||||
|
|
||||||
e) Verify that the user has already received a copy of these
|
|
||||||
materials or that you have already sent this user a copy.
|
|
||||||
|
|
||||||
For an executable, the required form of the "work that uses the
|
|
||||||
Library" must include any data and utility programs needed for
|
|
||||||
reproducing the executable from it. However, as a special exception,
|
|
||||||
the materials to be 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.
|
|
||||||
|
|
||||||
It may happen that this requirement contradicts the license
|
|
||||||
restrictions of other proprietary libraries that do not normally
|
|
||||||
accompany the operating system. Such a contradiction means you cannot
|
|
||||||
use both them and the Library together in an executable that you
|
|
||||||
distribute.
|
|
||||||
|
|
||||||
7. You may place library facilities that are a work based on the
|
|
||||||
Library side-by-side in a single library together with other library
|
|
||||||
facilities not covered by this License, and distribute such a combined
|
|
||||||
library, provided that the separate distribution of the work based on
|
|
||||||
the Library and of the other library facilities is otherwise
|
|
||||||
permitted, and provided that you do these two things:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work
|
|
||||||
based on the Library, uncombined with any other library
|
|
||||||
facilities. This must be distributed under the terms of the
|
|
||||||
Sections above.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library of the fact
|
|
||||||
that part of it is a work based on the Library, and explaining
|
|
||||||
where to find the accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
8. You may not copy, modify, sublicense, link with, or distribute
|
|
||||||
the Library except as expressly provided under this License. Any
|
|
||||||
attempt otherwise to copy, modify, sublicense, link with, or
|
|
||||||
distribute the Library 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.
|
|
||||||
|
|
||||||
9. 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 Library or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Library (or any work based on the
|
|
||||||
Library), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Library or works based on it.
|
|
||||||
|
|
||||||
10. Each time you redistribute the Library (or any work based on the
|
|
||||||
Library), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute, link with or modify the Library
|
|
||||||
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 with
|
|
||||||
this License.
|
|
||||||
|
|
||||||
11. 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 Library at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Library 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 Library.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
12. If the distribution and/or use of the Library is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Library 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.
|
|
||||||
|
|
||||||
13. The Free Software Foundation may publish revised and/or new
|
|
||||||
versions of the Lesser 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 Library
|
|
||||||
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 Library does not specify a
|
|
||||||
license version number, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
14. If you wish to incorporate parts of the Library into other free
|
|
||||||
programs whose distribution conditions are incompatible with these,
|
|
||||||
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
|
|
||||||
|
|
||||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
||||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
||||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
||||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
|
||||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
||||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. 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 LIBRARY 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
|
|
||||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
||||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
@ -1,67 +0,0 @@
|
|||||||
# lxqt-admin
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
This repository is providing two GUI tools to adjust settings of the operating system LXQt is running on.
|
|
||||||
|
|
||||||
Both are using [polkit](https://www.freedesktop.org/wiki/Software/polkit/) to handle permissions.
|
|
||||||
In contrast to the specific backends described below earlier versions of lxqt-admin were relying on [system-tools-backends](http://system-tools-backends.freedesktop.org) and their wrapper [liboobs](https://github.com/GNOME/liboobs). These were replaced as both go unmaintained for years and were hence dropped from many distributions heavily restricting the usage of lxqt-admin. As long as they can be built it should still be possible to compile lxqt-admin release ≤ 0.10 against them in order to make use of it on platforms lacking systemd like BSD.
|
|
||||||
|
|
||||||
### Time and date configuration
|
|
||||||
|
|
||||||
Adjusts time and date. Binary is `lxqt-admin-time`.
|
|
||||||
|
|
||||||
![lxqt-admin-time](lxqt-admin-time.png)
|
|
||||||
|
|
||||||
It is using `systemd-timedated` as backend which is accessed by its D-Bus interface. Among other this means the option
|
|
||||||
to sync the system time by NTP is relying on `systemd-timesyncd` as backend.
|
|
||||||
|
|
||||||
### User and Group Settings
|
|
||||||
|
|
||||||
Management of users and groups. Binary is `lxqt-admin-user`.
|
|
||||||
|
|
||||||
![lxqt-admin-user](lxqt-admin-user.png)
|
|
||||||
|
|
||||||
The backend is a script `lxqt-admin-user-helper`. By default it is in turn using the shadow tools to do the actual work.
|
|
||||||
The script can be modified to use different tools, though.
|
|
||||||
|
|
||||||
## Installing
|
|
||||||
|
|
||||||
### Compiling sources
|
|
||||||
|
|
||||||
Runtime dependencies are polkit and [liblxqt](https://github.com/lxde/liblxqt). A polkit agent should be available with [lxqt-policykit](https://github.com/lxde/lxqt-policykit/) representing the first choice in LXQt.
|
|
||||||
Additional build dependencies are CMake and optionally Git to pull latest VCS checkouts. The localization files were outsourced to repository [lxqt-l10n](https://github.com/lxde/lxqt-l10n) so the corresponding dependencies are needed, too. Please refer to this repository's `README.md` for further information.
|
|
||||||
|
|
||||||
Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` will normally have to be set to `/usr`.
|
|
||||||
|
|
||||||
To build run `make`, to install `make install` which accepts variable `DESTDIR` as usual.
|
|
||||||
|
|
||||||
### Binary packages
|
|
||||||
|
|
||||||
#### Arch Linux
|
|
||||||
|
|
||||||
[AUR](https://aur.archlinux.org) packages `lxqt-admin` and `lxqt-admin-git` are providing the current stable release and the
|
|
||||||
actual master checkout at compile time as usual.
|
|
||||||
Note that package `lxqt-admin` had to be kept in the AUR due to lack of the dependency liboobs as depicted [above](#overview).
|
|
||||||
So it will be transferred to community as of release 0.11.
|
|
||||||
|
|
||||||
#### Debian
|
|
||||||
|
|
||||||
Package `lxqt-admin` is available in the official repositories as of Debian stretch.
|
|
||||||
|
|
||||||
#### Fedora
|
|
||||||
|
|
||||||
Fedora doesn't provide lxqt-admin so far due to lack of the dependency liboobs as depicted [above](#overview). This will hopefully change
|
|
||||||
once release LXQt release 0.11 makes it into the Fedora repositories.
|
|
||||||
|
|
||||||
#### openSUSE
|
|
||||||
|
|
||||||
openSUSE does not ship with lxqt-admin in it's standard repositories since the functionality is covered by openSUSE's [YaST](http://yast.github.io/).
|
|
||||||
However it is still possible to install it on openSUSE. The package and its dependencies, like the [above](#overview) mentioned, outdated liboobs are available through the [X11:LXQt](https://build.opensuse.org/project/show/X11:LXQt) repository.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Much like similar tools provided by [lxqt-config](https://github.com/lxde/lxqt-config) the tools of lxqt-admin can be launched from the [Configuration Center](https://github.com/lxde/lxqt-config#configuration-center) as well as from the panel's main menu - Preferences - LXQt settings.
|
|
||||||
|
|
||||||
The actual usage should be self-explanatory. To apply settings the GUI of the polkit authentication agent that's in use is
|
|
||||||
launched to acquire the root password.
|
|
Before Width: | Height: | Size: 47 KiB |
@ -1,83 +0,0 @@
|
|||||||
project(lxqt-admin-time)
|
|
||||||
|
|
||||||
# build static helper class first
|
|
||||||
include_directories (
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
set ( lxqt-admin-time_HDRS
|
|
||||||
timeadmindialog.h
|
|
||||||
datetime.h
|
|
||||||
timezone.h
|
|
||||||
timedatectl.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set ( lxqt-admin-time_SRCS
|
|
||||||
main.cpp
|
|
||||||
timeadmindialog.cpp
|
|
||||||
datetime.cpp
|
|
||||||
timezone.cpp
|
|
||||||
timedatectl.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set ( lxqt-admin-time_MOCS
|
|
||||||
timeadmindialog.h
|
|
||||||
datetime.h
|
|
||||||
timezone.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set( lxqt-admin-time_UIS
|
|
||||||
datetime.ui
|
|
||||||
timezone.ui
|
|
||||||
)
|
|
||||||
|
|
||||||
qt5_wrap_cpp(MOCS ${lxqt-admin-time_MOCS})
|
|
||||||
qt5_wrap_ui(UIS ${lxqt-admin-time_UIS})
|
|
||||||
|
|
||||||
# Translations **********************************
|
|
||||||
lxqt_translate_ts(lxqt-admin-time_QM_FILES
|
|
||||||
UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
|
|
||||||
SOURCES
|
|
||||||
${lxqt-admin-time_HDRS}
|
|
||||||
${lxqt-admin-time_SRCS}
|
|
||||||
${lxqt-admin-time_UIS}
|
|
||||||
INSTALL_DIR
|
|
||||||
"${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
|
|
||||||
PULL_TRANSLATIONS
|
|
||||||
${PULL_TRANSLATIONS}
|
|
||||||
CLEAN_TRANSLATIONS
|
|
||||||
${CLEAN_TRANSLATIONS}
|
|
||||||
TRANSLATIONS_REPO
|
|
||||||
${TRANSLATIONS_REPO}
|
|
||||||
TRANSLATIONS_REFSPEC
|
|
||||||
${TRANSLATIONS_REFSPEC}
|
|
||||||
REPO_SUBDIR
|
|
||||||
"lxqt-admin/${PROJECT_NAME}"
|
|
||||||
)
|
|
||||||
|
|
||||||
lxqt_translate_desktop(DESKTOP_FILES
|
|
||||||
SOURCES
|
|
||||||
lxqt-admin-time.desktop.in
|
|
||||||
)
|
|
||||||
|
|
||||||
lxqt_app_translation_loader(lxqt-admin-time_QM_LOADER ${PROJECT_NAME})
|
|
||||||
#************************************************
|
|
||||||
|
|
||||||
add_executable(lxqt-admin-time
|
|
||||||
${lxqt-admin-time_SRCS}
|
|
||||||
${UIS}
|
|
||||||
${MOCS}
|
|
||||||
${DESKTOP_FILES}
|
|
||||||
${lxqt-admin-time_QM_FILES}
|
|
||||||
${lxqt-admin-time_QM_LOADER}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(lxqt-admin-time
|
|
||||||
KF5::WindowSystem
|
|
||||||
Qt5::Widgets
|
|
||||||
Qt5::DBus
|
|
||||||
lxqt
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS lxqt-admin-time RUNTIME DESTINATION bin)
|
|
||||||
install(FILES ${DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
|
@ -1,143 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include "datetime.h"
|
|
||||||
#include "ui_datetime.h"
|
|
||||||
#include <QTime>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QTextCharFormat>
|
|
||||||
|
|
||||||
DateTimePage::DateTimePage(bool useNtp, bool localRtc, QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::DateTime),
|
|
||||||
mUseNtp(useNtp),
|
|
||||||
mLocalRtc(localRtc)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
mTimer = new QTimer(this);
|
|
||||||
connect(mTimer,SIGNAL(timeout()),SLOT(timeout()));
|
|
||||||
|
|
||||||
//highlight today
|
|
||||||
QDate date = QDate::currentDate();
|
|
||||||
QTextCharFormat format = ui->calendar->dateTextFormat(date);
|
|
||||||
QBrush brush;
|
|
||||||
brush.setColor(Qt::green);
|
|
||||||
format.setBackground(brush);
|
|
||||||
ui->calendar->setDateTextFormat(date,format);
|
|
||||||
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTimePage::~DateTimePage()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DateTimePage::timeout()
|
|
||||||
{
|
|
||||||
ui->edit_time->blockSignals(true);
|
|
||||||
ui->edit_time->setTime(QTime::currentTime());
|
|
||||||
ui->edit_time->blockSignals(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DateTimePage::reload()
|
|
||||||
{
|
|
||||||
ui->calendar->setSelectedDate(QDate::currentDate());
|
|
||||||
ui->edit_time->setTime(QTime::currentTime());
|
|
||||||
|
|
||||||
ui->localRTC->setChecked(mLocalRtc);
|
|
||||||
ui->ntp->setChecked(mUseNtp);
|
|
||||||
|
|
||||||
mTimer->start(1000);
|
|
||||||
|
|
||||||
mModified = 0;
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DateTimePage::on_edit_time_userTimeChanged(const QTime &time)
|
|
||||||
{
|
|
||||||
mModified |= M_TIME;
|
|
||||||
mTimer->stop();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime DateTimePage::dateTime() const
|
|
||||||
{
|
|
||||||
QDateTime dt(ui->calendar->selectedDate(),ui->edit_time->time());
|
|
||||||
return dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DateTimePage::useNtp() const
|
|
||||||
{
|
|
||||||
return ui->ntp->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DateTimePage::localRtc() const
|
|
||||||
{
|
|
||||||
return ui->localRTC->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DateTimePage::on_calendar_selectionChanged()
|
|
||||||
{
|
|
||||||
QDate date = ui->calendar->selectedDate();
|
|
||||||
if (date != QDate::currentDate())
|
|
||||||
{
|
|
||||||
mModified |= M_DATE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mModified &= ~M_DATE;
|
|
||||||
}
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DateTimePage::on_ntp_toggled(bool toggled)
|
|
||||||
{
|
|
||||||
if(toggled != mUseNtp)
|
|
||||||
{
|
|
||||||
mModified |= M_NTP;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mModified &= ~M_NTP;
|
|
||||||
}
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DateTimePage::on_localRTC_toggled(bool toggled)
|
|
||||||
{
|
|
||||||
if(toggled != mLocalRtc)
|
|
||||||
{
|
|
||||||
mModified |= M_LOCAL_RTC;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mModified &= ~M_LOCAL_RTC;
|
|
||||||
}
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#ifndef DATETIME_H
|
|
||||||
#define DATETIME_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class DateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DateTimePage : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit DateTimePage(bool useNtp, bool localRtc, QWidget *parent = 0);
|
|
||||||
~DateTimePage();
|
|
||||||
|
|
||||||
enum ModifiedFlag {M_DATE = (1 << 0), M_TIME = (1 << 1), M_NTP = (1 << 2), M_LOCAL_RTC = (1 << 3)};
|
|
||||||
Q_DECLARE_FLAGS(ModifiedFlags,ModifiedFlag)
|
|
||||||
|
|
||||||
ModifiedFlags modified() const
|
|
||||||
{
|
|
||||||
return mModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime dateTime() const;
|
|
||||||
bool useNtp() const;
|
|
||||||
bool localRtc() const;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void on_edit_time_userTimeChanged(const QTime &time);
|
|
||||||
void timeout();
|
|
||||||
void on_calendar_selectionChanged();
|
|
||||||
void on_ntp_toggled(bool toggled);
|
|
||||||
void on_localRTC_toggled(bool toggled);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void changed();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::DateTime *ui;
|
|
||||||
QTimer * mTimer;
|
|
||||||
bool mUseNtp;
|
|
||||||
bool mLocalRtc;
|
|
||||||
ModifiedFlags mModified;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // DATETIME_H
|
|
@ -1,131 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>DateTime</class>
|
|
||||||
<widget class="QWidget" name="DateTime">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>365</width>
|
|
||||||
<height>323</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1,0,0,0">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_time">
|
|
||||||
<property name="text">
|
|
||||||
<string>Time:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTimeEdit" name="edit_time">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>400</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="currentSection">
|
|
||||||
<enum>QDateTimeEdit::HourSection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="displayFormat">
|
|
||||||
<string>HH:mm:ss</string>
|
|
||||||
</property>
|
|
||||||
<property name="time">
|
|
||||||
<time>
|
|
||||||
<hour>0</hour>
|
|
||||||
<minute>0</minute>
|
|
||||||
<second>0</second>
|
|
||||||
</time>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Date:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCalendarWidget" name="calendar">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>400</width>
|
|
||||||
<height>173</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="ntp">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable network time synchronization (NTP)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="localRTC">
|
|
||||||
<property name="text">
|
|
||||||
<string>RTC is in local time</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>ntp</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>calendar</receiver>
|
|
||||||
<slot>setDisabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>221</x>
|
|
||||||
<y>269</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>228</x>
|
|
||||||
<y>162</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>ntp</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>edit_time</receiver>
|
|
||||||
<slot>setDisabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>105</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>173</x>
|
|
||||||
<y>55</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@ -1,11 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=Date and Time
|
|
||||||
GenericName=Date and Time Settings
|
|
||||||
Comment=Configure the date and time of your system
|
|
||||||
Exec=lxqt-admin-time
|
|
||||||
Icon=preferences-system
|
|
||||||
Categories=Settings;System;DesktopSettings;Qt;LXQt;
|
|
||||||
OnlyShowIn=LXQt;
|
|
||||||
|
|
||||||
#TRANSLATIONS_DIR=translations
|
|
@ -1,52 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include <LXQt/SingleApplication>
|
|
||||||
#include <QCommandLineParser>
|
|
||||||
#include "timeadmindialog.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
LXQt::SingleApplication app(argc, argv);
|
|
||||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
|
||||||
parser.setApplicationDescription(QStringLiteral("LXQt Admin Time"));
|
|
||||||
const QString VERINFO = QStringLiteral(LXQT_ADMIN_VERSION
|
|
||||||
"\nliblxqt " LXQT_VERSION
|
|
||||||
"\nQt " QT_VERSION_STR);
|
|
||||||
app.setApplicationVersion(VERINFO);
|
|
||||||
parser.addVersionOption();
|
|
||||||
parser.addHelpOption();
|
|
||||||
parser.process(app);
|
|
||||||
|
|
||||||
TimeAdminDialog dlg;
|
|
||||||
dlg.setWindowIcon(QIcon::fromTheme("preferences-system"));
|
|
||||||
app.setActivationWindow(&dlg);
|
|
||||||
dlg.show();
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include "timeadmindialog.h"
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QCloseEvent>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "datetime.h"
|
|
||||||
#include "timezone.h"
|
|
||||||
|
|
||||||
#define ZONETAB_PATH "/usr/share/zoneinfo/zone.tab"
|
|
||||||
|
|
||||||
TimeAdminDialog::TimeAdminDialog(QWidget *parent):
|
|
||||||
LXQt::ConfigDialog(tr("Time and date configuration"),new LXQt::Settings("TimeDate"), parent)
|
|
||||||
{
|
|
||||||
setMinimumSize(QSize(400,400));
|
|
||||||
mWindowTitle = windowTitle();
|
|
||||||
|
|
||||||
mDateTimeWidget = new DateTimePage(mTimeDateCtl.useNtp(), mTimeDateCtl.localRtc(), this);
|
|
||||||
addPage(mDateTimeWidget,tr("Date and time"));
|
|
||||||
connect(this,SIGNAL(reset()),mDateTimeWidget,SLOT(reload()));
|
|
||||||
connect(mDateTimeWidget,&DateTimePage::changed,this,&TimeAdminDialog::onChanged);
|
|
||||||
|
|
||||||
QStringList zones;
|
|
||||||
QString currentZone;
|
|
||||||
loadTimeZones(zones,currentZone);
|
|
||||||
mTimezoneWidget = new TimezonePage(zones,currentZone,this);
|
|
||||||
addPage(mTimezoneWidget,tr("Timezone"));
|
|
||||||
connect(this,&TimeAdminDialog::reset,mTimezoneWidget,&TimezonePage::reload);
|
|
||||||
connect(mTimezoneWidget,&TimezonePage::changed,this,&TimeAdminDialog::onChanged);
|
|
||||||
|
|
||||||
setButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
|
||||||
connect(this, &LXQt::ConfigDialog::clicked, this, &TimeAdminDialog::onButtonClicked);
|
|
||||||
adjustSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeAdminDialog::~TimeAdminDialog()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimeAdminDialog::onChanged()
|
|
||||||
{
|
|
||||||
showChangedStar();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TimeAdminDialog::showChangedStar()
|
|
||||||
{
|
|
||||||
if(mTimezoneWidget->isChanged() || mDateTimeWidget->modified())
|
|
||||||
setWindowTitle(mWindowTitle + "*");
|
|
||||||
else
|
|
||||||
setWindowTitle(mWindowTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimeAdminDialog::loadTimeZones(QStringList & timeZones, QString & currentTimezone)
|
|
||||||
{
|
|
||||||
currentTimezone = mTimeDateCtl.timeZone();
|
|
||||||
|
|
||||||
timeZones.clear();
|
|
||||||
QFile file(ZONETAB_PATH);
|
|
||||||
if(file.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
QByteArray line;
|
|
||||||
while(!file.atEnd())
|
|
||||||
{
|
|
||||||
line = file.readLine().trimmed();
|
|
||||||
if(line.isEmpty() || line[0] == '#') // skip comments or empty lines
|
|
||||||
continue;
|
|
||||||
QList<QByteArray> items = line.split('\t');
|
|
||||||
if(items.length() <= 2)
|
|
||||||
continue;
|
|
||||||
timeZones.append(QLatin1String(items[2]));
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TimeAdminDialog::saveChangesToSystem()
|
|
||||||
{
|
|
||||||
QString errorMessage;
|
|
||||||
if(mTimezoneWidget->isChanged())
|
|
||||||
{
|
|
||||||
QString timeZone = mTimezoneWidget->timezone();
|
|
||||||
if(!timeZone.isEmpty())
|
|
||||||
{
|
|
||||||
if(false == mTimeDateCtl.setTimeZone(timeZone, errorMessage)) {
|
|
||||||
QMessageBox::critical(this, tr("Error"), errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto modified = mDateTimeWidget->modified();
|
|
||||||
bool useNtp = mDateTimeWidget->useNtp();
|
|
||||||
if(modified.testFlag(DateTimePage::M_NTP))
|
|
||||||
{
|
|
||||||
if(false == mTimeDateCtl.setUseNtp(useNtp, errorMessage)) {
|
|
||||||
QMessageBox::critical(this, tr("Error"), errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(modified.testFlag(DateTimePage::M_LOCAL_RTC))
|
|
||||||
{
|
|
||||||
if(false == mTimeDateCtl.setLocalRtc(mDateTimeWidget->localRtc(), errorMessage)) {
|
|
||||||
QMessageBox::critical(this, tr("Error"), errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we can only change the date & time explicitly when NTP is disabled.
|
|
||||||
if(false == useNtp)
|
|
||||||
{
|
|
||||||
if(modified.testFlag(DateTimePage::M_DATE) || modified.testFlag(DateTimePage::M_TIME))
|
|
||||||
{
|
|
||||||
if(false == mTimeDateCtl.setDateTime(mDateTimeWidget->dateTime(), errorMessage)) {
|
|
||||||
QMessageBox::critical(this, tr("Error"), errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimeAdminDialog::onButtonClicked(QDialogButtonBox::StandardButton button)
|
|
||||||
{
|
|
||||||
if(button == QDialogButtonBox::Ok)
|
|
||||||
{
|
|
||||||
saveChangesToSystem();
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
else if(button == QDialogButtonBox::Cancel)
|
|
||||||
{
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include <LXQt/ConfigDialog>
|
|
||||||
#include "timedatectl.h"
|
|
||||||
|
|
||||||
class DateTimePage;
|
|
||||||
class TimezonePage;
|
|
||||||
|
|
||||||
class TimeAdminDialog: public LXQt::ConfigDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
TimeAdminDialog(QWidget * parent = NULL) ;
|
|
||||||
~TimeAdminDialog();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onChanged();
|
|
||||||
void onButtonClicked(QDialogButtonBox::StandardButton button);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void saveChangesToSystem();
|
|
||||||
void loadTimeZones(QStringList & timeZones, QString & currentTimezone);
|
|
||||||
void showChangedStar();
|
|
||||||
|
|
||||||
private:
|
|
||||||
TimeDateCtl mTimeDateCtl;
|
|
||||||
DateTimePage * mDateTimeWidget;
|
|
||||||
TimezonePage * mTimezoneWidget;
|
|
||||||
QString mWindowTitle;
|
|
||||||
};
|
|
@ -1,112 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2016 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include "timedatectl.h"
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDBusInterface>
|
|
||||||
#include <QDBusConnection>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
|
|
||||||
TimeDateCtl::TimeDateCtl()
|
|
||||||
{
|
|
||||||
mIface = new QDBusInterface(QStringLiteral("org.freedesktop.timedate1"),
|
|
||||||
QStringLiteral("/org/freedesktop/timedate1"),
|
|
||||||
QStringLiteral("org.freedesktop.timedate1"),
|
|
||||||
QDBusConnection::systemBus());
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeDateCtl::~TimeDateCtl()
|
|
||||||
{
|
|
||||||
delete mIface;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TimeDateCtl::timeZone() const
|
|
||||||
{
|
|
||||||
return mIface->property("Timezone").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TimeDateCtl::setTimeZone(QString timeZone, QString& errorMessage)
|
|
||||||
{
|
|
||||||
mIface->call("SetTimezone", timeZone, true);
|
|
||||||
QDBusError err = mIface->lastError();
|
|
||||||
if(err.isValid())
|
|
||||||
{
|
|
||||||
errorMessage = err.message();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TimeDateCtl::setDateTime(QDateTime dateTime, QString& errorMessage)
|
|
||||||
{
|
|
||||||
// the timedatectl dbus service accepts "usec" input.
|
|
||||||
// Qt can only get "msec" => convert to usec here.
|
|
||||||
mIface->call("SetTime", dateTime.toMSecsSinceEpoch() * 1000, false, true);
|
|
||||||
QDBusError err = mIface->lastError();
|
|
||||||
if(err.isValid())
|
|
||||||
{
|
|
||||||
errorMessage = err.message();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TimeDateCtl::useNtp() const
|
|
||||||
{
|
|
||||||
return mIface->property("NTP").toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TimeDateCtl::setUseNtp(bool value, QString& errorMessage)
|
|
||||||
{
|
|
||||||
mIface->call("SetNTP", value, true);
|
|
||||||
QDBusError err = mIface->lastError();
|
|
||||||
if(err.isValid())
|
|
||||||
{
|
|
||||||
errorMessage = err.message();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TimeDateCtl::localRtc() const
|
|
||||||
{
|
|
||||||
return mIface->property("LocalRTC").toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TimeDateCtl::setLocalRtc(bool value, QString& errorMessage)
|
|
||||||
{
|
|
||||||
mIface->call("SetLocalRTC", value, false, true);
|
|
||||||
QDBusError err = mIface->lastError();
|
|
||||||
if(err.isValid())
|
|
||||||
{
|
|
||||||
errorMessage = err.message();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2016 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#ifndef TIMEDATECTL_H
|
|
||||||
#define TIMEDATECTL_H
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
class QDBusInterface;
|
|
||||||
|
|
||||||
class TimeDateCtl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit TimeDateCtl();
|
|
||||||
~TimeDateCtl();
|
|
||||||
|
|
||||||
bool useNtp() const;
|
|
||||||
bool setUseNtp(bool value, QString& errorMessage);
|
|
||||||
|
|
||||||
bool localRtc() const;
|
|
||||||
bool setLocalRtc(bool value, QString& errorMessage);
|
|
||||||
|
|
||||||
QString timeZone() const;
|
|
||||||
bool setTimeZone(QString timeZone, QString& errorMessage);
|
|
||||||
|
|
||||||
bool setDateTime(QDateTime dateTime, QString& errorMessage);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QDBusInterface* mIface;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TIMEDATECTL_H
|
|
@ -1,89 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include "timezone.h"
|
|
||||||
#include "ui_timezone.h"
|
|
||||||
|
|
||||||
TimezonePage::TimezonePage(const QStringList & zones, const QString & currentimezone, QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::Timezone),
|
|
||||||
mZoneChanged(false),
|
|
||||||
mZonesList(zones)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
if (!currentimezone.isEmpty())
|
|
||||||
ui->label_timezone->setText(currentimezone);
|
|
||||||
else
|
|
||||||
ui->label_timezone->setText(tr("None"));
|
|
||||||
|
|
||||||
mZonesList.sort();
|
|
||||||
ui->list_zones->addItems(mZonesList);
|
|
||||||
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
TimezonePage::~TimezonePage()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimezonePage::reload()
|
|
||||||
{
|
|
||||||
ui->list_zones->setCurrentRow(-1);
|
|
||||||
mZoneChanged = false;
|
|
||||||
QList<QListWidgetItem *> list = ui->list_zones->findItems(ui->label_timezone->text(),Qt::MatchExactly);
|
|
||||||
if (list.count())
|
|
||||||
ui->list_zones->setCurrentItem(list.at(0));
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TimezonePage::timezone() const
|
|
||||||
{
|
|
||||||
if (ui->list_zones->currentItem())
|
|
||||||
return ui->list_zones->currentItem()->text();
|
|
||||||
else
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimezonePage::on_list_zones_itemSelectionChanged()
|
|
||||||
{
|
|
||||||
QList<QListWidgetItem*> selected = ui->list_zones->selectedItems();
|
|
||||||
if(selected.empty())
|
|
||||||
return;
|
|
||||||
QListWidgetItem *item = selected.first();
|
|
||||||
mZoneChanged = item->text() != ui->label_timezone->text();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimezonePage::on_edit_filter_textChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
QRegExp reg(arg1, Qt::CaseInsensitive,QRegExp::Wildcard);
|
|
||||||
ui->list_zones->clear();
|
|
||||||
ui->list_zones->addItems(mZonesList.filter(reg));
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#ifndef TIMEZONE_H
|
|
||||||
#define TIMEZONE_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Timezone;
|
|
||||||
}
|
|
||||||
|
|
||||||
class QListWidgetItem;
|
|
||||||
class TimezonePage : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit TimezonePage(const QStringList & zones, const QString & currentimezone, QWidget *parent = 0);
|
|
||||||
~TimezonePage();
|
|
||||||
QString timezone() const;
|
|
||||||
inline bool isChanged() const {return mZoneChanged;}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void changed();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_list_zones_itemSelectionChanged();
|
|
||||||
void on_edit_filter_textChanged(const QString &arg1);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Timezone *ui;
|
|
||||||
bool mZoneChanged;
|
|
||||||
QString mCurrentTimeZone;
|
|
||||||
QStringList mZonesList;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TIMEZONE_H
|
|
@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Timezone</class>
|
|
||||||
<widget class="QWidget" name="Timezone">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Your current timezone:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLabel" name="label_timezone">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="edit_filter">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Filter</string>
|
|
||||||
</property>
|
|
||||||
<property name="clearButtonEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="list_zones"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[ar]=التّاريخ والوقت
|
|
||||||
GenericName[ar]=إعدادات التّاريخ والوقت
|
|
||||||
Comment[ar]=اضبط تاريخ النّظام ووقته
|
|
@ -1,3 +0,0 @@
|
|||||||
Name[ca]=Data i hora
|
|
||||||
GenericName[ca]=Ajusts de la data i l'hora
|
|
||||||
Comment[ca]=Configureu la data i l'hora del vostre sistema
|
|
@ -1,3 +0,0 @@
|
|||||||
Name[da]=Dato og klokkeslæt
|
|
||||||
GenericName[da]=Indstillinger for dato og klokkeslæt
|
|
||||||
Comment[da]=Konfigurér datoen og klokkeslættet på dit system
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[de]=Datum und Zeit
|
|
||||||
GenericName[de]=Einstellungen für Datum und Zeit
|
|
||||||
Comment[de]=Konfiguriert das Datum und die Zeit des Systems
|
|
@ -1,3 +0,0 @@
|
|||||||
Name[el]=Ημερομηνία και ώρα
|
|
||||||
GenericName[el]=Ρυθμίσεις της ημερομηνίας και της ώρας
|
|
||||||
Comment[el]=Διαμόρφωση της ημερομηνίας και της ώρας του συστήματός σας
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[fr]=Date et heure
|
|
||||||
GenericName[fr]=Paramétrer la date et l'heure
|
|
||||||
Comment[fr]=Paramétrer la date et l'heure du système
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[hu]=Dátum és idő
|
|
||||||
GenericName[hu]=Dátum és időbeállítás
|
|
||||||
Comment[hu]=A rendszeridő beállítása
|
|
@ -1,3 +0,0 @@
|
|||||||
#Translations
|
|
||||||
Name[it]=Data e ora
|
|
||||||
Comment[it]=Configura la data e l'ora del sistema
|
|
@ -1,6 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Name[ja]=日時設定
|
|
||||||
GenericName[ja]=日時の設定
|
|
||||||
Comment[ja]=システムに日付と時刻を設定します
|
|
||||||
|
|
||||||
#TRANSLATIONS_DIR=translations
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[lt]=Data ir laikas
|
|
||||||
GenericName[lt]=Datos ir laiko nustatymai
|
|
||||||
Comment[lt]=Konfigūruoti sistemos datą ir laiką
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[pl]=Data i czas
|
|
||||||
GenericName[pl]=Ustawienia daty i czasu
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[pt]=Data e hora
|
|
||||||
GenericName[pt]=Definições de data e hora
|
|
||||||
Comment[pt]=Configurar a data e a hora do seu sistema
|
|
@ -1,6 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Name[ru]=Дата и время
|
|
||||||
GenericName[ru]=Настройки даты и времени
|
|
||||||
Comment[ru]=Настроить дату и время вашей системы
|
|
||||||
|
|
||||||
#TRANSLATIONS_DIR=translations
|
|
Before Width: | Height: | Size: 44 KiB |
@ -1,91 +0,0 @@
|
|||||||
project(lxqt-admin-user)
|
|
||||||
|
|
||||||
# build static helper class first
|
|
||||||
include_directories (
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
set ( lxqt-admin-user_SRCS
|
|
||||||
main.cpp
|
|
||||||
mainwindow.cpp
|
|
||||||
userdialog.cpp
|
|
||||||
groupdialog.cpp
|
|
||||||
usermanager.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set ( lxqt-admin-user_MOCS
|
|
||||||
mainwindow.h
|
|
||||||
userdialog.h
|
|
||||||
groupdialog.h
|
|
||||||
usermanager.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set( lxqt-admin-user_UIS
|
|
||||||
mainwindow.ui
|
|
||||||
userdialog.ui
|
|
||||||
groupdialog.ui
|
|
||||||
)
|
|
||||||
|
|
||||||
qt5_wrap_cpp(MOCS ${lxqt-admin-user_MOCS})
|
|
||||||
qt5_wrap_ui(UIS ${lxqt-admin-user_UIS})
|
|
||||||
|
|
||||||
# Translations **********************************
|
|
||||||
lxqt_translate_ts(lxqt-admin-user_QM_FILES
|
|
||||||
UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
|
|
||||||
SOURCES
|
|
||||||
${lxqt-admin-user_MOCS}
|
|
||||||
${lxqt-admin-user_SRCS}
|
|
||||||
${lxqt-admin-user_UIS}
|
|
||||||
INSTALL_DIR
|
|
||||||
"${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
|
|
||||||
PULL_TRANSLATIONS
|
|
||||||
${PULL_TRANSLATIONS}
|
|
||||||
CLEAN_TRANSLATIONS
|
|
||||||
${CLEAN_TRANSLATIONS}
|
|
||||||
TRANSLATIONS_REPO
|
|
||||||
${TRANSLATIONS_REPO}
|
|
||||||
TRANSLATIONS_REFSPEC
|
|
||||||
${TRANSLATIONS_REFSPEC}
|
|
||||||
REPO_SUBDIR
|
|
||||||
"lxqt-admin/${PROJECT_NAME}"
|
|
||||||
)
|
|
||||||
|
|
||||||
lxqt_translate_desktop(DESKTOP_FILES
|
|
||||||
SOURCES
|
|
||||||
lxqt-admin-user.desktop.in
|
|
||||||
)
|
|
||||||
lxqt_app_translation_loader(lxqt-admin-user_QM_LOADER ${PROJECT_NAME})
|
|
||||||
#************************************************
|
|
||||||
|
|
||||||
add_executable(lxqt-admin-user
|
|
||||||
${lxqt-admin-user_SRCS}
|
|
||||||
${UIS}
|
|
||||||
${MOCS}
|
|
||||||
${DESKTOP_FILES}
|
|
||||||
${lxqt-admin-user_QM_FILES}
|
|
||||||
${lxqt-admin-user_QM_LOADER}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(lxqt-admin-user
|
|
||||||
KF5::WindowSystem
|
|
||||||
Qt5::Widgets
|
|
||||||
lxqt
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS lxqt-admin-user RUNTIME DESTINATION bin)
|
|
||||||
install(FILES ${DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
|
||||||
|
|
||||||
# for policykit
|
|
||||||
# manpage for pcmanfm-qt
|
|
||||||
configure_file(
|
|
||||||
"org.lxqt.lxqt-admin-user.policy.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.lxqt-admin-user.policy"
|
|
||||||
@ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
||||||
install(PROGRAMS "lxqt-admin-user-helper.freebsd" DESTINATION bin RENAME lxqt-admin-user-helper)
|
|
||||||
else()
|
|
||||||
install(PROGRAMS "lxqt-admin-user-helper.default" DESTINATION bin RENAME lxqt-admin-user-helper)
|
|
||||||
endif()
|
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.lxqt-admin-user.policy" DESTINATION "share/polkit-1/actions")
|
|
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "groupdialog.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include "usermanager.h"
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define DEFAULT_GID_MIN 1000
|
|
||||||
#define DEFAULT_GID_MAX 32768
|
|
||||||
|
|
||||||
GroupDialog::GroupDialog(UserManager* userManager, GroupInfo* group, QWidget *parent, Qt::WindowFlags f):
|
|
||||||
QDialog(parent, f),
|
|
||||||
mUserManager(userManager),
|
|
||||||
mGroup(group)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
ui.groupName->setText(group->name());
|
|
||||||
ui.gid->setValue(group->gid());
|
|
||||||
|
|
||||||
const QStringList& members = group->members(); // all users in this group
|
|
||||||
// load all users
|
|
||||||
for(const UserInfo* user: userManager->users())
|
|
||||||
{
|
|
||||||
QListWidgetItem* item = new QListWidgetItem();
|
|
||||||
item->setText(user->name());
|
|
||||||
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable);
|
|
||||||
if(members.indexOf(user->name()) != -1) // the user is in this group
|
|
||||||
item->setCheckState(Qt::Checked);
|
|
||||||
else
|
|
||||||
item->setCheckState(Qt::Unchecked);
|
|
||||||
QVariant obj = QVariant::fromValue<void*>((void*)user);
|
|
||||||
item->setData(Qt::UserRole, obj);
|
|
||||||
ui.userList->addItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupDialog::~GroupDialog()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupDialog::accept()
|
|
||||||
{
|
|
||||||
QString groupName = ui.groupName->text();
|
|
||||||
if(groupName.isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("The group name cannot be empty."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mGroup->setName(groupName);
|
|
||||||
mGroup->setGid(ui.gid->value());
|
|
||||||
|
|
||||||
// update users
|
|
||||||
mGroup->removeAllMemberss();
|
|
||||||
for(int row = 0; row < ui.userList->count(); ++row) {
|
|
||||||
QListWidgetItem* item = ui.userList->item(row);
|
|
||||||
if(item->checkState() == Qt::Checked) {
|
|
||||||
mGroup->addMember(item->text());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QDialog::accept();
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GROUPDIALOG_H
|
|
||||||
#define GROUPDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "ui_groupdialog.h"
|
|
||||||
|
|
||||||
class GroupInfo;
|
|
||||||
class UserManager;
|
|
||||||
|
|
||||||
class GroupDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
GroupDialog(UserManager* userManager, GroupInfo* group, QWidget *parent = nullptr, Qt::WindowFlags f = 0);
|
|
||||||
~GroupDialog();
|
|
||||||
|
|
||||||
virtual void accept();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::GroupDialog ui;
|
|
||||||
UserManager* mUserManager;
|
|
||||||
GroupInfo* mGroup;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GROUPDIALOG_H
|
|
@ -1,108 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>GroupDialog</class>
|
|
||||||
<widget class="QDialog" name="GroupDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>360</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Group Settings</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Group name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="groupName"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QSpinBox" name="gid">
|
|
||||||
<property name="specialValueText">
|
|
||||||
<string>Default</string>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>32768</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Group ID:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Users belong to this group:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" colspan="2">
|
|
||||||
<widget class="QListWidget" name="userList">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>1</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="2">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>GroupDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>GroupDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@ -1,13 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
case "$1" in
|
|
||||||
# we only allow executing these commands
|
|
||||||
useradd|usermod|userdel|groupadd|groupmod|groupdel|passwd|gpasswd)
|
|
||||||
# TODO: platforms using different commands can add wrapper scripts here.
|
|
||||||
export LC_ALL=C
|
|
||||||
exec "$@"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Command '$1' is not allowed!"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
case "$1" in
|
|
||||||
useradd|usermod|userdel|groupadd|groupmod|groupdel)
|
|
||||||
export LC_ALL=C
|
|
||||||
exec "pw" "${@}"
|
|
||||||
;;
|
|
||||||
passwd)
|
|
||||||
export LC_ALL=C
|
|
||||||
exec "$@"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Command '$1' is not allowed!"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,11 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=Users and Groups
|
|
||||||
GenericName=User and Group Settings
|
|
||||||
Comment=Configure the users and groups of your system
|
|
||||||
Exec=lxqt-admin-user
|
|
||||||
Icon=preferences-system
|
|
||||||
Categories=Settings;System;DesktopSettings;Qt;LXQt;
|
|
||||||
OnlyShowIn=LXQt;
|
|
||||||
|
|
||||||
#TRANSLATIONS_DIR=translations
|
|
@ -1,52 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2014 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include <LXQt/SingleApplication>
|
|
||||||
#include <QCommandLineParser>
|
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
LXQt::SingleApplication app(argc, argv);
|
|
||||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
|
||||||
parser.setApplicationDescription(QStringLiteral("LXQt Admin User"));
|
|
||||||
const QString VERINFO = QStringLiteral(LXQT_ADMIN_VERSION \
|
|
||||||
"\nliblxqt " LXQT_VERSION\
|
|
||||||
"\nQt " QT_VERSION_STR);
|
|
||||||
app.setApplicationVersion(VERINFO);
|
|
||||||
parser.addVersionOption();
|
|
||||||
parser.addHelpOption();
|
|
||||||
parser.process(app);
|
|
||||||
|
|
||||||
MainWindow window;
|
|
||||||
window.setWindowIcon(QIcon::fromTheme("preferences-system"));
|
|
||||||
app.setActivationWindow(&window);
|
|
||||||
window.show();
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
@ -1,273 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QRegExpValidator>
|
|
||||||
#include <QRegExp>
|
|
||||||
#include "userdialog.h"
|
|
||||||
#include "groupdialog.h"
|
|
||||||
#include "usermanager.h"
|
|
||||||
|
|
||||||
MainWindow::MainWindow():
|
|
||||||
QMainWindow(),
|
|
||||||
mUserManager(new UserManager(this))
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
connect(ui.actionAdd, SIGNAL(triggered(bool)), SLOT(onAdd()));
|
|
||||||
connect(ui.actionDelete, SIGNAL(triggered(bool)), SLOT(onDelete()));
|
|
||||||
connect(ui.actionProperties, SIGNAL(triggered(bool)), SLOT(onEditProperties()));
|
|
||||||
connect(ui.actionChangePasswd, SIGNAL(triggered(bool)), SLOT(onChangePasswd()));
|
|
||||||
connect(ui.actionRefresh, SIGNAL(triggered(bool)), SLOT(reload()));
|
|
||||||
|
|
||||||
#ifdef Q_OS_FREEBSD //Disable group gpasswd for FreeBSD
|
|
||||||
connect(ui.tabWidget, &QTabWidget::currentChanged, [this](int index) {
|
|
||||||
if(index==1) {
|
|
||||||
ui.actionChangePasswd->setEnabled(false);
|
|
||||||
} else {
|
|
||||||
ui.actionChangePasswd->setEnabled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
connect(ui.userList, &QListWidget::activated, this, &MainWindow::onRowActivated);
|
|
||||||
connect(ui.groupList, &QListWidget::activated, this, &MainWindow::onRowActivated);
|
|
||||||
|
|
||||||
connect(mUserManager, &UserManager::changed, this, &MainWindow::reload);
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::reloadUsers()
|
|
||||||
{
|
|
||||||
ui.userList->clear();
|
|
||||||
const auto& users = mUserManager->users();
|
|
||||||
for(const UserInfo* user: users)
|
|
||||||
{
|
|
||||||
uid_t uid = user->uid();
|
|
||||||
if(uid > 499 && !user->shell().isEmpty()) // exclude system users
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
|
||||||
item->setData(0, Qt::DisplayRole, user->name());
|
|
||||||
QVariant obj = QVariant::fromValue<void*>((void*)user);
|
|
||||||
item->setData(0, Qt::UserRole, obj);
|
|
||||||
item->setData(1, Qt::DisplayRole, uid);
|
|
||||||
item->setData(2, Qt::DisplayRole, user->fullName());
|
|
||||||
GroupInfo* group = mUserManager->findGroupInfo(user->gid());
|
|
||||||
if(group != nullptr) {
|
|
||||||
item->setData(3, Qt::DisplayRole, group->name());
|
|
||||||
}
|
|
||||||
item->setData(4, Qt::DisplayRole, user->homeDir());
|
|
||||||
ui.userList->addTopLevelItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::reloadGroups()
|
|
||||||
{
|
|
||||||
ui.groupList->clear();
|
|
||||||
// load groups
|
|
||||||
const auto& groups = mUserManager->groups();
|
|
||||||
for(const GroupInfo* group: groups)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
|
||||||
item->setData(0, Qt::DisplayRole, group->name());
|
|
||||||
QVariant obj = QVariant::fromValue<void*>((void*)group);
|
|
||||||
item->setData(0, Qt::UserRole, obj);
|
|
||||||
item->setData(1, Qt::DisplayRole, group->gid());
|
|
||||||
item->setData(2, Qt::DisplayRole, group->members().join(", "));
|
|
||||||
ui.groupList->addTopLevelItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::reload() {
|
|
||||||
reloadUsers();
|
|
||||||
reloadGroups();
|
|
||||||
}
|
|
||||||
|
|
||||||
UserInfo *MainWindow::userFromItem(QTreeWidgetItem *item)
|
|
||||||
{
|
|
||||||
if(item)
|
|
||||||
{
|
|
||||||
QVariant obj = item->data(0, Qt::UserRole);
|
|
||||||
return reinterpret_cast<UserInfo*>(obj.value<void*>());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupInfo* MainWindow::groupFromItem(QTreeWidgetItem *item)
|
|
||||||
{
|
|
||||||
if(item)
|
|
||||||
{
|
|
||||||
QVariant obj = item->data(0, Qt::UserRole);
|
|
||||||
return reinterpret_cast<GroupInfo*>(obj.value<void*>());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onAdd()
|
|
||||||
{
|
|
||||||
if(ui.tabWidget->currentIndex() == PageUsers)
|
|
||||||
{
|
|
||||||
UserInfo newUser;
|
|
||||||
UserDialog dlg(mUserManager, &newUser, this);
|
|
||||||
if(dlg.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
mUserManager->addUser(&newUser);
|
|
||||||
QByteArray newPasswd;
|
|
||||||
if(getNewPassword(newUser.name(), newPasswd)) {
|
|
||||||
mUserManager->changePassword(&newUser, newPasswd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ui.tabWidget->currentIndex() == PageGroups)
|
|
||||||
{
|
|
||||||
GroupInfo newGroup;
|
|
||||||
GroupDialog dlg(mUserManager, &newGroup, this);
|
|
||||||
if(dlg.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
mUserManager->addGroup(&newGroup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onDelete()
|
|
||||||
{
|
|
||||||
if(ui.tabWidget->currentIndex() == PageUsers)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = ui.userList->currentItem();
|
|
||||||
UserInfo* user = userFromItem(item);
|
|
||||||
if(user)
|
|
||||||
{
|
|
||||||
if(QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to delete the selected user?"), QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok)
|
|
||||||
{
|
|
||||||
mUserManager->deleteUser(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(ui.tabWidget->currentIndex() == PageGroups)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = ui.groupList->currentItem();
|
|
||||||
GroupInfo* group = groupFromItem(item);
|
|
||||||
if(group)
|
|
||||||
{
|
|
||||||
if(QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to delete the selected group?"), QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok)
|
|
||||||
{
|
|
||||||
mUserManager->deleteGroup(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWindow::getNewPassword(const QString& name, QByteArray& passwd) {
|
|
||||||
QInputDialog dlg(this);
|
|
||||||
dlg.setTextEchoMode(QLineEdit::Password);
|
|
||||||
dlg.setLabelText(tr("Input the new password for %1:").arg(name));
|
|
||||||
QLineEdit* edit = dlg.findChild<QLineEdit*>(QString());
|
|
||||||
if(edit) {
|
|
||||||
// NOTE: do we need to add a validator to limit the input?
|
|
||||||
// QRegExpValidator* validator = new QRegExpValidator(QRegExp(QStringLiteral("\\w*")), edit);
|
|
||||||
// edit->setValidator(validator);
|
|
||||||
}
|
|
||||||
if(dlg.exec() == QDialog::Accepted) {
|
|
||||||
passwd = dlg.textValue().toUtf8();
|
|
||||||
if(passwd.isEmpty()) {
|
|
||||||
if(QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to set a empty password?"), QMessageBox::Ok|QMessageBox::Cancel) != QMessageBox::Ok)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onChangePasswd() {
|
|
||||||
QString name;
|
|
||||||
UserInfo* user = nullptr;
|
|
||||||
GroupInfo* group = nullptr;
|
|
||||||
if(ui.tabWidget->currentIndex() == PageUsers)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = ui.userList->currentItem();
|
|
||||||
user = userFromItem(item);
|
|
||||||
if (!user)
|
|
||||||
return;
|
|
||||||
|
|
||||||
name = user->name();
|
|
||||||
}
|
|
||||||
else if(ui.tabWidget->currentIndex() == PageGroups)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = ui.groupList->currentItem();
|
|
||||||
group = groupFromItem(item);
|
|
||||||
if (!group)
|
|
||||||
return;
|
|
||||||
|
|
||||||
name = group->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray newPasswd;
|
|
||||||
if(getNewPassword(name, newPasswd)) {
|
|
||||||
if(user) {
|
|
||||||
mUserManager->changePassword(user, newPasswd);
|
|
||||||
}
|
|
||||||
if(group) {
|
|
||||||
mUserManager->changePassword(group, newPasswd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onRowActivated(const QModelIndex& index)
|
|
||||||
{
|
|
||||||
onEditProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onEditProperties()
|
|
||||||
{
|
|
||||||
if(ui.tabWidget->currentIndex() == PageUsers)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = ui.userList->currentItem();
|
|
||||||
UserInfo* user = userFromItem(item);
|
|
||||||
if(user) {
|
|
||||||
UserInfo newSettings(*user);
|
|
||||||
UserDialog dlg(mUserManager, &newSettings, this);
|
|
||||||
if(dlg.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
mUserManager->modifyUser(user, &newSettings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(ui.tabWidget->currentIndex() == PageGroups)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* item = ui.groupList->currentItem();
|
|
||||||
GroupInfo* group = groupFromItem(item);
|
|
||||||
if(group) {
|
|
||||||
GroupInfo newSettings(*group);
|
|
||||||
GroupDialog dlg(mUserManager, &newSettings, this);
|
|
||||||
if(dlg.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
mUserManager->modifyGroup(group, &newSettings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
|
|
||||||
class UserInfo;
|
|
||||||
class GroupInfo;
|
|
||||||
class UserManager;
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PageUsers = 0,
|
|
||||||
PageGroups
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MainWindow();
|
|
||||||
virtual ~MainWindow();
|
|
||||||
|
|
||||||
private:
|
|
||||||
UserInfo* userFromItem(QTreeWidgetItem* item);
|
|
||||||
GroupInfo* groupFromItem(QTreeWidgetItem *item);
|
|
||||||
bool getNewPassword(const QString& name, QByteArray& passwd);
|
|
||||||
void reloadUsers();
|
|
||||||
void reloadGroups();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onAdd();
|
|
||||||
void onDelete();
|
|
||||||
void onEditProperties();
|
|
||||||
void onChangePasswd();
|
|
||||||
void reload();
|
|
||||||
void onRowActivated(const QModelIndex& index);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::MainWindow ui;
|
|
||||||
UserManager* mUserManager;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
|
@ -1,215 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>MainWindow</class>
|
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>676</width>
|
|
||||||
<height>362</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>User and Group Settings</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralwidget">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="documentMode">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="tab">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>&Users</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeWidget" name="userList">
|
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="expandsOnDoubleClick">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Login Name</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>User ID</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Full Name</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Group</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Home Directory</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="showSystemUsers">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Show system users (for advanced users only)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="tab_2">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>&Groups</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeWidget" name="groupList">
|
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Group ID</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Members</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="toolBar">
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>toolBar</string>
|
|
||||||
</property>
|
|
||||||
<property name="movable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
|
||||||
</property>
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<addaction name="actionAdd"/>
|
|
||||||
<addaction name="actionDelete"/>
|
|
||||||
<addaction name="actionProperties"/>
|
|
||||||
<addaction name="actionChangePasswd"/>
|
|
||||||
<addaction name="actionRefresh"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
|
||||||
<action name="actionAdd">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="list-add">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Add</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Add new users or groups</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDelete">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="list-remove">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Delete selected item</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionProperties">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="document-properties">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Properties</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>edit properties of the selected item</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionRefresh">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="view-refresh">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Refresh the lists</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionChangePasswd">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="dialog-password">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Change Password</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Change password for the selected user or group</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE policyconfig PUBLIC
|
|
||||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
|
||||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
|
||||||
<policyconfig>
|
|
||||||
|
|
||||||
<action id="org.lxqt.lxqt-admin-user">
|
|
||||||
<message>Authentication is required for user administration</message>
|
|
||||||
<icon_name>preferences-system</icon_name>
|
|
||||||
<defaults>
|
|
||||||
<allow_any>auth_admin</allow_any>
|
|
||||||
<allow_inactive>auth_admin</allow_inactive>
|
|
||||||
<allow_active>auth_admin_keep</allow_active>
|
|
||||||
</defaults>
|
|
||||||
<annotate key="org.freedesktop.policykit.exec.path">@CMAKE_INSTALL_PREFIX@/bin/lxqt-admin-user-helper</annotate>
|
|
||||||
</action>
|
|
||||||
|
|
||||||
</policyconfig>
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[ar]=المستخدمون والمجموعات
|
|
||||||
GenericName[ar]=إعدادات المستخدمون والمجموعات
|
|
||||||
Comment[ar]=اضبط مستخدمو النّظام ومجموعاته
|
|
@ -1,3 +0,0 @@
|
|||||||
Name[ca]=Usuaris i grups
|
|
||||||
GenericName[ca]=Ajusts dels usuaris i dels grups
|
|
||||||
Comment[ca]=Configureu els usuaris i els grups del vostre sistema
|
|
@ -1,3 +0,0 @@
|
|||||||
Name[da]=Brugere og grupper
|
|
||||||
GenericName[da]=Indstillinger for brugere og grupper
|
|
||||||
Comment[da]=Konfigurér systemets brugere og grupper
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[de]=Benutzer und Gruppen
|
|
||||||
GenericName[de]=Einstellungen für Benutzer und Gruppen
|
|
||||||
Comment[de]=Konfiguriert die Benutzer und Gruppen des Systems
|
|
@ -1,3 +0,0 @@
|
|||||||
Name[el]=Χρήστες και ομάδες
|
|
||||||
GenericName[el]=Ρυθμίσεις χρηστών και ομάδων
|
|
||||||
Comment[el]=Διαμόρφωση των χρηστών και των ομάδων του συστήματός σας
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[fr]=Utilisateurs et groupes
|
|
||||||
GenericName[fr]=Paramétrage des utilisateurs et des groupes
|
|
||||||
Comment[fr]=Paramétrage des utilisateurs et des groupes du système
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[hu]=Felhasználók és csoportok
|
|
||||||
GenericName[hu]=Felhasználó és csoportkezelés
|
|
||||||
Comment[hu]=A rendszer felhasználóinak és csoportjainak kezeése
|
|
@ -1,3 +0,0 @@
|
|||||||
#Translations
|
|
||||||
Name[it]=Utenti e gruppi
|
|
||||||
Comment[it]=Configura utenti e gruppi del sistema
|
|
@ -1,6 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Name[ja]=ユーザーとグループ
|
|
||||||
GenericName[ja]=ユーザーとグループの設定
|
|
||||||
Comment[ja]=システム上のユーザーとグループを設定します
|
|
||||||
|
|
||||||
#TRANSLATIONS_DIR=translations
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[lt]=Naudotojai ir grupės
|
|
||||||
GenericName[lt]=Naudotojų ir grupių nustatymai
|
|
||||||
Comment[lt]=Konfigūruoti sistemos naudotojus ir grupes
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[pl]=Użytkownicy i grupy
|
|
||||||
GenericName[pl]=Zarządzanie użytkownikami i grupami
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
#TRANSLATIONS
|
|
||||||
Name[pt]=Utilizadores e grupos
|
|
||||||
GenericName[pt]=Definições de utilizadores e grupos
|
|
||||||
Comment[pt]=Configurar os utilizadores e os grupos do seu sistema
|
|
@ -1,6 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Name[ru]=Пользователи и группы
|
|
||||||
GenericName[ru]=Настройки пользователей и групп
|
|
||||||
Comment[ru]=Настроить пользователей и группы вашей системы
|
|
||||||
|
|
||||||
#TRANSLATIONS_DIR=translations
|
|
@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "userdialog.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QListWidgetItem>
|
|
||||||
#include <QDebug>
|
|
||||||
#include "usermanager.h"
|
|
||||||
|
|
||||||
#define DEFAULT_UID_MIN 1000
|
|
||||||
#define DEFAULT_UID_MAX 32768
|
|
||||||
|
|
||||||
UserDialog::UserDialog(UserManager* userManager, UserInfo* user, QWidget* parent):
|
|
||||||
QDialog(parent),
|
|
||||||
mUserManager(userManager),
|
|
||||||
mUser(user),
|
|
||||||
mFullNameChanged(false),
|
|
||||||
mHomeDirChanged(false)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
bool isNewUser = (user->uid() == 0 && user->name().isEmpty());
|
|
||||||
// load all groups
|
|
||||||
for(const GroupInfo* group: mUserManager->groups())
|
|
||||||
{
|
|
||||||
ui.mainGroup->addItem(group->name());
|
|
||||||
|
|
||||||
QListWidgetItem* item = new QListWidgetItem();
|
|
||||||
item->setText(group->name());
|
|
||||||
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable);
|
|
||||||
if(!isNewUser)
|
|
||||||
{
|
|
||||||
if(group->hasMember(user->name())) // the user is in this group
|
|
||||||
item->setCheckState(Qt::Checked);
|
|
||||||
else
|
|
||||||
item->setCheckState(Qt::Unchecked);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
item->setCheckState(Qt::Unchecked);
|
|
||||||
ui.groupList->addItem(item);
|
|
||||||
}
|
|
||||||
connect(ui.loginName, SIGNAL(textChanged(QString)), SLOT(onLoginNameChanged(QString)));
|
|
||||||
|
|
||||||
ui.loginShell->addItems(mUserManager->availableShells());
|
|
||||||
|
|
||||||
if(isNewUser) // new user
|
|
||||||
{
|
|
||||||
ui.mainGroup->setCurrentIndex(-1);
|
|
||||||
ui.loginShell->setCurrentIndex(-1);
|
|
||||||
}
|
|
||||||
else // edit an existing user
|
|
||||||
{
|
|
||||||
ui.loginName->setText(user->name());
|
|
||||||
ui.uid->setValue(user->uid());
|
|
||||||
ui.fullName->setText(user->fullName());
|
|
||||||
ui.loginShell->setEditText(user->shell());
|
|
||||||
ui.homeDir->setText(user->homeDir());
|
|
||||||
GroupInfo* group = userManager->findGroupInfo(user->gid());
|
|
||||||
if(group)
|
|
||||||
ui.mainGroup->setEditText(group->name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UserDialog::~UserDialog()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserDialog::onLoginNameChanged(const QString& text)
|
|
||||||
{
|
|
||||||
if(!mFullNameChanged)
|
|
||||||
{
|
|
||||||
ui.fullName->blockSignals(true);
|
|
||||||
ui.fullName->setText(text);
|
|
||||||
ui.fullName->blockSignals(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!mHomeDirChanged)
|
|
||||||
{
|
|
||||||
ui.homeDir->blockSignals(true);
|
|
||||||
ui.homeDir->setText("/home/" + text);
|
|
||||||
ui.homeDir->blockSignals(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserDialog::onFullNameChanged(const QString& text)
|
|
||||||
{
|
|
||||||
mFullNameChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserDialog::onHomeDirChanged(const QString& text)
|
|
||||||
{
|
|
||||||
mHomeDirChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserDialog::accept()
|
|
||||||
{
|
|
||||||
mUser->setUid(ui.uid->value());
|
|
||||||
QString loginName = ui.loginName->text();
|
|
||||||
if(loginName.isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("The user name cannot be empty."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mUser->setName(loginName);
|
|
||||||
mUser->setFullName(ui.fullName->text());
|
|
||||||
|
|
||||||
mUser->setHomeDir(ui.homeDir->text());
|
|
||||||
mUser->setShell(ui.loginShell->currentText());
|
|
||||||
// main group
|
|
||||||
QString groupName = ui.mainGroup->currentText();
|
|
||||||
if(!groupName.isEmpty()) {
|
|
||||||
GroupInfo* group = mUserManager->findGroupInfo(groupName);
|
|
||||||
if(group)
|
|
||||||
mUser->setGid(group->gid());
|
|
||||||
}
|
|
||||||
|
|
||||||
// other groups
|
|
||||||
mUser->removeAllGroups();
|
|
||||||
for(int row = 0; row < ui.groupList->count(); ++row) {
|
|
||||||
QListWidgetItem* item = ui.groupList->item(row);
|
|
||||||
if(item->checkState() == Qt::Checked) {
|
|
||||||
mUser->addGroup(item->text());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QDialog::accept();
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef USERDIALOG_H
|
|
||||||
#define USERDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "ui_userdialog.h"
|
|
||||||
#include "usermanager.h"
|
|
||||||
|
|
||||||
class UserManager;
|
|
||||||
class UserInfo;
|
|
||||||
|
|
||||||
class UserDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
UserDialog(UserManager* userManager, UserInfo* user, QWidget* parent = nullptr);
|
|
||||||
~UserDialog();
|
|
||||||
|
|
||||||
virtual void accept();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onLoginNameChanged(const QString& text);
|
|
||||||
void onFullNameChanged(const QString& text);
|
|
||||||
void onHomeDirChanged(const QString& text);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::UserDialog ui;
|
|
||||||
UserManager* mUserManager;
|
|
||||||
UserInfo* mUser;
|
|
||||||
|
|
||||||
bool mFullNameChanged;
|
|
||||||
bool mHomeDirChanged;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // USERDIALOG_H
|
|
@ -1,187 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>UserDialog</class>
|
|
||||||
<widget class="QDialog" name="UserDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>403</width>
|
|
||||||
<height>293</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>User Settings</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="tab">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>General</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
|
||||||
<property name="fieldGrowthPolicy">
|
|
||||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Login name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="loginName"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Full name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="fullName"/>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>User ID:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QSpinBox" name="uid">
|
|
||||||
<property name="specialValueText">
|
|
||||||
<string>Default</string>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>32768</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>Main group:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QComboBox" name="mainGroup">
|
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="tab_3">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Groups</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>The user belongs to the following groups:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="groupList">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>1</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="tab_2">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Advanced</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Login shell:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="loginShell">
|
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="homeDir"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="text">
|
|
||||||
<string>Home directory:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>UserDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>UserDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@ -1,443 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2016 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#include "usermanager.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <QFileSystemWatcher>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static const QString PASSWD_FILE = QStringLiteral("/etc/passwd");
|
|
||||||
static const QString GROUP_FILE = QStringLiteral("/etc/group");
|
|
||||||
static const QString LOGIN_DEFS_FILE = QStringLiteral("/etc/login.defs");
|
|
||||||
|
|
||||||
UserManager::UserManager(QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
mWatcher(new QFileSystemWatcher(QStringList() << PASSWD_FILE << GROUP_FILE, this))
|
|
||||||
{
|
|
||||||
loadUsersAndGroups();
|
|
||||||
connect(mWatcher, &QFileSystemWatcher::fileChanged, this, &UserManager::onFileChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserManager::~UserManager() {
|
|
||||||
qDeleteAll(mUsers);
|
|
||||||
qDeleteAll(mGroups);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserManager::loadUsersAndGroups()
|
|
||||||
{
|
|
||||||
// Note: getpwent(), getgrent() makes no attempt to suppress duplicate information
|
|
||||||
// if multiple sources are specified in nsswitch.conf(5).
|
|
||||||
|
|
||||||
// load groups
|
|
||||||
setgrent();
|
|
||||||
struct group * grp;
|
|
||||||
while((grp = getgrent())) {
|
|
||||||
if (mGroups.cend() != std::find_if(mGroups.cbegin(), mGroups.cend(), [grp] (const GroupInfo * g) -> bool { return g->gid() == grp->gr_gid; }))
|
|
||||||
continue;
|
|
||||||
GroupInfo* group = new GroupInfo(grp);
|
|
||||||
mGroups.append(group);
|
|
||||||
// add members of this group
|
|
||||||
for(char** member_name = grp->gr_mem; *member_name; ++member_name) {
|
|
||||||
group->addMember(QString::fromLatin1(*member_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endgrent();
|
|
||||||
std::sort(mGroups.begin(), mGroups.end(), [](GroupInfo* g1, GroupInfo* g2) {
|
|
||||||
return g1->name() < g2->name();
|
|
||||||
});
|
|
||||||
|
|
||||||
// load users
|
|
||||||
setpwent();
|
|
||||||
struct passwd * pw;
|
|
||||||
while((pw = getpwent())) {
|
|
||||||
if (mUsers.cend() != std::find_if(mUsers.cbegin(), mUsers.cend(), [pw] (const UserInfo * u) -> bool { return u->uid() == pw->pw_uid; }))
|
|
||||||
continue;
|
|
||||||
UserInfo* user = new UserInfo(pw);
|
|
||||||
mUsers.append(user);
|
|
||||||
// add groups to this user
|
|
||||||
for(const GroupInfo* group: mGroups) {
|
|
||||||
if(group->hasMember(user->name())) {
|
|
||||||
user->addGroup(group->name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endpwent();
|
|
||||||
std::sort(mUsers.begin(), mUsers.end(), [](UserInfo*& u1, UserInfo*& u2) {
|
|
||||||
return u1->name() < u2->name();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// load settings from /etc/login.defs
|
|
||||||
void UserManager::loadLoginDefs() {
|
|
||||||
// FIXME: parse /etc/login.defs to get max UID, max system UID...etc.
|
|
||||||
QFile file(LOGIN_DEFS_FILE);
|
|
||||||
if(file.open(QIODevice::ReadOnly)) {
|
|
||||||
while(!file.atEnd()) {
|
|
||||||
QByteArray line = file.readLine().trimmed();
|
|
||||||
if(line.isEmpty() || line.startsWith('#'))
|
|
||||||
continue;
|
|
||||||
QStringList parts = QString::fromUtf8(line).split(QRegExp("\\s"), QString::SkipEmptyParts);
|
|
||||||
if(parts.length() >= 2) {
|
|
||||||
QString& key = parts[0];
|
|
||||||
QString& val = parts[1];
|
|
||||||
if(key == QLatin1Literal("SYS_UID_MIN")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("SYS_UID_MAX")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("UID_MIN")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("UID_MAX")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("SYS_GID_MIN")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("SYS_GID_MAX")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("GID_MIN")) {
|
|
||||||
}
|
|
||||||
else if(key == QLatin1Literal("GID_MAX")) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
UserInfo* UserManager::findUserInfo(const char* name) {
|
|
||||||
auto it = std::find_if(mUsers.begin(), mUsers.end(), [name](const UserInfo* user) {
|
|
||||||
return user->name() == name;
|
|
||||||
});
|
|
||||||
return it != mUsers.end() ? *it : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserInfo* UserManager::findUserInfo(QString name) {
|
|
||||||
auto it = std::find_if(mUsers.begin(), mUsers.end(), [name](const UserInfo* user) {
|
|
||||||
return user->name() == name;
|
|
||||||
});
|
|
||||||
return it != mUsers.end() ? *it : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserInfo* UserManager::findUserInfo(uid_t uid) {
|
|
||||||
auto it = std::find_if(mUsers.begin(), mUsers.end(), [uid](const UserInfo* user) {
|
|
||||||
return user->uid() == uid;
|
|
||||||
});
|
|
||||||
return it != mUsers.end() ? *it : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupInfo* UserManager::findGroupInfo(const char* name) {
|
|
||||||
auto it = std::find_if(mGroups.begin(), mGroups.end(), [name](const GroupInfo* group) {
|
|
||||||
return group->name() == name;
|
|
||||||
});
|
|
||||||
return it != mGroups.end() ? *it : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupInfo* UserManager::findGroupInfo(QString name) {
|
|
||||||
auto it = std::find_if(mGroups.begin(), mGroups.end(), [name](const GroupInfo* group) {
|
|
||||||
return group->name() == name;
|
|
||||||
});
|
|
||||||
return it != mGroups.end() ? *it : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupInfo* UserManager::findGroupInfo(gid_t gid) {
|
|
||||||
auto it = std::find_if(mGroups.begin(), mGroups.end(), [gid](const GroupInfo* group) {
|
|
||||||
return group->gid() == gid;
|
|
||||||
});
|
|
||||||
return it != mGroups.end() ? *it : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserManager::reload() {
|
|
||||||
mWatcher->addPath(PASSWD_FILE);
|
|
||||||
mWatcher->addPath(GROUP_FILE);
|
|
||||||
|
|
||||||
qDeleteAll(mUsers); // free the old UserInfo objects
|
|
||||||
mUsers.clear();
|
|
||||||
|
|
||||||
qDeleteAll(mGroups); // free the old GroupInfo objects
|
|
||||||
mGroups.clear();
|
|
||||||
|
|
||||||
loadUsersAndGroups();
|
|
||||||
Q_EMIT changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserManager::onFileChanged(const QString &path) {
|
|
||||||
// QFileSystemWatcher is very broken and has a ridiculous design.
|
|
||||||
// we get "fileChanged()" when the file is deleted or modified,
|
|
||||||
// but there is no way to distinguish them. If the file is deleted,
|
|
||||||
// the QFileSystemWatcher stop working silently. Hence we workaround
|
|
||||||
// this by remove the paths from the watcher and add them back again
|
|
||||||
// to force the creation of new notifiers.
|
|
||||||
mWatcher->removePath(PASSWD_FILE);
|
|
||||||
mWatcher->removePath(GROUP_FILE);
|
|
||||||
QTimer::singleShot(500, this, &UserManager::reload);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::pkexec(const QStringList& command, const QByteArray& stdinData) {
|
|
||||||
Q_ASSERT(!command.isEmpty());
|
|
||||||
QProcess process;
|
|
||||||
qDebug() << command;
|
|
||||||
QStringList args;
|
|
||||||
args << QStringLiteral("--disable-internal-agent")
|
|
||||||
<< QStringLiteral("lxqt-admin-user-helper")
|
|
||||||
<< command;
|
|
||||||
process.start(QStringLiteral("pkexec"), args);
|
|
||||||
if(!stdinData.isEmpty()) {
|
|
||||||
process.waitForStarted();
|
|
||||||
process.write(stdinData);
|
|
||||||
process.waitForBytesWritten();
|
|
||||||
process.closeWriteChannel();
|
|
||||||
}
|
|
||||||
process.waitForFinished(-1);
|
|
||||||
QByteArray pkexec_error = process.readAllStandardError();
|
|
||||||
qDebug() << pkexec_error;
|
|
||||||
const bool succeeded = process.exitCode() == 0;
|
|
||||||
if (!succeeded)
|
|
||||||
{
|
|
||||||
QMessageBox * msg = new QMessageBox{QMessageBox::Critical, tr("lxqt-admin-user")
|
|
||||||
, tr("<strong>Action (%1) failed:</strong><br/><pre>%2</pre>").arg(command[0]).arg(pkexec_error.constData())};
|
|
||||||
msg->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
msg->show();
|
|
||||||
}
|
|
||||||
return succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::addUser(UserInfo* user) {
|
|
||||||
if(!user || user->name().isEmpty())
|
|
||||||
return false;
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("useradd");
|
|
||||||
if(user->uid() != 0) {
|
|
||||||
command << QStringLiteral("-u") << QString::number(user->uid());
|
|
||||||
}
|
|
||||||
if(!user->homeDir().isEmpty()) {
|
|
||||||
command << QStringLiteral("-d") << user->homeDir();
|
|
||||||
command << QStringLiteral("-m"); // create the user's home directory if it does not exist.
|
|
||||||
}
|
|
||||||
if(!user->shell().isEmpty()) {
|
|
||||||
command << QStringLiteral("-s") << user->shell();
|
|
||||||
}
|
|
||||||
if(!user->fullName().isEmpty()) {
|
|
||||||
command << QStringLiteral("-c") << user->fullName();
|
|
||||||
}
|
|
||||||
if(user->gid() != 0) {
|
|
||||||
command << QStringLiteral("-g") << QString::number(user->gid());
|
|
||||||
}
|
|
||||||
if(!user->groups().isEmpty()) { // set group membership
|
|
||||||
command << QStringLiteral("-G") << user->groups().join(',');
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_FREEBSD
|
|
||||||
command << QStringLiteral("-n");
|
|
||||||
#endif
|
|
||||||
command << user->name();
|
|
||||||
return pkexec(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::modifyUser(UserInfo* user, UserInfo* newSettings) {
|
|
||||||
if(!user || user->name().isEmpty() || !newSettings)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool isDirty = false;
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("usermod");
|
|
||||||
if(newSettings->uid() != user->uid()) {
|
|
||||||
command << QStringLiteral("-u") << QString::number(newSettings->uid());
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
if(newSettings->homeDir() != user->homeDir()) {
|
|
||||||
command << QStringLiteral("-d") << newSettings->homeDir();
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
if(newSettings->shell() != user->shell()) {
|
|
||||||
command << QStringLiteral("-s") << newSettings->shell();
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(newSettings->fullName() != user->fullName()) {
|
|
||||||
command << QStringLiteral("-c") << newSettings->fullName();
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
if(newSettings->gid() != user->gid()) {
|
|
||||||
command << QStringLiteral("-g") << QString::number(newSettings->gid());
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
if(newSettings->name() != user->name()) { // change login name
|
|
||||||
command << QStringLiteral("-l") << newSettings->name();
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
if(newSettings->groups() != user->groups()) { // change group membership
|
|
||||||
command << QStringLiteral("-G") << newSettings->groups().join(',');
|
|
||||||
isDirty=true;
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_FREEBSD
|
|
||||||
command << QStringLiteral("-n");
|
|
||||||
#endif
|
|
||||||
command << user->name();
|
|
||||||
if(isDirty) {
|
|
||||||
return pkexec(command);
|
|
||||||
}
|
|
||||||
return true; //No changes
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::deleteUser(UserInfo* user) {
|
|
||||||
if(!user || user->name().isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("userdel");
|
|
||||||
command << user->name();
|
|
||||||
return pkexec(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::changePassword(UserInfo* user, QByteArray newPasswd) {
|
|
||||||
// In theory, the current user should be able to use "passwd" to
|
|
||||||
// reset his/her own password without root permission, but...
|
|
||||||
// /usr/bin/passwd is a setuid program running as root and QProcess
|
|
||||||
// does not seem to capture its stdout... So... requires root for now.
|
|
||||||
if(geteuid() == user->uid()) {
|
|
||||||
// FIXME: there needs to be a way to let a user change his/her own password.
|
|
||||||
// Maybe we can use our pkexec helper script to achieve this.
|
|
||||||
}
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("passwd");
|
|
||||||
command << user->name();
|
|
||||||
|
|
||||||
// we need to type the new password for two times.
|
|
||||||
QByteArray stdinData;
|
|
||||||
stdinData += newPasswd;
|
|
||||||
stdinData += "\n";
|
|
||||||
stdinData += newPasswd;
|
|
||||||
stdinData += "\n";
|
|
||||||
return pkexec(command, stdinData);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::addGroup(GroupInfo* group) {
|
|
||||||
if(!group || group->name().isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("groupadd");
|
|
||||||
if(group->gid() != 0) {
|
|
||||||
command << QStringLiteral("-g") << QString::number(group->gid());
|
|
||||||
}
|
|
||||||
command << group->name();
|
|
||||||
return pkexec(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::modifyGroup(GroupInfo* group, GroupInfo* newSettings) {
|
|
||||||
if(!group || group->name().isEmpty() || !newSettings)
|
|
||||||
return false;
|
|
||||||
QStringList command;
|
|
||||||
bool isDirty = false;
|
|
||||||
command << QStringLiteral("groupmod");
|
|
||||||
if(newSettings->gid() != group->gid()) {
|
|
||||||
command << QStringLiteral("-g") << QString::number(newSettings->gid());
|
|
||||||
isDirty = true;
|
|
||||||
}
|
|
||||||
if(newSettings->name() != group->name()) {
|
|
||||||
isDirty = true;
|
|
||||||
#ifdef Q_OS_FREEBSD
|
|
||||||
command << QStringLiteral("-l");
|
|
||||||
#else
|
|
||||||
command << QStringLiteral("-n");
|
|
||||||
#endif
|
|
||||||
command << newSettings->name();
|
|
||||||
}
|
|
||||||
#ifdef Q_OS_FREEBSD
|
|
||||||
if(newSettings->members() != group->members()) {
|
|
||||||
isDirty = true;
|
|
||||||
command << QStringLiteral("-M"); // Set the list of group members.
|
|
||||||
command << newSettings->members().join(',');
|
|
||||||
}
|
|
||||||
command << QStringLiteral("-n");
|
|
||||||
#endif
|
|
||||||
command << group->name();
|
|
||||||
|
|
||||||
if(isDirty && !pkexec(command))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// if group members are changed, use gpasswd to reset members on linux
|
|
||||||
#ifndef Q_OS_FREEBSD //This is already done with pw groupmod -M earlier.
|
|
||||||
if(newSettings->members() != group->members()) {
|
|
||||||
command.clear();
|
|
||||||
command << QStringLiteral("gpasswd");
|
|
||||||
command << QStringLiteral("-M"); // Set the list of group members.
|
|
||||||
command << newSettings->members().join(',');
|
|
||||||
//if the group name changed the group->name() is still the old setting.
|
|
||||||
if(newSettings->name() != group->name()) {
|
|
||||||
command << newSettings->name();
|
|
||||||
} else {
|
|
||||||
command << group->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pkexec(command);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::deleteGroup(GroupInfo* group) {
|
|
||||||
if(!group || group->name().isEmpty())
|
|
||||||
return false;
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("groupdel");
|
|
||||||
command << group->name();
|
|
||||||
return pkexec(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserManager::changePassword(GroupInfo* group, QByteArray newPasswd) {
|
|
||||||
QStringList command;
|
|
||||||
command << QStringLiteral("gpasswd");
|
|
||||||
command << group->name();
|
|
||||||
|
|
||||||
// we need to type the new password for two times.
|
|
||||||
QByteArray stdinData = newPasswd;
|
|
||||||
stdinData += "\n";
|
|
||||||
stdinData += newPasswd;
|
|
||||||
stdinData += "\n";
|
|
||||||
return pkexec(command, stdinData);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList& UserManager::availableShells() {
|
|
||||||
if(mAvailableShells.isEmpty()) {
|
|
||||||
QFile file("/etc/shells");
|
|
||||||
if(file.open(QIODevice::ReadOnly)) {
|
|
||||||
while(!file.atEnd()) {
|
|
||||||
QByteArray line = file.readLine().trimmed();
|
|
||||||
if(line.isEmpty() || line.startsWith('#'))
|
|
||||||
continue;
|
|
||||||
mAvailableShells.append(QString::fromLocal8Bit(line));
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mAvailableShells;
|
|
||||||
}
|
|
||||||
|
|
@ -1,239 +0,0 @@
|
|||||||
/* BEGIN_COMMON_COPYRIGHT_HEADER
|
|
||||||
* (c)LGPL2+
|
|
||||||
*
|
|
||||||
* LXQt - a lightweight, Qt based, desktop toolset
|
|
||||||
* http://lxqt.org
|
|
||||||
*
|
|
||||||
* Copyright: 2016 LXQt team
|
|
||||||
* Authors:
|
|
||||||
* Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
|
||||||
*
|
|
||||||
* This program or library is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU Lesser General
|
|
||||||
* Public License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* END_COMMON_COPYRIGHT_HEADER */
|
|
||||||
|
|
||||||
#ifndef USERMANAGER_H
|
|
||||||
#define USERMANAGER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <grp.h>
|
|
||||||
|
|
||||||
class QFileSystemWatcher;
|
|
||||||
|
|
||||||
class UserInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit UserInfo():mUid(0), mGid(0) {
|
|
||||||
}
|
|
||||||
explicit UserInfo(struct passwd* pw):
|
|
||||||
mUid(pw->pw_uid),
|
|
||||||
mGid(pw->pw_gid),
|
|
||||||
mName(QString::fromLatin1(pw->pw_name)),
|
|
||||||
mFullName(QString::fromUtf8(pw->pw_gecos)),
|
|
||||||
mShell(QString::fromLocal8Bit(pw->pw_shell)),
|
|
||||||
mHomeDir(QString::fromLocal8Bit(pw->pw_dir))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
uid_t uid()const {
|
|
||||||
return mUid;
|
|
||||||
}
|
|
||||||
void setUid(uid_t uid) {
|
|
||||||
mUid = uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
gid_t gid() const {
|
|
||||||
return mGid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGid(gid_t gid) {
|
|
||||||
mGid = gid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString name() const {
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setName(const QString& name) {
|
|
||||||
mName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fullName() const {
|
|
||||||
return mFullName;
|
|
||||||
}
|
|
||||||
void setFullName(const QString& fullName) {
|
|
||||||
mFullName = fullName;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString shell() const {
|
|
||||||
return mShell;
|
|
||||||
}
|
|
||||||
void setShell(const QString& shell) {
|
|
||||||
mShell = shell;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString homeDir() const {
|
|
||||||
return mHomeDir;
|
|
||||||
}
|
|
||||||
void setHomeDir(const QString& homeDir) {
|
|
||||||
mHomeDir = homeDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList& groups() const {
|
|
||||||
return mGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addGroup(const QString& group) {
|
|
||||||
mGroups.append(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeGroup(const QString& group) {
|
|
||||||
mGroups.removeOne(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeAllGroups() {
|
|
||||||
mGroups.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasGroup(const QString& group) {
|
|
||||||
return mGroups.contains(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uid_t mUid;
|
|
||||||
gid_t mGid;
|
|
||||||
QString mName;
|
|
||||||
QString mFullName;
|
|
||||||
QString mShell;
|
|
||||||
QString mHomeDir;
|
|
||||||
QStringList mGroups;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GroupInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit GroupInfo(): mGid(0) {
|
|
||||||
}
|
|
||||||
explicit GroupInfo(struct group* grp):
|
|
||||||
mGid(grp->gr_gid),
|
|
||||||
mName(grp->gr_name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
gid_t gid() const {
|
|
||||||
return mGid;
|
|
||||||
}
|
|
||||||
void setGid(gid_t gid) {
|
|
||||||
mGid = gid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString name() const {
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
void setName(const QString& name) {
|
|
||||||
mName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList& members() const {
|
|
||||||
return mMembers;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMembers(const QStringList& members) {
|
|
||||||
mMembers = members;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addMember(const QString& userName) {
|
|
||||||
mMembers.append(userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeMember(const QString& userName) {
|
|
||||||
mMembers.removeOne(userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeAllMemberss() {
|
|
||||||
mMembers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasMember(const QString& userName) const {
|
|
||||||
return mMembers.contains(userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
gid_t mGid;
|
|
||||||
QString mName;
|
|
||||||
QStringList mMembers;
|
|
||||||
};
|
|
||||||
|
|
||||||
class UserManager : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit UserManager(QObject *parent = 0);
|
|
||||||
~UserManager();
|
|
||||||
|
|
||||||
const QList<UserInfo*>& users() const {
|
|
||||||
return mUsers;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<GroupInfo*>& groups() const {
|
|
||||||
return mGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList& availableShells();
|
|
||||||
|
|
||||||
bool addUser(UserInfo* user);
|
|
||||||
bool modifyUser(UserInfo* user, UserInfo* newSettings);
|
|
||||||
bool deleteUser(UserInfo* user);
|
|
||||||
bool changePassword(UserInfo* user, QByteArray newPasswd);
|
|
||||||
|
|
||||||
bool addGroup(GroupInfo* group);
|
|
||||||
bool modifyGroup(GroupInfo* group, GroupInfo* newSettings);
|
|
||||||
bool deleteGroup(GroupInfo* group);
|
|
||||||
bool changePassword(GroupInfo* group, QByteArray newPasswd);
|
|
||||||
|
|
||||||
// FIXME: add APIs to change group membership with "gpasswd"
|
|
||||||
|
|
||||||
UserInfo* findUserInfo(const char* name);
|
|
||||||
UserInfo* findUserInfo(QString name);
|
|
||||||
UserInfo* findUserInfo(uid_t uid);
|
|
||||||
|
|
||||||
GroupInfo* findGroupInfo(const char* name);
|
|
||||||
GroupInfo* findGroupInfo(QString name);
|
|
||||||
GroupInfo* findGroupInfo(gid_t gid);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void loadUsersAndGroups();
|
|
||||||
void loadLoginDefs();
|
|
||||||
bool pkexec(const QStringList &command, const QByteArray &stdinData = QByteArray());
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void changed();
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
|
||||||
void onFileChanged(const QString &path);
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<UserInfo*> mUsers;
|
|
||||||
QList<GroupInfo*> mGroups;
|
|
||||||
QFileSystemWatcher* mWatcher;
|
|
||||||
QStringList mAvailableShells;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // USERMANAGER_H
|
|
Loading…
Reference in new issue