Skip to content
Snippets Groups Projects
Commit 2ee6ed46 authored by inso's avatar inso
Browse files

Display navigation panel

parent 798ce197
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,7 @@ class Application(QObject): ...@@ -86,7 +86,7 @@ class Application(QObject):
app.get_last_version() app.get_last_version()
if app.preferences["account"] != "": if app.preferences["account"] != "":
account = app.get_account(app.preferences["account"]) account = app.get_account(app.preferences["account"])
app.change_current_account(account) app._current_account = account
# no default account... # no default account...
else: else:
# if at least one account exists, set it as default... # if at least one account exists, set it as default...
......
...@@ -27,13 +27,14 @@ class MainWindowController(AgentController): ...@@ -27,13 +27,14 @@ class MainWindowController(AgentController):
classdocs classdocs
""" """
def __init__(self, view, model, password_asker, status_bar, toolbar): def __init__(self, view, model, password_asker, status_bar, toolbar, navigation):
""" """
Init Init
:param MainWindowView view: the ui of the mainwindow agent :param MainWindowView view: the ui of the mainwindow agent
:param sakia.gui.main_window.model.MainWindowModel: the model of the mainwindow agent :param sakia.gui.main_window.model.MainWindowModel: the model of the mainwindow agent
:param sakia.gui.status_bar.controller.StatusBarController: the controller of the status bar agent :param sakia.gui.status_bar.controller.StatusBarController status_bar: the controller of the status bar agent
:param sakia.gui.toolbar.controller.ToolbarController: the controller of the toolbar agent :param sakia.gui.toolbar.controller.ToolbarController toolbar: the controller of the toolbar agent
:param sakia.gui.navigation.contoller.NavigationController navigation: the controller of the navigation
:param PasswordAsker password_asker: the password asker of the application :param PasswordAsker password_asker: the password asker of the application
:type: sakia.core.app.Application :type: sakia.core.app.Application
...@@ -44,6 +45,7 @@ class MainWindowController(AgentController): ...@@ -44,6 +45,7 @@ class MainWindowController(AgentController):
self.password_asker = password_asker self.password_asker = password_asker
self.status_bar = self.attach(status_bar) self.status_bar = self.attach(status_bar)
self.toolbar = self.attach(toolbar) self.toolbar = self.attach(toolbar)
self.navigation = self.attach(navigation)
QApplication.setWindowIcon(QIcon(":/icons/sakia_logo")) QApplication.setWindowIcon(QIcon(":/icons/sakia_logo"))
...@@ -52,11 +54,13 @@ class MainWindowController(AgentController): ...@@ -52,11 +54,13 @@ class MainWindowController(AgentController):
view = MainWindowView(None) view = MainWindowView(None)
model = MainWindowModel(None, app) model = MainWindowModel(None, app)
password_asker = PasswordAskerDialog(None) password_asker = PasswordAskerDialog(None)
main_window = cls(view, model, password_asker, None, None) main_window = cls(view, model, password_asker, None, None, None)
main_window.status_bar = main_window.attach(StatusBarController.create(main_window, app)) main_window.status_bar = main_window.attach(StatusBarController.create(main_window, app))
view.setStatusBar(main_window.status_bar.view) view.setStatusBar(main_window.status_bar.view)
main_window.toolbar = main_window.attach(ToolbarController.create(main_window, password_asker)) main_window.toolbar = main_window.attach(ToolbarController.create(main_window, password_asker))
main_window.toolbar.view.setParent(view.centralwidget) view.top_layout.addWidget(main_window.toolbar.view)
main_window.navigation = main_window.attach(NavigationController.create(main_window, app))
view.bottom_layout.addWidget(main_window.navigation.view)
#app.version_requested.connect(main_window.latest_version_requested) #app.version_requested.connect(main_window.latest_version_requested)
#app.account_imported.connect(main_window.import_account_accepted) #app.account_imported.connect(main_window.import_account_accepted)
#app.account_changed.connect(main_window.change_account) #app.account_changed.connect(main_window.change_account)
......
...@@ -16,11 +16,13 @@ ...@@ -16,11 +16,13 @@
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"/> <layout class="QHBoxLayout" name="top_layout"/>
</item>
<item>
<layout class="QHBoxLayout" name="bottom_layout"/>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionManage_accounts"> <action name="actionManage_accounts">
<property name="text"> <property name="text">
<string>Manage accounts</string> <string>Manage accounts</string>
......
from sakia.gui.agent.model import AgentModel from sakia.gui.agent.model import AgentModel
from sakia.core.money import Referentials
class MainWindowModel(AgentModel): class MainWindowModel(AgentModel):
...@@ -11,5 +10,3 @@ class MainWindowModel(AgentModel): ...@@ -11,5 +10,3 @@ class MainWindowModel(AgentModel):
super().__init__(parent) super().__init__(parent)
self.app = app self.app = app
def referentials(self):
return Referentials
from PyQt5.QtWidgets import QTreeView from PyQt5.QtWidgets import QTreeView
from .model import NavigationModel from .model import NavigationModel
from ..agent.controller import AgentController from ..agent.controller import AgentController
from ..agent.model import AgentModel from .view import NavigationView
class NavigationController(AgentController): class NavigationController(AgentController):
...@@ -9,14 +9,15 @@ class NavigationController(AgentController): ...@@ -9,14 +9,15 @@ class NavigationController(AgentController):
The navigation panel The navigation panel
""" """
def __init__(self, parent, presentation, model): def __init__(self, parent, view, model):
""" """
Constructor of the navigation agent Constructor of the navigation agent
:param PyQt5.QtWidgets.QTreeView presentation: the presentation :param PyQt5.QtWidgets.QTreeView view: the presentation
:param sakia.core.gui.navigation.model.NavigationModel model: the model :param sakia.core.gui.navigation.model.NavigationModel model: the model
""" """
super().__init__(parent, presentation, model) super().__init__(parent, view, model)
self.view.setModel(model.tree())
@classmethod @classmethod
def create(cls, parent, app): def create(cls, parent, app):
...@@ -26,9 +27,9 @@ class NavigationController(AgentController): ...@@ -26,9 +27,9 @@ class NavigationController(AgentController):
:return: a new Navigation controller :return: a new Navigation controller
:rtype: NavigationController :rtype: NavigationController
""" """
presentation = QTreeView(parent.presentation) view = NavigationView(parent.view)
model = NavigationModel(None, app) model = NavigationModel(None, app)
navigation = cls(presentation, model) navigation = cls(parent, view, model)
model.setParent(navigation) model.setParent(navigation)
return navigation return navigation
from PyQt5.QtCore import QAbstractItemModel, Qt, QVariant from ..agent.model import AgentModel
from sakia.models.generic_tree import GenericTreeModel
class NavigationModel(QAbstractItemModel): class NavigationModel(AgentModel):
""" """
The model of Navigation agent The model of Navigation agent
""" """
...@@ -10,66 +11,33 @@ class NavigationModel(QAbstractItemModel): ...@@ -10,66 +11,33 @@ class NavigationModel(QAbstractItemModel):
self.app = app self.app = app
def tree(self): def tree(self):
navigation = {'profile': { navigation = [{'node': {
'node': { 'title': self.app.current_account.name
'title': self.account.name
}, },
'children': {} 'children': []
}
} }
for c in self.account.communities: ]
navigation['profile']['children'].append({ for c in self.app.current_account.communities:
navigation[0]['children'].append({
'node': { 'node': {
'title': c.currency 'title': c.currency
}, },
'children': { 'children': [
'transfers': { {
'node': { 'node': {
'title': self.tr('Transfers') 'title': self.tr('Transfers')
} }
}, },
'network': { {
'node': { 'node': {
'title': self.tr('Network') 'title': self.tr('Network')
} }
}, },
'network': { {
'node': { 'node': {
'title': self.tr('Network') 'title': self.tr('Network')
} }
} }
} ]
}) })
return GenericTreeModel.create("Navigation", navigation)
def rowCount(self, parent):
return len(self.nodes_data)
def columnCount(self, parent):
return len(self.columns_types)
def headerData(self, section, orientation, role):
if role != Qt.DisplayRole:
return QVariant()
return self.columns_types[section]
def data(self, index, role):
row = index.row()
col = index.column()
if not index.isValid():
return QVariant()
node = self.nodes_data[row]
if role == Qt.DisplayRole:
return node[col]
if role == Qt.BackgroundColorRole:
return self.node_colors[node[self.columns_types.index('state')]]
if role == Qt.ToolTipRole:
return self.node_states[node[self.columns_types.index('state')]]()
return QVariant()
def flags(self, index):
return Qt.ItemIsSelectable | Qt.ItemIsEnabled
from PyQt5.QtWidgets import QTreeView, QSizePolicy
class NavigationView(QTreeView):
"""
The view of navigation panel
"""
def __init__(self, parent):
super().__init__(parent)
self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding)
\ No newline at end of file
...@@ -64,11 +64,10 @@ class StatusBarController(AgentController): ...@@ -64,11 +64,10 @@ class StatusBarController(AgentController):
self.view.combo_referential.clear() self.view.combo_referential.clear()
for ref in self.model.referentials(): for ref in self.model.referentials():
self.view.combo_referential.addItem(ref.translated_name()) self.view.combo_referential.addItem(ref.translated_name())
logging.debug(self.app.preferences)
self.view.combo_referential.setEnabled(True) self.view.combo_referential.setEnabled(True)
self.view.combo_referential.blockSignals(False) self.view.combo_referential.blockSignals(False)
self.view.combo_referential.setCurrentIndex(self.app.preferences['ref']) self.view.combo_referential.setCurrentIndex(self.model.default_referential())
@pyqtSlot(int) @pyqtSlot(int)
def referential_changed(self, index): def referential_changed(self, index):
......
from sakia.gui.agent.model import AgentModel from sakia.gui.agent.model import AgentModel
from sakia.core.money import Referentials
import logging
class StatusBarModel(AgentModel): class StatusBarModel(AgentModel):
""" """
...@@ -9,3 +10,10 @@ class StatusBarModel(AgentModel): ...@@ -9,3 +10,10 @@ class StatusBarModel(AgentModel):
def __init__(self, parent, app): def __init__(self, parent, app):
super().__init__(parent) super().__init__(parent)
self.app = app self.app = app
def referentials(self):
return Referentials
def default_referential(self):
logging.debug(self.app.preferences)
return self.app.preferences['ref']
\ No newline at end of file
from PyQt5.QtWidgets import QFrame, QAction, QMenu, QDialog, QMessageBox from PyQt5.QtWidgets import QFrame, QAction, QMenu, QSizePolicy, QMessageBox
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QObject, QT_TRANSLATE_NOOP, Qt from PyQt5.QtCore import QObject, QT_TRANSLATE_NOOP, Qt
from .toolbar_uic import Ui_SakiaToolbar from .toolbar_uic import Ui_SakiaToolbar
...@@ -42,4 +42,6 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): ...@@ -42,4 +42,6 @@ class ToolbarView(QFrame, Ui_SakiaToolbar):
menu_advanced.addAction(self.action_gen_revokation) menu_advanced.addAction(self.action_gen_revokation)
tool_menu.addMenu(menu_advanced) tool_menu.addMenu(menu_advanced)
tool_menu.addAction(self.action_publish_uid) tool_menu.addAction(self.action_publish_uid)
self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Minimum)
self.setMaximumHeight(60)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment