# HG changeset patch # User unc0rr # Date 1154297917 0 # Node ID c21ff3af56cfbdf85554dbf7e29f9d083a2635c3 # Parent 0c359a7a23561ede19141c37a5d9bb55f0443f1d - small fix to translation - Forts preview renders square pixmap diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Sun Jul 30 18:59:35 2006 +0000 +++ b/QTfrontend/CMakeLists.txt Sun Jul 30 22:18:37 2006 +0000 @@ -17,7 +17,8 @@ gameuiconfig.cpp ui_hwform.cpp gamecfgwidget.cpp - pages.cpp) + pages.cpp + SquareLabel.cpp) if (WIN32) set(hwfr_src ${hwfr_src} res/hedgewars.rc) @@ -35,7 +36,8 @@ ui_hwform.h gamecfgwidget.h predefteams.h - pages.h) + pages.h + SquareLabel.h) set(hwfr_rez diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/SquareLabel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/SquareLabel.cpp Sun Jul 30 22:18:37 2006 +0000 @@ -0,0 +1,56 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Andrey Korotaev + * + * Distributed under the terms of the BSD-modified licence: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * with the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "SquareLabel.h" + +SquareLabel::SquareLabel(QWidget * parent) : + QLabel(parent) +{ + +} + +void SquareLabel::paintEvent(QPaintEvent * event) +{ + QPainter painter(this); + int pixsize; + if (width() > height()) { + pixsize = height(); + painter.translate((width() - pixsize) / 2, 0); + } else { + pixsize = width(); + painter.translate(0, (height() - pixsize) / 2); + } + painter.drawPixmap(0, 0, pixsize, pixsize, pixmap()->scaled(pixsize, pixsize, Qt::KeepAspectRatio)); +} diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/SquareLabel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/SquareLabel.h Sun Jul 30 22:18:37 2006 +0000 @@ -0,0 +1,50 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Andrey Korotaev + * + * Distributed under the terms of the BSD-modified licence: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * with the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SQUARELABEL_H +#define _SQUARELABEL_H + +#include + +class SquareLabel : public QLabel +{ + Q_OBJECT + +public: + SquareLabel(QWidget * parent = 0); + +protected: + virtual void paintEvent(QPaintEvent * event); +}; + +#endif // _SQUARELABEL_H diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/hedgewars.pro --- a/QTfrontend/hedgewars.pro Sun Jul 30 18:59:35 2006 +0000 +++ b/QTfrontend/hedgewars.pro Sun Jul 30 22:18:37 2006 +0000 @@ -26,7 +26,8 @@ ui_hwform.h \ gamecfgwidget.h \ predefteams.h \ - pages.h + pages.h \ + SquareLabel.h SOURCES += game.cpp \ main.cpp \ @@ -42,7 +43,8 @@ gameuiconfig.cpp \ ui_hwform.cpp \ gamecfgwidget.cpp \ - pages.cpp + pages.cpp \ + SquareLabel.cpp TRANSLATIONS += translations/hedgewars_ru.ts diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Sun Jul 30 18:59:35 2006 +0000 +++ b/QTfrontend/pages.cpp Sun Jul 30 22:18:37 2006 +0000 @@ -48,6 +48,7 @@ #include "gamecfgwidget.h" #include "teamselect.h" #include "gamecfgwidget.h" +#include "SquareLabel.h" PageMain::PageMain(QWidget* parent) : QWidget(parent) { @@ -207,7 +208,7 @@ CBFort = new QComboBox(GBoxFort); CBFort->setMaxCount(65535); GBFLayout->addWidget(CBFort, 0, 0); - FortPreview = new QLabel(GBoxFort); + FortPreview = new SquareLabel(GBoxFort); FortPreview->setPixmap(QPixmap()); FortPreview->setScaledContents(true); GBFLayout->addWidget(FortPreview, 1, 0); diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/pages.h --- a/QTfrontend/pages.h Sun Jul 30 18:59:35 2006 +0000 +++ b/QTfrontend/pages.h Sun Jul 30 22:18:37 2006 +0000 @@ -49,6 +49,7 @@ class DemosList; class QListWidget; class QCheckBox; +class SquareLabel; class PageMain : public QWidget { @@ -87,7 +88,7 @@ QGroupBox *GBoxTeam; QGroupBox *GBoxFort; QComboBox *CBFort; - QLabel *FortPreview; + SquareLabel *FortPreview; QGroupBox *GBoxGrave; QComboBox *CBGrave; QLabel *GravePreview; diff -r 0c359a7a2356 -r c21ff3af56cf QTfrontend/translations/hedgewars_ru.ts --- a/QTfrontend/translations/hedgewars_ru.ts Sun Jul 30 18:59:35 2006 +0000 +++ b/QTfrontend/translations/hedgewars_ru.ts Sun Jul 30 22:18:37 2006 +0000 @@ -11,7 +11,7 @@ Quit - Выход + Выйти Cannot save options to file %1