]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/qvlcframe.hpp
Fix some typos.
[vlc] / modules / gui / qt4 / util / qvlcframe.hpp
index ddc271da3420946560fd732317eaac30fad29562..edaa08be96d10a89257974ef4b2a36fdc4b568e7 100644 (file)
 
 #include <QWidget>
 #include <QDialog>
-#include <QSpacerItem>
 #include <QHBoxLayout>
 #include <QApplication>
 #include <QMainWindow>
-#include <QPushButton>
 #include <QKeyEvent>
 #include <QDesktopWidget>
 #include <QSettings>
+#include <QStyle>
 
 #include "qt4.hpp"
 
@@ -43,7 +42,7 @@ class QVLCTools
        /*
         use this function to save a widgets screen position
         only for windows / dialogs which are floating, if a
-        window is docked into an other - don't all this function
+        window is docked into another - don't all this function
         or it may write garbage to position info!
        */
        static void saveWidgetPosition( QSettings *settings, QWidget *widget)
@@ -51,7 +50,7 @@ class QVLCTools
          settings->setValue("geometry", widget->saveGeometry());
        }
        static void saveWidgetPosition( intf_thread_t *p_intf,
-                                       QString configName,
+                                       const QString& configName,
                                        QWidget *widget)
        {
          getSettings()->beginGroup( configName );
@@ -76,14 +75,14 @@ class QVLCTools
             widget->resize(defSize);
 
             if(defPos.x() == 0 && defPos.y()==0)
-               centerWidgetOnScreen(widget);
+               widget->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, widget->size(), qApp->desktop()->availableGeometry()));
             return true;
           }
           return false;
        }
 
        static bool restoreWidgetPosition( intf_thread_t *p_intf,
-                                           QString configName,
+                                           const QString& configName,
                                            QWidget *widget,
                                            QSize defSize = QSize( 0, 0 ),
                                            QPoint defPos = QPoint( 0, 0 ) )
@@ -97,29 +96,12 @@ class QVLCTools
 
          return defaultUsed;
        }
-
-      /*
-        call this method for a window or dialog to show it centred on
-        current screen
-      */
-      static void centerWidgetOnScreen(QWidget *widget)
-      {
-         QDesktopWidget * const desktop = QApplication::desktop();
-         QRect screenRect = desktop->availableGeometry(widget);
-         QPoint p1 = widget->frameGeometry().center();
-
-         widget->move ( screenRect.center() - p1 );
-      }
 };
 
 class QVLCFrame : public QWidget
 {
 public:
-#ifdef __APPLE__
-    QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL, Qt::Window ), p_intf( _p_intf )
-#else
     QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
-#endif
     {};
     virtual ~QVLCFrame()   {};
 
@@ -131,14 +113,14 @@ public:
 protected:
     intf_thread_t *p_intf;
 
-    void readSettings( QString name,
+    void readSettings( const QString& name,
                        QSize defSize = QSize( 1, 1 ),
                        QPoint defPos = QPoint( 0, 0 ) )
     {
         QVLCTools::restoreWidgetPosition(p_intf, name, this, defSize, defPos);
     }
 
-    void writeSettings( QString name )
+    void writeSettings( const QString& name )
     {
         QVLCTools::saveWidgetPosition( p_intf, name, this);
     }
@@ -155,14 +137,13 @@ protected:
     {
         if( keyEvent->key() == Qt::Key_Escape )
         {
-            msg_Dbg( p_intf, "Escp Key pressed" );
-            cancel();
+            this->cancel();
         }
-        else if( keyEvent->key() == Qt::Key_Return )
+        else if( keyEvent->key() == Qt::Key_Return
+              || keyEvent->key() == Qt::Key_Enter )
         {
-             msg_Dbg( p_intf, "Enter Key pressed" );
-             close();
-         }
+             this->close();
+        }
     }
 };
 
@@ -194,13 +175,12 @@ protected:
     {
         if( keyEvent->key() == Qt::Key_Escape )
         {
-            msg_Dbg( p_intf, "Escp Key pressed" );
-            cancel();
+            this->cancel();
         }
-        else if( keyEvent->key() == Qt::Key_Return )
+        else if( keyEvent->key() == Qt::Key_Return
+              || keyEvent->key() == Qt::Key_Enter )
         {
-             msg_Dbg( p_intf, "Enter Key pressed" );
-             close();
+            this->close();
         }
     }
 };
@@ -220,12 +200,12 @@ protected:
     intf_thread_t *p_intf;
     QSize mainSize;
 
-    void readSettings( QString name, QSize defSize )
+    void readSettings( const QString& name, QSize defSize )
     {
         QVLCTools::restoreWidgetPosition( p_intf, name, this, defSize);
     }
 
-    void readSettings( QString name )
+    void readSettings( const QString& name )
     {
         QVLCTools::restoreWidgetPosition( p_intf, name, this);
     }
@@ -239,7 +219,7 @@ protected:
         QVLCTools::restoreWidgetPosition(settings, this, defSize);
     }
 
-    void writeSettings(QString name )
+    void writeSettings( const QString& name )
     {
         QVLCTools::saveWidgetPosition( p_intf, name, this);
     }