Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions src/mainApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import os
import signal

from PyQt5.QtCore import pyqtSignal, QSettings
from PyQt5.QtCore import pyqtSignal, QSettings, QFile, QTextStream
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QMainWindow, QAction
from PyQt5.QtWidgets import QMainWindow, QAction, QApplication

from database import Database
from misc import printDbg, initLogs, saveCacheSettings, readCacheSettings, getVersion
Expand Down Expand Up @@ -50,6 +50,7 @@ def __init__(self, imgDir, app, start_args):
# Register the signal handlers
signal.signal(signal.SIGTERM, service_shutdown)
signal.signal(signal.SIGINT, service_shutdown)
self.set_customtheme_ifneeded()

# Get version and title
self.version = getVersion()
Expand All @@ -73,6 +74,41 @@ def __init__(self, imgDir, app, start_args):
# Initialize user interface
self.initUI(imgDir)

def set_customtheme_ifneeded(self):
self.settings = settings = QSettings('PIVX', 'PET4L')
themeindex = settings.value("qt_theme",0)
use_dark_theme = themeindex == 1

# Add switcher for Qtum core style themes on electrum
use_qtum_theme1 = themeindex == 2
use_qtum_theme2 = themeindex == 3
use_qtum_theme3 = themeindex == 4
if use_dark_theme:
try:
import qdarkstyle
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
except BaseException as e:
use_dark_theme = False
print(f'Error setting dark theme: {repr(e)}')
if use_qtum_theme1:
try:
self.app.setStyleSheet(open('src/styles/theme1/app.css').read())
except BaseException as e:
use_dark_theme = False
print(f'Error setting Qtum theme: {repr(e)}')
if use_qtum_theme2:
try:
self.app.setStyleSheet(open('src/styles/theme2/app.css').read())
except BaseException as e:
use_dark_theme = False
print(f'Error setting Qtum theme: {repr(e)}')
if use_qtum_theme3:
try:
self.app.setStyleSheet(open('src/styles/theme3/app.css').read())
except BaseException as e:
use_dark_theme = False
print(f'Error setting Qtum theme: {repr(e)}')


def initUI(self, imgDir):
# Set title and geometry
Expand All @@ -84,7 +120,7 @@ def initUI(self, imgDir):
self.script_icon = QIcon(os.path.join(imgDir, 'icon_script.png'))
self.setWindowIcon(self.spmtIcon)
# Create main window
self.mainWindow = MainWindow(self, imgDir)
self.mainWindow = MainWindow(self, imgDir,self.app)
self.setCentralWidget(self.mainWindow)
# Add RPC server menu
mainMenu = self.menuBar()
Expand Down
45 changes: 41 additions & 4 deletions src/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from time import strftime, gmtime
import threading

from PyQt5.QtCore import pyqtSignal, Qt, QThread
from PyQt5.QtCore import pyqtSignal, Qt, QThread, QTextStream, QFile, QSettings
from PyQt5.QtGui import QPixmap, QColor, QPalette, QTextCursor, QFont, QIcon
from PyQt5.QtWidgets import QWidget, QPushButton, QHBoxLayout, QGroupBox, QVBoxLayout, \
QFileDialog, QTextEdit, QTabWidget, QLabel, QSplitter
QFileDialog, QTextEdit, QTabWidget, QLabel, QSplitter, QApplication

from apiClient import ApiClient
from constants import starting_height, DefaultCache, wqueue
Expand Down Expand Up @@ -45,13 +45,13 @@ class MainWindow(QWidget):
# signal: UTXO list has been reloaded (emitted by load_utxos_thread in tabRewards)
sig_UTXOsLoaded = pyqtSignal()

def __init__(self, parent, imgDir):
def __init__(self, parent, imgDir,app):
super(QWidget, self).__init__(parent)
self.parent = parent
self.imgDir = imgDir
self.runInThread = ThreadFuns.runInThread
self.lock = threading.Lock()

self.app = app
###-- Create clients and statuses
self.hwStatus = 0
self.hwModel = 0
Expand Down Expand Up @@ -168,6 +168,7 @@ def connButtons(self):
self.header.button_checkRpc.clicked.connect(lambda: self.onCheckRpc())
self.header.button_checkHw.clicked.connect(lambda: self.onCheckHw())
self.header.rpcClientsBox.currentIndexChanged.connect(self.onChangeSelectedRPC)
self.header.changeTheme.currentIndexChanged.connect(self.onChangeTheme)
self.header.hwDevices.currentIndexChanged.connect(self.onChangeSelectedHW)
##-- Connect signals
self.sig_clearRPCstatus.connect(self.clearRPCstatus)
Expand Down Expand Up @@ -309,10 +310,46 @@ def onChangeSelectedRPC(self, i):
self.parent.cache['selectedRPC_index'] = persistCacheSetting('cache_RPCindex',i)
self.runInThread(self.updateRPCstatus, (True,), )

def onChangeTheme(self, i):
# Don't update when we are clearing the box
self.toggle_stylesheet(i)



def onCleanConsole(self):
self.consoleArea.clear()

def toggle_stylesheet(self,i):
'''
Toggle the stylesheet to use the desired path in the Qt resource
system (prefixed by `:/`) or generically (a path to a file on
system).

:path: A full path to a resource or file on system
'''
#theme1 - dark
#theme2 hyrid
#theme3 pivx light
# get the QApplication instance, or crash if not set
app = self.app
self.settings = settings = QSettings('PIVX', 'PET4L')
settings.setValue("qt_theme",i)
if app is None:
raise RuntimeError("No Qt Application found.")
#get path for index
if i == 0:
path = ""
elif i == 1:
import qdarkstyle
path = qdarkstyle.load_stylesheet_pyqt5()
elif i == 2:
path = open('src/styles/theme3/app.css').read()
elif i == 3:
path = open('src/styles/theme2/app.css').read()
elif i == 4:
path = open('src/styles/theme1/app.css').read()

app.setStyleSheet(path)

def onSaveConsole(self):
timestamp = strftime('%Y-%m-%d_%H-%M-%S', gmtime(now()))
Expand Down
Binary file added src/qt/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion src/qt/dlg_signmessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self):
# row2b fromAddress/fromSpath
row2b = QHBoxLayout()
self.hwAccountSpingBox = QSpinBox()
self.hwAccountSpingBox.setFixedWidth(50)
self.hwAccountSpingBox.setFixedWidth(70)
self.hwAccountSpingBox.setToolTip("account number of the hardware wallet.\nIf unsure put 0")
self.hwAccountSpingBox.setValue(0)
row2b.addWidget(QLabel("Account n."))
Expand Down
15 changes: 14 additions & 1 deletion src/qt/guiHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import os

from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QSettings
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QPushButton, QLabel, QGridLayout, QHBoxLayout, QComboBox, QWidget

Expand Down Expand Up @@ -34,6 +34,19 @@ def __init__(self, caller, *args, **kwargs):
self.rpcLed.setToolTip("%s" % caller.rpcStatusMess)
self.rpcLed.setPixmap(caller.ledGrayH_icon)
self.centralBox.addWidget(self.rpcLed, 0, 3)
self.changeTheme = QComboBox()
self.changeTheme.setToolTip("Select UI Theme")
self.changeTheme.addItem("Light",0)
self.changeTheme.addItem("Dark",1)
self.changeTheme.addItem("PIVX Light Hybrid",2)
self.changeTheme.addItem("PIVX Hybrid",3)
self.changeTheme.addItem("PIVX Dark",4)
self.settings = settings = QSettings('PIVX', 'PET4L')
self.changeTheme.setCurrentIndex(settings.value("qt_theme",0))
labeltheme = QLabel("UI Theme")
self.centralBox.addWidget(labeltheme, 3, 0)
self.centralBox.addWidget(self.changeTheme, 3, 1)

self.lastPingBox = QWidget()
sp_retain = QSizePolicy()
sp_retain.setRetainSizeWhenHidden(True)
Expand Down
8 changes: 4 additions & 4 deletions src/qt/gui_tabRewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ def initRewardsForm(self):
line1.addWidget(QLabel("Account HW"))
self.edt_hwAccount = QSpinBox()
self.edt_hwAccount.setMaximum(9999)
self.edt_hwAccount.setFixedWidth(50)
self.edt_hwAccount.setFixedWidth(70)
self.edt_hwAccount.setToolTip("account number of the hardware wallet.\nIf unsure put 0")
self.edt_hwAccount.setValue(0)
line1.addWidget(self.edt_hwAccount)
line1.addWidget(QLabel("spath from"))
self.edt_spathFrom = QSpinBox()
self.edt_spathFrom.setMaximum(9999)
self.edt_spathFrom.setFixedWidth(50)
self.edt_spathFrom.setFixedWidth(70)
self.edt_spathFrom.setToolTip("starting address n.")
self.edt_spathFrom.setValue(0)
line1.addWidget(self.edt_spathFrom)
line1.addWidget(QLabel("spath to"))
self.edt_spathTo = QSpinBox()
self.edt_spathTo.setMaximum(9999)
self.edt_spathTo.setFixedWidth(50)
self.edt_spathTo.setFixedWidth(70)
self.edt_spathTo.setToolTip("ending address n.")
self.edt_spathTo.setValue(10)
line1.addWidget(self.edt_spathTo)
line1.addWidget(QLabel("internal/external"))
self.edt_internalExternal = QSpinBox()
self.edt_internalExternal.setFixedWidth(50)
self.edt_internalExternal.setFixedWidth(70)
self.edt_internalExternal.setToolTip("ending address n.")
self.edt_internalExternal.setValue(0)
self.edt_internalExternal.setMaximum(1)
Expand Down
Binary file added src/styles/.DS_Store
Binary file not shown.
Binary file added src/styles/theme1/app-icons/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/cb_up_down_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/checkbox_checked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/checkbox_unchecked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/down_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/down_arrow_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/down_arrow_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/down_arrow_unit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/message_critical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/message_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/message_question.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/message_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/styles/theme1/app-icons/slider_switcher.png
Binary file added src/styles/theme1/app-icons/spinBox.png
Binary file added src/styles/theme1/app-icons/spinBoxDisabled.png
Binary file added src/styles/theme1/app-icons/spinBoxFocus.png
Binary file added src/styles/theme1/app-icons/spinBoxHover.png
Binary file added src/styles/theme1/app-icons/splash_bg.png
Binary file added src/styles/theme1/app-icons/up_arrow.png
Binary file added src/styles/theme1/app-icons/up_arrow_disabled.png
Binary file added src/styles/theme1/app-icons/up_arrow_hover.png
Loading