2025-02-24 10:17:46 +03:00
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
StopWatch-tr Türkçe bir kronometre uygulamasıdır. Geliştirdikçe farklı diller de gelebilir.
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2025 Emrullah Enis Çetinkaya and contributors
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
2025-02-19 11:55:03 +03:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "./ui_mainwindow.h"
|
2025-02-23 18:07:34 +03:00
|
|
|
|
|
2025-02-19 11:55:03 +03:00
|
|
|
|
int pause_start=0;
|
|
|
|
|
int second=0,minute=0,hour=0;
|
2025-02-19 22:09:37 +03:00
|
|
|
|
QTime current_time=QTime::currentTime();
|
|
|
|
|
QDate today=QDate::currentDate();
|
2025-02-19 11:55:03 +03:00
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
, ui(new Ui::MainWindow)
|
|
|
|
|
{
|
2025-02-19 22:09:37 +03:00
|
|
|
|
|
2025-02-19 11:55:03 +03:00
|
|
|
|
timer=new QTimer(this);
|
2025-02-19 22:09:37 +03:00
|
|
|
|
timer2=new QTimer(this);
|
|
|
|
|
timer2->start(1000);
|
|
|
|
|
ui->setupUi(this);
|
2025-02-23 18:07:34 +03:00
|
|
|
|
timer_window=new second_window(this);
|
2025-02-19 22:09:37 +03:00
|
|
|
|
|
2025-02-23 18:07:34 +03:00
|
|
|
|
connect(timer_window,&second_window::main_window_show,this,&MainWindow::main_window_show2);
|
2025-02-19 11:55:03 +03:00
|
|
|
|
connect(timer,&QTimer::timeout,this,&MainWindow::timer_func);
|
2025-02-19 22:09:37 +03:00
|
|
|
|
connect(timer2,&QTimer::timeout,this,&MainWindow::main_timer_func);
|
2025-02-23 18:07:34 +03:00
|
|
|
|
connect(ui->action_menu_timer,&QAction::triggered,this,&MainWindow::timer_window_open);
|
2025-02-19 11:55:03 +03:00
|
|
|
|
ui->start_pause->setShortcut(QKeySequence(Qt::Key_Space));
|
|
|
|
|
ui->reset->setShortcut(QKeySequence(Qt::Key_R));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_start_pause_clicked()
|
|
|
|
|
{
|
|
|
|
|
if(pause_start){
|
|
|
|
|
timer->stop();
|
|
|
|
|
ui->start_pause->setIcon(QIcon(":/icons/icons/play(1).svg"));
|
|
|
|
|
pause_start=0;
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->statusbar->showMessage("Sayaç durduruldu.",1500);
|
2025-02-19 11:55:03 +03:00
|
|
|
|
}
|
|
|
|
|
else if(pause_start==0){
|
|
|
|
|
timer->start(1000);
|
|
|
|
|
ui->start_pause->setIcon(QIcon(":/icons/icons/pause(2).svg"));
|
|
|
|
|
pause_start=1;
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->statusbar->showMessage("Sayaç başlatıldı.",1500);
|
2025-02-19 11:55:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::timer_func(){
|
|
|
|
|
second++;
|
|
|
|
|
if(second==60){
|
|
|
|
|
minute++;
|
|
|
|
|
second=0;
|
|
|
|
|
if(minute==60){
|
|
|
|
|
hour++;
|
|
|
|
|
minute=0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(hour==0){
|
|
|
|
|
if(minute==0){
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->label_time->setText(QString("%1").arg(second));
|
2025-02-19 11:55:03 +03:00
|
|
|
|
}
|
|
|
|
|
else {
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->label_time->setText(QString("%1:%2").arg(minute).arg(second));
|
2025-02-19 11:55:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->label_time->setText(QString("%1:%2:%3").arg(hour).arg(minute).arg(second));
|
2025-02-19 11:55:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_reset_clicked()
|
|
|
|
|
{
|
|
|
|
|
timer->stop();
|
|
|
|
|
second=0;
|
|
|
|
|
minute=0;
|
|
|
|
|
hour=0;
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->label_time->setText(QString("%1").arg(second));
|
2025-02-19 11:55:03 +03:00
|
|
|
|
pause_start=0;
|
|
|
|
|
ui->start_pause->setIcon(QIcon(":/icons/icons/play(1).svg"));
|
2025-02-19 22:09:37 +03:00
|
|
|
|
ui->statusbar->showMessage("Sayaç sıfırlandı.",1500);
|
2025-02-19 11:55:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_about_triggered()
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::about(this,"Hakkında","Bu uygulama <b>Emrullah Enis Çetinkaya</b> tarafından"
|
|
|
|
|
" QT ile açık kaynak olarak geliştirilmektedir.<br></br>"
|
|
|
|
|
"<a href=\"https://youtube.com/@teknolojimuhafizi?feature=shared\">Youtube sayfası</a>");
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 22:09:37 +03:00
|
|
|
|
void MainWindow::main_timer_func(){
|
|
|
|
|
current_time=QTime::currentTime();
|
|
|
|
|
ui->label_main_time->setText(current_time.toString("HH:mm:ss"));
|
|
|
|
|
ui->label_main_date->setText(today.toString("dd.MM.yyyy"));
|
|
|
|
|
}
|
2025-02-23 18:07:34 +03:00
|
|
|
|
void MainWindow::timer_window_open(bool){
|
|
|
|
|
timer_window->show();
|
|
|
|
|
this->hide();
|
|
|
|
|
}
|
|
|
|
|
void MainWindow::main_window_show2(){
|
|
|
|
|
this->show();
|
|
|
|
|
timer_window->hide();
|
|
|
|
|
}
|