The Block Clock #220

Manually merged
johnny9 merged 6 commits from the-block-clock into main 2023-01-29 15:42:22 +00:00 AGit
johnny9 commented 2023-01-19 23:19:28 +00:00 (Migrated from github.com)

This is a continuation of #148. The goal of this PR is to get the working features from #148 merged in using a QQuickPainterItem implementation of the dial instead of the javascript canvas. Connection state as well as the animating icon will be implemented in a later PR. Refactoring and clean up from the removal of the Canvas code still remains.

Windows
Intel macOS
Apple Silicon macOS
ARM64 Android

This is a continuation of #148. The goal of this PR is to get the working features from #148 merged in using a QQuickPainterItem implementation of the dial instead of the javascript canvas. Connection state as well as the animating icon will be implemented in a later PR. Refactoring and clean up from the removal of the Canvas code still remains. [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/220) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/220) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/220) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/220)
johnny9 commented 2023-01-19 23:27:31 +00:00 (Migrated from github.com)

Update from 90469cb to e9b5dd:

  • Replace tabs with spaces
Update from[ 90469cb ](https://github.com/bitcoin-core/gui-qml/commit/90469cb85211ecf3933602d33712eb95c89f2838)to[ e9b5dd](https://github.com/bitcoin-core/gui-qml/commit/e9b5ddd27596b647f7f56ef72302bcba3771a9e8): - Replace tabs with spaces
johnny9 commented 2023-01-19 23:54:08 +00:00 (Migrated from github.com)

Update branch from e9b5ddd to 96e47f8:

  • Fix painting of last block. index 0 of timeRatioList is actually the current time.
Update branch from[ e9b5ddd ](https://github.com/bitcoin-core/gui-qml/commit/e9b5ddd27596b647f7f56ef72302bcba3771a9e8)to 96e47f8: - Fix painting of last block. index 0 of timeRatioList is actually the current time.
johnny9 commented 2023-01-20 01:26:04 +00:00 (Migrated from github.com)

Update from 96e47f8 to 63792bf:

  • Fix Makefile includes
Update from[ 96e47f8 ](https://github.com/bitcoin-core/gui-qml/commit/96e47f8242c6be0dce8e4235bfdff483d4fdf586)to[ 63792bf](https://github.com/bitcoin-core/gui-qml/commit/63792bfca32b3327aecd0b9577c24fd0f175ccef): - Fix Makefile includes
johnny9 commented 2023-01-20 02:42:42 +00:00 (Migrated from github.com)

Update branch from 37b6257 to 8515fdf:

  • Added comment for calculating the "gap" between painted blocks.
Update branch from[ 37b6257 ](https://github.com/bitcoin-core/gui-qml/commit/37b6257bd3f4951d18cb323a8fc06b8423a0a211)to 8515fdf: - Added comment for calculating the "gap" between painted blocks.
johnny9 commented 2023-01-20 13:53:32 +00:00 (Migrated from github.com)

I noticed that these changes require the QtGraphicalEffects module (qml-module-graphicaleffects ubuntu package). I'll likely have to update the depends to include that module or change how the icon is forced into a specific color. Looking for an opinion one way or the other.

I noticed that these changes require the QtGraphicalEffects module (qml-module-graphicaleffects ubuntu package). I'll likely have to update the depends to include that module or change how the icon is forced into a specific color. Looking for an opinion one way or the other.
johnny9 (Migrated from github.com) reviewed 2023-01-21 15:44:09 +00:00
johnny9 (Migrated from github.com) commented 2023-01-21 15:44:09 +00:00

This line causes an abort during sync. Need to root cause and fix before merge.

This line causes an abort during sync. Need to root cause and fix before merge.
johnny9 (Migrated from github.com) reviewed 2023-01-21 15:47:23 +00:00
johnny9 (Migrated from github.com) commented 2023-01-21 15:47:23 +00:00

Ok, I think i see it. During sync there are no blocks in the list so erase call in that range is invalid.

Ok, I think i see it. During sync there are no blocks in the list so erase call in that range is invalid.
jarolrod (Migrated from github.com) reviewed 2023-01-23 16:41:32 +00:00
jarolrod (Migrated from github.com) left a comment

concept ack

concept ack
jarolrod (Migrated from github.com) reviewed 2023-01-25 05:07:54 +00:00
jarolrod (Migrated from github.com) left a comment

Let's squash some of the history to have a clean commit record, but also I'm seeing some slight misalignment with the design file.

Below, the more visible layer is the design file, and below that is this PR on signet (hence diff block heights). Looks like the block height, the words "Blocktime" and peers indicator should be a bit higher up. Also fine with leaving this fixup for a follow-up!

Screen Shot 2023-01-25 at 12 05 42 AM
Let's squash some of the history to have a clean commit record, but also I'm seeing some slight misalignment with the design file. Below, the more visible layer is the design file, and below that is this PR on signet (hence diff block heights). Looks like the block height, the words "Blocktime" and peers indicator should be a bit higher up. Also fine with leaving this fixup for a follow-up! <img width="786" alt="Screen Shot 2023-01-25 at 12 05 42 AM" src="https://user-images.githubusercontent.com/23396902/214484384-fa12d111-5441-490a-ba45-08aaa7380238.png">
johnny9 commented 2023-01-27 23:09:24 +00:00 (Migrated from github.com)

Update branch from 8ecfae6 to 76a504e:

  • Squashed all BlockClock control commits into one
Update branch from[ 8ecfae6 ](https://github.com/bitcoin-core/gui-qml/commit/8ecfae6227047c66242881c4b50d5527bbf5fc3f)to 76a504e: - Squashed all BlockClock control commits into one
johnny9 commented 2023-01-28 15:57:19 +00:00 (Migrated from github.com)

Update branch from 76a504e to 2e5a0d8:

  • Adjusted alignment of labels to better match the figma spec

Screenshot from 2023-01-28 10-37-08

Update branch from[ 76a504e ](https://github.com/bitcoin-core/gui-qml/commit/76a504e826482a5ff62cffeea4ec9863d2a746d9)to[ 2e5a0d8](https://github.com/bitcoin-core/gui-qml/commit/2e5a0d83c2bcfdfc878a46b2ce1d23d1ceb74b8d): - Adjusted alignment of labels to better match the figma spec ![Screenshot from 2023-01-28 10-37-08](https://user-images.githubusercontent.com/985648/215276307-a1675e9e-de17-4aec-88fd-f909fa6eddff.png)
johnny9 commented 2023-01-28 16:25:09 +00:00 (Migrated from github.com)

Update. Remove a missed trailing whitespace

Update. Remove a missed trailing whitespace
johnny9 commented 2023-01-28 18:11:10 +00:00 (Migrated from github.com)

Update from 3fd696d to 33eb4af:

  • Fixed potential initialization error in ChainModel, possible root cause of an issue Jarol discovered with the dial not lining up with 12 o'clock.
Update from[ 3fd696d ](https://github.com/bitcoin-core/gui-qml/commit/3fd696d6036fe737bf1c9dbb8427cc838d4dda7a)to 33eb4af: - Fixed potential initialization error in ChainModel, possible root cause of an issue Jarol discovered with the dial not lining up with 12 o'clock.
jarolrod (Migrated from github.com) reviewed 2023-01-28 20:55:26 +00:00
jarolrod (Migrated from github.com) left a comment

Almost there, just one change needed.

Additionally, i'd structure the commits something similar to this: https://github.com/jarolrod/gui-qml/tree/block-clock-review

But not necessary.

Almost there, just one change needed. Additionally, i'd structure the commits something similar to this: https://github.com/jarolrod/gui-qml/tree/block-clock-review But not necessary.
jarolrod (Migrated from github.com) commented 2023-01-28 20:54:53 +00:00

Per developer notes

Class names, function names, and method names are UpperCamelCase (PascalCase). Do not prefix class names with C. See Internal interface naming style for an exception to this convention.

Per [developer notes](https://github.com/bitcoin-core/gui-qml/blob/main/doc/developer-notes.md#coding-style-c) > Class names, function names, and method names are UpperCamelCase (PascalCase). Do not prefix class names with C. See Internal interface naming style for an exception to this convention.
jarolrod (Migrated from github.com) commented 2023-01-28 20:55:22 +00:00

Why should this be a control, and the block clock dial a component?

Why should this be a control, and the block clock dial a component?
johnny9 (Migrated from github.com) reviewed 2023-01-28 21:04:46 +00:00
johnny9 (Migrated from github.com) commented 2023-01-28 21:04:46 +00:00

This item can take focus and accept input. The dial just renders the blocks.

This item can take focus and accept input. The dial just renders the blocks.
johnny9 (Migrated from github.com) reviewed 2023-01-28 21:14:42 +00:00
johnny9 (Migrated from github.com) commented 2023-01-28 21:14:42 +00:00

Thanks, will fix this.

Thanks, will fix this.
johnny9 (Migrated from github.com) reviewed 2023-01-28 21:32:05 +00:00
johnny9 (Migrated from github.com) commented 2023-01-28 21:32:05 +00:00

Actually not really convinced of this. Can see it living in components and making sense too

Actually not really convinced of this. Can see it living in components and making sense too
johnny9 (Migrated from github.com) reviewed 2023-01-29 01:48:37 +00:00
johnny9 (Migrated from github.com) commented 2023-01-29 01:48:37 +00:00

Really liked how you structured the commits in that branch. Going to use that.

Really liked how you structured the commits in that branch. Going to use that.
johnny9 commented 2023-01-29 02:12:30 +00:00 (Migrated from github.com)

Update branch to 6701ad2:

  • Fixed code style issue in blockclock.cpp/.h
  • Moved BlockClock.qml to components
  • Split BlockClock commit up to clarify history
Update branch to 6701ad2: - Fixed code style issue in blockclock.cpp/.h - Moved BlockClock.qml to components - Split BlockClock commit up to clarify history
jarolrod (Migrated from github.com) approved these changes 2023-01-29 06:21:47 +00:00
jarolrod (Migrated from github.com) left a comment

ACK 6701ad2438

This works, with improvements to be made in follow-ups

ACK 6701ad24382ae4a23d3e55c8d952df2ca061e737 This works, with improvements to be made in follow-ups
jarolrod (Migrated from github.com) commented 2023-01-29 06:07:49 +00:00

could add, since the paused state is implemented

        anchors.fill: dial
        cursorShape: Qt.PointingHandCursor
could add, since the paused state is implemented ```suggestion anchors.fill: dial cursorShape: Qt.PointingHandCursor ```
jarolrod (Migrated from github.com) commented 2023-01-29 04:53:23 +00:00

I'd prefer all caps short names for states. in the codebase like, can be changed afterwards

  • "IBD"
  • "BLOCKCLOCK"
  • "PAUSED"
  • "CONNECTING"
I'd prefer all caps short names for states. in the codebase like, can be changed afterwards - "IBD" - "BLOCKCLOCK" - "PAUSED" - "CONNECTING"
jarolrod (Migrated from github.com) commented 2023-01-29 05:26:16 +00:00

I think this could be simplified into:

QRectF BlockClockDial::getBoundsForPen(const QPen & pen)
{
    const QRectF bounds = boundingRect();
    QRectF rect = bounds.marginsRemoved(QMarginsF(pen.widthF() / 2.0, pen.widthF() / 2.0, pen.widthF() / 2.0, pen.widthF() / 2.0));
    return rect.toAlignedRect();
}
This PR My Suggestion
Screen Shot 2023-01-29 at 12 23 42 AM Screen Shot 2023-01-29 at 12 24 12 AM
I think this could be simplified into: ```cpp QRectF BlockClockDial::getBoundsForPen(const QPen & pen) { const QRectF bounds = boundingRect(); QRectF rect = bounds.marginsRemoved(QMarginsF(pen.widthF() / 2.0, pen.widthF() / 2.0, pen.widthF() / 2.0, pen.widthF() / 2.0)); return rect.toAlignedRect(); } ``` | This PR | My Suggestion | | ------- | ------------- | | <img width="246" alt="Screen Shot 2023-01-29 at 12 23 42 AM" src="https://user-images.githubusercontent.com/23396902/215306844-a1ad5191-0873-46ed-b738-3cd558056df8.png"> | <img width="246" alt="Screen Shot 2023-01-29 at 12 24 12 AM" src="https://user-images.githubusercontent.com/23396902/215306850-31fa098d-0964-4901-8460-f84441063530.png"> |
jarolrod (Migrated from github.com) commented 2023-01-29 02:41:36 +00:00

in a follow-up all of these colors should be defined in our theme.qml, because the colors would actually be slightly different when on dark or light mode. We'll circle back with @GBKS about these values.

in a follow-up all of these colors should be defined in our theme.qml, because the colors would actually be slightly different when on dark or light mode. We'll circle back with @GBKS about these values.
jarolrod (Migrated from github.com) commented 2023-01-29 05:09:26 +00:00

does this need to be calculated each time the paintBlocks function is called, or can it be cached when the object is constructed?

does this need to be calculated each time the paintBlocks function is called, or can it be cached when the object is constructed?
jarolrod (Migrated from github.com) commented 2023-01-29 05:07:21 +00:00

can this be initialized outside of the loop, then have its properties updated?

can this be initialized outside of the loop, then have its properties updated?
jarolrod (Migrated from github.com) commented 2023-01-29 06:12:20 +00:00

This function is pretty confusing in general, we'll heavily change this in follow-ups

This function is pretty confusing in general, we'll heavily change this in follow-ups
jarolrod (Migrated from github.com) commented 2023-01-29 06:20:01 +00:00

should probably do an early test on new_progress to make sure it's a valid value

should probably do an early test on new_progress to make sure it's a valid value
jarolrod (Migrated from github.com) commented 2023-01-29 06:14:18 +00:00

starting from 1, isn't it skipping the first value in the list?

starting from 1, isn't it skipping the first value in the list?
jarolrod (Migrated from github.com) commented 2023-01-29 06:17:13 +00:00

but currentTime was set in milliseconds in line 33, now we're doing math with seconds values?

but `currentTime` was set in milliseconds in line 33, now we're doing math with seconds values?
jarolrod (Migrated from github.com) commented 2023-01-29 06:18:30 +00:00

not sure why we're removing the first element here; but in follow-ups its better if this is a queue, instead of a vector that we manually remove elements from

not sure why we're removing the first element here; but in follow-ups its better if this is a queue, instead of a vector that we manually remove elements from
Sign in to join this conversation.
No description provided.