motd as standard msgbox

This commit is contained in:
Wiktor Mazur
2020-05-08 18:45:12 +02:00
parent 0aa354b786
commit 7f1eaa7f34
2 changed files with 21 additions and 8 deletions
+15 -8
View File
@@ -1,5 +1,7 @@
import os import os
import platform
import sys import sys
import requests
from PySide2 import QtCore # type: ignore from PySide2 import QtCore # type: ignore
from PySide2.QtCore import Qt # type: ignore from PySide2.QtCore import Qt # type: ignore
@@ -7,7 +9,6 @@ from PySide2 import QtGui # type: ignore
from PySide2.QtWidgets import QApplication # type: ignore from PySide2.QtWidgets import QApplication # type: ignore
from PySide2.QtWidgets import QMessageBox # type: ignore from PySide2.QtWidgets import QMessageBox # type: ignore
from PySide2.QtWidgets import QPushButton # type: ignore from PySide2.QtWidgets import QPushButton # type: ignore
from PySide2.QtWebEngineWidgets import QWebEngineView
from ..engine import InitializationResult from ..engine import InitializationResult
from ..engine import initialize from ..engine import initialize
@@ -23,16 +24,22 @@ from ..utils.assets import scripts
sys.path.append(os.path.dirname(os.path.abspath('__file__'))) sys.path.append(os.path.dirname(os.path.abspath('__file__')))
def fix_npcap(): def fix_npcap():
os.system(scripts('fixnpcap.bat')) os.system(scripts('fixnpcap.bat'))
sys.exit(0) sys.exit(0)
def get_modt(always_on_top):
view = QWebEngineView()
view.load(QtCore.QUrl('https://mazurwiktor.github.io/aostats/motd'))
view.page().profile().clearHttpCache()
return view def get_modt(always_on_top):
motd_url = 'https://mazurwiktor.github.io/aostats/motd'
msg = QMessageBox()
msg.setObjectName("Motd")
msg.setWindowTitle("MOTD")
msg.setInformativeText(str(requests.get(motd_url).text))
msg.setStandardButtons(QMessageBox.Ok)
return msg
def run(): def run():
initialization_result = initialize() initialization_result = initialize()
@@ -93,9 +100,9 @@ def run():
In case where npcap is installed try to fix npcap and restart the app" In case where npcap is installed try to fix npcap and restart the app"
.format('https://nmap.org/npcap/dist/npcap-0.9990.exe')) .format('https://nmap.org/npcap/dist/npcap-0.9990.exe'))
msg.setStandardButtons(QMessageBox.Ok) msg.setStandardButtons(QMessageBox.Ok)
button = QPushButton("Fix npcap") button = QPushButton("Fix npcap")
button.clicked.connect(fix_npcap) button.clicked.connect(fix_npcap)
msg.addButton(button, QMessageBox.NoRole) msg.addButton(button, QMessageBox.NoRole)
msg.show() msg.show()
+6
View File
@@ -10,6 +10,12 @@ style = """
color: white; color: white;
} }
#Motd, #Motd > * {
background-color: none;
color: none;
font-size: auto;
}
QListView { QListView {
min-height: 100px; min-height: 100px;
} }