Frameless + always_on_top config options

This commit is contained in:
Wiktor Mazur
2020-01-15 20:57:13 +01:00
parent 72bd1b0a18
commit 057cda91ab
3 changed files with 51 additions and 38 deletions
+19 -15
View File
@@ -1,20 +1,19 @@
from .version import latest_url
from .version import latest_version as get_latest_version
from .version import current_version as get_current_version
from .styling import style
from .engine import InitializationResult
from .engine import initialize
from .main import MainWidget
from .config import config
from PySide2.QtWidgets import QMessageBox
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import Qt
import sys import sys
import os import os
sys.path.append(os.path.dirname(os.path.abspath('__file__'))) sys.path.append(os.path.dirname(os.path.abspath('__file__')))
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QApplication
from PySide2.QtWidgets import QMessageBox
from .config import config
from .main import MainWidget
from .engine import initialize
from .engine import InitializationResult
from .styling import style
from .version import current_version as get_current_version
from .version import latest_version as get_latest_version
from .version import latest_url
def run(): def run():
initialization_result = initialize() initialization_result = initialize()
@@ -39,11 +38,15 @@ def run():
widget.setWindowTitle('Damage Meter') widget.setWindowTitle('Damage Meter')
if window_config['always_on_top']:
widget.setWindowFlag(Qt.WindowStaysOnTopHint) widget.setWindowFlag(Qt.WindowStaysOnTopHint)
if window_config['frameless']:
widget.setWindowFlag(Qt.FramelessWindowHint) widget.setWindowFlag(Qt.FramelessWindowHint)
widget.show() widget.show()
current_version, latest_version = (get_current_version(), get_latest_version()) current_version, latest_version = (
get_current_version(), get_latest_version())
if latest_version and current_version != latest_version: if latest_version and current_version != latest_version:
msg = QMessageBox() msg = QMessageBox()
@@ -59,9 +62,10 @@ def run():
msg = QMessageBox() msg = QMessageBox()
msg.setIcon(QMessageBox.Critical) msg.setIcon(QMessageBox.Critical)
msg.setWindowTitle("Unable to track network traffic data!") msg.setWindowTitle("Unable to track network traffic data!")
msg.setText("On windows make sure that WinPcap is installed in your system.") msg.setText(
"On windows make sure that WinPcap is installed in your system.")
msg.setInformativeText("WinPcap can be installed from <a href='{}'>here</a> <br> <b>Make sure to install with the \"Install Npcap in WinPcap API-compatible Mode\"<b> option" msg.setInformativeText("WinPcap can be installed from <a href='{}'>here</a> <br> <b>Make sure to install with the \"Install Npcap in WinPcap API-compatible Mode\"<b> option"
.format('https://nmap.org/npcap/dist/npcap-0.9983.exe')) .format('https://nmap.org/npcap/dist/npcap-0.9986.exe'))
msg.setStandardButtons(QMessageBox.Ok) msg.setStandardButtons(QMessageBox.Ok)
msg.show() msg.show()
+3 -1
View File
@@ -2,7 +2,7 @@ import os
import sys import sys
import toml import toml
CFG_VERSION = '0.5' CFG_VERSION = '0.6'
default = """ default = """
[window] [window]
@@ -10,6 +10,8 @@ width = 300
height = 220 height = 220
font-size = '10px' font-size = '10px'
opacity = 0.8 opacity = 0.8
frameless = true
always_on_top = true
[app] [app]
+23 -16
View File
@@ -19,6 +19,8 @@ from .dmg_list import DmgList
from . import about from . import about
from . import engine from . import engine
from . import assets from . import assets
from .config import config
class Mode: class Mode:
DMG_CURRENT_ZONE = 'Stats (dmg): Current zone' DMG_CURRENT_ZONE = 'Stats (dmg): Current zone'
@@ -28,6 +30,7 @@ class Mode:
OVERALL = 'Stats (all): Overall' OVERALL = 'Stats (all): Overall'
LAST_FIGHT = 'Stats (all): Last fight' LAST_FIGHT = 'Stats (all): Last fight'
class InteractiveBar(QWidget): class InteractiveBar(QWidget):
def __init__(self, table, clipboard): def __init__(self, table, clipboard):
QWidget.__init__(self) QWidget.__init__(self)
@@ -38,43 +41,46 @@ class InteractiveBar(QWidget):
self.fame_per_minute = 0.0 self.fame_per_minute = 0.0
self.clipboard = clipboard self.clipboard = clipboard
self.layout.addWidget(self.mode)
self.copy_button = QPushButton(self) self.copy_button = QPushButton(self)
self.copy_button.setIcon(QtGui.QIcon(assets.path('copy.png'))) self.copy_button.setIcon(QtGui.QIcon(assets.path('copy.png')))
self.copy_button.setToolTip("Copy to clipboard") self.copy_button.setToolTip("Copy to clipboard")
self.layout.addWidget(self.copy_button)
self.copy_button.clicked.connect(self.copy)
self.reset_button = QPushButton() self.reset_button = QPushButton()
self.reset_button.setIcon(QtGui.QIcon(assets.path('reset.png'))) self.reset_button.setIcon(QtGui.QIcon(assets.path('reset.png')))
self.reset_button.setToolTip("Reset") self.reset_button.setToolTip("Reset")
self.layout.addWidget(self.reset_button)
self.close_button = QPushButton(self) self.reset_button.clicked.connect(self.reset)
self.close_button.setIcon(QtGui.QIcon(assets.path('close.png')))
self.close_button.setToolTip("Close")
self.about_button = QPushButton(self) self.about_button = QPushButton(self)
self.about_button.setIcon(QtGui.QIcon(assets.path('about.png'))) self.about_button.setIcon(QtGui.QIcon(assets.path('about.png')))
self.about_button.setToolTip("About") self.about_button.setToolTip("About")
self.layout.addWidget(self.mode)
self.layout.addWidget(self.copy_button)
self.layout.addWidget(self.reset_button)
self.layout.addWidget(self.about_button) self.layout.addWidget(self.about_button)
self.layout.addWidget(self.close_button)
self.setLayout(self.layout)
self.copy_button.clicked.connect(self.copy)
self.reset_button.clicked.connect(self.reset)
self.close_button.clicked.connect(self.close)
self.about_button.clicked.connect(self.about.show) self.about_button.clicked.connect(self.about.show)
if config()['window']['frameless']:
self.close_button = QPushButton(self)
self.close_button.setIcon(QtGui.QIcon(assets.path('close.png')))
self.close_button.setToolTip("Close")
self.layout.addWidget(self.close_button)
self.close_button.clicked.connect(self.close)
self.setLayout(self.layout)
def copy(self): def copy(self):
model = self.table.model model = self.table.model
items = sorted( items = sorted(
[model.item(i).player for i in range(model.rowCount())], [model.item(i).player for i in range(model.rowCount())],
key=lambda i: i.damage, key=lambda i: i.damage,
reverse=True) reverse=True)
clip = "{}, FPM: {}\nDMG: \n".format(self.mode.currentText(), self.fame_per_minute) clip = "{}, FPM: {}\nDMG: \n".format(
self.mode.currentText(), self.fame_per_minute)
for index, i in enumerate(items[:3]): for index, i in enumerate(items[:3]):
clip += '{}. {}-{}/{}-{}%'.format(index+1, i.name, i.damage, i.dps, i.percentage) clip += '{}. {}-{}/{}-{}%'.format(index+1,
i.name, i.damage, i.dps, i.percentage)
clip += "\n" clip += "\n"
clip += "(AOStats https://git.io/JeBD1)" clip += "(AOStats https://git.io/JeBD1)"
@@ -99,6 +105,7 @@ class InteractiveBar(QWidget):
def close(self): def close(self):
sys.exit(0) sys.exit(0)
class ModeWidget(QComboBox): class ModeWidget(QComboBox):
def __init__(self): def __init__(self):
QComboBox.__init__(self) QComboBox.__init__(self)