Commit b89fe482 authored by Ramon Buldó's avatar Ramon Buldó

Port manjaro-settings-manager to a plasma 5 kcm module. Still not finished.

parent 87572804
[main]
host = https://www.transifex.com
[manjaro-settings-manager.msmts]
file_filter = src/manjaro-settings-manager/translations/msm_<lang>.ts
source_lang = en
type = QT
[manjaro-settings-manager.msmdts]
file_filter = src/manjaro-settings-manager-daemon/translations/msmd_<lang>.ts
source_lang = en
type = QT
project(manjaro-settings-manager)
SET(PROJECT_VERSION "1.0.0")
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
set(QT_MIN_VERSION "5.3.0")
find_package(ECM 1.4.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${PROJECT_SOURCE_DIR})
include(ECMInstallIcons)
include(FeatureSummary)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets WebKitWidgets DBus)
find_package(KF5 REQUIRED COMPONENTS
CoreAddons
I18n
Auth
ConfigWidgets
ItemModels
)
find_package(ICU REQUIRED)
add_subdirectory(src)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
qt5-core
qt5-webkit
pacman
ckbcomp
locale-info
icu
hwinfo
This diff is collapsed.
# This is meant to be build using makepkg in the root of the cloned repo
# Maintainer : Ramon Buldo <ramon@manjaro.org>
pkgname=kcm-msm
pkgver=0.0.1
pkgrel=1
pkgdesc="Manjaro settings manager module for Plasma 5"
arch=('i686' 'x86_64')
url="https://github.com/manjaro/manjaro-settings-manager"
license=("GPL")
depends=('locale-info' 'icu' 'qt5-base' 'qt5-webkit' 'hwinfo' 'kitemmodels' 'kauth' 'ki18n' 'kconfigwidgets' 'kcoreaddons')
makedepends=('git' 'extra-cmake-modules' 'kdoctools' 'qt5-tools')
build() {
cd ..
mkdir -p build
cd build
cmake ../ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIB_INSTALL_DIR=lib \
-DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
-DSYSCONF_INSTALL_DIR=/etc
make
}
package() {
cd ..
cd build
make DESTDIR=${pkgdir} install
}
\ No newline at end of file
#! /bin/sh
/usr/lib/qt/bin/lrelease src/manjaro-settings-manager/manjaro-settings-manager.pro
/usr/lib/qt/bin/lrelease src/manjaro-settings-manager-daemon/manjaro-settings-manager-daemon.pro
#! /bin/sh
/usr/lib/qt/bin/lupdate src/manjaro-settings-manager/manjaro-settings-manager.pro -ts src/manjaro-settings-manager/translations/msm_en.ts
/usr/lib/qt/bin/lupdate src/manjaro-settings-manager-daemon/manjaro-settings-manager-daemon.pro -ts src/manjaro-settings-manager-daemon/translations/msmd_en.ts
add_subdirectory(modules)
install(FILES manjaro-category.desktop DESTINATION ${SERVICES_INSTALL_DIR})
[Desktop Entry]
Name=Manjaro Settings Manager
Name[de]=Manjaro Einstellungen
Name[en_GB]=Manjaro Settings Manager
Name[fr]=Manjaro Gestionnaire de paramètres
Comment=Graphical Settings Manager for Manjaro
Comment[de]=Grafische Einstellungsverwaltung für Manjaro
Comment[en_GB]=Graphical Settings Manager for Manjaro
Comment[fr]=Gestionnaire graphique de paramètres pour Manjaro
Exec=manjaro-settings-manager
Icon=preferences-desktop
Terminal=false
Type=Application
Categories=Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=Manjaro Settings Manager Daemon
Comment=
Exec=manjaro-settings-manager-daemon
StartupNotify=false
Terminal=false
Hidden=false
\ No newline at end of file
#!/bin/sh
PROGRAM="/usr/bin/manjaro-settings-manager-gui"
if [ $(which gksu) ]; then
gksu "$PROGRAM" -- $@
elif [ $(which kdesu) ]; then
kdesu "$PROGRAM" -- $@
elif [ $(which pkexec) ]; then
pkexec "$PROGRAM" "$@"
else
echo "error: no pkexec nor sudo frontend application found! Abording..." 1>&2
exit 1
fi
<?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.manjaro.pkexec.manjaro-settings-manager-gui">
<message>Authentication is required to run Manjaro Settings Manager</message>
<icon_name>preferences-desktop</icon_name>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/manjaro-settings-manager-gui</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
##
## Package : Language Package
##
## Examples how % will be replaced
##
## |-> firefox-i18n-en-US
## |-> firefox-i18n-en-us
## firefox-i18n-% -> |-> firefox-i18n-en_US
## |-> firefox-i18n-en_us
## |-> firefox-i18n-en
##
## Split language packages
##
firefox:firefox-i18n-%
firefox-kde:firefox-kde-i18n-%
thunderbird:thunderbird-i18n-%
aspell:aspell-%
calligra-words:calligra-l10n-%
gimp:gimp-help-%
hunspell:hunspell-%
hyphen:hyphen-%
kdebase-workspace:kde-l10n-%
libreoffice-common:libreoffice-%
libreoffice-still-common:libreoffice-still-%
libreoffice-fresh:libreoffice-fresh-%
man-pages:man-pages-%
libmythes:mythes-%
vim:vim-spell-%
kompozer:kompozer-i18n-%
eric:eric-i18n-%
##
## Global language packages
##
psi:psi-i18n
#-------------------------------------------------
#
# Project created by QtCreator 2013-03-14T19:23:46
#
#-------------------------------------------------
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = global
TEMPLATE = lib
CONFIG += staticlib \
c++11
SOURCES += global.cpp
HEADERS += global.h \
const.h
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=SystemSettingsCategory
X-KDE-System-Settings-Category=manjaro
X-KDE-System-Settings-Parent-Category=
X-KDE-Weight=1
Icon=preferences-desktop-peripherals
Name=Manjaro
This diff is collapsed.
/*
* Manjaro Settings Manager
* Roland Singer <roland@manjaro.org>
* Ramon Buldó <ramon@manjaro.org>
*
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DAEMON_H
#define DAEMON_H
#include <QDir>
#include <QFlags>
#include <QIcon>
#include <QLabel>
#include <QProcess>
#include <QSettings>
#include <QStringList>
#include <QTimer>
#include <QSystemTrayIcon>
#include <global.h>
class Daemon : public QTimer
{
Q_OBJECT
public:
explicit Daemon(QObject *parent = 0);
void start();
enum KernelFlag {
Unsupported = 0x01,
Running = 0x02,
New = 0x04,
};
Q_DECLARE_FLAGS(KernelFlags, KernelFlag)
private:
QSystemTrayIcon trayIcon, kernelTrayIcon;
QString messageTitle, messageText;
QString kernelMessageTitle, kernelMessageText;
bool checkLanguagePackage;
bool checkKernel, checkUnsupportedKernel, checkUnsupportedKernelRunning;
bool checkNewKernel, checkNewKernelLts, checkNewKernelRecommended;
void cLanguagePackage();
void cKernel();
void showMessage(QString messageTitle, QString messageText);
void showKernelMessage(QString messageTitle, QString messageText);
bool isPackageIgnored(const QString package, const QString group);
void addToConfig(const QString package, const QString group);
bool hasPacmanEverSynced();
protected slots:
void run();
void runKernel();
void trayIconClicked();
void trayIconShowMessage();
void kernelTrayIconClicked();
void kernelTrayIconShowMessage();
void loadConfiguration();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Daemon::KernelFlags)
#endif // DAEMON_H
#-------------------------------------------------
#
# Project created by QtCreator 2013-03-13T01:28:06
#
#-------------------------------------------------
QT += core gui
TARGET = manjaro-settings-manager-daemon
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++0x
SOURCES += main.cpp\
daemon.cpp \
models/Kernel.cpp \
models/KernelModel.cpp
HEADERS += daemon.h \
models/Kernel.h \
models/KernelModel.h
unix:!macx: LIBS += -L$$OUT_PWD/../global/ -lglobal
INCLUDEPATH += $$PWD/../global
DEPENDPATH += $$PWD/../global
unix:!macx: PRE_TARGETDEPS += $$OUT_PWD/../global/libglobal.a
TRANSLATIONS += translations/msmd_ast.ts \
translations/msmd_bg_BG.ts \
translations/msmd_ca.ts \
translations/msmd_cs_CZ.ts \
translations/msmd_da.ts \
translations/msmd_de.ts \
translations/msmd_en.ts \
translations/msmd_el.ts \
translations/msmd_es.ts \
translations/msmd_fa.ts \
translations/msmd_fa_IR.ts \
translations/msmd_fo.ts \
translations/msmd_fr.ts \
translations/msmd_he.ts \
translations/msmd_hi.ts \
translations/msmd_hr.ts \
translations/msmd_hu.ts \
translations/msmd_id_ID.ts \
translations/msmd_it.ts \
translations/msmd_ja.ts \
translations/msmd_nb.ts \
translations/msmd_nl.ts \
translations/msmd_pl.ts \
translations/msmd_pt_BR.ts \
translations/msmd_pt_PT.ts \
translations/msmd_ro.ts \
translations/msmd_ru.ts \
translations/msmd_sk_SK.ts \
translations/msmd_sl.ts \
translations/msmd_sr@latin.ts \
translations/msmd_sv.ts \
translations/msmd_tr.ts \
translations/msmd_uk.ts \
translations/msmd_vi.ts \
translations/msmd_zh_CN.ts \
translations/msmd_zh_TW.ts
RESOURCES += \
resources.qrc
target.path = /usr/bin
INSTALLS += target
include(qtsingleapplication/src/qtsingleapplication.pri)
/*
* Manjaro Settings Manager
* Ramon Buldó <ramon@manjaro.org>
*
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "KernelModel.h"
#include <global.h>
#include <QtCore/QRegularExpression>
#include <QtCore/QSet>
KernelModel::KernelModel(QObject *parent)
: QAbstractListModel(parent)
{
}
/*
* Clear and update ther list of kernels
*/
void KernelModel::update()
{
QStringList installedKernelPackages = getInstalledPackages();
QStringList availableKernelPackages = getAvailablePackages();
QStringList allKernelPackages = QStringList() << installedKernelPackages << availableKernelPackages;
allKernelPackages.removeDuplicates();
QString runningKernel = Global::getRunningKernel();
QStringList ltsKernels = Global::getLtsKernels();
QStringList recommendedKernels = Global::getRecommendedKernels();
QSet<QString> modulesToInstall;
for (const QString &module : installedKernelPackages.filter(QRegularExpression("^linux[0-9][0-9]?([0-9])-"))) {
QString aux = QString(module).remove(QRegularExpression("^linux[0-9][0-9]?([0-9])-"));
modulesToInstall.insert(aux);
}
beginResetModel();
kernels_.clear();
for (const QString &kernel : allKernelPackages.filter(QRegularExpression("^linux[0-9][0-9]?([0-9])$"))) {
Kernel newKernel;
newKernel.setPackage(kernel);
newKernel.setAvailable(availableKernelPackages.contains(kernel));
newKernel.setInstalled(installedKernelPackages.contains(kernel));
QString pkgInfo = Global::packageInformation(kernel, !newKernel.isAvailable());
newKernel.setVersion(Global::packageVersion(pkgInfo));
newKernel.setAvailableModules(availableKernelPackages
.filter(QRegularExpression(QString("^%1-").arg(kernel))));
if (newKernel.isInstalled()) {
newKernel.setInstalledModules(installedKernelPackages
.filter(QRegularExpression(QString("^%1-").arg(kernel))));
} else {
QStringList installableModules;
for (const QString &module : modulesToInstall) {
QString modulePackage = QString("%1-%2").arg(kernel).arg(module);
if (availableKernelPackages.contains(modulePackage)) {
installableModules << modulePackage;
}
}
newKernel.setInstalledModules(installableModules);
}
newKernel.setLts(ltsKernels.contains(kernel));
newKernel.setRecommended(recommendedKernels.contains(kernel));
newKernel.setRunning(QString::compare(runningKernel, kernel) == 0);
kernels_.append(newKernel);
}
endResetModel();
}
void KernelModel::add(const Kernel &kernel)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
kernels_ << kernel;
endInsertRows();
}
bool KernelModel::remove(int position, int rows, const QModelIndex &parent)
{
Q_UNUSED(parent)
beginRemoveRows(QModelIndex(), position, position+rows-1);
for (int row = 0; row < rows; ++row) {
kernels_.removeAt(position);
}
endRemoveRows();
return true;
}
int KernelModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return kernels_.size();
}
QVariant KernelModel::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() >= kernels_.count())
return QVariant();
const Kernel &kernel = kernels_[index.row()];
if (role == PackageRole)
return kernel.package();
else if (role == VersionRole)
return kernel.version();
else if (role == MajorVersionRole)
return kernel.majorVersion();
else if (role == MinorVersionRole)
return kernel.minorVersion();
else if (role == InstalledModulesRole)
return kernel.installedModules();
else if (role == AvailableModulesRole)
return kernel.availableModules();
else if (role == IsAvailableRole)
return kernel.isAvailable();
else if (role == IsInstalledRole)
return kernel.isInstalled();