Skip to content

Commit

Permalink
Reloaded theme after changing config to avoid restart
Browse files Browse the repository at this point in the history
  • Loading branch information
satanas committed Jun 4, 2014
1 parent 96ffe63 commit 8bc0f5d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions turpial/ui/qt/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ def notify_warning(self, id_, message):
def notify_info(self, id_, message):
self.notify(id_, self.NOTIFICATION_INFO, message)

def redraw(self):
self.webview.clear()
self.webview.update_statuses(self.statuses)

class StatusDelegate(QStyledItemDelegate):
FullnameRole = Qt.UserRole + 100
Expand Down
4 changes: 4 additions & 0 deletions turpial/ui/qt/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,7 @@ def previousInFocusChain(self):
def load_style(self):
for id_, column in self.columns.iteritems():
column.webview.load_style()

def redraw(self):
for id_, column in self.columns.iteritems():
column.redraw()
9 changes: 8 additions & 1 deletion turpial/ui/qt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,20 @@ def save_filters(self, filters):

def update_config(self, new_config):
current_config = self.core.read_config()
changed_font_size = self.get_message_font_size() != new_config['General']['font-size']
changed_theme = self.core.get_theme() != new_config['General']['theme']

current_queue_interval = int(current_config['General']['queue-interval'])

self.core.update_config(new_config)

if current_queue_interval != new_config['General']['queue-interval']:
self.turn_on_queue_timer(force=True)

if changed_font_size or changed_theme:
self.reload_theme()
self._container.redraw()

def restore_config(self):
self.core.restore_config()

Expand Down Expand Up @@ -647,8 +654,8 @@ def get_alert_font_size(self):
def reload_theme(self):
theme = self.core.get_theme()
self.load_theme(theme)
self._container.load_style()
self.dock.load_style()
print self.get_themes_list()

#================================================================
# Hooks definitions
Expand Down
4 changes: 2 additions & 2 deletions turpial/ui/qt/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def update_statuses(self, statuses):

current_page = self.page().currentFrame().toHtml()

if current_page == self.EMPTY_PAGE:
if current_page == self.EMPTY_PAGE or current_page == '':
for status in statuses_:
content += self.__render_status(status)
column = self.__load_template('column.html')
Expand All @@ -195,7 +195,7 @@ def update_statuses(self, statuses):
self.execute_javascript('restoreScrollPosition()')

def clear(self):
self.setHtml('')
self.setHtml(self.EMPTY_PAGE)

def execute_javascript(self, js_cmd):
self.page().mainFrame().evaluateJavaScript(js_cmd)
Expand Down

0 comments on commit 8bc0f5d

Please sign in to comment.