Zamanlayıcı için üçüncü pencere oluşturuldu

This commit is contained in:
Emrullah Enis Çetinkaya 2025-02-23 18:07:34 +03:00
parent 3491f8e91c
commit 197dca0646
10 changed files with 671 additions and 68 deletions

View file

@ -27,6 +27,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
MANUAL_FINALIZATION
${PROJECT_SOURCES}
images.qrc
second_window.h second_window.cpp second_window.ui
time_set_window.h time_set_window.cpp time_set_window.ui
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET kronometre APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR

View file

@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
int pause_start=0;
int second=0,minute=0,hour=0;
QTime current_time=QTime::currentTime();
@ -13,12 +14,12 @@ MainWindow::MainWindow(QWidget *parent)
timer2=new QTimer(this);
timer2->start(1000);
ui->setupUi(this);
timer_window=new second_window(this);
connect(timer_window,&second_window::main_window_show,this,&MainWindow::main_window_show2);
connect(timer,&QTimer::timeout,this,&MainWindow::timer_func);
connect(timer2,&QTimer::timeout,this,&MainWindow::main_timer_func);
connect(ui->action_menu_timer,&QAction::triggered,this,&MainWindow::timer_window_open);
ui->start_pause->setShortcut(QKeySequence(Qt::Key_Space));
ui->reset->setShortcut(QKeySequence(Qt::Key_R));
}
@ -97,3 +98,11 @@ void MainWindow::main_timer_func(){
ui->label_main_time->setText(current_time.toString("HH:mm:ss"));
ui->label_main_date->setText(today.toString("dd.MM.yyyy"));
}
void MainWindow::timer_window_open(bool){
timer_window->show();
this->hide();
}
void MainWindow::main_window_show2(){
this->show();
timer_window->hide();
}

View file

@ -6,6 +6,7 @@
#include "QMessageBox"
#include "QTime"
#include "QDate"
#include "second_window.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
@ -18,24 +19,22 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget *parent = nullptr);
void main_window_show2();
~MainWindow();
private slots:
void on_start_pause_clicked();
void on_reset_clicked();
void on_about_triggered();
void timer_window_open(bool checked);
private:
Ui::MainWindow *ui;
QTimer *timer,*timer2;
void main_timer_func();
void timer_func();
second_window *timer_window;
};
#endif // MAINWINDOW_H

View file

@ -32,6 +32,44 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_main_time">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 85, 0);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" rowspan="3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -132,45 +170,6 @@
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_main_date">
<property name="sizePolicy">
@ -196,30 +195,31 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_main_time">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<bold>true</bold>
</font>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 85, 0);</string>
</spacer>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="text">
<string/>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
@ -236,6 +236,8 @@
<property name="title">
<string>Araçlar</string>
</property>
<addaction name="action_menu_timer"/>
<addaction name="separator"/>
<addaction name="about"/>
</widget>
<addaction name="menuAra_lar"/>
@ -256,6 +258,11 @@
<string>Hakkında</string>
</property>
</action>
<action name="action_menu_timer">
<property name="text">
<string>Zamanlayıcı</string>
</property>
</action>
</widget>
<resources>
<include location="images.qrc"/>

45
second_window.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "second_window.h"
#include "ui_second_window.h"
#include "QTimer"
QString minute_variable=0;
QString hour_variable=0;
QString second_variable=0;
second_window::second_window(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::second_window)
{
ui->setupUi(this);
QTimer *timer;
timer=new QTimer();
third_window=new time_set_window(this);
connect(ui->stopwatch,&QAction::triggered,this,&second_window::main_window_show);
connect(ui->about,&QAction::triggered,this,&second_window::about_triggered);
connect(ui->time_set,SIGNAL(clicked()),this,SLOT(time_set_triggered()));
connect(third_window,SIGNAL(push_button_clicked()),this,SLOT(third_window_set()));
}
second_window::~second_window()
{
delete ui;
}
void second_window::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>");
}
void second_window::time_set_triggered(){
this->hide();
third_window->show();
}
void second_window::third_window_set(){
third_window->hide();
second_variable=third_window->line_edit_second_func();
minute_variable=third_window->line_edit_minute_func();
hour_variable=third_window->line_edit_hour_func();
//ui->label_time->setText();//buradan devam edilecek
this->show();
}

31
second_window.h Normal file
View file

@ -0,0 +1,31 @@
#ifndef SECOND_WINDOW_H
#define SECOND_WINDOW_H
#include <QMainWindow>
#include "QMessageBox"
#include "time_set_window.h"
namespace Ui {
class second_window;
}
class second_window : public QMainWindow
{
Q_OBJECT
public:
explicit second_window(QWidget *parent = nullptr);
void about_triggered();
~second_window();
signals:
void main_window_show();
private slots:
void time_set_triggered();
void third_window_set();
private:
Ui::second_window *ui;
time_set_window *third_window;
};
#endif // SECOND_WINDOW_H

314
second_window.ui Normal file
View file

@ -0,0 +1,314 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>second_window</class>
<widget class="QMainWindow" name="second_window">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>886</width>
<height>664</height>
</rect>
</property>
<property name="windowTitle">
<string>Zamanlayıcı</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_time">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="font">
<font>
<pointsize>100</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="start_pause">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/icons/icons/play(1).svg</normaloff>:/icons/icons/play(1).svg</iconset>
</property>
<property name="iconSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="reset">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/icons/icons/circle.svg</normaloff>:/icons/icons/circle.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="time_set">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>70</height>
</size>
</property>
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(85, 255, 127);</string>
</property>
<property name="text">
<string>Süreyi Ayarla</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_main_time">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 85, 0);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLabel" name="label_main_date">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 85, 0);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>886</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menu">
<property name="title">
<string>Araçlar</string>
</property>
<addaction name="stopwatch"/>
<addaction name="separator"/>
<addaction name="about"/>
</widget>
<addaction name="menu"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="stopwatch">
<property name="text">
<string>Kronometre</string>
</property>
</action>
<action name="about">
<property name="text">
<string>Hakkında</string>
</property>
</action>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

37
time_set_window.cpp Normal file
View file

@ -0,0 +1,37 @@
#include "time_set_window.h"
#include "ui_time_set_window.h"
time_set_window::time_set_window(QWidget *parent)
: QWidget(parent)
, ui(new Ui::time_set_window)
{
ui->setupUi(this);
setWindowTitle("Zamanı Ayarla");
setWindowFlags(Qt::Window);
connect(ui->pushButton_time_set,SIGNAL(clicked()),this,SIGNAL(push_button_clicked()));
}
time_set_window::~time_set_window()
{
delete ui;
}
QString time_set_window::line_edit_second_func()
{
return ui->lineEdit_second->text();
}
QString time_set_window::line_edit_minute_func()
{
return ui->lineEdit_minute->text();
}
QString time_set_window::line_edit_hour_func()
{
return ui->lineEdit_hour->text();
}
void time_set_window::line_edit_clear(){
ui->lineEdit_second->clear();
ui->lineEdit_hour->clear();
ui->lineEdit_minute->clear();
}

27
time_set_window.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef TIME_SET_WINDOW_H
#define TIME_SET_WINDOW_H
#include <QWidget>
namespace Ui {
class time_set_window;
}
class time_set_window : public QWidget
{
Q_OBJECT
public:
explicit time_set_window(QWidget *parent = nullptr);
~time_set_window();
QString line_edit_second_func();
QString line_edit_minute_func();
QString line_edit_hour_func();
void line_edit_clear();
signals:
void push_button_clicked();
private:
Ui::time_set_window *ui;
};
#endif // TIME_SET_WINDOW_H

132
time_set_window.ui Normal file
View file

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>time_set_window</class>
<widget class="QWidget" name="time_set_window">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>250</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>250</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_hour">
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(0, 170, 255);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_minute">
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(0, 170, 255);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_second">
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(0, 170, 255);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_time_set">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(85, 255, 127);</string>
</property>
<property name="text">
<string>Ayarla</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>