On pagenetgame, when window is too small the map/game options becomes a tabbed interface to allow for a few lines of chat to always be visible.
authordag10
Mon, 21 Jan 2013 21:52:49 -0500
changeset 8424 225ede46e3dc
parent 8423 8aa450f6cf2c
child 8425 4f226963faef
On pagenetgame, when window is too small the map/game options becomes a tabbed interface to allow for a few lines of chat to always be visible. Restored HWForm's min height to 580. Fixed the 2px alignment issue with the map list and map previews' top edges that unC0Rr was whining about. <3
QTfrontend/hwform.cpp
QTfrontend/res/css/qt.css
QTfrontend/ui/page/pagenetgame.cpp
QTfrontend/ui/page/pagenetgame.h
QTfrontend/ui/widget/gamecfgwidget.cpp
QTfrontend/ui/widget/gamecfgwidget.h
QTfrontend/ui/widget/mapContainer.cpp
QTfrontend/ui/widget/teamselect.cpp
--- a/QTfrontend/hwform.cpp	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/hwform.cpp	Mon Jan 21 21:52:49 2013 -0500
@@ -144,7 +144,7 @@
 #endif
     this->setStyleSheet(styleSheet);
     ui.setupUi(this);
-    setMinimumSize(760, 610);
+    setMinimumSize(760, 580);
     //setFocusPolicy(Qt::StrongFocus);
     CustomizePalettes();
 
--- a/QTfrontend/res/css/qt.css	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/res/css/qt.css	Mon Jan 21 21:52:49 2013 -0500
@@ -44,7 +44,7 @@
 QPushButton, QListWidget, QListView, QTableView, QLineEdit, QHeaderView,
 QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit,
 QComboBox QAbstractItemView, IconedGroupBox,
-.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget,
+.QGroupBox, #gameStackContainer, TeamSelWidget, SelWeaponWidget,
 QTabWidget::pane, QTabBar::tab, #mapPreview, #labelLikeLineEdit {
 border: solid;
 border-width: 3px;
@@ -79,7 +79,7 @@
 
 QLineEdit, QLabel, QHeaderView, QListWidget, QListView, QTableView,
 QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView,
-IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget,
+IconedGroupBox, .QGroupBox, #gameStackContainer, TeamSelWidget,
 SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit {
 font: bold 13px;
 }
@@ -88,7 +88,7 @@
 background-repeat: repeat-x;
 background-color: #000000;
 }
-.QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {
+.QGroupBox, #gameStackContainer, TeamSelWidget, SelWeaponWidget {
 background-position: bottom center;
 background-repeat: repeat-x;
 border-radius: 16px;
@@ -106,14 +106,18 @@
 }
 
 QTabWidget::pane {
-border-bottom-left-radius: 8px;
-border-bottom-right-radius: 8px;
+border-radius: 8px;
+border-top-left-radius: 0px;
 }
 
 QLineEdit:disabled, QSpinBox:disabled {
 border-color: gray;
 }
 
+GameCFGWidget {
+border: none;
+}
+
 QPushButton {
 border-radius: 8px;
 background-origin: margin;
@@ -313,4 +317,13 @@
 
 QDialogButtonBox QPushButton {
 padding: 3px 5px;
+}
+
+#gameCfgWidgetTabs {
+border-radius: 16px;
+border-top-left-radius: 0px;
+}
+
+TeamSelWidget, #gameStackContainer, #GBoxOptions {
+border-radius: 10px;
 }
\ No newline at end of file
--- a/QTfrontend/ui/page/pagenetgame.cpp	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/ui/page/pagenetgame.cpp	Mon Jan 21 21:52:49 2013 -0500
@@ -28,6 +28,9 @@
 #include "teamselect.h"
 #include "chatwidget.h"
 
+const int cutoffHeight = 688; /* Don't make this number below 605, or else it'll
+                                 let the GameCFGWidget shrink too much before switching to tabbed mode. */
+
 QLayout * PageNetGame::bodyLayoutDefinition()
 {
     QGridLayout * pageLayout = new QGridLayout();
@@ -35,7 +38,7 @@
     pageLayout->setColumnStretch(0, 1);
     pageLayout->setColumnStretch(1, 1);
     pageLayout->setRowStretch(0, 0);
-    pageLayout->setRowStretch(1, 1);
+    pageLayout->setRowStretch(1, 0);
     pageLayout->setRowStretch(2, 1);
 
     // Room config
@@ -93,14 +96,16 @@
 
     pNetTeamsWidget = new TeamSelWidget(this);
     pNetTeamsWidget->setAcceptOuter(true);
-    pNetTeamsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-    pageLayout->addWidget(pNetTeamsWidget, 1, 1, 1, 1);
+    pNetTeamsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    pageLayout->addWidget(pNetTeamsWidget, 1, 1);
 
     // Chat
     
     chatWidget = new HWChatWidget(this, true);
     chatWidget->setShowFollow(false); // don't show follow in nicks' context menus
     chatWidget->setIgnoreListKick(true); // kick ignored players automatically
+    chatWidget->setMinimumHeight(350);
+    chatWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
     pageLayout->addWidget(chatWidget, 2, 0, 1, 2);
 
     return pageLayout;
@@ -172,8 +177,21 @@
     menu->addAction(restrictTeamAdds);
 
     BtnMaster->setMenu(menu);
+
+    if (height() < cutoffHeight)
+        pGameCFG->setTabbed(true);
 }
 
+void PageNetGame::resizeEvent(QResizeEvent * event)
+{
+    int oldHeight = event->oldSize().height();
+    int newHeight = event->size().height();
+
+    if (newHeight < cutoffHeight && oldHeight >= cutoffHeight)
+        pGameCFG->setTabbed(true);
+    else if (newHeight >= cutoffHeight && oldHeight < cutoffHeight)
+        pGameCFG->setTabbed(false);
+}
 
 void PageNetGame::displayError(const QString & message)
 {
--- a/QTfrontend/ui/page/pagenetgame.h	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/ui/page/pagenetgame.h	Mon Jan 21 21:52:49 2013 -0500
@@ -71,6 +71,9 @@
         void SetupClicked();
         void askForUpdateRoomName(const QString &);
 
+    protected:
+        void resizeEvent(QResizeEvent * event);
+
     private:
         QLayout * bodyLayoutDefinition();
         QLayout * footerLayoutDefinition();
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Mon Jan 21 21:52:49 2013 -0500
@@ -24,6 +24,7 @@
 #include <QLabel>
 #include <QMessageBox>
 #include <QTableView>
+#include <QTabWidget>
 #include <QPushButton>
 #include <QDebug>
 #include <QList>
@@ -43,31 +44,75 @@
     , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}")
 {
     mainLayout.setMargin(0);
+    setMinimumHeight(310);
+    setMaximumHeight(447);
+    setMinimumWidth(470);
+    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
-    pMapContainer = new HWMapContainer(this);
-    mainLayout.addWidget(pMapContainer, 0, 0, Qt::AlignHCenter | Qt::AlignTop);
-    pMapContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-    pMapContainer->setFixedSize(460, 275);
+    // Easy containers for the map/game options in either stacked or tabbed mode
+
+    mapContainerFree = new QWidget();
+    mapContainerTabbed = new QWidget();
+    optionsContainerFree = new QWidget();
+    optionsContainerTabbed = new QWidget();
+    tabbed = false;
+
+    // Container for when in tabbed mode
+
+    tabs = new QTabWidget(this);
+    tabs->setFixedWidth(470);
+    tabs->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+    tabs->addTab(mapContainerTabbed, tr("Map"));
+    tabs->addTab(optionsContainerTabbed, tr("Game options"));
+    tabs->setObjectName("gameCfgWidgetTabs");
+    mainLayout.addWidget(tabs, 1);
+    tabs->setVisible(false);
+
+    // Container for when in stacked mode
+
+    StackContainer = new QWidget();
+    StackContainer->setObjectName("gameStackContainer");
+    mainLayout.addWidget(StackContainer, 1);
+    QVBoxLayout * stackLayout = new QVBoxLayout(StackContainer);
 
-    IconedGroupBox *GBoxOptions = new IconedGroupBox(this);
-    m_childWidgets << GBoxOptions;
-    GBoxOptions->setFixedWidth(pMapContainer->width());
-    GBoxOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
-    mainLayout.addWidget(GBoxOptions, 1, 0);
+    // Map options
+
+    pMapContainer = new HWMapContainer(mapContainerFree);
+    stackLayout->addWidget(mapContainerFree, 0, Qt::AlignHCenter);
+    pMapContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    pMapContainer->setFixedSize(width() - 14, 278);
+    mapContainerFree->setFixedSize(pMapContainer->width(), pMapContainer->height());
+
+    // Horizontal divider
+
+    QFrame * divider = new QFrame();
+    divider->setFrameShape(QFrame::HLine);
+    divider->setFrameShadow(QFrame::Plain);
+    stackLayout->addWidget(divider, 0, Qt::AlignBottom);
+    //stackLayout->setRowMinimumHeight(1, 10);
 
-    QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
+    // Game options
+
+    optionsContainerTabbed->setContentsMargins(0, 0, 0, 0);
+    optionsContainerFree->setFixedSize(width() - 14, 140);
+    stackLayout->addWidget(optionsContainerFree, 0, Qt::AlignHCenter);
 
-    GBoxOptions->setTitle(tr("Game Options"));
-    GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0);
+    OptionsInnerContainer = new QWidget(optionsContainerFree);
+    m_childWidgets << OptionsInnerContainer;
+    OptionsInnerContainer->setFixedSize(optionsContainerFree->width(), optionsContainerFree->height());
+    OptionsInnerContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+    GBoxOptionsLayout = new QGridLayout(OptionsInnerContainer);
 
-    Scripts = new QComboBox(GBoxOptions);
+    GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), this), 1, 0);
+
+    Scripts = new QComboBox(this);
     GBoxOptionsLayout->addWidget(Scripts, 1, 1);
 
     Scripts->setModel(DataManager::instance().gameStyleModel());
     m_curScript = Scripts->currentText();
     connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int)));
 
-    QWidget *SchemeWidget = new QWidget(GBoxOptions);
+    QWidget *SchemeWidget = new QWidget(this);
     GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2);
 
     QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget);
@@ -124,6 +169,31 @@
     connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews()));
 }
 
+void GameCFGWidget::setTabbed(bool tabbed)
+{
+    if (tabbed && !this->tabbed)
+    { // Make tabbed
+        tabs->setCurrentIndex(0);
+        StackContainer->setVisible(false);
+        tabs->setVisible(true);
+        pMapContainer->setParent(mapContainerTabbed);
+        OptionsInnerContainer->setParent(optionsContainerTabbed);
+        pMapContainer->setVisible(true);
+        setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+        this->tabbed = true;
+    }
+    else if (!tabbed && this->tabbed)
+    { // Make stacked
+        pMapContainer->setParent(mapContainerFree);
+        OptionsInnerContainer->setParent(optionsContainerFree);
+        tabs->setVisible(false);
+        StackContainer->setVisible(true);
+        pMapContainer->setVisible(true);
+        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+        this->tabbed = false;
+    }
+}
+
 void GameCFGWidget::jumpToSchemes()
 {
     emit goToSchemes(GameSchemes->currentIndex());
--- a/QTfrontend/ui/widget/gamecfgwidget.h	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.h	Mon Jan 21 21:52:49 2013 -0500
@@ -31,6 +31,7 @@
 class QVBoxLayout;
 class QLabel;
 class QTableView;
+class QTabWidget;
 
 class GameCFGWidget : public QGroupBox
 {
@@ -56,6 +57,7 @@
         void fullNetConfig();
         void resendSchemeData();
         void setMaster(bool master);
+        void setTabbed(bool tabbed);
 
     signals:
         void paramChanged(const QString & param, const QStringList & value);
@@ -79,7 +81,7 @@
         void updateModelViews();
 
     private:
-        QGridLayout mainLayout;
+        QVBoxLayout mainLayout;
         QCheckBox * bindEntries;
         QString curNetAmmoName;
         QString curNetAmmo;
@@ -87,6 +89,16 @@
         QString m_curScript;
         bool m_master;
         QList<QWidget *> m_childWidgets;
+        QGridLayout * GBoxOptionsLayout;
+        QWidget * OptionsInnerContainer;
+        QWidget * StackContainer;
+
+        QWidget * mapContainerFree;
+        QWidget * mapContainerTabbed;
+        QWidget * optionsContainerFree;
+        QWidget * optionsContainerTabbed;
+        bool tabbed;
+        QTabWidget * tabs;
 
         void setNetAmmo(const QString& name, const QString& ammo);
 
--- a/QTfrontend/ui/widget/mapContainer.cpp	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Mon Jan 21 21:52:49 2013 -0500
@@ -65,7 +65,7 @@
     linearGrad.setColorAt(0, QColor(66, 115, 225));
 
     mainLayout.setContentsMargins(HWApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
-                                  1,
+                                  10,
                                   HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin),
                                   HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
 
@@ -131,7 +131,8 @@
 
     QLabel * lblMapPreviewText = new QLabel(this);
     lblMapPreviewText->setText(tr("Map preview:"));
-    leftLayout->addWidget(lblMapPreviewText, 0, Qt::AlignLeft);
+    leftLayout->addWidget(lblMapPreviewText, 0);
+    leftLayout->addSpacing(2);
 
     /* Map Preview */
 
--- a/QTfrontend/ui/widget/teamselect.cpp	Tue Jan 22 00:33:37 2013 +0400
+++ b/QTfrontend/ui/widget/teamselect.cpp	Mon Jan 21 21:52:49 2013 -0500
@@ -273,7 +273,7 @@
 
     QPalette p;
     p.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00));
-    addScrArea(framePlaying, p.color(QPalette::Window).light(105), 250);
+    addScrArea(framePlaying, p.color(QPalette::Window).light(105), 150);
     addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0);
 }