commit f5c827290ebf4dcb5f11f7d3753d5af764a54588 Author: Hans P. Möller Date: Sat Apr 18 22:17:58 2020 -0400 initial commit diff --git a/__pycache__/lubuntuBreeze.cpython-38.pyc b/__pycache__/lubuntuBreeze.cpython-38.pyc new file mode 100644 index 0000000..2330053 Binary files /dev/null and b/__pycache__/lubuntuBreeze.cpython-38.pyc differ diff --git a/breeze-color b/breeze-color new file mode 100755 index 0000000..deea656 --- /dev/null +++ b/breeze-color @@ -0,0 +1,36 @@ +#!/usr/bin/python3 +# coding=utf-8 + +# Copyright (C) 2020 Hans P. Möller +# +# 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. +# 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 . + +import sys +from argparse import ArgumentParser + +import lubuntuBreeze + +if __name__ == "__main__": + parser = ArgumentParser() + parser.add_argument('--version', + action='version', + version='%(prog)s 0.1') + options = parser.parse_args() + + # TODO translations replace gettext with _ ??? + # localesApp="lubuntu-breeze" + # localesDir="/usr/share/locale" + # gettext.bindtextdomain(localesApp, localesDir) + # gettext.textdomain(localesApp) + lubuntuBreeze.main(sys.argv) diff --git a/data/breeze-color.desktop b/data/breeze-color.desktop new file mode 100644 index 0000000..0d140d9 --- /dev/null +++ b/data/breeze-color.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Exec=breeze-config +Name=Lubuntu Breeze Config +GenericName=Lubuntu Breeze Config +Comment=Configure Breeze Theme +Icon=preferences-desktop-color +Type=Application +Version=0.1 +Categories=System;Settings;DesktopSettings;Qt;LXQt; +Keywords=breeze;config +Terminal=false diff --git a/data/designer/main.ui b/data/designer/main.ui new file mode 100644 index 0000000..e32b8a8 --- /dev/null +++ b/data/designer/main.ui @@ -0,0 +1,54 @@ + + + Main + + + + 0 + 0 + 479 + 168 + + + + Lubuntu Breeze Config + + + + .. + + + + + + + + + Select Color Scheme + + + + + + + + + + <font size="-1">Applications need to be restarted for changes to take effect.<br> +In case of pcmanfm-qt, since it handles the desktop, a restart of the desktop is needed<br/> +Easier, restart session.<br/>Best results if a matching GTK Theme is selected.</font> + + + + + + + QDialogButtonBox::Apply|QDialogButtonBox::Close + + + + + + + + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..232909e --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +lubuntu-breeze-color (0.1) UNRELEASED; urgency=medium + + * Initial release. (Closes: #XXXXXX) + + -- Hans P. Möller Thu, 05 Mar 2020 17:18:27 -0300 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..cdb45bd --- /dev/null +++ b/debian/control @@ -0,0 +1,22 @@ +Source: lubuntu-breeze-color +Section: utils +Priority: optional +Maintainer: Hans P Möller +Build-Depends: debhelper-compat (= 12), + dh-python, + python3-all, + python3-setuptools, +Standards-Version: 4.5.0 +Rules-Requires-Root: no + +Package: lubuntu-breeze-color +Architecture: all +Depends: python3, + python3-pyqt5, + ${misc:Depends}, + ${python3:Depends}, +Description: Breeze Theme Color Scheme Selector + It lets you pick a color scheme from "/usr/share/color-schemes/" and copy it + to "~/.config/kdeglobals" so system use it. Applications need restart in order + to use it. Take into consideration that some file managers also manage the + desktop so you need to restart that too. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..1d08024 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,16 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://phab.lubuntu.me/################################## + +Files: * +Copyright: © 2020 Lubuntu Team. + © 2020 Hans P Möller +License: GPL-3+ + +License: GPL-3+ + 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. + . + On Debian systems, the full text of the GNU General Public License version + 3 can be found in the file `/usr/share/common-licenses/GPL-3'. diff --git a/debian/help2man.include b/debian/help2man.include new file mode 100644 index 0000000..0290f64 --- /dev/null +++ b/debian/help2man.include @@ -0,0 +1,5 @@ +[authors] + lubuntu-breeze-color was primarily written by Hans P Moller. + +[name] + breeze-color \- is a Color Scheme Selector for Breeze Theme. diff --git a/debian/lubuntu-breeze-color.install b/debian/lubuntu-breeze-color.install new file mode 100644 index 0000000..9e25e95 --- /dev/null +++ b/debian/lubuntu-breeze-color.install @@ -0,0 +1,2 @@ +data/breeze-color.desktop /usr/share/applications/breeze-color.desktop +data/designer /usr/share/lubuntu-breeze-color/designer diff --git a/debian/lubuntu-breeze-config.manpages b/debian/lubuntu-breeze-config.manpages new file mode 100644 index 0000000..74c2bd8 --- /dev/null +++ b/debian/lubuntu-breeze-config.manpages @@ -0,0 +1 @@ +debian/manpages/breeze-config.1 diff --git a/debian/manpages/breeze-color.1 b/debian/manpages/breeze-color.1 new file mode 100644 index 0000000..a5755d3 --- /dev/null +++ b/debian/manpages/breeze-color.1 @@ -0,0 +1,15 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.12. +.TH BREEZE-CONFIG "1" "March 2020" "breeze-config 0.1" "User Commands" +.SH NAME + breeze-config \- is a Color Scheme Selector for Breeze Theme. +.SH DESCRIPTION +usage: breeze\-config [\-h] [\-\-version] +.SS "optional arguments:" +.TP +\fB\-h\fR, \fB\-\-help\fR +show this help message and exit +.TP +\fB\-\-version\fR +show program's version number and exit +.SH AUTHORS + lubuntu-breeze-config was primarily written by Hans P Moller. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..3c213a2 --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#! /usr/bin/make -f +export DH_VERBOSE=1 +export PYBUILD_INTERPRETERS=python3 +export PYBUILD_NAME=lubuntu-breeze-color + +%: + dh $@ --with python3 --buildsystem=pybuild diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..184337b --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: run-tests +Depends: xvfb, + @ diff --git a/debian/tests/run-tests b/debian/tests/run-tests new file mode 100644 index 0000000..9ba9a5c --- /dev/null +++ b/debian/tests/run-tests @@ -0,0 +1,4 @@ +#!/bin/sh + +xvfb-run +python3 setup.py test diff --git a/lubuntu-breeze-color/__init__.py b/lubuntu-breeze-color/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lubuntuBreeze.py b/lubuntuBreeze.py new file mode 100755 index 0000000..c03a38a --- /dev/null +++ b/lubuntuBreeze.py @@ -0,0 +1,113 @@ +#!/usr/bin/python3 +# coding=utf-8 + +# Copyright (C) 2020 Hans P. Möller +# +# 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. +# 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 . + +import os +import subprocess +import sys +from pathlib import Path +from shutil import copyfile +from PyQt5.QtWidgets import (QWidget, QApplication, QDialogButtonBox) +from PyQt5.QtCore import (QDir, qDebug, QSettings) +from PyQt5 import uic +from gettext import gettext as _ # better than in main "_ = gettext.gettext" for testing + +class MainWindow(QWidget): + def __init__(self): + QWidget.__init__(self) + uic.loadUi("data/designer/main.ui", self) + self.confFile = Path(Path.home() / ".config/kdeglobals") + self.schemeDir = "/usr/share/color-schemes/" + self.initUI() + + def initUI(self): + '''populate text and combobox needed with uic''' + self.label.setText(_("Select Color Scheme for Breeze Qt Style:")) + noteText =_("Applications need to be restarted for changes to take effect.") + noteText += "
" + noteText += _("In case of pcmanfm-qt, since it handles the desktop, ") + noteText += _("a restart of the desktop is needed") + "
" + noteText += _("Easier, restart session.") + noteText += "
" + noteText += _("Best results if a matching GTK Theme is selected.") + + self.note.setText('' + noteText + '') + dir = QDir(self.schemeDir) + self.files = dir.entryList(dir, dir.Files) + self.comboBox.clear() + self.comboBox.addItem(_("None")) + for f in self.files: + settings = QSettings(self.schemeDir + f, QSettings.NativeFormat) + self.comboBox.addItem(settings.value("ColorScheme")) + self.comboBox.setCurrentText(self.checkCurrent()) + self.buttonBox.clicked.connect(self.btnClk) + self.center() + + def center(self): + '''centers UI''' + frameGm = self.frameGeometry() + screen = QApplication.desktop().screenNumber( + QApplication.desktop().cursor().pos()) + centerPoint = QApplication.desktop().screenGeometry(screen).center() + frameGm.moveCenter(centerPoint) + self.move(frameGm.topLeft()) + + def checkCurrent(self): + '''check current used theme''' + if self.confFile.is_file(): + qDebug("exist: " + str(self.confFile)) + settings = QSettings(str(self.confFile), QSettings.NativeFormat) + set = settings.value("ColorScheme") + qDebug(set) + if set != "": + return(set) + else: + return("None") + else: + qDebug(str(self.confFile) + " wasn't found") + return("None") + + def btnClk(self, btn): + '''copy selected color-scheme to kdeglobals or close''' + if btn == self.buttonBox.button(QDialogButtonBox.Apply): + qDebug("apply") + if self.comboBox.currentText() != "None": + for f in self.files: + set = QSettings(self.schemeDir + f, QSettings.NativeFormat) + if(set.value("ColorScheme") == self.comboBox.currentText()): + copyfile(self.schemeDir + f, self.confFile) + else: + os.remove(self.confFile) + filename = os.path.dirname(os.path.abspath(__file__)) + '/breeze-color' + print(filename) + subprocess.Popen(filename) + sys.exit(0) + + elif btn == self.buttonBox.button(QDialogButtonBox.Close): + exit(0) + +class App(QApplication): + def __init__(self, *args): + QApplication.__init__(self, *args) + self.main = MainWindow() + self.main.show() + +def main(args): + global app + app = App(args) + # app.setWindowIcon(QIcon.fromTheme("preferences-desktop-color")) + app.exec_() diff --git a/po/es.po b/po/es.po new file mode 100644 index 0000000..42ccdf2 --- /dev/null +++ b/po/es.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2020-03-02 20:52-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + + +#: lubuntuBreeze.py:39 +msgid "Select Color Scheme for Breeze Qt Style:" +msgstr "Selecciona el Esquema de Color de Breeze para el estilo Qt" + +#: lubuntuBreeze.py:40 +msgid "Applications need to be restarted for changes to take effect." +msgstr "Las aplicaciones se deben reiniciar para que los cambios tengan efecto." + +#: lubuntuBreeze.py:42 +msgid "In case of pcmanfm-qt, since it handles the desktop, a restart of the desktop is needed" +msgstr "En caso de pcmanfm-qt, dado que maneja el escritorio, un reinicio del escritorio es necesario" + +#: lubuntuBreeze.py:44 +msgid "Easier, restart session." +msgstr "Más fácil es reiniciar la sesión" + +#: lubuntuBreeze.py:46 +msgid "Best results if a matching GTK Theme is selected." +msgstr "Mejores resultados si se ocupa un tema GTK que se asemeje." + diff --git a/po/lubuntu-breeze-color.pot b/po/lubuntu-breeze-color.pot new file mode 100644 index 0000000..faf17c5 --- /dev/null +++ b/po/lubuntu-breeze-color.pot @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2020-03-02 20:52-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + + +#: lubuntuBreeze.py:39 +msgid "Select Color Scheme for Breeze Qt Style:" +msgstr "" + +#: lubuntuBreeze.py:40 +msgid "Applications need to be restarted for changes to take effect." +msgstr "" + +#: lubuntuBreeze.py:42 +msgid "In case of pcmanfm-qt, since it handles the desktop, a restart of the desktop is needed" +msgstr "" + +#: lubuntuBreeze.py:44 +msgid "Easier, restart session." +msgstr "" + +#: lubuntuBreeze.py:46 +msgid "Best results if a matching GTK Theme is selected." +msgstr "" + diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..ee3c6e9 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[sdist] +formats = bztar diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3ff4bff --- /dev/null +++ b/setup.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# coding=utf-8 + +# Copyright (C) 2019 Hans P. Möller +# +# 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 . + +from setuptools import setup + +setup( + name="lubuntu-breeze-color", + version="0.1", + packages=['lubuntu-breeze-color'], + scripts=['breeze-color'], + data_files=[ + ('lib/lubuntu-breeze-color/', + ['lubuntuBreeze.py', ] + ), + ], + test_suite="tests", +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_gui.py b/tests/test_gui.py new file mode 100755 index 0000000..a28ca93 --- /dev/null +++ b/tests/test_gui.py @@ -0,0 +1,82 @@ +#!/usr/bin/python3 +# coding=utf-8 + +import unittest +import sys +from PyQt5.QtWidgets import QApplication +from PyQt5.QtCore import QDir, QSettings +# from PyQt5.QtTest import QTest +from pathlib import Path +from gettext import gettext as _ # better than in main "_ = gettext.gettext" for testing + + +# from lubuntuBreezeConfig import lubuntuBreeze +# import lubuntuBreezeConfig +# help(lubuntuBreezeConfig) + +sys.path.insert(0, "") +import lubuntuBreeze + + +app = QApplication(sys.argv) + +class LubuntuBreezeTest(unittest.TestCase): + + def setUp(self): + self.form = lubuntuBreeze.MainWindow() + dir = QDir(self.form.schemeDir) + self.files = dir.entryList(dir, dir.Files) + self.confFile = Path(Path.home() / ".config/kdeglobals") + + def testText(self): + '''Test GUI in default state''' + label = _("Select Color Scheme for Breeze Qt Style:") + noteText =_("Applications need to be restarted for changes to take effect.") + noteText += "
" + noteText += _("In case of pcmanfm-qt, since it handles the desktop, ") + noteText += _("a restart of the desktop is needed") + "
" + noteText += _("Easier, restart session.") + noteText += "
" + noteText += _("Best results if a matching GTK Theme is selected.") + + self.assertEqual(self.form.label.text(), label) + self.assertEqual(self.form.note.text(), '' + noteText + '') + + def testComoboxPopulation(self): + '''test if combobox is populated with same entries as number of files + (+1 because on None)''' + len(self.files) + self.assertEqual(self.form.comboBox.count(), len(self.files) + 1) + + def testComoboxSelected(self): + '''test if comobox select the actual''' + if self.confFile.is_file(): + settings = QSettings(str(self.confFile), QSettings.NativeFormat) + set = settings.value("ColorScheme") + self.assertEqual(self.form.comboBox.currentText(), set) + else: + self.assertEqual(self.form.comboBox.currentText(), _("None")) + + + """def testSelectApply(self): + '''check if ''' + if self.form.comboBox.currentText() == "None": + # select something else + for f in self.files: + set = QSettings(self.form.schemeDir + f, QSettings.NativeFormat) + if(set.value("ColorScheme") == self.form.comboBox.currentText()): + settings = QSettings(str(self.confFile), QSettings.NativeFormat) + set = settings.value("ColorScheme") + self.assertEqual(self.form.comboBox.currentText(),set) + # copyfile(self.schemeDir + f, self.confFile) + else: + # select NONE and see if file is removed + + + + def testClose(self): + '''test apply''' + """ + +if __name__ == "__main__": + unittest.main()