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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import os
import sys 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 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): def __init__(self):
super().__init__() super().__init__()
self.ui = Ui_MainWindow() self.ui = Ui_Dialog()
self.ui.setupUi(self) 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__": if __name__ == "__main__":
setvariables()
about = QApplication(sys.argv) about = QApplication(sys.argv)
aboutwindow = LubuntuAbout() aboutwindow = LubuntuAbout()
aboutwindow.show() aboutwindow.show()

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

Loading…
Cancel
Save