QTfrontend/ui/widget/SDTimeoutSpinBox.h
author unC0Rr
Sat, 28 Sep 2024 22:27:13 +0200
changeset 16066 2b4f361e3891
parent 13840 419de2dea82b
permissions -rw-r--r--
Wrap chat lines into div
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13840
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     1
/*
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     4
 *
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     8
 *
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    13
 *
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    17
 */
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    18
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    19
/**
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    20
 * @file
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    21
 * @brief SDTimeoutSpinBox class definition
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    22
 */
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    23
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    24
#ifndef HEDGEWARS_SDTIMEOUTSPINBOX_H
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    25
#define HEDGEWARS_SDTIMEOUTSPINBOX_H
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    26
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    27
#include <QObject>
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    28
#include <QSpinBox>
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    29
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    30
/**
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    31
 * <code>SpinBox</code> for Sudden Death timeout.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    32
 * The internally stored Sudden Death timeout is different
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    33
 * from the actual number of rounds it takes until SD starts.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    34
 * e.g. value 0 means SD starts in 2nd round
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    35
 * @author Wuzzy
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    36
 * @since  0.9.25
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    37
 */
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    38
class SDTimeoutSpinBox : public QSpinBox
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    39
{
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    40
        Q_OBJECT
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    41
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    42
    public:
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    43
        /**
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    44
         * @brief Class constructor.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    45
         * @param parent parent widget.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    46
         */
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    47
        SDTimeoutSpinBox(QWidget * parent);
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    48
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    49
    protected:
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    50
        /**
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    51
         * Returns its value in real number of rounds.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    52
         * @param internal value integer value to be represented as string.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    53
         * @return the real number of rounds
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    54
         */
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    55
        QString textFromValue(int value) const;
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    56
        /**
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    57
         * Returns the internally-used value for SD timeout.
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    58
         * @param user-facing string, i.e. real number of rounds
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    59
         * @return internally-stored SD timeout value
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    60
         */
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    61
        int valueFromText(const QString & text) const;
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    62
};
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    63
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    64
419de2dea82b Fix frontend displayed value of Sudden Death timeout being off-by-one
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    65
#endif // HEDGEWARS_SDTIMEOUTSPINBOX_H