Fixed searchclients to handle new Google URLs correctly; added GUI
[movie-schedule] / src / ui / locationdialog.cpp
index 095da2b..c05de0b 100644 (file)
@@ -17,6 +17,9 @@
 
 #include "locationdialog.h"
 #include "ui_locationdialog.h"
+#include "uiutils.h"
+
+#include <QDesktopWidget>
 
 LocationDialog::LocationDialog(QWidget *parent) :
     QDialog(parent),
@@ -39,6 +42,8 @@ LocationDialog::LocationDialog(QWidget *parent) :
     _location_buttons.append(ui->Location3);
     _location_buttons.append(ui->Location4);
     _location_buttons.append(ui->Location5);
+    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(Rotate()));
+    Rotate();
 }
 
 LocationDialog::~LocationDialog()
@@ -80,6 +85,7 @@ void LocationDialog::SetGPSEnabled(bool gps_enabled)
 
 void LocationDialog::show()
 {
+    bool landscape = UiUtils::IsLandscape();
     ui->gridLayout->removeWidget(ui->GPS);
     for (int i = 0; i < _location_buttons.size(); ++i) {
         ui->gridLayout->removeWidget(_location_buttons[i]);
@@ -89,12 +95,16 @@ void LocationDialog::show()
     if (ui->GPS->isEnabled()) {
         ui->gridLayout->addWidget(ui->GPS, row, column);
         ++column;
+        if (column > (landscape ? 1 : 0)) {
+            ++row;
+            column = 0;
+        }
     }
     for (int i = 0; i < _location_buttons.size(); ++i) {
         if (_location_buttons[i]->isEnabled()) {
             ui->gridLayout->addWidget(_location_buttons[i], row, column);
             ++column;
-            if (column > 1) {
+            if (column > (landscape ? 1 : 0)) {
                 ++row;
                 column = 0;
             }
@@ -175,3 +185,13 @@ void LocationDialog::changeEvent(QEvent *e)
         break;
     }
 }
+
+void LocationDialog::Rotate()
+{
+    bool landscape = UiUtils::IsLandscape();
+    ui->_search_layout->setDirection(landscape ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom);
+    ui->_button_box->setOrientation(landscape ? Qt::Vertical : Qt::Horizontal);
+    if (isVisible()) {
+        show();
+    }
+}