#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"
/*
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)
settings->setValue("geometry", widget->saveGeometry());
}
static void saveWidgetPosition( intf_thread_t *p_intf,
- QString configName,
+ const QString& configName,
QWidget *widget)
{
getSettings()->beginGroup( configName );
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 ) )
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() {};
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);
}
{
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();
+ }
}
};
{
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();
}
}
};
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);
}
QVLCTools::restoreWidgetPosition(settings, this, defSize);
}
- void writeSettings(QString name )
+ void writeSettings( const QString& name )
{
QVLCTools::saveWidgetPosition( p_intf, name, this);
}