Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Screenshot hack for fake fast startup. Minor improvement for redu…

…cing startup delay
  • Loading branch information...
commit 8b551b76a1d3d84858dd01a6e718d843bfd03f9d 1 parent b89833d
@khertan authored
View
1  khweeteur.desktop
@@ -5,3 +5,4 @@ Type=Application
Name=Khweeteur
Exec=/usr/bin/khweeteur
Icon=khweeteur
+X-Osso-Service=net.khertan.khweeteur
View
18 khweeteur/__init__.py
@@ -6,20 +6,17 @@
'''A Twitter client made with Python and Qt'''
-from qwidget_gui import Khweeteur, __version__
-import os.path
-from PySide.QtCore import QSettings
+from qwidget_gui import Khweeteur
import sys
#Here is the installation of the hook. Each time a untrapped/unmanaged exception will
#happen my_excepthook will be called.
def install_excepthook():
'''Install exception hook for the bug reporter'''
- APP_NAME = 'Khweeteur'
- APP_VERSION = __version__
def write_report(error):
import pickle
+ import os.path
filename = os.path.join(os.path.join(os.path.expanduser("~"),'.khweeteur_crash_report'))
output = open(filename, 'wb')
pickle.dump(error, output)
@@ -29,16 +26,23 @@ def my_excepthook(exctype, value, tb):
#traceback give us all the errors information message like the method, file line ... everything like
#we have in the python interpreter
import traceback
+ from qwidget_gui import __version__
s = ''.join(traceback.format_exception(exctype, value, tb))
print 'Except hook', exctype
print 'Except hook called : %s' % (s)
- formatted_text = "%s Version %s\nTrace : %s\nComments : " % (APP_NAME, APP_VERSION, s)
+ formatted_text = "%s Version %s\nTrace : %s\nComments : " % ('Khweeteur', __version__, s)
write_report(formatted_text)
sys.excepthook = my_excepthook
+def takeScreenShot(app):
+ from PySide.QtGui import QPixmap
+ pvr = "/home/user/.cache/launch/net.khertan.khweeteur.pvr"
+ QPixmap.grabWidget(app.win).save(pvr, 'png') # tell it to grab only your self.centralwidget screen, which is just window screen without the menu status bar on top.
+
if __name__ == '__main__':
from subprocess import Popen
+ import os.path
Popen(['/usr/bin/python',
os.path.join(os.path.dirname(__file__),
'daemon.py'),
@@ -46,6 +50,8 @@ def my_excepthook(exctype, value, tb):
install_excepthook()
app = Khweeteur()
app.exec_()
+ takeScreenShot(app)
+ from PySide.QtCore import QSettings
settings = QSettings("Khertan Software", "Khweeteur")
if settings.contains('useDaemon'):
print settings.value('useDaemon')
View
2  khweeteur/daemon.py
@@ -21,7 +21,7 @@
import pickle
import re
-__version__ = '0.5.17'
+__version__ = '0.5.18'
import dbus
View
195 khweeteur/qwidget_gui.py
@@ -9,7 +9,7 @@
from __future__ import with_statement
-__version__ = '0.5.17'
+__version__ = '0.5.18'
# import sip
# sip.setapi('QString', 2)
@@ -23,6 +23,8 @@
from PySide.QtMaemo5 import *
from qbadgebutton import QToolBadgeButton
+import osso
+
import dbus
import dbus.service
import os
@@ -31,8 +33,6 @@
import time
from list_view import KhweetsView
from list_model import KhweetsModel, ISMEROLE, IDROLE, ORIGINROLE, SCREENNAMEROLE, PROTECTEDROLE, USERIDROLE
-from settings import KhweeteurPref
-from dbusobj import KhweeteurDBus
import re
try:
@@ -210,6 +210,8 @@ def __init__(self):
self.setOrganizationName('Khertan Software')
self.setOrganizationDomain('khertan.net')
self.setApplicationName('Khweeteur')
+
+ self.osso_c = osso.Context('net.khertan.khweeteur', "0.0.1", False)
self.run()
def check_crash_report(self):
@@ -281,11 +283,11 @@ def __init__(self, parent=None):
self.setAttribute(Qt.WA_Maemo5StackedWindow, True)
self.setWindowTitle('Khweeteur')
- self.listen_dbus()
-
settings = QSettings()
self.view = KhweetsView()
+ self.setCentralWidget(self.view)
+
self.model = KhweetsModel()
try:
self.model.setLimit(int(settings.value('tweetHistory')))
@@ -294,8 +296,6 @@ def __init__(self, parent=None):
self.view.setModel(self.model)
self.view.clicked.connect(self.switch_tb_action)
- self.dbus_handler.require_update()
-
self.toolbar = QToolBar('Toolbar')
self.addToolBar(Qt.BottomToolBarArea, self.toolbar)
@@ -312,51 +312,10 @@ def __init__(self, parent=None):
self.toolbar.addAction(self.tb_new)
self.list_tb_action.append(self.tb_new)
- # Back button (Edit + Action)
-
- self.tb_back = QAction(QIcon.fromTheme('general_back'), 'Back', self)
- self.tb_back.triggered.connect(self.switch_tb_default)
- self.toolbar.addAction(self.tb_back)
- self.edit_tb_action.append(self.tb_back)
- self.action_tb_action.append(self.tb_back)
-
- self.setupMenu()
-
- # Twitpic button
-
- self.tb_twitpic = QAction(QIcon.fromTheme('tasklaunch_images'),
- 'Twitpic', self)
- self.tb_twitpic.triggered.connect(self.do_tb_twitpic)
- self.toolbar.addAction(self.tb_twitpic)
- self.edit_tb_action.append(self.tb_twitpic)
-
- # Text field (edit)
-
- self.tb_text = QPlainTextEdit()
- self.tb_text_reply_id = 0
- self.tb_text_reply_base_url = ''
- self.tb_text.setFixedHeight(66)
- self.edit_tb_action.append(self.toolbar.addWidget(self.tb_text))
-
- # Char count (Edit)
-
- self.tb_charCounter = QLabel('140')
- self.edit_tb_action.append(self.toolbar.addWidget(self.tb_charCounter))
- self.tb_text.textChanged.connect(self.countCharsAndResize)
-
- # Send tweet (Edit)
-
- self.tb_send = QAction(QIcon.fromTheme('khweeteur'), 'Tweet', self)
- self.tb_send.triggered.connect(self.do_tb_send)
- self.tb_send.setVisible(False)
- self.toolbar.addAction(self.tb_send)
- self.edit_tb_action.append(self.tb_send)
-
# Refresh (Default)
self.tb_update = QAction(QIcon.fromTheme('general_refresh'), 'Update',
self)
- self.tb_update.triggered.connect(self.dbus_handler.require_update)
self.toolbar.addAction(self.tb_update)
self.list_tb_action.append(self.tb_update)
@@ -388,7 +347,6 @@ def __init__(self, parent=None):
# Search Button
self.tb_search_menu = QMenu()
- self.loadSearchMenu()
# Search (Default)
@@ -404,7 +362,6 @@ def __init__(self, parent=None):
# Lists Button
self.tb_list_menu = QMenu()
- self.loadListMenu()
# Lists (Default)
@@ -425,10 +382,102 @@ def __init__(self, parent=None):
self.toolbar.addAction(self.tb_fullscreen)
self.list_tb_action.append(self.tb_fullscreen)
+ # Actions not in toolbar
+
+ self.tb_scrolltop = QAction('Scroll to top', self)
+ self.tb_scrolltop.setShortcut(Qt.CTRL + Qt.Key_Up)
+ self.tb_scrolltop.triggered.connect(self.view.scrollToTop)
+ self.addAction(self.tb_scrolltop)
+
+ self.tb_scrollbottom = QAction('Scroll to bottom', self)
+ self.tb_scrollbottom.setShortcut(Qt.CTRL + Qt.Key_Down)
+ self.tb_scrollbottom.triggered.connect(self.view.scrollToBottom)
+ self.addAction(self.tb_scrollbottom)
+
+ self.tb_zoomin = QAction('ZoomIn', self)
+ self.tb_zoomin.setShortcut(Qt.CTRL + Qt.Key_Left)
+ self.tb_zoomin.triggered.connect(self.view.do_zoom_in)
+ self.addAction(self.tb_zoomin)
+
+ self.tb_zoomout = QAction('ZoomOut', self)
+ self.tb_zoomout.setShortcut(Qt.CTRL + Qt.Key_Right)
+ self.tb_zoomout.triggered.connect(self.view.do_zoom_out)
+ self.addAction(self.tb_zoomout)
+
+ self.tb_copy = QAction('Copy', self)
+ self.tb_copy.setShortcut(Qt.CTRL + Qt.Key_C)
+ self.tb_copy.triggered.connect(self.do_tb_copy)
+ self.addAction(self.tb_copy)
+
+# self.switch_tb_default()
+
+ self.setWindowTitle('Khweeteur : Home')
+ self.model.load('HomeTimeline')
+ self.show()
+ QTimer.singleShot(500,self.post_init)
+
+ @Slot()
+ def post_init(self):
+ self.listen_dbus()
+ self.dbus_handler.require_update()
+ self.tb_update.triggered.connect(self.dbus_handler.require_update)
+ self.geolocDoStart()
+
+ self.loadSearchMenu()
+ self.loadListMenu()
+
+ #Toolbar to set after startup
+ # Back button (Edit + Action)
+
+ self.tb_back = QAction(QIcon.fromTheme('general_back'), 'Back', self)
+ self.tb_back.triggered.connect(self.switch_tb_default)
+ self.toolbar.addAction(self.tb_back)
+ self.tb_back.setVisible(False)
+ self.edit_tb_action.append(self.tb_back)
+ self.action_tb_action.append(self.tb_back)
+
+ self.setupMenu()
+
+ # Twitpic button
+
+ self.tb_twitpic = QAction(QIcon.fromTheme('tasklaunch_images'),
+ 'Twitpic', self)
+ self.tb_twitpic.triggered.connect(self.do_tb_twitpic)
+ self.tb_twitpic.setVisible(False)
+ self.toolbar.addAction(self.tb_twitpic)
+ self.edit_tb_action.append(self.tb_twitpic)
+
+ # Text field (edit)
+
+ self.tb_text = QPlainTextEdit()
+ self.tb_text_reply_id = 0
+ self.tb_text_reply_base_url = ''
+ self.tb_text.setFixedHeight(66)
+ action = self.toolbar.addWidget(self.tb_text)
+ action.setVisible(False)
+ self.edit_tb_action.append(action)
+
+ # Char count (Edit)
+
+ self.tb_charCounter = QLabel('140')
+ action = self.toolbar.addWidget(self.tb_charCounter)
+ action.setVisible(False)
+ self.edit_tb_action.append(action)
+ self.tb_text.textChanged.connect(self.countCharsAndResize)
+
+ # Send tweet (Edit)
+
+ self.tb_send = QAction(QIcon.fromTheme('khweeteur'), 'Tweet', self)
+ self.tb_send.triggered.connect(self.do_tb_send)
+ self.tb_send.setVisible(False)
+ self.toolbar.addAction(self.tb_send)
+ self.edit_tb_action.append(self.tb_send)
+
# Reply button (Action)
self.tb_reply = QAction('Reply', self)
self.tb_reply.setShortcut('Ctrl+M')
+ self.tb_reply.setVisible(False)
self.toolbar.addAction(self.tb_reply)
self.tb_reply.triggered.connect(self.do_tb_reply)
self.action_tb_action.append(self.tb_reply)
@@ -437,6 +486,7 @@ def __init__(self, parent=None):
self.tb_retweet = QAction('Retweet', self)
self.tb_retweet.setShortcut('Ctrl+P')
+ self.tb_retweet.setVisible(False)
self.toolbar.addAction(self.tb_retweet)
self.tb_retweet.triggered.connect(self.do_tb_retweet)
self.action_tb_action.append(self.tb_retweet)
@@ -445,6 +495,7 @@ def __init__(self, parent=None):
self.tb_follow = QAction('Follow', self)
self.tb_follow.triggered.connect(self.do_tb_follow)
+ self.tb_follow.setVisible(False)
self.toolbar.addAction(self.tb_follow)
self.action_tb_action.append(self.tb_follow)
@@ -452,6 +503,7 @@ def __init__(self, parent=None):
self.tb_unfollow = QAction('Unfollow', self)
self.tb_unfollow.triggered.connect(self.do_tb_unfollow)
+ self.tb_unfollow.setVisible(False)
self.toolbar.addAction(self.tb_unfollow)
self.action_tb_action.append(self.tb_unfollow)
@@ -459,6 +511,7 @@ def __init__(self, parent=None):
self.tb_favorite = QAction('Favorite', self)
self.tb_favorite.triggered.connect(self.do_tb_favorite)
+ self.tb_favorite.setVisible(False)
self.toolbar.addAction(self.tb_favorite)
self.action_tb_action.append(self.tb_favorite)
@@ -466,6 +519,7 @@ def __init__(self, parent=None):
self.tb_urls = QAction('Open URLs', self)
self.tb_urls.setShortcut('Ctrl+O')
+ self.tb_urls.setVisible(False)
self.toolbar.addAction(self.tb_urls)
self.tb_urls.triggered.connect(self.do_tb_openurl)
self.action_tb_action.append(self.tb_urls)
@@ -473,48 +527,11 @@ def __init__(self, parent=None):
# Delete (Action)
self.tb_delete = QAction('Delete', self)
+ self.tb_delete.setVisible(False)
self.toolbar.addAction(self.tb_delete)
self.tb_delete.triggered.connect(self.do_tb_delete)
self.action_tb_action.append(self.tb_delete)
- # Actions not in toolbar
-
- self.tb_scrolltop = QAction('Scroll to top', self)
- self.tb_scrolltop.setShortcut(Qt.CTRL + Qt.Key_Up)
- self.tb_scrolltop.triggered.connect(self.view.scrollToTop)
- self.addAction(self.tb_scrolltop)
-
- self.tb_scrollbottom = QAction('Scroll to bottom', self)
- self.tb_scrollbottom.setShortcut(Qt.CTRL + Qt.Key_Down)
- self.tb_scrollbottom.triggered.connect(self.view.scrollToBottom)
- self.addAction(self.tb_scrollbottom)
-
- self.tb_zoomin = QAction('ZoomIn', self)
- self.tb_zoomin.setShortcut(Qt.CTRL + Qt.Key_Left)
- self.tb_zoomin.triggered.connect(self.view.do_zoom_in)
- self.addAction(self.tb_zoomin)
-
- self.tb_zoomout = QAction('ZoomOut', self)
- self.tb_zoomout.setShortcut(Qt.CTRL + Qt.Key_Right)
- self.tb_zoomout.triggered.connect(self.view.do_zoom_out)
- self.addAction(self.tb_zoomout)
-
- self.tb_copy = QAction('Copy', self)
- self.tb_copy.setShortcut(Qt.CTRL + Qt.Key_C)
- self.tb_copy.triggered.connect(self.do_tb_copy)
- self.addAction(self.tb_copy)
-
- self.switch_tb_default()
-
- self.setWindowTitle('Khweeteur : Home')
- self.setCentralWidget(self.view)
- QTimer.singleShot(100,self.post_init)
-
- @Slot()
- def post_init(self):
- self.model.load('HomeTimeline')
- self.geolocDoStart()
-
@Slot()
def do_tb_fullscreen(self):
if self.isFullScreen():
@@ -540,6 +557,7 @@ def enterEvent(self, event):
self.model.refreshTimestamp()
def listen_dbus(self):
+ from dbusobj import KhweeteurDBus
from dbus.mainloop.qt import DBusQtMainLoop
self.dbus_loop = DBusQtMainLoop()
dbus.set_default_main_loop(self.dbus_loop)
@@ -1087,6 +1105,7 @@ def setupMenu(self):
@Slot()
def showPrefs(self):
+ from settings import KhweeteurPref
khtsettings = KhweeteurPref(parent=self)
khtsettings.save.connect(self.refreshPrefs)
khtsettings.show()
Please sign in to comment.
Something went wrong with that request. Please try again.