Change to using QDialog and add logic for screen.

HEAD
Simon Quigley 6 years ago
parent 1ed8aba050
commit 93294a3ae8

@ -18,17 +18,76 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
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()

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
<width>612</width>
<height>412</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>400</height>
<width>612</width>
<height>412</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>400</height>
<width>612</width>
<height>412</height>
</size>
</property>
<property name="windowTitle">
@ -29,193 +29,347 @@
<iconset resource="main.qrc">
<normaloff>:/images/Lubuntu.png</normaloff>:/images/Lubuntu.png</iconset>
</property>
<widget class="QWidget" name="mainform">
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<layout class="QVBoxLayout" name="specs">
<item>
<layout class="QHBoxLayout" name="graphics">
<item>
<widget class="QLabel" name="graphicsicon">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/graphics.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QWidget" name="mainform" native="true">
<property name="minimumSize">
<size>
<width>600</width>
<height>400</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>400</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" rowspan="4" colspan="4">
<layout class="QGridLayout" name="itemcontainer">
<item row="0" column="0">
<layout class="QHBoxLayout" name="logoandtextlayout">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/Lubuntu.png&quot; height=&quot;64&quot; width=&quot;64&quot; /&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="Lubuntudetails">
<item>
<widget class="QLabel" name="versiondetails">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>26</pointsize>
</font>
</property>
<property name="text">
<string>Lubuntu VERSION</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="smalldetails">
<property name="text">
<string>OS KERNEL, ARCH</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="graphicsdetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<item row="0" column="1">
<widget class="QLabel" name="links">
<property name="text">
<string>graphics</string>
</property>
</widget>
</item>
<item>
<spacer name="graphicsspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<string>&lt;span style=&quot;text-decoration: underline; color:#0000ff;&quot; align=&quot;right&quot;&gt;
&lt;p&gt;&lt;a href=&quot;http://lubuntu.me/&quot;&gt;Website&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://lubuntu.me/links/&quot;&gt;Contact us&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://phab.lubuntu.me/w/contributor-guide/&quot;&gt;Contribute&lt;/a&gt;&lt;/p&gt;
&lt;/span&gt;</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</spacer>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="memory">
<item row="10" column="0">
<widget class="Line" name="line">
<property name="minimumSize">
<size>
<width>800</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<layout class="QVBoxLayout" name="specs">
<item>
<widget class="QLabel" name="memoryicon">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/memory.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
</property>
</widget>
<layout class="QHBoxLayout" name="hostname">
<item>
<widget class="QLabel" name="hostnameicon">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/storage.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="hostnamedetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>hostname</string>
</property>
</widget>
</item>
<item>
<spacer name="hostnamespacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="memorydetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>memory</string>
</property>
</widget>
<layout class="QHBoxLayout" name="cpu">
<item>
<widget class="QLabel" name="cpuicon">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/cpu.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="cpudetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>cpu</string>
</property>
</widget>
</item>
<item>
<spacer name="cpuspecspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="memoryspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<layout class="QHBoxLayout" name="memory">
<item>
<widget class="QLabel" name="memoryicon">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/memory.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="memorydetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>memory</string>
</property>
</widget>
</item>
<item>
<spacer name="memoryspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="graphics">
<item>
<widget class="QLabel" name="graphicsicon">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/graphics.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="graphicsdetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>graphics</string>
</property>
</widget>
</item>
<item>
<spacer name="graphicsspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="cpu">
<item row="11" column="0" colspan="4">
<layout class="QHBoxLayout" name="buttonslayout">
<item>
<widget class="QLabel" name="cpuicon">
<widget class="QPushButton" name="translation">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/cpu.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
<string>Translation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="cpudetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>cpu</string>
</property>
</widget>
</item>
<item>
<spacer name="cpuspecspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="storage">
<item>
<widget class="QLabel" name="storageicon">
<widget class="QPushButton" name="license">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/storage.png&quot; height=&quot;32&quot; width=&quot;32&quot; /&gt;</string>
<string>License</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="storagedetails">
<property name="font">
<font>
<family>Oxygen-Sans</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>storage</string>
</property>
</widget>
</item>
<item>
<spacer name="storagespacer">
<spacer name="buttonspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -227,196 +381,58 @@
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" rowspan="4" colspan="4">
<layout class="QGridLayout" name="itemcontainer">
<item row="0" column="0">
<layout class="QHBoxLayout" name="logoandtextlayout">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string>&lt;img src=&quot;:/images/Lubuntu.png&quot; height=&quot;64&quot; width=&quot;64&quot; /&gt;</string>
<widget class="QDialogButtonBox" name="close">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="Lubuntudetails">
<item>
<widget class="QLabel" name="versiondetails">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>26</pointsize>
</font>
</property>
<property name="text">
<string>Lubuntu VERSION</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="smalldetails">
<property name="text">
<string>OS KERNEL, ARCH</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QLabel" name="links">
<property name="text">
<string>&lt;span style=&quot;text-decoration: underline; color:#0000ff;&quot; align=&quot;right&quot;&gt;
&lt;p&gt;&lt;a href=&quot;http://lubuntu.me/&quot;&gt;Website&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://lubuntu.me/links/&quot;&gt;Contact us&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://phab.lubuntu.me/w/contributor-guide/&quot;&gt;Contribute&lt;/a&gt;&lt;/p&gt;
&lt;/span&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="0" colspan="4">
<layout class="QHBoxLayout" name="buttonslayout">
<item>
<widget class="QPushButton" name="translation">
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
<item row="9" column="0">
<spacer name="verticalSpacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="maximumSize">
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>30</height>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>Translation</string>
</property>
</widget>
</spacer>
</item>
<item>
<widget class="QPushButton" name="license">
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
<item row="5" column="0">
<spacer name="verticalSpacer3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="maximumSize">
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>30</height>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>License</string>
</property>
</widget>
</spacer>
</item>
<item>
<spacer name="buttonspacer">
<item row="0" column="0">
<spacer name="verticalSpacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="close">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0">
<widget class="Line" name="line">
<property name="minimumSize">
<size>
<width>800</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="main.qrc"/>
@ -425,12 +441,12 @@
<connection>
<sender>close</sender>
<signal>clicked(QAbstractButton*)</signal>
<receiver>MainWindow</receiver>
<receiver>Dialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>500</x>
<y>376</y>
<x>509</x>
<y>387</y>
</hint>
<hint type="destinationlabel">
<x>299</x>

Loading…
Cancel
Save