diff --git a/CHANGELOG.md b/CHANGELOG.md index 9123466..a5c17cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.1] - 2022-01-09 +### Changed +- Content of "about" tab was updated. +- Gold won from consecutive pomodoro changed from 2 to 1.5 gold. +- Improved animations. + +### Fixed +- More specific trap to understand if Arduino is connected. + +## [1.1.0] - 2020-02-26 +### Added +- Bell sound at the end of a pomodoro & break. + ## [1.0.0] - 2016-02-06 ### Added - Pristine version. diff --git a/Gemfile b/Gemfile index 6a10106..e795266 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,8 @@ source 'https://rubygems.org' group :development do gem 'rake' - gem 'rdoc' gem 'bundler' + gem 'ocra' end group :production do @@ -14,4 +14,6 @@ group :production do gem 'fastimage' gem 'win32-clipboard' gem 'win32-mutex' + gem 'win32-sound' + gem 'mini_portile2' end diff --git a/Rakefile b/Rakefile index b84fe6c..19fdae8 100644 --- a/Rakefile +++ b/Rakefile @@ -17,13 +17,19 @@ end desc 'ocra --no-lzma(testing purpose)' task :ocra_no_lzma, :version do |t, args| args.with_defaults(:version => '') - system("ocra --chdir-first --no-lzma --icon './data/icon.ico' --output 'Pomodoro Tracker #{args[:version].!=('') ? "#{args[:version]}" : ''}.exe' './bin/pomodoro_tracker' './lib/**/*' './data/**/*.png' './ext/**/*'") + system("ocra --gemfile Gemfile --chdir-first --no-lzma --gem-full --icon './data/icon.ico' --output 'releases/Pomodoro Tracker #{args[:version].!=('') ? "#{args[:version]}" : ''}.exe' './bin/pomodoro_tracker' './lib/**/*' './data/**/*.wav' './data/**/*.png' './ext/**/*'") end desc 'ocra' task :ocra, :version do |t, args| args.with_defaults(:version => '') - system("ocra --chdir-first --windows --icon './data/icon.ico' --output 'Pomodoro Tracker #{args[:version].!=('') ? "#{args[:version]}" : ''}.exe' './bin/pomodoro_tracker' './lib/**/*' './data/**/*.png' './ext/**/*'") + system("ocra --gemfile Gemfile --chdir-first --windows --gem-full --icon './data/icon.ico' --output 'releases/Pomodoro Tracker #{args[:version].!=('') ? "#{args[:version]}" : ''}.exe' './bin/pomodoro_tracker' './lib/**/*' './data/**/*.wav' './data/**/*.png' './ext/**/*'") +end + +desc 'ocra_with_window' +task :ocra_with_window, :version do |t, args| + args.with_defaults(:version => '') + system("ocra --gemfile Gemfile --chdir-first --gem-full --icon './data/icon.ico' --output 'releases/Pomodoro Tracker #{args[:version].!=('') ? "#{args[:version]}" : ''}.exe' './bin/pomodoro_tracker' './lib/**/*' './data/**/*.wav' './data/**/*.png' './ext/**/*'") end desc 'erase persisted data' diff --git a/data/bell.wav b/data/bell.wav new file mode 100644 index 0000000..03d263c Binary files /dev/null and b/data/bell.wav differ diff --git a/ext/AutoItX3.dll b/ext/AutoItX3.dll index 09851e8..f7b8257 100644 Binary files a/ext/AutoItX3.dll and b/ext/AutoItX3.dll differ diff --git a/ext/AutoItX3_x64.dll b/ext/AutoItX3_x64.dll new file mode 100644 index 0000000..437d74c Binary files /dev/null and b/ext/AutoItX3_x64.dll differ diff --git a/ext/autoit-ffi.rb b/ext/autoit-ffi.rb index 2ef0251..add1cc7 100644 --- a/ext/autoit-ffi.rb +++ b/ext/autoit-ffi.rb @@ -11,9 +11,12 @@ module AutoIt AU3_INTDEFAULT = -2147483647 # Used when constructing strings consumed by AutoIt UTF_16LE_NULL = "\0".encode("UTF-16LE") - + PLATFORM_X64 = RUBY_PLATFORM.match(/64/) ? true : false + extend FFI::Library - ffi_lib File.expand_path(File.dirname(__FILE__)) + "/AutoItX3.dll" + dll_path = File.expand_path(File.dirname(__FILE__)) + dll_path << (PLATFORM_X64 ? "/AutoItX3_x64.dll" : "/AutoItX3.dll") + ffi_lib dll_path ffi_convention :stdcall FunctionAttacher.attach(self) diff --git a/ext/function_attacher.rb b/ext/function_attacher.rb index 0bc4fc6..e3c367d 100644 --- a/ext/function_attacher.rb +++ b/ext/function_attacher.rb @@ -33,9 +33,15 @@ module FunctionAttacher # See "doc/Function Prototypes (C).txt" for the C header file. # def self.attach(lib) - FUNCTION_PROTOTYPES.each { |fun| lib.attach_function *fun } + FUNCTION_PROTOTYPES.each do |fun| + begin + lib.attach_function *fun + # don't do this at home kids + rescue Exception + next + end + end end - end end diff --git a/lib/pomodoro_tracker.rb b/lib/pomodoro_tracker.rb index 5d14c38..097b33e 100644 --- a/lib/pomodoro_tracker.rb +++ b/lib/pomodoro_tracker.rb @@ -8,6 +8,7 @@ require 'date' require 'win32/clipboard' require 'win32/mutex' +require 'win32/sound' # source code require_relative './pomodoro_tracker/v_fxgui' diff --git a/lib/pomodoro_tracker/m_arduino_interpreter.rb b/lib/pomodoro_tracker/m_arduino_interpreter.rb index eb25aaa..821b0c0 100644 --- a/lib/pomodoro_tracker/m_arduino_interpreter.rb +++ b/lib/pomodoro_tracker/m_arduino_interpreter.rb @@ -11,7 +11,7 @@ def arduino_present?(serial_port) @sp = Serial.new(serial_port) puts("#{serial_port} opened.") true - rescue RubySerial::Exception + rescue RubySerial::Error # there is nothing connected on *serial_port* puts("#{serial_port} not opened.") false diff --git a/lib/pomodoro_tracker/m_pomodoro_system.rb b/lib/pomodoro_tracker/m_pomodoro_system.rb index fd6e1fb..ce0ad2e 100644 --- a/lib/pomodoro_tracker/m_pomodoro_system.rb +++ b/lib/pomodoro_tracker/m_pomodoro_system.rb @@ -70,7 +70,7 @@ def current_pomodoro_finished @consecutive_pomodoros[:working_day] += 1 @consecutive_pomodoros[:global] += 1 # raise gold - @pomodoro_tracker.gamification.raise_gold(2) + @pomodoro_tracker.gamification.raise_gold(1.5) else # raise gold @pomodoro_tracker.gamification.raise_gold(1) diff --git a/lib/pomodoro_tracker/m_pomodoro_tracker.rb b/lib/pomodoro_tracker/m_pomodoro_tracker.rb index 989a4e7..944ee88 100644 --- a/lib/pomodoro_tracker/m_pomodoro_tracker.rb +++ b/lib/pomodoro_tracker/m_pomodoro_tracker.rb @@ -5,10 +5,9 @@ class PomodoroTracker PROGRAM_DATA_PATH = "#{ENV['ProgramData'] || ENV['ALLUSERSPROFILE']}".gsub('\\', '/') PROGRAM_DATA_PT_PATH = "#{PROGRAM_DATA_PATH}/Pomodoro Tracker" PERSISTED_DATA_FILENAME = 'pd.pt' - VERSION = '1.0' - BUG_REPORTS_AND_FEATURES_REQUEST_URI = 'https://github.com/IgorJorobus/pomodoro_tracker/issues' - DONATIONS_URI = 'http://jorobuslab.net/main/en/pomodoro_tracker.html' - JOROBUSLAB_WEBSITE = 'http://jorobuslab.net' + VERSION = '1.3.1' + BUG_REPORTS_AND_FEATURES_REQUEST_URI = 'https://github.com/damian-m-g/pomodoro_tracker/issues' + JOROBUSLAB_WEBSITE = 'https://damian-m-g.github.io/' # *dropbox_present* is #TrueClass or #FalseClass # *arduino_connected* is #TrueClass or #FalseClass diff --git a/lib/pomodoro_tracker/v_fxgui.rb b/lib/pomodoro_tracker/v_fxgui.rb index 8728c37..bc38fe0 100644 --- a/lib/pomodoro_tracker/v_fxgui.rb +++ b/lib/pomodoro_tracker/v_fxgui.rb @@ -1,6 +1,8 @@ # Graphic User Interface. class FXGUI + BELL_SOUND_PATH = "#{File.dirname(File.dirname(File.dirname(__FILE__ )))}/data/bell.wav" + # @param persisted_data [Array, NilClass] # @param pomodoro_tracker [PomodoroTracker] def initialize(persisted_data, pomodoro_tracker) @@ -213,7 +215,7 @@ def start_counter @main_window.update() @main_window.repaint() # put window on front - AutoItFFI::AutoIt.win_activate(@main_window.title) + AutoItFFI::AutoIt.win_activate(@main_window.title) if defined?(AutoItFFI) @tabbook.setCurrent(0, true) # update GUI @main_window.create() @@ -225,6 +227,8 @@ def start_counter @main_window.update() @main_window.repaint() end + # play sound + Win32::Sound.play(BELL_SOUND_PATH) # start animation start_pomodoro_finished_animation() # update GUI @@ -255,7 +259,7 @@ def start_counter @main_window.repaint() # put window on front @tabbook.setCurrent(0, true) - AutoItFFI::AutoIt.win_activate(@main_window.title) + AutoItFFI::AutoIt.win_activate(@main_window.title) if defined?(AutoItFFI) @tabbook.setCurrent(0, true) # update GUI @main_window.create() @@ -267,6 +271,8 @@ def start_counter @main_window.update() @main_window.repaint() end + # play sound + Win32::Sound.play(BELL_SOUND_PATH) # start animation start_break_finished_animation() # update labels on gbs @@ -305,62 +311,62 @@ def transform_seconds_to_pretty_timeshow(seconds) # Holds the entire system for a few seconds while an animation is performed on the seven segments. def start_pomodoro_finished_animation @app.beginWaitCursor() - sleep(0.75) - @seven_segment.text = ' : ' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = '25:00' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = ' : ' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = '25:00' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = ' : ' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - # break begins - @seven_segment.text = '00:00' - @main_window.update() - @main_window.repaint() + sleep(0.75) + @seven_segment.text = ' : ' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = '25:00' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = ' : ' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = '25:00' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = ' : ' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + # break begins + @seven_segment.text = '00:00' + @main_window.update() + @main_window.repaint() @app.endWaitCursor() end def start_break_finished_animation long_break = @pomodoro_system.current_break.long #: TrueClass or FalseClass @app.beginWaitCursor() - sleep(0.75) - @seven_segment.text = ' : ' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = (long_break ? '15:00' : '05:00') - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = ' : ' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = (long_break ? '15:00' : '05:00') - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - @seven_segment.text = ' : ' - @seven_segment.update() - @seven_segment.repaint() - sleep(0.75) - # break begins - @seven_segment.text = '00:00' - @seven_segment.update() - @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = ' : ' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = (long_break ? '15:00' : '05:00') + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = ' : ' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = (long_break ? '15:00' : '05:00') + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + @seven_segment.text = ' : ' + @seven_segment.update() + @seven_segment.repaint() + sleep(0.75) + # break begins + @seven_segment.text = '00:00' + @seven_segment.update() + @seven_segment.repaint() @app.endWaitCursor() end @@ -546,7 +552,7 @@ def create_coins_label(parent) # icon = FXPNGIcon.new(@app, File.read('./data/coin.png', {mode: 'rb'}), 0, IMAGE_ALPHAGUESS, 40, 42) icon = FXPNGIcon.new(@app, File.read('./data/vault.png', {mode: 'rb'}), 0, IMAGE_ALPHAGUESS, 42, 42) @label_coins_on_counter = FXLabel.new(parent, '', icon, opts: LABEL_NORMAL|LAYOUT_FILL) - @label_coins_on_counter.tipText = 'Accumulated coins' + @label_coins_on_counter.tipText = "Accumulated coins. You obtain 1 coin per pomodoro finished, 1.5 if it's consecutive (started within the minute of a break's end). You get -1 coin to interrupt a pomodoro." fill_coins_amount_on_counter_tab() FXPainter.paint_background(FXColor::VERDE, @label_coins_on_counter) end @@ -1249,26 +1255,20 @@ def draw_dinamyc_things_on_chart_graphic =end def create_tab_about(parent) - vertical0 = FXVerticalFrame.new(parent, opts: LAYOUT_CENTER_X|LAYOUT_CENTER_Y) - l0 = FXLabel.new(vertical0, "Version #{PomodoroTracker::VERSION}", opts: LABEL_NORMAL|LAYOUT_CENTER_X) + vertical0 = FXVerticalFrame.new(parent, opts: LAYOUT_CENTER_X|LAYOUT_CENTER_Y, padTop: 0) + l0 = FXLabel.new(vertical0, "Version #{PomodoroTracker::VERSION}", opts: LABEL_NORMAL|LAYOUT_CENTER_X, padTop: 0) l0.font = big_font = FXFont.new(@app, 'Segoe UI,100,Bold,Straight') horizontal0 = FXHorizontalFrame.new(vertical0, padding: 0, padTop: 10, opts: LAYOUT_CENTER_X, hSpacing: 0) - l1 = FXLabel.new(horizontal0, "\u{1 f 4 1e} Bug report && feature requests:", padRight: 0) + l1 = FXLabel.new(horizontal0, "Bug report && feature requests: ", padRight: 0) l1.tipText = 'Label "bug" to point a bug, and "enhancement" to point a feature request' l2 = FXLabel.new(horizontal0, PomodoroTracker::BUG_REPORTS_AND_FEATURES_REQUEST_URI, padLeft: 0) l2.textColor = blue_link_color = FXRGB(34, 52, 83) copy_s = 'Left click to copy on clipboard' l2.tipText = copy_s l2.connect(SEL_LEFTBUTTONPRESS) {|sender, selector, data| Win32::Clipboard.set_data(sender.text)} - horizontal1 = FXHorizontalFrame.new(vertical0, padding: 0, opts: LAYOUT_CENTER_X) - l3 = FXLabel.new(horizontal1, "\u2764 To donate:") - l4 = FXLabel.new(horizontal1, PomodoroTracker::DONATIONS_URI) - l4.textColor = blue_link_color - l4.tipText = copy_s - l4.connect(SEL_LEFTBUTTONPRESS) {|sender, selector, data| Win32::Clipboard.set_data(sender.text)} horizontal2 = FXHorizontalFrame.new(vertical0, padding: 0, padTop: 10, opts: LAYOUT_CENTER_X, hSpacing: 0) l5 = FXLabel.new(horizontal2, 'Developed by ', padRight: 0, opts: JUSTIFY_CENTER_Y|LAYOUT_CENTER_Y|LAYOUT_FILL_Y) - l6 = FXLabel.new(horizontal2, 'JorobusLab', padTop: 0) + l6 = FXLabel.new(horizontal2, 'DMG', padTop: 0) l6.textColor = FXRGB(150, 0, 0) l6.font = big_font horizontal3 = FXHorizontalFrame.new(vertical0, padding: 0, opts: LAYOUT_CENTER_X)