File indexing completed on 2024-12-08 09:27:36

0001 /*
0002     SPDX-FileCopyrightText: 2001 Jason Harris <jharris@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kstarsdatetime.h"
0010 
0011 #include <QDialog>
0012 #include <QHBoxLayout>
0013 #include <QKeyEvent>
0014 #include <QLabel>
0015 #include <QVariant>
0016 #include <QVBoxLayout>
0017 
0018 class QHBoxLayout;
0019 class QVBoxLayout;
0020 class KDatePicker;
0021 class QTimeEdit;
0022 class QPushButton;
0023 class GeoLocation;
0024 
0025 /**
0026  * @class TimeDialog
0027  *
0028  * A class for adjusting the Time and Date.  Contains a KDatePicker widget
0029  * for selecting the date, and a QTimeEdit for selecting the time.  There
0030  * is also a "Now" button for selecting the Time and Date from the system clock.
0031  *
0032  *
0033  * @short Dialog for adjusting the Time and Date.
0034  * @author Jason Harris
0035  * @version 1.0
0036  */
0037 class TimeDialog : public QDialog
0038 {
0039     Q_OBJECT
0040   public:
0041     /**
0042      * Constructor. Creates widgets and packs them into QLayouts.
0043      * Connects Signals and Slots.
0044      */
0045     TimeDialog(const KStarsDateTime &now, GeoLocation *_geo, QWidget *parent, bool UTCFrame = false);
0046 
0047     ~TimeDialog() override = default;
0048 
0049     /** @returns a QTime object with the selected time */
0050     QTime selectedTime(void);
0051 
0052     /** @returns a QDate object with the selected date */
0053     QDate selectedDate(void);
0054 
0055     /** @returns a KStarsDateTime object with the selected date and time */
0056     KStarsDateTime selectedDateTime(void);
0057 
0058   public slots:
0059     /**
0060      * When the "Now" button is pressed, read the time and date from the system clock.
0061      * Change the selected date in the KDatePicker to the system's date, and the displayed time
0062      * to the system time.
0063      */
0064     void setNow(void);
0065 
0066   protected:
0067     void keyReleaseEvent(QKeyEvent *) override;
0068 
0069   private:
0070     bool UTCNow;
0071     QHBoxLayout *hlay { nullptr };
0072     QVBoxLayout *vlay { nullptr };
0073     KDatePicker *dPicker { nullptr };
0074     QTimeEdit *tEdit { nullptr };
0075     QPushButton *NowButton { nullptr };
0076     GeoLocation *geo { nullptr };
0077 };