Browse Source

Show localized time in tooltip

master
Johann Schmitz 2 years ago
parent
commit
602219834b
Signed by: ercpe <johann@j-schmitz.net> GPG Key ID: A084064277C501ED
4 changed files with 12 additions and 2 deletions
  1. +7
    -1
      ptt/main.py
  2. +1
    -1
      ptt/timetracker.py
  3. +3
    -0
      ptt/ui.py
  4. +1
    -0
      requirements.txt

+ 7
- 1
ptt/main.py View File

@@ -4,12 +4,14 @@ import logging
import os
from configparser import ConfigParser

import pytz
from PyQt5 import QtSql
from PyQt5.QtCore import Qt, QEvent, QBasicTimer, QVariant
from PyQt5.QtGui import QColor
from PyQt5.QtSql import QSqlDatabase, QSqlTableModel, QSqlQuery
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QLineEdit, QVBoxLayout, QPushButton, \
QTableView, QCompleter, QMessageBox, QApplication, QSystemTrayIcon, QStyle
from tzlocal import get_localzone

from ptt.remote import Remote
from ptt.submit import SubmitWindow
@@ -297,8 +299,12 @@ class MainWindow(QWidget):
self.current_entry.setEnabled(False)
self.timer_label.setText('0:00:00')
self.duration_timer.start(1000, self)

start = self.timetracker.start_time.replace(tzinfo=pytz.utc)
start = start.astimezone(get_localzone())
self.tray_icon.setToolTip("%s since %s" % (self.current_entry.text(),
self.timetracker.start_time.strftime("%X")))
start.strftime("%X")))
self.tray_icon.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))

self.tte_model.refresh()


+ 1
- 1
ptt/timetracker.py View File

@@ -18,7 +18,7 @@ class Timetracker(object):
@property
def start_time(self):
return self._current_activity_start
def start(self, activity):
logger.debug("Start tracking: %s", activity)



+ 3
- 0
ptt/ui.py View File

@@ -22,6 +22,9 @@ class DurationFormatDelegate(QStyledItemDelegate):

def displayText(self, value, locale):

if not value:
return ''
if isinstance(value, int):
seconds = value
else:


+ 1
- 0
requirements.txt View File

@@ -4,3 +4,4 @@ sqlalchemy[sqlite]
jira
keyring
pytz
tzlocal