From 93294a3ae8778c9cbaa846dab360df990638977d Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 15 Jan 2018 21:06:15 -0600 Subject: [PATCH] Change to using QDialog and add logic for screen. --- src/main.py | 65 +++++- src/main.ui | 658 +++++++++++++++++++++++++++------------------------- 2 files changed, 399 insertions(+), 324 deletions(-) diff --git a/src/main.py b/src/main.py index 5de8245..9ebf9bc 100755 --- a/src/main.py +++ b/src/main.py @@ -18,17 +18,76 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +import os import sys +import math +import cpuinfo +import threading +from time import sleep +from socket import gethostname +from subprocess import run, PIPE +from psutil import virtual_memory +from platform import system, uname +from lsb_release import get_distro_information from PyQt5.QtWidgets import QWidget, QApplication, QMainWindow -from aboutlubuntu_auto import Ui_MainWindow -class LubuntuAbout(QMainWindow, Ui_MainWindow): +from aboutlubuntu_auto import Ui_Dialog + +class LubuntuAbout(QMainWindow, Ui_Dialog): def __init__(self): super().__init__() - self.ui = Ui_MainWindow() + self.ui = Ui_Dialog() self.ui.setupUi(self) + self.ui.versiondetails.setText("Lubuntu %s" % version) + self.ui.smalldetails.setText("%s %s, %s" % (os, kernel, arch)) + self.ui.hostnamedetails.setText(hostname) + self.ui.cpudetails.setText("%s" % cpu) + self.ui.graphicsdetails.setText("%s" % graphics) + self.ui.memorydetails.setText("%s / %s used" % (freemem, totalmem)) + self.infupdate() + + +def memcalc(mem): + # FIXME: I bet there's a native Python interface to grab the highest unit + mem = round(mem / math.pow(1024, int(math.floor(math.log(mem, 1024)))), 2) + if mem <= 1: + return str(round(mem * 1024))+" MB" + else: + return str(mem)+" GB" + +def setvariables(): + global os + global kernel + global arch + global hostname + global version + global cpu + global graphics + global freemem + global totalmem + + os = system() + kernel = uname()[2] + arch = uname()[5] + hostname = gethostname() + + if "development branch" in get_distro_information()["DESCRIPTION"]: + version = get_distro_information()["DESCRIPTION"] + version = version.replace(" (development branch)", "") + version = version.replace("Ubuntu ", "").title() + else: + version = get_distro_information()["RELEASE"].title() + + cpu = cpuinfo.get_cpu_info()["brand"] + + # FIXME: Please, someone simplify this... + graphics = (run(["lspci", "-mm"], stdout=PIPE).stdout.decode('utf-8').split("\n")[2].replace("\"", "").split("VGA compatible controller ")[1].split("Controller")[0])+"Controller" + + freemem = memcalc(virtual_memory().free) + totalmem = memcalc(virtual_memory().total) if __name__ == "__main__": + setvariables() about = QApplication(sys.argv) aboutwindow = LubuntuAbout() aboutwindow.show() diff --git a/src/main.ui b/src/main.ui index 3e6e7e8..5f4e9e1 100644 --- a/src/main.ui +++ b/src/main.ui @@ -1,25 +1,25 @@ - MainWindow - + Dialog + 0 0 - 600 - 400 + 612 + 412 - 600 - 400 + 612 + 412 - 600 - 400 + 612 + 412 @@ -29,193 +29,347 @@ :/images/Lubuntu.png:/images/Lubuntu.png - - - - - - - - - - - 32 - 32 - - - - - 32 - 32 - - - - <img src=":/images/graphics.png" height="32" width="32" /> - - + + + + + + 600 + 400 + + + + + 600 + 400 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + <img src=":/images/Lubuntu.png" height="64" width="64" /> + + + + + + + + + + 0 + 0 + + + + + 26 + + + + Lubuntu VERSION + + + + + + + OS KERNEL, ARCH + + + + + + - - - - - Oxygen-Sans - 12 - - + + - graphics - - - - - - - Qt::Horizontal + <span style="text-decoration: underline; color:#0000ff;" align="right"> + <p><a href="http://lubuntu.me/">Website</a></p> + <p><a href="http://lubuntu.me/links/">Contact us</a></p> + <p><a href="http://phab.lubuntu.me/w/contributor-guide/">Contribute</a></p> +</span> - - - 40 - 20 - + + true - + - - + + + + + 800 + 0 + + + + Qt::Horizontal + + + + + - - - - 32 - 32 - - - - - 32 - 32 - - - - <img src=":/images/memory.png" height="32" width="32" /> - - + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <img src=":/images/storage.png" height="32" width="32" /> + + + + + + + + Oxygen-Sans + 12 + + + + hostname + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - - Oxygen-Sans - 12 - - - - memory - - + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <img src=":/images/cpu.png" height="32" width="32" /> + + + + + + + + Oxygen-Sans + 12 + + + + cpu + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - Qt::Horizontal - - - - 40 - 20 - - - + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <img src=":/images/memory.png" height="32" width="32" /> + + + + + + + + Oxygen-Sans + 12 + + + + memory + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <img src=":/images/graphics.png" height="32" width="32" /> + + + + + + + + Oxygen-Sans + 12 + + + + graphics + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - + + - + - 32 - 32 + 100 + 30 - 32 - 32 + 100 + 30 - <img src=":/images/cpu.png" height="32" width="32" /> + Translation - - - - Oxygen-Sans - 12 - - - - cpu - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - + - 32 - 32 + 100 + 30 - 32 - 32 + 100 + 30 - <img src=":/images/storage.png" height="32" width="32" /> + License - - - - Oxygen-Sans - 12 - - - - storage - - - - - + Qt::Horizontal @@ -227,196 +381,58 @@ - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - <img src=":/images/Lubuntu.png" height="64" width="64" /> + + + QDialogButtonBox::Close - - - - - - - 0 - 0 - - - - - 26 - - - - Lubuntu VERSION - - - - - - - OS KERNEL, ARCH - - - - - - - - - <span style="text-decoration: underline; color:#0000ff;" align="right"> - <p><a href="http://lubuntu.me/">Website</a></p> - <p><a href="http://lubuntu.me/links/">Contact us</a></p> - <p><a href="http://phab.lubuntu.me/w/contributor-guide/">Contribute</a></p> -</span> - - - true - - - - - - - - - - - - 100 - 30 - + + + + Qt::Vertical - + - 100 - 30 + 20 + 40 - - Translation - - + - - - - - 100 - 30 - + + + + Qt::Vertical - + - 100 - 30 + 20 + 40 - - License - - + - - + + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 20 + 40 - - - - QDialogButtonBox::Close - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 800 - 0 - - - - Qt::Horizontal - - - - - + + + @@ -425,12 +441,12 @@ close clicked(QAbstractButton*) - MainWindow + Dialog close() - 500 - 376 + 509 + 387 299