Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xDEEVx authored Nov 1, 2023
1 parent 9ec396f commit b3c10e3
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

qmake pomodoro.pro
make
11 changes: 11 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.setStyleSheet( " background-color: #303030; " );
mainWindow.show();
return app.exec();
}
96 changes: 96 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "mainwindow.h"
#include <QFont>
#include <QPalette>
#include <QPushButton>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle("~ pomodoro ~");
setFixedSize(250, 120);

titleLabel = new QLabel("POMODORO", this);
titleLabel->setGeometry(0, 0, 250, 50);
titleLabel->setAlignment(Qt::AlignCenter);
titleLabel->setFont(QFont("SF Pro Display Black", 30));
titleLabel->setStyleSheet( " color: #ffffff; " );

progressBar = new QProgressBar(this);
progressBar->setGeometry(10, 50, 230, 25);
progressBar->setStyleSheet( "color: #ffffff; selection-color: #000000; gridline-color: #393939; background-color: #393939; selection-background-color: #ffffff;" );

timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateTimer()));

startButton = new QPushButton("START", this);
startButton->setGeometry(10, 80, 100, 30);
connect(startButton, SIGNAL(clicked()), this, SLOT(startPomodoro()));
startButton->setStyleSheet( " background-color: #393939; color: #ffffff; border-color: #393939; alternate-background-color: #393939;" );

stopButton = new QPushButton("STOP", this);
stopButton->setGeometry(140, 80, 100, 30);
connect(stopButton, SIGNAL(clicked()), timer, SLOT(stop()));
stopButton->setStyleSheet( " background-color: #393939; color: #ffffff; border-color: #393939; alternate-background-color: #393939;" );

timeLeft = 25 * 60;
isPomodoro = true;
}

MainWindow::~MainWindow()
{
}

void MainWindow::startPomodoro()
{
timeLeft = 25 * 60;
progressBar->setRange(0, timeLeft);
progressBar->setValue(timeLeft);
titleLabel->setText("POMODORO");
titleLabel->setStyleSheet( " color: #ff3438; " );
startButton->setText("RESTART");
timer->start(1000);
}

void MainWindow::startBreak()
{
timeLeft = 5 * 60;
progressBar->setRange(0, timeLeft);
progressBar->setValue(timeLeft);
titleLabel->setText("BREAK");
titleLabel->setStyleSheet( " color: #5fe053; " );
setWindowTitle("~ break ~");
timer->start(1000);
}

void MainWindow::updateTimer()
{
if (timeLeft > 0) {
timeLeft--;
progressBar->setValue(timeLeft);

int minutes = timeLeft / 60;
int seconds = timeLeft % 60;

QString timeString = QString("%1:%2").arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0'));
titleLabel->setText(timeString);
} else {
timer->stop();
if (isPomodoro) {
isPomodoro = false;
startBreak();
} else {
isPomodoro = true;
titleLabel->setText("POMODORO");
}
}
}

void MainWindow::stop()
{
titleLabel->setText("POMODORO");
setWindowTitle("pomodoro");
timeLeft=0;
progressBar->setValue(0);
isPomodoro = false;
}
36 changes: 36 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QProgressBar>
#include <QTimer>
#include <QMessageBox>

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();

private slots:
void startPomodoro();
void updateTimer();
void startBreak();
void stop();

private:
QLabel *titleLabel;
QProgressBar *progressBar;
QTimer *timer;
QMessageBox *notificationwork;
QMessageBox *notificationpause;
int timeLeft;
bool isPomodoro;
QPushButton *startButton;
QPushButton *stopButton;
};

#endif // MAINWINDOW_H
54 changes: 54 additions & 0 deletions mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>249</width>
<height>223</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset theme="clock"/>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>50</x>
<y>40</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(239, 239, 239);
background-color: rgb(40, 40, 40);
alternate-background-color: rgb(36, 36, 36);
border-color: rgb(40, 40, 40);</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>249</width>
<height>19</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
24 changes: 24 additions & 0 deletions pomodoro.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
main.cpp \
mainwindow.cpp

HEADERS += \
mainwindow.h

FORMS += \
mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

0 comments on commit b3c10e3

Please sign in to comment.