Frameless + always_on_top config options
This commit is contained in:
+21
-17
@@ -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 os
|
||||
|
||||
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():
|
||||
initialization_result = initialize()
|
||||
@@ -39,11 +38,15 @@ def run():
|
||||
|
||||
widget.setWindowTitle('Damage Meter')
|
||||
|
||||
widget.setWindowFlag(Qt.WindowStaysOnTopHint)
|
||||
widget.setWindowFlag(Qt.FramelessWindowHint)
|
||||
if window_config['always_on_top']:
|
||||
widget.setWindowFlag(Qt.WindowStaysOnTopHint)
|
||||
if window_config['frameless']:
|
||||
widget.setWindowFlag(Qt.FramelessWindowHint)
|
||||
|
||||
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:
|
||||
msg = QMessageBox()
|
||||
@@ -59,9 +62,10 @@ def run():
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Critical)
|
||||
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"
|
||||
.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.show()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import sys
|
||||
import toml
|
||||
|
||||
CFG_VERSION = '0.5'
|
||||
CFG_VERSION = '0.6'
|
||||
|
||||
default = """
|
||||
[window]
|
||||
@@ -10,6 +10,8 @@ width = 300
|
||||
height = 220
|
||||
font-size = '10px'
|
||||
opacity = 0.8
|
||||
frameless = true
|
||||
always_on_top = true
|
||||
|
||||
[app]
|
||||
|
||||
|
||||
+24
-17
@@ -19,6 +19,8 @@ from .dmg_list import DmgList
|
||||
from . import about
|
||||
from . import engine
|
||||
from . import assets
|
||||
from .config import config
|
||||
|
||||
|
||||
class Mode:
|
||||
DMG_CURRENT_ZONE = 'Stats (dmg): Current zone'
|
||||
@@ -28,6 +30,7 @@ class Mode:
|
||||
OVERALL = 'Stats (all): Overall'
|
||||
LAST_FIGHT = 'Stats (all): Last fight'
|
||||
|
||||
|
||||
class InteractiveBar(QWidget):
|
||||
def __init__(self, table, clipboard):
|
||||
QWidget.__init__(self)
|
||||
@@ -38,47 +41,50 @@ class InteractiveBar(QWidget):
|
||||
self.fame_per_minute = 0.0
|
||||
self.clipboard = clipboard
|
||||
|
||||
self.layout.addWidget(self.mode)
|
||||
|
||||
self.copy_button = QPushButton(self)
|
||||
self.copy_button.setIcon(QtGui.QIcon(assets.path('copy.png')))
|
||||
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.setIcon(QtGui.QIcon(assets.path('reset.png')))
|
||||
self.reset_button.setToolTip("Reset")
|
||||
|
||||
self.close_button = QPushButton(self)
|
||||
self.close_button.setIcon(QtGui.QIcon(assets.path('close.png')))
|
||||
self.close_button.setToolTip("Close")
|
||||
self.layout.addWidget(self.reset_button)
|
||||
self.reset_button.clicked.connect(self.reset)
|
||||
|
||||
self.about_button = QPushButton(self)
|
||||
self.about_button.setIcon(QtGui.QIcon(assets.path('about.png')))
|
||||
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.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)
|
||||
|
||||
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):
|
||||
model = self.table.model
|
||||
items = sorted(
|
||||
[model.item(i).player for i in range(model.rowCount())],
|
||||
key=lambda i: i.damage,
|
||||
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]):
|
||||
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 += "(AOStats https://git.io/JeBD1)"
|
||||
|
||||
self.clipboard.clear(mode=self.clipboard.Clipboard )
|
||||
self.clipboard.clear(mode=self.clipboard.Clipboard)
|
||||
self.clipboard.setText(clip, mode=self.clipboard.Clipboard)
|
||||
|
||||
def set_fame_per_minute(self, fpm):
|
||||
@@ -99,6 +105,7 @@ class InteractiveBar(QWidget):
|
||||
def close(self):
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
class ModeWidget(QComboBox):
|
||||
def __init__(self):
|
||||
QComboBox.__init__(self)
|
||||
|
||||
Reference in New Issue
Block a user