# HG changeset patch # User Wuzzy # Date 1462552434 -7200 # Node ID 68bc5ebce319623d4d4da9fdb17ee0ecebdbe7b2 # Parent 8eccc307ca1eeec6ea9b31cb011d5dff36c07e73 Fix mines time displaying "1 seconds" in frontend diff -r 8eccc307ca1e -r 68bc5ebce319 QTfrontend/ui/page/pagescheme.cpp --- a/QTfrontend/ui/page/pagescheme.cpp Fri May 06 17:26:06 2016 +0200 +++ b/QTfrontend/ui/page/pagescheme.cpp Fri May 06 18:33:54 2016 +0200 @@ -30,6 +30,7 @@ #include "ammoSchemeModel.h" #include "pagescheme.h" #include "FreqSpinBox.h" +#include "MinesTimeSpinBox.h" QLayout * PageScheme::bodyLayoutDefinition() @@ -368,13 +369,11 @@ l->setFixedSize(32,32); l->setPixmap(QPixmap(":/res/iconMineTime.png")); glBSLayout->addWidget(l,10,1,1,1); - SB_MinesTime = new QSpinBox(gbBasicSettings); + SB_MinesTime = new MinesTimeSpinBox(gbBasicSettings); SB_MinesTime->setWhatsThis(wtMinesTime); SB_MinesTime->setRange(-1, 5); SB_MinesTime->setValue(3); SB_MinesTime->setSingleStep(1); - SB_MinesTime->setSpecialValueText(tr("Random")); - SB_MinesTime->setSuffix(" "+ tr("Seconds")); glBSLayout->addWidget(SB_MinesTime,10,2,1,1); l = new QLabel(gbBasicSettings); diff -r 8eccc307ca1e -r 68bc5ebce319 QTfrontend/ui/page/pagescheme.h --- a/QTfrontend/ui/page/pagescheme.h Fri May 06 17:26:06 2016 +0200 +++ b/QTfrontend/ui/page/pagescheme.h Fri May 06 18:33:54 2016 +0200 @@ -23,6 +23,7 @@ #include "togglebutton.h" class FreqSpinBox; +class MinesTimeSpinBox; class PageScheme : public AbstractPage { @@ -85,7 +86,7 @@ FreqSpinBox * SB_CaseProb; QSpinBox * SB_HealthCrates; QSpinBox * SB_CrateHealth; - QSpinBox * SB_MinesTime; + MinesTimeSpinBox * SB_MinesTime; QSpinBox * SB_Mines; QSpinBox * SB_AirMines; QSpinBox * SB_MineDuds; diff -r 8eccc307ca1e -r 68bc5ebce319 QTfrontend/ui/widget/MinesTimeSpinBox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/MinesTimeSpinBox.cpp Fri May 06 18:33:54 2016 +0200 @@ -0,0 +1,40 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2015 Andrey Korotaev + * + * 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; version 2 of the License + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief MinesTimeSpinBox class implementation + */ + +#include "MinesTimeSpinBox.h" + + +MinesTimeSpinBox::MinesTimeSpinBox(QWidget* parent) : QSpinBox(parent) +{ + // do nothing +}; + + +QString MinesTimeSpinBox::textFromValue(int value) const +{ + switch (value) + { + case -1: return tr("Random"); + default: return tr("%1 seconds", "", value).arg(value); + } +} diff -r 8eccc307ca1e -r 68bc5ebce319 QTfrontend/ui/widget/MinesTimeSpinBox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/MinesTimeSpinBox.h Fri May 06 18:33:54 2016 +0200 @@ -0,0 +1,55 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2015 Andrey Korotaev + * + * 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; version 2 of the License + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief MinesTimeSpinBox class definition + */ + +#ifndef HEDGEWARS_MINESTIMESPINBOX_H +#define HEDGEWARS_MINESTIMESPINBOX_H + +#include +#include + +/** + * SpinBox that returns its value as localized mines time. + * @since 0.9.23 + */ +class MinesTimeSpinBox : public QSpinBox +{ + Q_OBJECT + + public: + /** + * @brief Class constructor. + * @param parent parent widget. + */ + MinesTimeSpinBox(QWidget * parent); + + protected: + /** + * Returns it's value localized. + * @param value integer value to be representing as string. + * @return string representation + */ + QString textFromValue(int value) const; +}; + + +#endif // HEDGEWARS_MINESTIMESPINBOX_H diff -r 8eccc307ca1e -r 68bc5ebce319 share/hedgewars/Data/Locale/hedgewars_en.ts --- a/share/hedgewars/Data/Locale/hedgewars_en.ts Fri May 06 17:26:06 2016 +0200 +++ b/share/hedgewars/Data/Locale/hedgewars_en.ts Fri May 06 18:33:54 2016 +0200 @@ -138,6 +138,20 @@ + MinesTimeSpinBox + + Random + Random + + + %1 seconds + + %1 second + %1 seconds + + + + GameCFGWidget Edit weapons @@ -1440,14 +1454,6 @@ Your hogs are unable to move, put your artillery skills to the test - Random - Random - - - Seconds - Seconds - - New New