Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tclaus/stocks
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: Beta-4
Choose a base ref
...
head repository: tclaus/stocks
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
  • 4 commits
  • 17 files changed
  • 4 contributors

Commits on Sep 19, 2023

  1. Enabling translations (#38)

    * Add localization support
    * Enabling localizations
    * Implementing review suggestions for translations
    * adding initial en.catkeys file
    * build system modifications to support translations (#46)
    
    * Switch the cmake conifigure_file() commands to work on the headers instead of
      cpp files. Make use of C++17 inline initializer for the configured variables
    
    * Remove headers from the list of sources in CMakeLists.txt
      It generally isn't required to have the headers there and it confuses the
      cmake translation functions because the generated headers can't be found.
    
    * No sizeLimits in MainWindow - UI seems to be broken then
    
    ---------
    
    Co-authored-by: hfsfox <darkkitsunezx128k2309@gmail.com>
    Co-authored-by: augiedoggie <augiedoggie@users.noreply.github.com>
    3 people authored Sep 19, 2023
    Copy the full SHA
    1fea801 View commit details
  2. New screenshot

    tclaus committed Sep 19, 2023
    Copy the full SHA
    73102f8 View commit details

Commits on May 23, 2024

  1. Create automatic build (#16)

    Automatic build on a Haiku qemu machine
    tclaus authored May 23, 2024
    Copy the full SHA
    9cdd1ab View commit details

Commits on May 26, 2024

  1. Remove scheduled builds

    A build on a PR is enough.
    tclaus authored May 26, 2024
    Copy the full SHA
    eef617e View commit details
27 changes: 27 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
workflow_dispatch:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
build:
name: 'build on Haiku'
runs-on: 'ubuntu-latest'
container: 'docker.io/hectorm/qemu-haiku:latest'
steps:
- name: 'Wait until the VM is ready'
run: 'container-init & timeout 600 vmshell exit 0'
- name: 'Install packages'
run: 'vmshell pkgman install -y gcc haiku_devel make makefile_engine libgit2_devel lexilla_devel yaml_cpp*_devel editorconfig_core_c_devel cmake'
- name: 'Checkout project'
uses: actions/checkout@v4
- name: 'Copy project to VM'
run: 'vmshell mkdir ./src/; tar -cf - ./ | vmshell tar -xvf - -C ./src/'
- name: 'Prepare Build project'
run: 'vmshell cmake -DCMAKE_BUILD_TYPE=Release -DHAIKU_ENABLE_I18N=ON -S ./src -B build'
- name: 'Build project'
run: 'vmshell cmake --build ./build --target Stocks -- -j 2'
76 changes: 22 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ project(
)

set(CMAKE_MODULE_PATH "${Stocks_SOURCE_DIR}/CMakeModules")

if (CMAKE_PROJECT_NAME STREQUAL ${PROJECT_NAME})
set(CMAKE_EXPORT_COMPILE_COMMANDS On)
set(CMAKE_CXX_STANDARD 17)
@@ -18,9 +19,15 @@ if (CMAKE_PROJECT_NAME STREQUAL ${PROJECT_NAME})
endif ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(HAIKU_ENABLE_I18N ON)

include(UseHaiku)

# Needed dependencies because FinancialmodelingApiKey and RepositoryConfig should be copied to the right place
add_dependencies("catkeys" ${PROJECT_NAME})
add_dependencies("catalogs" ${PROJECT_NAME})
add_dependencies("bindcatalogs" ${PROJECT_NAME})

option(STRICT_WARNINGS "Compile with extra warnings and errors" ON)

if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.96 AND STRICT_WARNINGS)
@@ -49,19 +56,21 @@ include_directories(AFTER
source/gui/chartView
source/gui/utils
source/repository
source/api)
source/api
${CMAKE_BINARY_DIR}/source/repository
${CMAKE_BINARY_DIR}/source/api)

# Set project name
configure_file(
"source/repository/RepositoryConfig.cpp.in"
"source/repository/RepositoryConfig.cpp"
"source/repository/RepositoryConfig.h.in"
"source/repository/RepositoryConfig.h"
)

# Set the api key from an environment variable
set(FINANCIAL_API_KEY $ENV{STOCKS_APP_API_KEY})
configure_file(
"source/api/FinancialmodelingApiKey.cpp.in"
"source/api/FinancialmodelingApiKey.cpp"
"source/api/FinancialmodelingApiKey.h.in"
"source/api/FinancialmodelingApiKey.h"
)

# JSON Parser
@@ -98,97 +107,56 @@ catch_discover_tests(tests)
haiku_add_executable(${PROJECT_NAME}
source/Stocks.rdef
source/App.cpp
source/App.h
source/gui/MainWindow.h
source/gui/MainWindow.cpp
source/gui/Colors.h
source/gui/Colors.cpp
source/gui/chartView/DetailsView.h
source/gui/chartView/DetailsView.cpp
source/gui/chartView/DetailsChart.h
source/gui/chartView/DetailsChart.cpp
source/gui/chartView/DetailsDataList.h
source/gui/chartView/DetailsDataList.cpp
source/gui/chartView/DetailsHeadline.h
source/gui/chartView/DetailsHeadline.cpp
source/gui/chartView/ChartTimeRangeBar.h
source/gui/chartView/ChartTimeRangeBar.cpp
source/gui/chartView/ChartView.h
source/gui/chartView/ChartView.cpp
source/gui/chartView/drawer/GridlineDrawer.h
source/gui/chartView/drawer/GridlineDrawer.cpp
source/gui/chartView/drawer/SeriesDrawer.h
source/gui/chartView/drawer/SeriesDrawer.cpp
source/gui/chartView/drawer/DataSeriesLimiter.h
source/gui/chartView/drawer/DataSeriesLimiter.cpp
source/gui/chartView/drawer/DateTimeCalculator.h
source/gui/chartView/drawer/DateTimeCalculator.cpp
source/gui/chartView/drawer/VerticalAxisDrawer.h
source/gui/chartView/drawer/VerticalAxisDrawer.cpp
source/gui/stocksPanel/StocksPanelView.h
source/gui/stocksPanel/StocksPanelView.cpp
source/gui/stocksPanel/SearchFieldControl.h
source/gui/stocksPanel/SearchFieldControl.cpp
source/gui/stocksPanel/ListItemConstants.h
source/gui/stocksPanel/listView/QuoteListItem.h
source/gui/stocksPanel/listView/QuoteListItem.cpp
source/gui/stocksPanel/listView/FoundShareListItem.h
source/gui/stocksPanel/listView/FoundShareListItem.cpp
source/gui/stocksPanel/listView/ShareListItem.h
source/gui/stocksPanel/listView/ShareListItem.cpp
source/gui/utils/ListItemDrawer.h
source/gui/utils/ListItemDrawer.cpp
source/gui/utils/QuoteFormatter.h
source/gui/utils/QuoteFormatter.cpp
source/gui/utils/DelayedQueryTimer.h
source/gui/utils/DelayedQueryTimer.cpp
source/gui/utils/EscapeCancelFilter.h
source/gui/utils/EscapeCancelFilter.cpp
source/api/StockConnector.h
source/api/Financialmodelingprep.h
source/api/Financialmodelingprep.cpp
source/api/FinancialmodelingApiKey.cpp
source/api/FinancialmodelingApiKey.h
source/api/NetRequester.h
source/api/NetRequester.cpp
source/api/ApiBuilder.h
source/api/ApiBuilder.cpp
source/model/Quote.cpp
source/model/Quote.h
source/model/Portfolio.h
source/model/Portfolio.cpp
source/model/SearchResultItem.h
source/model/SearchResultItem.cpp
source/model/SearchResultList.h
source/model/SearchResultList.cpp
source/model/SelectionOfSymbols.h
source/model/SelectionOfSymbols.cpp
source/model/HistoricalPrice.h
source/model/HistoricalPrice.cpp
source/model/HistoricalPriceList.h
source/model/HistoricalPriceList.cpp
source/model/TimeRange.h
source/repository/QuotesRepository.h
source/repository/QuotesRepository.cpp
source/repository/RepositoryConfig.h
source/repository/RepositoryConfig.cpp
source/repository/Repository.h
source/repository/Repository.cpp
source/model/linkedRequestQuoteStore/BaseLinkedRequestToQuoteStore.h
source/model/linkedRequestQuoteStore/BaseLinkedRequestToQuoteStore.cpp
source/model/linkedRequestQuoteStore/QuoteRequestStore.h
source/model/linkedRequestQuoteStore/QuoteRequestStore.cpp
source/handler/QuoteResultHandler.h
source/handler/QuoteResultHandler.cpp
source/handler/HistoricalPriceResultHandler.h
source/handler/HistoricalPriceResultHandler.cpp
source/utils/BaseThreadedJob.h
source/utils/BaseThreadedJob.cpp
source/utils/ObservableSubject.h
source/utils/ObservableSubject.cpp
source/utils/Observer.h
source/quoteUpdateJob/QuoteUpdateJob.h
source/quoteUpdateJob/QuoteUpdateJob.cpp
)

target_link_libraries(${PROJECT_NAME} be ${STDCPPLIBS} network netservices2 bnetapi nlohmann_json::nlohmann_json)
target_link_directories(${PROJECT_NAME} PUBLIC /boot/system/develop/lib)
target_link_libraries(${PROJECT_NAME} be ${STDCPPLIBS} localestub network netservices2 bnetapi nlohmann_json::nlohmann_json)

if (HAIKU_ENABLE_I18N)
set("${PROJECT_NAME}-APP_MIME_SIG" "application/x-vnd.tclaus-StocksApp")
set("${PROJECT_NAME}-LOCALES" "en")
haiku_add_i18n(${PROJECT_NAME})
endif ()
2 changes: 1 addition & 1 deletion CMakeModules/UseHaiku.cmake
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ if (HAIKU_ENABLE_I18N)
add_custom_target("catalogsinstall"
DEPENDS "catalogs"
COMMAND "${CMAKE_COMMAND}" "-DCMAKE_INSTALL_COMPONENT=locales" "-P" "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
)

if (NOT DEFINED CMAKE_INSTALL_LOCALEDIR)
set(CMAKE_INSTALL_LOCALEDIR "data/locale")
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
echo Building stocks
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B build
cmake --build ./build --target Stocks -- -j 4
cmake -DCMAKE_BUILD_TYPE=Release -DHAIKU_ENABLE_I18N=ON -S ./ -B build
cmake --build ./build --target Stocks -- -j 2

echo Building package

21 changes: 21 additions & 0 deletions locales/en.catkeys
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 English x-vnd.tclaus-StocksApp 3946264694
52-W-L DetailsDataList Abbreviation for the lowest price in last 52 weeks. 52-W-L
3 M ChartTimeRangeBar Abbreviation for 'three months' 3 M
Open DetailsDataList Last daily opening price Open
1 M ChartTimeRangeBar Abbreviation for 'one month' 1 M
1 W ChartTimeRangeBar Abbreviation for 'one Week' 1 W
Stocks System name Stocks
5 Y ChartTimeRangeBar Abbreviation for '5 years', the longest possible period 5 Y
SYM DetailsHeadline Abbreviation for 'symbol' the stocks identifier. SYM
Avg. Vol DetailsDataList Abbreviation for the average volume. Avg. Vol
6 M ChartTimeRangeBar Abbreviation for 'six months' 6 M
2 Y ChartTimeRangeBar Abbreviation for 'two years' 2 Y
52W-H DetailsDataList Abbreviation for the highest price in last 52 weeks. 52W-H
Volume DetailsDataList Volume
Symbol DetailsHeadline The stocks full name. Used as a placeholder here. Symbol
1 Y ChartTimeRangeBar Abbreviation for 'one year', the last 12 months 1 Y
1 D ChartTimeRangeBar Abbreviation for 'one day', short as possible 1 D
Low DetailsDataList Lowest price for current or last day Low
Cap DetailsDataList Abbreviation for the total value of shares owned by stockholders. Cap
P/E ratio DetailsDataList The price-earnings ratio, also known as P/E, or PER, is the ratio of a company's share price to the company's earnings per share. Keep as short as possible. P/E ratio
High DetailsDataList Highest price for current or last day High
Binary file modified pictures/stocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@

#include "FinancialmodelingApiKey.h"

const std::string FinancialmodelingApiKey::fApiKey = "@FINANCIAL_API_KEY@";

std::string FinancialmodelingApiKey::GetApiKey() {
return fApiKey;
}
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ class FinancialmodelingApiKey {
static std::string GetApiKey();

private:
static const std::string fApiKey;
inline static const std::string fApiKey = "@FINANCIAL_API_KEY@";
};


7 changes: 6 additions & 1 deletion source/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -3,14 +3,19 @@
#include "DetailsView.h"
#include "stocksPanel/SearchFieldControl.h"
#include <Application.h>
#include <Catalog.h>
#include <InterfaceKit.h>
#include <LayoutBuilder.h>
#include "utils/EscapeCancelFilter.h"
#include <Window.h>
#include <private/netservices2/NetServicesDefs.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "MainWindow"


MainWindow::MainWindow()
: BWindow(BRect(100, 100, 500, 400), "Stocks", B_TITLED_WINDOW,
: BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_SYSTEM_NAME("Stocks"), B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS),
fQuoteResultHandler(new QuoteResultHandler()) {

29 changes: 21 additions & 8 deletions source/gui/chartView/ChartTimeRangeBar.cpp
Original file line number Diff line number Diff line change
@@ -4,9 +4,14 @@

#include "ChartTimeRangeBar.h"

#include <Catalog.h>
#include <LayoutBuilder.h>
#include "Button.h"

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ChartTimeRangeBar"


ChartTimeRangeBar::ChartTimeRangeBar() :
BView(BRect(), "chartTimeRangeBar", B_FOLLOW_ALL, B_WILL_DRAW),
fListOfButtons(new std::list<BButton *>()) {
@@ -19,18 +24,26 @@ ChartTimeRangeBar::~ChartTimeRangeBar() {

void
ChartTimeRangeBar::InitTabs() {
BButton *oneDayButton = createButton("1 D", new BMessage(TimeRange::M_DAY));
BButton *oneDayButton = createButton(B_TRANSLATE_COMMENT("1 D", "Abbreviation for 'one day', short as possible"),
new BMessage(TimeRange::M_DAY));
oneDayButton->SetValue(B_CONTROL_ON);

BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0)
.Add(oneDayButton)
.Add(createButton("1 W", new BMessage(TimeRange::M_WEEK)))
.Add(createButton("1 M", new BMessage(TimeRange::M_MONTH)))
.Add(createButton("3 M", new BMessage(TimeRange::M_THREE_MONTH)))
.Add(createButton("6 M", new BMessage(TimeRange::M_SIX_MONTH)))
.Add(createButton("1 Y", new BMessage(TimeRange::M_YEAR)))
.Add(createButton("2 Y", new BMessage(TimeRange::M_TWO_YEARS)))
.Add(createButton("5 Y", new BMessage(TimeRange::M_FIVE_YEARS)));
.Add(createButton(B_TRANSLATE_COMMENT("1 W", "Abbreviation for 'one Week'"),
new BMessage(TimeRange::M_WEEK)))
.Add(createButton(B_TRANSLATE_COMMENT("1 M", "Abbreviation for 'one month'"),
new BMessage(TimeRange::M_MONTH)))
.Add(createButton(B_TRANSLATE_COMMENT("3 M", "Abbreviation for 'three months'"),
new BMessage(TimeRange::M_THREE_MONTH)))
.Add(createButton(B_TRANSLATE_COMMENT("6 M", "Abbreviation for 'six months'"),
new BMessage(TimeRange::M_SIX_MONTH)))
.Add(createButton(B_TRANSLATE_COMMENT("1 Y", "Abbreviation for 'one year', the last 12 months"),
new BMessage(TimeRange::M_YEAR)))
.Add(createButton(B_TRANSLATE_COMMENT("2 Y", "Abbreviation for 'two years'"),
new BMessage(TimeRange::M_TWO_YEARS)))
.Add(createButton(B_TRANSLATE_COMMENT("5 Y", "Abbreviation for '5 years', the longest possible period"),
new BMessage(TimeRange::M_FIVE_YEARS)));
}

BButton *
4 changes: 4 additions & 0 deletions source/gui/chartView/ChartView.cpp
Original file line number Diff line number Diff line change
@@ -2,12 +2,16 @@
// Created by Thorsten Claus on 10.07.23.
//

#include <Catalog.h>
#include <NetServicesDefs.h>
#include "ChartView.h"
#include "Portfolio.h"
#include "TimeRange.h"
#include "ApiBuilder.h"

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ChartView"

ChartView::ChartView() :
BView(BRect(), "chartView", B_FOLLOW_ALL, B_WILL_DRAW),
fTimeRange(TimeRange::M_DAY),
4 changes: 4 additions & 0 deletions source/gui/chartView/DetailsChart.cpp
Original file line number Diff line number Diff line change
@@ -2,9 +2,13 @@
// Created by Thorsten Claus on 01.05.23.
//

#include <Catalog.h>
#include <LayoutBuilder.h>
#include "DetailsChart.h"

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "DetailsChart"

DetailsChart::DetailsChart() :
BView(BRect(), "detailsChartView", B_FOLLOW_ALL, B_WILL_DRAW) {
InitView();
Loading