moving a file around, fixing a png, etc.
authorsheepluva
Sat, 22 Oct 2011 00:00:48 +0200
changeset 6175 a80833ddaef0
parent 6174 2d5717595471
child 6176 19ef039a8474
moving a file around, fixing a png, etc.
QTfrontend/AbstractPage.cpp
QTfrontend/AbstractPage.h
QTfrontend/CMakeLists.txt
QTfrontend/res/Trainings.png
QTfrontend/ui/page/AbstractPage.cpp
QTfrontend/ui/page/AbstractPage.h
QTfrontend/ui/widget/about.cpp
QTfrontend/ui/widget/about.h
project_files/hedgewars.pro
--- a/QTfrontend/AbstractPage.cpp	Fri Oct 21 20:58:49 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "AbstractPage.h"
-
-AbstractPage::AbstractPage(QWidget* parent)
-{
-    Q_UNUSED(parent);
-
-    font14 = new QFont("MS Shell Dlg", 14);
-}
-
-void AbstractPage::initPage()
-{
-    QGridLayout * pageLayout = new QGridLayout(this);
-
-    // stretch grid space for body and footer
-    pageLayout->setColumnStretch(0,0);
-    pageLayout->setColumnStretch(1,1);
-    pageLayout->setRowStretch(0,1);
-    pageLayout->setRowStretch(1,0);
-
-    // add back/exit button
-    btnBack = formattedButton(":/res/Exit.png", true);
-    pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom);
-
-    // add body layout as defined by the subclass
-    pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 2);
-
-    // add footer layout
-    QLayout * fld = footerLayoutDefinition();
-    if (fld != NULL)
-        pageLayout->addLayout(fld, 1, 1);
-
-    // connect signals
-    connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
-    connectSignals();
-}
-
-QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
-{
-    QPushButton * btn = new QPushButton(this);
-
-    if (hasIcon)
-    {
-        const QIcon& lp=QIcon(btname);
-        QSize sz = lp.actualSize(QSize(65535, 65535));
-        btn->setIcon(lp);
-        btn->setFixedSize(sz);
-        btn->setIconSize(sz);
-        btn->setFlat(true);
-        btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-    }
-    else
-    {
-        btn->setFont(*font14);
-        btn->setText(btname);
-    }
-    return btn;
-}
-
-QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
-{
-    QPushButton * btn = formattedButton(btname, hasIcon);
-    grid->addWidget(btn, wy, wx);
-    return btn;
-}
-
-QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
-{
-    QPushButton * btn = formattedButton(btname, hasIcon);
-    grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
-    return btn;
-}
-
-QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
-{
-    QPushButton * btn = formattedButton(btname, hasIcon);
-    box->addWidget(btn, where);
-    return btn;
-}
-
-void AbstractPage::setBackButtonVisible(bool visible)
-{
-    btnBack->setVisible(visible);
-}
--- a/QTfrontend/AbstractPage.h	Fri Oct 21 20:58:49 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef ABSTRACTPAGE_H
-#define ABSTRACTPAGE_H
-
-#include <QWidget>
-#include <QPushButton>
-#include <QFont>
-#include <QGridLayout>
-#include <QComboBox>
-#include <QSignalMapper>
-
-class QPushButton;
-class QGroupBox;
-class QComboBox;
-class QLabel;
-class QToolBox;
-class QLineEdit;
-class QListWidget;
-class QCheckBox;
-class QSpinBox;
-class QTextEdit;
-class QRadioButton;
-class QTableView;
-class QTextBrowser;
-class QTableWidget;
-class QAction;
-class QDataWidgetMapper;
-class QAbstractItemModel;
-class QSettings;
-class QSlider;
-class QGridlayout;
-
-class AbstractPage : public QWidget
-{
-    Q_OBJECT
-
-    signals:
-        void goBack();
-
-    protected:
-        // constructor and virtual destructor
-        AbstractPage(QWidget * parent = 0);
-
-        // call this in the constructor of your subclass
-        void initPage();
-
-        // the following methods are used during page construction
-
-            // you MUST implement this method in your subclass
-            // only define layout, not behavior in here
-            virtual QLayout * bodyLayoutDefinition() = 0;
-
-            // you CAN implement this method in your subclass
-            virtual QLayout * footerLayoutDefinition() { return NULL; };
-
-            // you CAN but most likely want to implement this method in your subclass
-            // keep in mind not to expose twidgets as public!
-            // instead define a signal with a meaningful name and connect the widget
-            // signals to your page signals
-            virtual void connectSignals() {};
-
-        virtual ~AbstractPage() {};
-
-        QPushButton * formattedButton(const QString & btname, bool hasIcon = false);
-        QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, bool hasIcon = false);
-        QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon = false);
-        QPushButton * addButton(const QString & btname, QBoxLayout * box, int where, bool hasIcon = false);
-
-        void setBackButtonVisible(bool visible = true);
-
-        QFont * font14;
-
-    private:
-
-        QPushButton * btnBack;
-};
-
-#endif
-
--- a/QTfrontend/CMakeLists.txt	Fri Oct 21 20:58:49 2011 +0200
+++ b/QTfrontend/CMakeLists.txt	Sat Oct 22 00:00:48 2011 +0200
@@ -74,7 +74,6 @@
     ${NetCpp}
     ${UIcpp}
     ${UtilCpp}
-    AbstractPage.cpp
     achievements.cpp
     binds.cpp
     drawmapscene.cpp
@@ -114,7 +113,6 @@
     ${ModelHdr}
     ${NetHdr}
     ${UIhdr}
-    AbstractPage.h
     drawmapscene.h
     game.h
     gameuiconfig.h
Binary file QTfrontend/res/Trainings.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/ui/page/AbstractPage.cpp	Sat Oct 22 00:00:48 2011 +0200
@@ -0,0 +1,101 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "AbstractPage.h"
+
+AbstractPage::AbstractPage(QWidget* parent)
+{
+    Q_UNUSED(parent);
+
+    font14 = new QFont("MS Shell Dlg", 14);
+}
+
+void AbstractPage::initPage()
+{
+    QGridLayout * pageLayout = new QGridLayout(this);
+
+    // stretch grid space for body and footer
+    pageLayout->setColumnStretch(0,0);
+    pageLayout->setColumnStretch(1,1);
+    pageLayout->setRowStretch(0,1);
+    pageLayout->setRowStretch(1,0);
+
+    // add back/exit button
+    btnBack = formattedButton(":/res/Exit.png", true);
+    pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom);
+
+    // add body layout as defined by the subclass
+    pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 2);
+
+    // add footer layout
+    QLayout * fld = footerLayoutDefinition();
+    if (fld != NULL)
+        pageLayout->addLayout(fld, 1, 1);
+
+    // connect signals
+    connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
+    connectSignals();
+}
+
+QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
+{
+    QPushButton * btn = new QPushButton(this);
+
+    if (hasIcon)
+    {
+        const QIcon& lp=QIcon(btname);
+        QSize sz = lp.actualSize(QSize(65535, 65535));
+        btn->setIcon(lp);
+        btn->setFixedSize(sz);
+        btn->setIconSize(sz);
+        btn->setFlat(true);
+        btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+    }
+    else
+    {
+        btn->setFont(*font14);
+        btn->setText(btname);
+    }
+    return btn;
+}
+
+QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
+{
+    QPushButton * btn = formattedButton(btname, hasIcon);
+    grid->addWidget(btn, wy, wx);
+    return btn;
+}
+
+QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
+{
+    QPushButton * btn = formattedButton(btname, hasIcon);
+    grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
+    return btn;
+}
+
+QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
+{
+    QPushButton * btn = formattedButton(btname, hasIcon);
+    box->addWidget(btn, where);
+    return btn;
+}
+
+void AbstractPage::setBackButtonVisible(bool visible)
+{
+    btnBack->setVisible(visible);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/ui/page/AbstractPage.h	Sat Oct 22 00:00:48 2011 +0200
@@ -0,0 +1,96 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef ABSTRACTPAGE_H
+#define ABSTRACTPAGE_H
+
+#include <QWidget>
+#include <QPushButton>
+#include <QFont>
+#include <QGridLayout>
+#include <QComboBox>
+#include <QSignalMapper>
+
+class QPushButton;
+class QGroupBox;
+class QComboBox;
+class QLabel;
+class QToolBox;
+class QLineEdit;
+class QListWidget;
+class QCheckBox;
+class QSpinBox;
+class QTextEdit;
+class QRadioButton;
+class QTableView;
+class QTextBrowser;
+class QTableWidget;
+class QAction;
+class QDataWidgetMapper;
+class QAbstractItemModel;
+class QSettings;
+class QSlider;
+class QGridlayout;
+
+class AbstractPage : public QWidget
+{
+    Q_OBJECT
+
+    signals:
+        void goBack();
+
+    protected:
+        // constructor and virtual destructor
+        AbstractPage(QWidget * parent = 0);
+
+        // call this in the constructor of your subclass
+        void initPage();
+
+        // the following methods are used during page construction
+
+            // you MUST implement this method in your subclass
+            // only define layout, not behavior in here
+            virtual QLayout * bodyLayoutDefinition() = 0;
+
+            // you CAN implement this method in your subclass
+            virtual QLayout * footerLayoutDefinition() { return NULL; };
+
+            // you CAN but most likely want to implement this method in your subclass
+            // keep in mind not to expose twidgets as public!
+            // instead define a signal with a meaningful name and connect the widget
+            // signals to your page signals
+            virtual void connectSignals() {};
+
+        virtual ~AbstractPage() {};
+
+        QPushButton * formattedButton(const QString & btname, bool hasIcon = false);
+        QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, bool hasIcon = false);
+        QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon = false);
+        QPushButton * addButton(const QString & btname, QBoxLayout * box, int where, bool hasIcon = false);
+
+        void setBackButtonVisible(bool visible = true);
+
+        QFont * font14;
+
+    private:
+
+        QPushButton * btnBack;
+};
+
+#endif
+
--- a/QTfrontend/ui/widget/about.cpp	Fri Oct 21 20:58:49 2011 +0200
+++ b/QTfrontend/ui/widget/about.cpp	Sat Oct 22 00:00:48 2011 +0200
@@ -18,9 +18,13 @@
 
 #include <QGridLayout>
 #include <QLabel>
-#include <QTextBrowser>
+#include <QList>
+#include <QUrl>
+#include <QRegExp>
+#include "hwconsts.h"
+#include "SDLInteraction.h"
+
 #include "about.h"
-#include "hwconsts.h"
 
 About::About(QWidget * parent) :
   QWidget(parent)
@@ -54,7 +58,7 @@
     lbl1->setWordWrap(true);
     mainLayout->addWidget(lbl1, 0, 1);
 
-    QTextBrowser *lbl2 = new QTextBrowser(this);
+    lbl2 = new QTextBrowser(this);
 
     lbl2->setOpenExternalLinks(true);
     lbl2->setText(
@@ -143,4 +147,28 @@
             "</p>"
             );
     mainLayout->addWidget(lbl2, 1, 1);
+
+    setAcceptDrops(true);
 }
+
+void About::dragEnterEvent(QDragEnterEvent * event)
+{
+    if (event->mimeData()->hasUrls())
+    {
+        QList<QUrl> urls = event->mimeData()->urls();
+        QString url = urls[0].toString();
+        if (urls.count() == 1)
+            if (url.contains(QRegExp("^file://.*\\.ogg$")))
+                event->acceptProposedAction();
+    }
+}
+
+void About::dropEvent(QDropEvent * event)
+{
+    QString file =
+        event->mimeData()->urls()[0].toString().remove(QRegExp("^file://"));
+
+    SDLInteraction::instance().setMusicTrack(file);
+
+    event->acceptProposedAction();
+}
--- a/QTfrontend/ui/widget/about.h	Fri Oct 21 20:58:49 2011 +0200
+++ b/QTfrontend/ui/widget/about.h	Sat Oct 22 00:00:48 2011 +0200
@@ -20,6 +20,8 @@
 #define _ABOUT_H
 
 #include <QWidget>
+#include <QDropEvent>
+#include <QTextBrowser>
 
 
 class About : public QWidget
@@ -28,6 +30,13 @@
 
 public:
     About(QWidget * parent = 0);
+
+protected:
+    virtual void dragEnterEvent(QDragEnterEvent * event);
+    virtual void dropEvent(QDropEvent * event);
+
+private:
+    QTextBrowser * lbl2;
 };
 
 #endif // _ABOUT_H
--- a/project_files/hedgewars.pro	Fri Oct 21 20:58:49 2011 +0200
+++ b/project_files/hedgewars.pro	Sat Oct 22 00:00:48 2011 +0200
@@ -82,7 +82,7 @@
     ../QTfrontend/net/netudpserver.h \
     ../QTfrontend/net/hwmap.h \
     ../QTfrontend/util/namegen.h \
-    ../QTfrontend/AbstractPage.h \
+    ../QTfrontend/ui/page/AbstractPage.h \
     ../QTfrontend/drawmapscene.h \
     ../QTfrontend/game.h \
     ../QTfrontend/gameuiconfig.h \
@@ -157,7 +157,7 @@
     ../QTfrontend/net/netudpwidget.cpp \
     ../QTfrontend/net/netserver.cpp \
     ../QTfrontend/util/namegen.cpp \
-    ../QTfrontend/AbstractPage.cpp \
+    ../QTfrontend/ui/page/AbstractPage.cpp \
     ../QTfrontend/achievements.cpp \
     ../QTfrontend/binds.cpp \
     ../QTfrontend/drawmapscene.cpp \