[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [confine/gilbert] /: kderestrictions dialog redesign
From: Gilbert Assaf <gassaf () gmx ! de>
Date: 2016-12-06 16:38:25
Message-ID: E1cEIl7-0001AS-2G () code ! kde ! org
[Download RAW message or body]
Git commit 623fdb0564a5213e84bd3aadaf810170b07e81e5 by Gilbert Assaf.
Committed on 06/12/2016 at 15:29.
Pushed by gassaf into branch 'gilbert'.
kderestrictions dialog redesign
M +1 -0 CMakeLists.txt
M +14 -1 src/kderestrictions.ui
C +15 -18 src/restrictionelement.cpp [from: src/restrictionsdialog.h - 067% \
similarity] C +12 -18 src/restrictionelement.h [from: src/restrictionsdialog.h - \
068% similarity] M +76 -65 src/restrictionsdialog.cpp
M +3 -1 src/restrictionsdialog.h
https://commits.kde.org/confine/623fdb0564a5213e84bd3aadaf810170b07e81e5
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5097880..d4ad95b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,6 +54,7 @@ set(confineUI_SRCS
${CMAKE_SOURCE_DIR}/src/copyconfigfile.cpp
${CMAKE_SOURCE_DIR}/src/restrictionsdialog.cpp
${CMAKE_SOURCE_DIR}/src/settingsdialog.cpp
+ ${CMAKE_SOURCE_DIR}/src/restrictionelement.cpp
)
qt5_wrap_ui(confine_UI ${CMAKE_SOURCE_DIR}/src/mainwindow.ui \
${CMAKE_SOURCE_DIR}/src/configdialog.ui ${CMAKE_SOURCE_DIR}/src/settingsdialog.ui \
${CMAKE_SOURCE_DIR}/src/copyconfigfile.ui \
${CMAKE_SOURCE_DIR}/src/kderestrictions.ui)
diff --git a/src/kderestrictions.ui b/src/kderestrictions.ui
index 3cbf6b4..0601bc0 100644
--- a/src/kderestrictions.ui
+++ b/src/kderestrictions.ui
@@ -10,6 +10,12 @@
<height>415</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="windowTitle">
<string>KDE Restrictions</string>
</property>
@@ -57,7 +63,14 @@
</widget>
</item>
<item>
- <widget class="QListWidget" name="restrictionSets"/>
+ <widget class="QTableWidget" name="restrictionSets">
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="showGrid">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item>
<widget class="QLabel" name="label_2">
diff --git a/src/restrictionsdialog.h b/src/restrictionelement.cpp
similarity index 67%
copy from src/restrictionsdialog.h
copy to src/restrictionelement.cpp
index 10882a6..87210f3 100644
--- a/src/restrictionsdialog.h
+++ b/src/restrictionelement.cpp
@@ -20,29 +20,26 @@
*
*/
-#ifndef RESTRICTIONSDIALOG_H
-#define RESTRICTIONSDIALOG_H
+#include "restrictionelement.h"
-#include "profile.h"
+RestrictionElement::RestrictionElement(const QString& key, const QString& caption, \
const QString& description) : m_key(key), m_caption(caption), \
m_description(description) +{
-#include <ui_kderestrictions.h>
+}
-class RestrictionsDialog : public QDialog
+QString RestrictionElement::getCaption() const
{
- Q_OBJECT
-
-public:
- explicit RestrictionsDialog ( const Profile& pf, QWidget* parent=0 );
+ return m_caption;
+}
-public Q_SLOTS:
- void save();
+QString RestrictionElement::getKey() const
+{
+ return m_key;
+}
-private:
- void fillWithRestrictions();
- void readKDERestrictionsFromProfile ( const Profile& pf );
+QString RestrictionElement::getDescription() const
+{
+ return m_description;
+}
- Ui::KDERestrictions ui;
- Profile profile;
-};
-#endif // RESTRICTIONSDIALOG_H
diff --git a/src/restrictionsdialog.h b/src/restrictionelement.h
similarity index 68%
copy from src/restrictionsdialog.h
copy to src/restrictionelement.h
index 10882a6..426d7c6 100644
--- a/src/restrictionsdialog.h
+++ b/src/restrictionelement.h
@@ -20,29 +20,23 @@
*
*/
-#ifndef RESTRICTIONSDIALOG_H
-#define RESTRICTIONSDIALOG_H
+#ifndef RESTRICTIONELEMENT_H
+#define RESTRICTIONELEMENT_H
-#include "profile.h"
+#include <QString>
-#include <ui_kderestrictions.h>
-
-class RestrictionsDialog : public QDialog
+class RestrictionElement
{
- Q_OBJECT
-
public:
- explicit RestrictionsDialog ( const Profile& pf, QWidget* parent=0 );
-
-public Q_SLOTS:
- void save();
+ RestrictionElement(const QString& key, const QString& caption, const QString& \
description); + QString getKey() const;
+ QString getCaption() const;
+ QString getDescription() const;
private:
- void fillWithRestrictions();
- void readKDERestrictionsFromProfile ( const Profile& pf );
-
- Ui::KDERestrictions ui;
- Profile profile;
+ QString m_key;
+ QString m_caption;
+ QString m_description;
};
-#endif // RESTRICTIONSDIALOG_H
+#endif // RESTRICTIONELEMENT_H
diff --git a/src/restrictionsdialog.cpp b/src/restrictionsdialog.cpp
index 349e9e0..7bc5d3e 100644
--- a/src/restrictionsdialog.cpp
+++ b/src/restrictionsdialog.cpp
@@ -24,62 +24,85 @@
#include <QMessageBox>
#include <KLocalizedString>
+#include <QDebug>
RestrictionsDialog::RestrictionsDialog(const Profile& pf, QWidget* parent) : \
QDialog(parent) {
ui.setupUi(this);
connect(ui.cancelButton, SIGNAL(released()), this, SLOT(close()));
connect(ui.saveButton, SIGNAL(released()), this, SLOT(save()));
-
- readKDERestrictionsFromProfile(pf);
+ profile = pf;
+ readKDERestrictionsFromProfile();
}
void RestrictionsDialog::fillWithRestrictions()
{
+ QMap<QString, QString> profileRestrictions = profile.getKDEActionRestrictions();
ui.restrictionSets->clear();
ui.modulRestrictionSets->clear();
- QStringList actionRestrictions;
- actionRestrictions << "movable_toolbars" <<
- "plasma-desktop/add_activities" <<
- "lineedit_text_completion" <<
- "run_desktop_files" <<
- "warn_unwritable_config" <<
- "shell_access" <<
- "plasma/allow_configure_when_locked" <<
- "plasma-desktop/add_activities" <<
- "skip_drm" <<
- "logout" <<
- "run_command" <<
- "action/kdesktop_rmb" <<
- "plasma/plasmashell/unlockedDesktop" <<
- "plasma-desktop/scripting_console" <<
- "action/menuedit" <<
- "action/openwith" <<
- "action/editfiletype" <<
- "action/logout" <<
- "action/lock_screen" <<
- "action/start_new_session" <<
- "action/switch_user" <<
- "action/help_contents" <<
- "action/help_whats_this" <<
- "action/help_report_bug" <<
- "action/switch_application_language" <<
- "action/help_about_app" <<
- "action/help_about_kde" <<
- "action/options_show_toolbar" <<
- "action/allow_downloading" <<
- "action/bookmarks" <<
- "action/switch_application_language" <<
- "action/plasma/containment_actions" <<
- "action/shell_access" <<
- "action/editable_desktop_icons" <<
- "action/bookmarks" <<
- "action/kwin_rmb" <<
- "action/show_lancelot" <<
- "action/run_command" <<
- "action/lock widgets";
- ui.restrictionSets->insertItems(0, actionRestrictions);
+ kdeRestrictions.append(RestrictionElement("action/logout", i18n("Disable Logout \
option"), i18n("This prevents the user from logging out. To make this option \
effective it is important to ensure that key-combinations to terminate the X-server, \
such as Alt-Ctrl-Backspace, are disabled in the configuration of the X-server."))); + \
kdeRestrictions.append(RestrictionElement("skip_drm", i18n("Enforce DRM \
restrictions"), i18n("Some KDE applications can enforce DRM restrictions on content. \
You may want to enable this if your organisation relies on such restrictions or if \
local law requires it."))); + \
kdeRestrictions.append(RestrictionElement("action/run_command", i18n("Disable \"Run \
Command\" option (Alt-F2)"), i18n("The \"Run Command\" option can normally be used to \
execute arbitrary commands; however, when access to a command shell is restricted \
only applications and services defined by a .desktop file can be started this way. \
Disabling \"Run Command\" here hides the option completely."))); + \
kdeRestrictions.append(RestrictionElement("action/kwin_rmb", i18n("Disable Window \
Manager context menu (Alt-F3)"), i18n("The Window Manager context menu is normally \
shown when Alt-F3 is pressed or when the menu button on the window frame is \
pressed."))); + kdeRestrictions.append(RestrictionElement("action/bookmarks", \
i18n("Disable Bookmarks"), i18n("Disable Bookmarks in all applications."))); + \
kdeRestrictions.append(RestrictionElement("action/shell_access", i18n("Disable access \
to a command shell"), i18n("In an environment where the desktop is dedicated to a \
defined set of tasks it may be desirable to disable access to a command shell to \
prevent users from engaging in tasks that were not intended or authorized; hence, it \
is strongly recommended to disable access to a command shell if the desktop is to act \
as a public terminal."))); + \
kdeRestrictions.append(RestrictionElement("lock_screen", i18n("Disable Lock Screen \
option"), i18n("When the desktop is to act as a public terminal or is to be shared by \
different users it may be desirable to prevent locking of the screen to ensure that \
the system remains accessible if a user leaves the terminal."))); + \
kdeRestrictions.append(RestrictionElement("movable_toolbars", i18n("Disable toolbar \
moving"), i18n("Normally toolbars in applications can be moved around; when this \
option is chosen all toolbars are fixed in their original positions."))); + \
kdeRestrictions.append(RestrictionElement("run_desktop_files", i18n("Disable \
execution of arbitrary .desktop files."), i18n("This option defines whether users may \
execute .desktop files that are not part of the system-wide desktop icons, KDE menu, \
registered services or autostart services. When access to a command shell is \
restricted it is recommended to to disable the execution of arbitrary .desktop files \
as well since such .desktop files can be used to circumvent the command shell \
restriction."))); + \
kdeRestrictions.append(RestrictionElement("lineedit_text_completion", i18n("Disable \
input line history"), i18n("If a single account is used by multiple people it may be \
desirable to disable the input line history out of privacy considerations."))); + \
kdeRestrictions.append(RestrictionElement("action/kdesktop_rmb", i18n("Disable \
context menus"), i18n("When checked the user will no longer get any context menu. \
Normally the user can get a context menu by clicking with the right mouse \
button."))); + kdeRestrictions.append(RestrictionElement("action/menuedit", \
i18n("Disable menu editing"), i18n("This disables the menu-option to edit the KDE \
Application Menu. When disabled, users will no longer be able to make changes to \
their personal application menu."))); + \
kdeRestrictions.append(RestrictionElement("action/openwith", i18n("Disable Open With \
action"), i18n("This option can be used to disable the <i>Open With</i> menu \
option."))); + kdeRestrictions.append(RestrictionElement("action/editfiletype", \
i18n("Disable \"Edit file type\" in properties dialog"), i18n("The \"Edit file type\" \
can be used to change how files are recognized and with which applications such files \
are opened."))); + \
kdeRestrictions.append(RestrictionElement("action/help_contents", i18n("Disable Help \
-> <Application> Handbook"), i18n("This option can be used to remove the <i>Help -> \
<Application> Handbook</i> menu-option from all applications."))); + \
kdeRestrictions.append(RestrictionElement("action/help_whats_this", i18n("Disable \
Help -> What's this?"), i18n("This option can be used to remove the <i>Help -> What's \
this?</i> menu-option from all applications."))); + \
kdeRestrictions.append(RestrictionElement("action/help_report_bug", i18n("Disable \
Help -> Report Bug..."), i18n("This option can be used to remove the <i>Help -> \
Report Bug...</i> menu-option from all applications. "))); + \
kdeRestrictions.append(RestrictionElement("action/help_about_app", i18n("Disable Help \
-> About <Application> "), i18n("This option can be used to remove the <i>Help -> \
About <Application></i> menu-option from all applications. "))); + \
kdeRestrictions.append(RestrictionElement("action/help_about_kde", i18n("Disable Help \
-> About KDE"), i18n("This option can be used to remove the <i>Help -> About KDE</i> \
menu-option from all applications."))); + \
kdeRestrictions.append(RestrictionElement("action/options_show_toolbar", \
i18n("Disable Settings -> Configure Toolbars..."), i18n("This option can be used to \
remove the <i>Settings -> Configure Toolbars...</i> menu-option from all \
applications."))); + \
kdeRestrictions.append(RestrictionElement("action/allow_downloading", i18n("Prevent \
Downloading"), i18n("Some KDE applications can prevent the user from downloading or \
uploading files. The normal web browsing experience will not be affected. Note that \
you still have to set up the unix file permissions correctly - treat this as merely \
cosmetic for security."))); + \
kdeRestrictions.append(RestrictionElement("action/editable_desktop_icons", i18n("Lock \
down all Desktop icons"), i18n("When checked the user will not be able to remove or \
edit any existing icon or file on the Desktop or add any new icon or file."))); + \
kdeRestrictions.append(RestrictionElement("action/start_new_session", i18n("Disable \
starting of a second X session."), i18n("KDM has the possibility to login a second \
user in parallel to the current session. Note that this can also be configured as \
part of the KDM settings in which case the setting here should be left enabled."))); \
+ //TODO: get detailed desciptions + \
kdeRestrictions.append(RestrictionElement("plasma-desktop/add_activities", \
i18n("plasma-desktop/add_activities"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("warn_unwritable_config", \
i18n("warn_unwritable_config"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("plasma/allow_configure_when_locked", \
i18n("pplasma/allow_configure_when_locked"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("plasma/plasmashell/unlockedDesktop", \
i18n("plasma/plasmashell/unlockedDesktop"), i18n("Whether or not widgets can be \
unlocked by the user. Unlocking widgets would allow the user to move around, add, and \
remove widgets, panels, launchers, etc."))); + \
kdeRestrictions.append(RestrictionElement("plasma-desktop/scripting_console", \
i18n("plasma - desktop / scripting_console"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("action/switch_user", \
i18n("action/switch_user"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("action/switch_application_language", \
i18n("action/switch_application_language"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("action/plasma/containment_actions", \
i18n("action/plasma/containment_actions"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("action/show_lancelot", \
i18n("action/show_lancelot"), i18n(""))); + \
kdeRestrictions.append(RestrictionElement("action/lock widgets", i18n("action/lock \
widgets"), i18n(""))); +
+ ui.restrictionSets->setRowCount(kdeRestrictions.count());
+ ui.restrictionSets->setColumnCount(3);
+ ui.restrictionSets->verticalHeader()->setVisible(false);
+
+ QStringList m_TableHeader;
+ m_TableHeader << i18n("Enabled") << i18n("Caption") << i18n("Description");
+ ui.restrictionSets->setHorizontalHeaderLabels(m_TableHeader);
+
+
+ for (int i = 0; i < kdeRestrictions.count(); i++) {
+ QTableWidgetItem* capItem = new \
QTableWidgetItem(kdeRestrictions.at(i).getCaption()); + QTableWidgetItem* \
descItem = new QTableWidgetItem(kdeRestrictions.at(i).getDescription()); + \
QTableWidgetItem* enableItem = new QTableWidgetItem(QString()); +
+ enableItem->setCheckState(Qt::Unchecked);
+
+ if (profileRestrictions.contains(kdeRestrictions.at(i).getKey())) {
+ if (profileRestrictions.value(kdeRestrictions.at(i).getKey()) == "true") \
{ + enableItem->setCheckState(Qt::Checked);
+ }
+ }
+ ui.restrictionSets->setItem(i, 0, enableItem);
+ ui.restrictionSets->setItem(i, 1, capItem);
+ ui.restrictionSets->setItem(i, 2, descItem);
+
+ }
+ ui.restrictionSets->resizeColumnsToContents();
QStringList controlRestrictions;
controlRestrictions << "filebehavior" <<
@@ -90,25 +113,11 @@ void RestrictionsDialog::fillWithRestrictions()
}
-void RestrictionsDialog::readKDERestrictionsFromProfile(const Profile& pf)
+void RestrictionsDialog::readKDERestrictionsFromProfile()
{
- profile = pf;
-
fillWithRestrictions();
- QMap<QString, QString> profileRestrictions = pf.getKDEActionRestrictions();
- for (int i = 0; i < ui.restrictionSets->count(); i++) {
- QListWidgetItem* item = ui.restrictionSets->item(i);
- item->setCheckState(Qt::Unchecked);
-
- if (profileRestrictions.contains(item->text())) {
- if (profileRestrictions.value(item->text()) == "true") {
- item->setCheckState(Qt::Checked);
- }
- }
- }
-
- QMap<QString, QString> controlRestrictions = \
pf.getKDEControlModuleRestrictions(); + QMap<QString, QString> controlRestrictions \
= profile.getKDEControlModuleRestrictions(); for (int i = 0; i < \
ui.modulRestrictionSets->count(); i++) { QListWidgetItem* item = \
ui.modulRestrictionSets->item(i); item->setCheckState(Qt::Unchecked);
@@ -124,14 +133,16 @@ void RestrictionsDialog::readKDERestrictionsFromProfile(const \
Profile& pf) void RestrictionsDialog::save()
{
- for (int i = 0; i < ui.restrictionSets->count(); i++) {
- QListWidgetItem* item = ui.restrictionSets->item(i);
+ for (int i = 0; i < ui.restrictionSets->rowCount(); i++) {
+ QTableWidgetItem* item = ui.restrictionSets->item(i, 0);
+ QString actionKey = kdeRestrictions.at(i).getKey();
+ qDebug() << actionKey;
if (item->checkState() == Qt::Unchecked) {
- if (profile.setKDEActionRestriction(item->text(), "false")) {
+ if (!profile.setKDEActionRestriction(actionKey, "false")) {
return;
}
} else if (item->checkState() == Qt::Checked) {
- if (profile.setKDEActionRestriction(item->text(), "true")) {
+ if (!profile.setKDEActionRestriction(actionKey, "true")) {
return;
}
}
@@ -141,11 +152,11 @@ void RestrictionsDialog::save()
for (int i = 0; i < ui.modulRestrictionSets->count(); i++) {
QListWidgetItem* item = ui.modulRestrictionSets->item(i);
if (item->checkState() == Qt::Unchecked) {
- if (profile.setKDEControlModuleRestrictions(item->text(), "false")) {
+ if (!profile.setKDEControlModuleRestrictions(item->text(), "false")) {
return;
}
} else if (item->checkState() == Qt::Checked) {
- if (profile.setKDEControlModuleRestrictions(item->text(), "true")) {
+ if (!profile.setKDEControlModuleRestrictions(item->text(), "true")) {
return;
}
}
diff --git a/src/restrictionsdialog.h b/src/restrictionsdialog.h
index 10882a6..9374882 100644
--- a/src/restrictionsdialog.h
+++ b/src/restrictionsdialog.h
@@ -24,6 +24,7 @@
#define RESTRICTIONSDIALOG_H
#include "profile.h"
+#include "restrictionelement.h"
#include <ui_kderestrictions.h>
@@ -39,10 +40,11 @@ public Q_SLOTS:
private:
void fillWithRestrictions();
- void readKDERestrictionsFromProfile ( const Profile& pf );
+ void readKDERestrictionsFromProfile ();
Ui::KDERestrictions ui;
Profile profile;
+ QList<RestrictionElement> kdeRestrictions;
};
#endif // RESTRICTIONSDIALOG_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic