OTHER: Fix memleak and fixed small bug in hideEvent handlers
When promoe was minimized or on a different virtual desktop when it was quit, the visible setting of playlist and equalizer was set to false. So even when those two were visible before switching to a different desktop they where set to closed when promoe was started the next time
This commit is contained in:
parent
4df3266088
commit
c7e1a7fa6b
8 changed files with 105 additions and 112 deletions
|
@ -38,6 +38,7 @@ inline QString
|
||||||
decodeXmmsUrl (const QString &path)
|
decodeXmmsUrl (const QString &path)
|
||||||
{
|
{
|
||||||
QByteArray p_enc = path.toUtf8 ();
|
QByteArray p_enc = path.toUtf8 ();
|
||||||
|
QString ret;
|
||||||
#if HAVE_XMMSV
|
#if HAVE_XMMSV
|
||||||
// TODO: error checking...
|
// TODO: error checking...
|
||||||
xmmsv_t *v_enc = xmmsv_new_string (p_enc.constData ());
|
xmmsv_t *v_enc = xmmsv_new_string (p_enc.constData ());
|
||||||
|
@ -46,15 +47,15 @@ decodeXmmsUrl (const QString &path)
|
||||||
const char *p;
|
const char *p;
|
||||||
unsigned int p_len;
|
unsigned int p_len;
|
||||||
xmmsv_get_bin (p_dec, reinterpret_cast<const unsigned char **>(&p), &p_len);
|
xmmsv_get_bin (p_dec, reinterpret_cast<const unsigned char **>(&p), &p_len);
|
||||||
QString ret = QString::fromUtf8 (p, p_len);
|
ret = QString::fromUtf8 (p, p_len);
|
||||||
xmmsv_unref (p_dec);
|
xmmsv_unref (p_dec);
|
||||||
// Free p?
|
// Free p?
|
||||||
return ret;
|
|
||||||
#else
|
#else
|
||||||
char *p_dec = const_cast<char *> (xmmsc_result_decode_url (NULL, p_enc.constData ()));
|
char *p_dec = const_cast<char *> (xmmsc_result_decode_url (NULL, p_enc.constData ()));
|
||||||
return QString::fromUtf8 (p_dec);
|
ret = QString::fromUtf8 (p_dec);
|
||||||
free (p_dec);
|
free (p_dec);
|
||||||
#endif
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,49 +19,66 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QWidgetList>
|
#include <QWidgetList>
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <QHideEvent>
|
||||||
|
#include <QShowEvent>
|
||||||
|
#include <QMoveEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
BaseWindow::BaseWindow (QWidget *parent) : QMainWindow (parent)
|
BaseWindow::BaseWindow (QWidget *parent) : QMainWindow (parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
BaseWindow::touches (QWidget *widget)
|
// Qt Event Handlers
|
||||||
|
void
|
||||||
|
BaseWindow::hideEvent (QHideEvent *event)
|
||||||
{
|
{
|
||||||
if (this == widget) {
|
if (event->spontaneous ()) {
|
||||||
return true;
|
event->ignore ();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32 left = x ();
|
if ((objectName ().isEmpty ()) | (objectName () == "MainWindow")) {
|
||||||
qint32 right = left + width ();
|
event->ignore ();
|
||||||
qint32 top = y ();
|
return;
|
||||||
qint32 bottom = top + height ();
|
|
||||||
|
|
||||||
qint32 w_left = widget->x ();
|
|
||||||
qint32 w_right = w_left + widget->width ();
|
|
||||||
qint32 w_top = widget->y ();
|
|
||||||
qint32 w_bottom = w_top + widget->height ();
|
|
||||||
|
|
||||||
if (( (top <= w_bottom) && (bottom >= w_top) &&
|
|
||||||
((left == w_right || right == w_left)) ) ||
|
|
||||||
( (left <= w_right) && (right >= w_left) &&
|
|
||||||
((top == w_bottom) || (bottom == w_top) ) )) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
QSettings s;
|
||||||
|
s.setValue (objectName ()+"/visible", false);
|
||||||
|
|
||||||
|
emit visibilityChanged (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow *
|
void
|
||||||
BaseWindow::mw ()
|
BaseWindow::showEvent (QShowEvent *event)
|
||||||
{
|
{
|
||||||
//MainWindow is the only BaseWindow without a *parent
|
if (objectName ().isEmpty ()) {
|
||||||
if (parent ()) {
|
event->ignore ();
|
||||||
return qobject_cast<MainWindow *>(parent ());
|
return;
|
||||||
} else {
|
|
||||||
return qobject_cast<MainWindow *>(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.setValue (objectName ()+"/visible", true);
|
||||||
|
mw ()->attachWidgets ();
|
||||||
|
|
||||||
|
emit visibilityChanged (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BaseWindow::moveEvent (QMoveEvent *event)
|
||||||
|
{
|
||||||
|
if (objectName ().isEmpty ()) {
|
||||||
|
event->ignore ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.setValue (objectName ()+"/pos", pos ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -91,6 +108,45 @@ BaseWindow::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper classes vor snapping windows
|
||||||
|
MainWindow *
|
||||||
|
BaseWindow::mw ()
|
||||||
|
{
|
||||||
|
//MainWindow is the only BaseWindow without a *parent
|
||||||
|
if (parent ()) {
|
||||||
|
return qobject_cast<MainWindow *>(parent ());
|
||||||
|
} else {
|
||||||
|
return qobject_cast<MainWindow *>(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BaseWindow::touches (QWidget *widget)
|
||||||
|
{
|
||||||
|
if (this == widget) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32 left = x ();
|
||||||
|
qint32 right = left + width ();
|
||||||
|
qint32 top = y ();
|
||||||
|
qint32 bottom = top + height ();
|
||||||
|
|
||||||
|
qint32 w_left = widget->x ();
|
||||||
|
qint32 w_right = w_left + widget->width ();
|
||||||
|
qint32 w_top = widget->y ();
|
||||||
|
qint32 w_bottom = w_top + widget->height ();
|
||||||
|
|
||||||
|
if (( (top <= w_bottom) && (bottom >= w_top) &&
|
||||||
|
((left == w_right || right == w_left)) ) ||
|
||||||
|
( (left <= w_right) && (right >= w_left) &&
|
||||||
|
((top == w_bottom) || (bottom == w_top) ) )) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QPoint
|
QPoint
|
||||||
BaseWindow::snapWindow(QPoint pos, AttachedWindowMap attached)
|
BaseWindow::snapWindow(QPoint pos, AttachedWindowMap attached)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,24 +20,33 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
class QMouseEvent;
|
|
||||||
class QPoint;
|
class QPoint;
|
||||||
|
|
||||||
class MainWindow;
|
class QHideEvent;
|
||||||
|
class QShowEvent;
|
||||||
|
class QMoveEvent;
|
||||||
|
class QMouseEvent;
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
class BaseWindow;
|
class BaseWindow;
|
||||||
typedef QMap<BaseWindow *, QPoint> AttachedWindowMap;
|
typedef QMap<BaseWindow *, QPoint> AttachedWindowMap;
|
||||||
|
|
||||||
class BaseWindow : public QMainWindow {
|
class BaseWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void visibilityChanged (bool visible);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseWindow (QWidget *parent);
|
BaseWindow (QWidget *parent);
|
||||||
|
|
||||||
bool touches (QWidget *);
|
bool touches (QWidget *);
|
||||||
MainWindow * mw ();
|
MainWindow * mw ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void hideEvent (QHideEvent *event);
|
||||||
|
void showEvent (QShowEvent *event);
|
||||||
|
void moveEvent (QMoveEvent *event);
|
||||||
void mousePressEvent (QMouseEvent *event);
|
void mousePressEvent (QMouseEvent *event);
|
||||||
void mouseReleaseEvent (QMouseEvent *event);
|
void mouseReleaseEvent (QMouseEvent *event);
|
||||||
void mouseMoveEvent (QMouseEvent *event);
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
|
|
||||||
#include "QWidget"
|
#include "QWidget"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QMoveEvent>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "equalizerwidget.h"
|
#include "equalizerwidget.h"
|
||||||
|
|
||||||
EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent)
|
EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent)
|
||||||
{
|
{
|
||||||
|
setObjectName ("equalizer");
|
||||||
m_mw = dynamic_cast<MainWindow *>(parent);
|
m_mw = dynamic_cast<MainWindow *>(parent);
|
||||||
|
|
||||||
setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);
|
setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);
|
||||||
|
@ -37,34 +37,8 @@ EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent)
|
||||||
setFixedSize (275, 116);
|
setFixedSize (275, 116);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
EqualizerWindow::hideEvent (QHideEvent *event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.setValue ("equalizer/visible", false);
|
|
||||||
|
|
||||||
emit visibilityChanged (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
EqualizerWindow::showEvent (QShowEvent *event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.setValue ("equalizer/visible", true);
|
|
||||||
m_mw->attachWidgets ();
|
|
||||||
|
|
||||||
emit visibilityChanged (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EqualizerWindow::setEnabled (void)
|
EqualizerWindow::setEnabled (void)
|
||||||
{
|
{
|
||||||
qDebug ("test");
|
qDebug ("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
EqualizerWindow::moveEvent (QMoveEvent *event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.setValue ("equalizer/pos", pos ());
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
#include "basewindow.h"
|
#include "basewindow.h"
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QMoveEvent;
|
|
||||||
class QHideEvent;
|
|
||||||
class QShowEvent;
|
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class EqualizerWidget;
|
class EqualizerWidget;
|
||||||
|
|
||||||
|
@ -33,18 +29,9 @@ class EqualizerWindow : public BaseWindow
|
||||||
EqualizerWindow(QWidget *parent);
|
EqualizerWindow(QWidget *parent);
|
||||||
~EqualizerWindow() {}
|
~EqualizerWindow() {}
|
||||||
|
|
||||||
signals:
|
|
||||||
void visibilityChanged(bool visible);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setEnabled (void);
|
void setEnabled (void);
|
||||||
|
|
||||||
protected:
|
|
||||||
void hideEvent (QHideEvent *event);
|
|
||||||
void showEvent (QShowEvent *event);
|
|
||||||
void moveEvent(QMoveEvent *event);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow *m_mw;
|
MainWindow *m_mw;
|
||||||
EqualizerWidget *m_equalizer;
|
EqualizerWidget *m_equalizer;
|
||||||
|
|
|
@ -39,6 +39,7 @@ MainWindow::MainWindow (QWidget *parent) : BaseWindow (parent)
|
||||||
{
|
{
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
|
setWindowTitle (App->applicationName ());
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
setMaximumSize (275, 116);
|
setMaximumSize (275, 116);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include "playlistwindow.h"
|
#include "playlistwindow.h"
|
||||||
|
|
||||||
#include <QMoveEvent>
|
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
@ -27,15 +26,16 @@
|
||||||
|
|
||||||
PlaylistWindow::PlaylistWindow (QWidget *parent) : BaseWindow (parent)
|
PlaylistWindow::PlaylistWindow (QWidget *parent) : BaseWindow (parent)
|
||||||
{
|
{
|
||||||
QSettings s;
|
setObjectName ("playlist"); // Name of the config group
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
setWindowIcon (QIcon (":icon.png"));
|
setWindowIcon (QIcon (":icon.png"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);
|
setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);
|
||||||
setAttribute (Qt::WA_DeleteOnClose);
|
setAttribute (Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
s.beginGroup ("playlist");
|
s.beginGroup (objectName ());
|
||||||
if (!s.contains ("size")) {
|
if (!s.contains ("size")) {
|
||||||
s.setValue ("size", QSize (275, 350));
|
s.setValue ("size", QSize (275, 350));
|
||||||
}
|
}
|
||||||
|
@ -58,26 +58,6 @@ PlaylistWindow::PlaylistWindow (QWidget *parent) : BaseWindow (parent)
|
||||||
//setSizeIncrement (25, 29);
|
//setSizeIncrement (25, 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::hideEvent (QHideEvent *event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.setValue ("playlist/visible", false);
|
|
||||||
|
|
||||||
emit visibilityChanged (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::showEvent (QShowEvent *event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.setValue ("playlist/visible", true);
|
|
||||||
mw ()->attachWidgets ();
|
|
||||||
|
|
||||||
emit visibilityChanged (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::switchDisplay (void)
|
PlaylistWindow::switchDisplay (void)
|
||||||
{
|
{
|
||||||
|
@ -119,13 +99,6 @@ PlaylistWindow::resizeEvent (QResizeEvent *event)
|
||||||
mw ()->attachWidgets ();
|
mw ()->attachWidgets ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::moveEvent (QMoveEvent *event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.setValue ("playlist/pos", pos ());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::enterEvent (QEvent *event)
|
PlaylistWindow::enterEvent (QEvent *event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
#include "basewindow.h"
|
#include "basewindow.h"
|
||||||
|
|
||||||
class QEvent;
|
class QEvent;
|
||||||
class QMoveEvent;
|
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
class QHideEvent;
|
|
||||||
class QShowEvent;
|
|
||||||
class QPoint;
|
class QPoint;
|
||||||
|
|
||||||
// our own classes
|
// our own classes
|
||||||
|
@ -41,8 +38,6 @@ class PlaylistWindow : public BaseWindow {
|
||||||
void setActive (bool);
|
void setActive (bool);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void visibilityChanged(bool visible);
|
|
||||||
|
|
||||||
// setTime is used to set playtime in playlistcontrols
|
// setTime is used to set playtime in playlistcontrols
|
||||||
void setDisplayTime (int seconds);
|
void setDisplayTime (int seconds);
|
||||||
|
|
||||||
|
@ -50,11 +45,8 @@ class PlaylistWindow : public BaseWindow {
|
||||||
void switchDisplay (void);
|
void switchDisplay (void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hideEvent (QHideEvent *event);
|
|
||||||
void showEvent (QShowEvent *event);
|
|
||||||
void enterEvent (QEvent *event);
|
void enterEvent (QEvent *event);
|
||||||
void leaveEvent (QEvent *event);
|
void leaveEvent (QEvent *event);
|
||||||
void moveEvent (QMoveEvent *event);
|
|
||||||
void resizeEvent (QResizeEvent *event);
|
void resizeEvent (QResizeEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue