Skip to content

Commit

Permalink
Sequencer
Browse files Browse the repository at this point in the history
* Add tooltip tray icon

* Add, remove, copy, drag items in sequence list

* Add presets

* Shitty drag and drop

* Add current list saving and loading

* Randomize colors

* Move sequence model to root folder

* Bind new model to timer and dials

* add color selector

* repair master model add and copy

* reload colors order on change

* Refactor colors model

* Restore image-based tray icon

* Add external preset drop

* add json file drag

* Fix drag and drop glitches

* Remove all unused properties from drag

* Refactor sequence view. Add QML native header and footer items

* Bring back notification system

* Add split highlighting

* Fix next item creation

* Remove special pomodoro model

* Remove cpp notification system

* Fix notification text on in global timer mode

* Block sequence editing while timer is running

* Minor appearance tweaks

* Add resource files

* Fix notify on setting

* Resolve some user experience issues

* Add custom font

* Add checkboxes to preferences

* Add text input validation
  • Loading branch information
vladtsm authored Nov 28, 2019
1 parent b6cd9ab commit de2492e
Show file tree
Hide file tree
Showing 77 changed files with 1,759 additions and 785 deletions.
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ include_directories(
file(GLOB SRCS_TOP ${PROJECT_SOURCE_DIR}/*.cpp)

file( GLOB_RECURSE SRCS_NESTED
${PROJECT_SOURCE_DIR}/notifications/*.cpp
)

file( GLOB_RECURSE HDRS
${PROJECT_SOURCE_DIR}/notifications/*.h
)

file( GLOB_RECURSE QRCS *.qrc)
Expand Down
96 changes: 91 additions & 5 deletions src/Components/Colors.qml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import QtQuick 2.13

Item {
ListModel{
id: colors

property color bgDark: "#282828"
property color bgLight: "#F3F3F3"
// property color bgLight: "#EFEEE9"

property color fakeDark: "#4F5655"
property color fakeLight: "#D0CBCC"
// property color fakeLight: "#CEC9B6"

property color accentDark: "#859391"
property color accentLight: "#999394"
// property color accentLight: "#968F7E"

property color accentTextDark: "#fff"
property color accentTextLight: "#0A1A39"
// property color accentTextLight: "#000"

property color pomodoroLight: "#E26767"
property color pomodoroDark: "#C23E3E"
Expand All @@ -26,4 +23,93 @@ Item {

property color longBreakLight: "#6F85CF"
property color longBreakDark: "#5069BE"

ListElement{
name: "bg"
night: "#282828"
day: "#F3F3F3"
}

ListElement{
name: "dark"
night: "#fff"
day: "#3E393A"
}
ListElement{
name: "mid"
night: "#859391"
day: "#999394"
}
ListElement{
name: "light"
night: "#4F5655"
day: "#D0CBCC"
}
ListElement{
name: "mid gray"
night: "#878681"
day: "#878681"
}

// Colors from index 5


ListElement{
name: "red"
night: "#C23E3E"
day: "#E26767"
}
ListElement{
name: "orange"
night: "#BF733D"
day: "#E09B49"
}
ListElement{
name: "yellow"
night: "#C8AC4B"
day: "#E7D054"
}
ListElement{
name: "green"
night: "#5BB44C"
day: "#7DCF6F"
}
ListElement{
name: "cyan"
night: "#339BA7"
day: "#59BDC9"
}
ListElement{
name: "blue"
night: "#5069BE"
day: "#6F85CF"
}
ListElement{
name: "violet"
night: "#A647BE"
day: "#B66FCF"
}

function list(){
var colors = []
for(var i= 5; i<count; i++){
colors.push(get(i).name)
}
return colors
}

function getColor(color) {
let colorIndex = 0
for(var i= 0; i<count; i++){
if(color === get(i).name){
colorIndex = i
break;
} else if(!color) {
colorIndex = 0
break;
}
}
if (appSettings.darkMode){ return get(colorIndex).night }
else { return get(colorIndex).day }
}
}
8 changes: 5 additions & 3 deletions src/Components/DarkModeButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ Item {

property string iconDark: "../assets/img/sun.svg"
property string iconLight: "../assets/img/moon.svg"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
anchors.topMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0

source: appSettings.darkMode ? iconDark : iconLight

ColorOverlay{
id: modeSwitchOverlay
anchors.fill: parent
source: parent
color: appSettings.darkMode ? colors.fakeDark : colors.fakeLight
color: colors.getColor('light')
antialiasing: true
}
}
Expand Down
72 changes: 20 additions & 52 deletions src/Components/Dials.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Canvas {

ctx.beginPath();
ctx.lineWidth = stroke;
ctx.strokeStyle = appSettings.darkMode ? colors.fakeDark : colors.fakeLight;
ctx.strokeStyle = colors.getColor("light")
ctx.setLineDash([dash / 2, space, dash / 2, 0]);
ctx.arc(centreX, centreY, (diameter - stroke) / 2 , 1.5 * Math.PI, 3.5 * Math.PI);
ctx.stroke();
Expand All @@ -60,15 +60,15 @@ Canvas {

ctx.beginPath();
ctx.lineWidth = calibrationWidth;
ctx.strokeStyle = appSettings.darkMode ? colors.accentDark : colors.accentLight;
ctx.strokeStyle = colors.getColor('mid');
ctx.setLineDash([dash2 / 2, space2, dash2 / 2, 0]);
ctx.arc(centreX, centreY, (diameter2 - calibrationWidth) / 2 , 1.5 * Math.PI, 3.5 * Math.PI);
ctx.stroke();

} else if (devisions) {
ctx.beginPath();
ctx.lineWidth = calibrationWidth;
ctx.strokeStyle = appSettings.darkMode ? colors.fakeDark : colors.fakeLight;
ctx.strokeStyle = colors.getColor('light');
ctx.setLineDash([1, 0]);
ctx.arc(centreX, centreY, (diameter2 - calibrationWidth) / 2 , 1.5 * Math.PI, 3.5 * Math.PI);
ctx.stroke();
Expand All @@ -82,83 +82,51 @@ Canvas {
function mainDialTurn(){
var t;
for(t = mainDialTurns; t > 0; t--){
dial(width - (t - 1) * (mainTurnsWidth * 2 + mainTurnsPadding) , mainTurnsWidth, appSettings.darkMode ? colors.fakeDark : colors.fakeLight, 0, 3600)
dial(width - (t - 1) * (mainTurnsWidth * 2 + mainTurnsPadding) , mainTurnsWidth, colors.getColor('light'), 0, 3600)
}

dial(mainDialDiameter, mainWidth, appSettings.darkMode ? colors.accentDark : colors.accentLight, 0, globalTimer.duration - (mainDialTurns * 3600))
tray.dialTime = globalTimer.duration * 3600 / durationSettings.timer
dial(mainDialDiameter, mainWidth, colors.getColor('mid'), 0, globalTimer.duration - (mainDialTurns * 3600))
}

mainDialTurn()


function getSplit(type){
let splitIncrement;
let splitColor;
let splitDuration;

switch (type) {
case "pomodoro":
splitDuration = durationSettings.pomodoro
splitIncrement = 3600 / durationSettings.pomodoro ;
splitColor = appSettings.darkMode ? colors.pomodoroDark : colors.pomodoroLight
break;
case "pause":
splitDuration = durationSettings.pause
splitIncrement = 3600 / durationSettings.pause;
splitColor = appSettings.darkMode ? colors.shortBreakDark : colors.shortBreakLight
break;
case "break":
splitDuration = durationSettings.breakTime
splitIncrement = 3600 / durationSettings.breakTime;
splitColor = appSettings.darkMode ? colors.longBreakDark : colors.longBreakLight
break;
default:
throw "can't calculate split time values";
}
return {duration: splitDuration, increment: splitIncrement, color: splitColor};
}


if (pomodoroQueue.infiniteMode){
calibration(width, fakeWidth, getSplit(pomodoroQueue.first().type).duration / 60)
} else if (!pomodoroQueue.infiniteMode && !appSettings.splitToSequence && !globalTimer.running && globalTimer.duration){
calibration(globalTimer.duration > 0 ? fakeDialDiameter : width, fakeWidth, 12)
} else if (!pomodoroQueue.infiniteMode && appSettings.splitToSequence && globalTimer.duration){
calibration(width, fakeWidth, masterModel.get(pomodoroQueue.first().id).duration / 60)
} else if (!pomodoroQueue.infiniteMode && !globalTimer.running && globalTimer.duration){
calibration(globalTimer.duration > 0 ? fakeDialDiameter : width, fakeWidth, 12)
} else {
calibration(globalTimer.duration > 0 ? fakeDialDiameter : width, fakeWidth, 60)
}

if (pomodoroQueue.infiniteMode && globalTimer.running){
if (pomodoroQueue.infiniteMode){

dial(width, fakeWidth,
getSplit(pomodoroQueue.first().type).color,
0, pomodoroQueue.first().duration * getSplit(pomodoroQueue.first().type).increment )
tray.dialTime = pomodoroQueue.first().duration * getSplit(pomodoroQueue.first().type).increment
} else if (!pomodoroQueue.infiniteMode && appSettings.splitToSequence && globalTimer.duration){
var i;
colors.getColor(masterModel.get(pomodoroQueue.get(0).id).color),
0, pomodoroQueue.first().duration * 3600 / masterModel.get(pomodoroQueue.first().id).duration )

} else if (!pomodoroQueue.infiniteMode && appSettings.splitToSequence ){

var splitVisibleEnd = 0;
var splitVisibleStart = 0;
var prevSplit;
var splitColor;
var prevSplit = 0
var splitIncrement = 3600 / globalTimer.duration

calibration(fakeDialDiameter, fakeWidth, calibrationGrades)

for(i = 0; i <= pomodoroQueue.count - 1; i++){
for(let i = 0; i <= pomodoroQueue.count - 1; i++){
i <= 0 ? prevSplit = 0 : prevSplit = pomodoroQueue.get(i-1).duration

splitVisibleStart = prevSplit + splitVisibleStart;
splitVisibleEnd = pomodoroQueue.get(i).duration + splitVisibleEnd;
splitColor = masterModel.get(pomodoroQueue.get(i).id).color

dial(fakeDialDiameter, fakeWidth, getSplit(pomodoroQueue.get(i).type).color,
dial(fakeDialDiameter, fakeWidth, colors.getColor(splitColor),
splitVisibleStart <= mainDialTurns * 3600 ? mainDialTurns * 3600 : splitVisibleStart,
splitVisibleEnd <= mainDialTurns * 3600 ? mainDialTurns * 3600 : splitVisibleEnd
)
}
} else if (!pomodoroQueue.infiniteMode && !appSettings.splitToSequence && globalTimer.duration && globalTimer.running){
dial(fakeDialDiameter, fakeWidth, appSettings.darkMode ? colors.fakeDark : colors.fakeLight,
0, (globalTimer.duration - Math.trunc(globalTimer.duration / 60) * 60) * 60 )
} else {
dial(fakeDialDiameter, fakeWidth, colors.getColor('light'), 0, globalTimer.duration - (mainDialTurns * 3600) )
}


Expand Down
78 changes: 78 additions & 0 deletions src/Components/ExternalDrop.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import QtQuick 2.0

Item{
id: externalDrop
anchors.fill: parent

property bool validFile: false

function loadContent(url){
var req = new XMLHttpRequest;
req.open("GET", url);
req.onreadystatechange = function() {
if (req.readyState === XMLHttpRequest.DONE) {
console.log(req.responseText)
masterModel.data = req.responseText
masterModel.load()
}
};
req.send();
}

Rectangle{
id: rectangle
visible: validFile
color: colors.getColor('bg')
radius: 3
border.color: colors.getColor('light')
border.width: 2
anchors.fill: parent

Text {
id: externalDropText
height: 150
color: colors.getColor("mid")
text: "Not valid file type"
clip: true
fontSizeMode: Text.Fit
anchors.right: parent.right
anchors.rightMargin: 50
anchors.left: parent.left
anchors.leftMargin: 50
font.pointSize: 26
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}

DropArea {
id: dropData
anchors.fill: parent
onEntered: {
externalDrop.validFile = true
drag.accept()
externalDropText.text = "Drop "+ window.title + " preset here"
}
onExited: {
externalDrop.validFile = false
}
onDropped: if (drop.hasText) {
if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) {
externalDrop.loadContent(drop.text)
drop.acceptProposedAction()
externalDrop.validFile = false
}
}

}

}



/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}D{i:2;anchors_width:447}
}
##^##*/
5 changes: 0 additions & 5 deletions src/Components/InfiniteScreen.qml

This file was deleted.

Loading

0 comments on commit de2492e

Please sign in to comment.