Skip to content
Snippets Groups Projects
Commit 00c6038c authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] fix bad label "ok" on startup message box

Add qdesigner dialog with Sakia version and a cancel button
Update translation
parent a226c959
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StartupDialog</class>
<widget class="QDialog" name="StartupDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<height>95</height>
</rect>
</property>
<property name="windowTitle">
<string>Sakia</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>341</width>
<height>81</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../../res/icons/sakia.icons.qrc">:/icons/sakia_logo</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Connecting to the network
please wait...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="cancelButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../../../../res/icons/sakia.icons.qrc"/>
</resources>
<connections/>
</ui>
......@@ -5,8 +5,8 @@ import signal
import sys
import traceback
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtCore import Qt, QObject, QCoreApplication
from PyQt5.QtWidgets import QApplication, QMessageBox, QDialog, QPushButton, QLabel
from duniterpy.api.errors import DuniterError
from sakia.helpers import single_instance_lock, cleanup_lock
......@@ -17,6 +17,24 @@ from sakia.gui.dialogs.connection_cfg.controller import ConnectionConfigControll
from sakia.gui.main_window.controller import MainWindowController
from sakia.gui.preferences import PreferencesDialog
from sakia.gui.widgets import QAsyncMessageBox
from sakia.gui.dialogs.startup_uic import Ui_StartupDialog
from sakia import __version__
class StartupDialog(QDialog, Ui_StartupDialog):
def __init__(self):
super().__init__()
self.setupUi(self)
self.setWindowTitle("Sakia {version}".format(version=__version__))
def closeEvent(self, event):
"""
Overide close event to exit application if dialog is closed
:param QDialogEvent event:
:return:
"""
cancel_connection()
def exit_exception_handler(loop, context):
......@@ -121,6 +139,17 @@ def exception_message(log_lines, exc_info):
mb.exec()
def cancel_connection(button=None):
"""
Exit application
:param QMessageBox button: Clicked button or None if close event
:return:
"""
print("Cancel connection! Exited.")
sys.exit(0)
def main():
# activate ctrl-c interrupt
signal.signal(signal.SIGINT, signal.SIG_DFL)
......@@ -149,14 +178,9 @@ def main():
keep_trying = True
while not app.blockchain_service.initialized():
try:
box = QMessageBox()
box.setWindowTitle("Initialization")
box.setText("Connecting to the network...")
wFlags = box.windowFlags()
if Qt.WindowCloseButtonHint == (wFlags & Qt.WindowCloseButtonHint):
wFlags = wFlags ^ Qt.WindowCloseButtonHint
box.setWindowFlags(wFlags)
box = StartupDialog()
box.show()
box.cancelButton.clicked.connect(cancel_connection)
loop.run_until_complete(app.initialize_blockchain())
box.hide()
except (DuniterError, NoPeerAvailable) as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment