@@ -30,7 +30,7 @@ class StatusBar : StatusBarWidgetFactory {
3030
3131 override fun isEnabledByDefault (): Boolean = true
3232
33- class ZiitStatusBarWidget (val project : Project ) : StatusBarWidget {
33+ class ZiitStatusBarWidget (val project : Project ) : StatusBarWidget, StatusBarWidget.TextPresentation {
3434 private val config = Config .getInstance()
3535 private val heartbeatService = HeartbeatService .getInstance()
3636
@@ -94,45 +94,43 @@ class StatusBar : StatusBarWidgetFactory {
9494
9595 override fun ID (): String = " StatusBar"
9696
97- override fun getPresentation (): StatusBarWidget .WidgetPresentation {
98- return object : StatusBarWidget .MultipleTextValuesPresentation {
99- override fun getTooltipText (): String {
100- return when {
101- ! hasValidApiKey -> " Invalid or missing API key. Click to configure."
102- ! isOnline -> " Working offline. Changes will be synced when online."
103- else -> " Ziit: Today's coding time. Click to open dashboard."
104- }
105- }
97+ override fun getTooltipText (): String? {
98+ return when {
99+ ! hasValidApiKey -> " Invalid or missing API key. Click to configure."
100+ ! isOnline -> " Working offline. Changes will be synced when online."
101+ else -> " Ziit: Today's coding time. Click to open dashboard."
102+ }
103+ }
106104
107- override fun getSelectedValue (): String {
108- if (! hasValidApiKey) {
109- return " ⚠ Unconfigured"
110- }
105+ override fun getText (): String {
106+ if (! hasValidApiKey) {
107+ return " ⚠ Unconfigured"
108+ }
111109
112- var displaySeconds = totalSeconds
110+ var displaySeconds = totalSeconds
113111
114- if (isTracking) {
115- val elapsedSeconds = (System .currentTimeMillis() - trackingStartTime) / 1000
116- displaySeconds + = elapsedSeconds.toInt()
117- }
112+ if (isTracking) {
113+ val elapsedSeconds = (System .currentTimeMillis() - trackingStartTime) / 1000
114+ displaySeconds + = elapsedSeconds.toInt()
115+ }
118116
119- val hours = displaySeconds / 3600
120- val minutes = (displaySeconds % 3600 ) / 60
117+ val hours = displaySeconds / 3600
118+ val minutes = (displaySeconds % 3600 ) / 60
121119
122- return when {
123- ! isOnline -> " ⏱ $hours hrs $minutes mins (offline)"
124- else -> " ⏱ $hours hrs $minutes mins"
125- }
126- }
120+ return when {
121+ ! isOnline -> " ⏱ $hours hrs $minutes mins (offline)"
122+ else -> " ⏱ $hours hrs $minutes mins"
123+ }
124+ }
127125
128- override fun getClickConsumer (): Consumer < MouseEvent > ? {
129- return Consumer { _ ->
130- if ( ! hasValidApiKey) {
131- config.promptForApiKey()
132- } else {
133- openDashboard ()
134- }
135- }
126+ override fun getAlignment (): Float = 0.5f
127+
128+ override fun getClickConsumer (): Consumer < MouseEvent > ? {
129+ return Consumer < MouseEvent > { _ ->
130+ if ( ! hasValidApiKey) {
131+ config.promptForApiKey ()
132+ } else {
133+ openDashboard()
136134 }
137135 }
138136 }
0 commit comments