From 353b7314e6b5297041cb5e29f4e453334600c2fc Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Sat, 6 Mar 2010 11:40:24 +0100 Subject: [PATCH] OTHER: select active window on click istead of on mouseover --- src/basewindow.cpp | 25 ++++++++++++++++++++++++- src/basewindow.h | 6 +++++- src/equalizer/equalizerwidget.cpp | 12 ++++++++++++ src/equalizer/equalizerwidget.h | 11 +++++++---- src/equalizer/equalizerwindow.cpp | 20 +++++++++++++++++--- src/equalizer/equalizerwindow.h | 8 ++++++-- src/mainwindow/mainwindow.cpp | 18 ++++++++++++++++++ src/mainwindow/mainwindow.h | 6 +++++- src/mainwindow/skindisplay.cpp | 10 ++-------- src/mainwindow/skindisplay.h | 9 ++++----- src/playlist/playlistwidget.cpp | 2 +- src/playlist/playlistwindow.cpp | 8 +++++--- src/playlist/playlistwindow.h | 8 ++++---- 13 files changed, 110 insertions(+), 33 deletions(-) diff --git a/src/basewindow.cpp b/src/basewindow.cpp index fa1ce52..7421498 100644 --- a/src/basewindow.cpp +++ b/src/basewindow.cpp @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,6 +35,29 @@ BaseWindow::BaseWindow (QWidget *parent) : QMainWindow (parent) // Qt Event Handlers +bool +BaseWindow::event (QEvent *event) +{ + if (event->type () == QEvent::ActivationChange) { + if (isActiveWindow()) { + activeWindowInEvent (event); + } else { + activeWindowOutEvent (event); + } + } + return QMainWindow::event (event); +} + +void +BaseWindow::activeWindowInEvent (QEvent *event) +{ +} + +void +BaseWindow::activeWindowOutEvent (QEvent *event) +{ +} + void BaseWindow::hideEvent (QHideEvent *event) { diff --git a/src/basewindow.h b/src/basewindow.h index 7870f90..4a42a99 100644 --- a/src/basewindow.h +++ b/src/basewindow.h @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -51,6 +51,10 @@ class BaseWindow : public QMainWindow { void mouseReleaseEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event); + bool event (QEvent *event); + virtual void activeWindowInEvent (QEvent *event); + virtual void activeWindowOutEvent (QEvent *event); + QPoint snapWindow (QPoint pos, AttachedWindowMap attached = AttachedWindowMap()); QPoint m_diff; }; diff --git a/src/equalizer/equalizerwidget.cpp b/src/equalizer/equalizerwidget.cpp index cd87a5e..f6d7da1 100644 --- a/src/equalizer/equalizerwidget.cpp +++ b/src/equalizer/equalizerwidget.cpp @@ -63,6 +63,8 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent) connect (SkinManager::instance (), SIGNAL(skinChanged(Skin *)), this, SLOT(setPixmaps(Skin *))); + setActive (isActiveWindow ()); + m_closebtn = new PixmapButton (this); m_closebtn->resize (skin->getSize (Skin::BUTTON_EQ_CLOSE)); m_closebtn->move (skin->getPos (Skin::BUTTON_EQ_CLOSE)); @@ -157,9 +159,19 @@ EqualizerWidget::setPixmaps (Skin *skin) m_bands[i]->setBackground (bgslist); } + setActive (m_active); + update(); } +void +EqualizerWidget::setActive (bool active) +{ + Skin *skin = SkinManager::instance ()->activeSkin (); + + m_active = active; +} + void EqualizerWidget::paintEvent (QPaintEvent *event) { diff --git a/src/equalizer/equalizerwidget.h b/src/equalizer/equalizerwidget.h index 6e54f7e..7dff44a 100644 --- a/src/equalizer/equalizerwidget.h +++ b/src/equalizer/equalizerwidget.h @@ -34,16 +34,16 @@ class EqualizerSlider : public PixmapSlider Q_OBJECT public: - EqualizerSlider (QWidget*, int); + EqualizerSlider (QWidget*, int); signals: - void numberedValueChanged (int value, int id); + void numberedValueChanged (int value, int id); protected slots: - void on_self_value_changed (int value); + void on_self_value_changed (int value); private: - int m_id; + int m_id; }; class EqualizerWidget : public QWidget @@ -53,6 +53,8 @@ class EqualizerWidget : public QWidget public: EqualizerWidget(QWidget *parent); ~EqualizerWidget(); + + void setActive (bool); void paintEvent (QPaintEvent *event); public slots: @@ -68,6 +70,7 @@ class EqualizerWidget : public QWidget private: bool haveEqualizerEffect(); + bool m_active; XConfig *m_xconfig; QPixmap m_pixmap; QPixmap m_graph; diff --git a/src/equalizer/equalizerwindow.cpp b/src/equalizer/equalizerwindow.cpp index 94503ee..010cbfa 100644 --- a/src/equalizer/equalizerwindow.cpp +++ b/src/equalizer/equalizerwindow.cpp @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client. * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,9 +38,23 @@ EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent) } void -EqualizerWindow::setEnabled (void) +EqualizerWindow::activeWindowInEvent (QEvent *event) { - qDebug ("test"); + m_equalizer->setActive (true); + BaseWindow::activeWindowInEvent (event); +} + +void +EqualizerWindow::activeWindowOutEvent (QEvent *event) +{ + m_equalizer->setActive (false); + BaseWindow::activeWindowOutEvent (event); +} + +void +EqualizerWindow::switchDisplay (void) +{ + qDebug("switchDisplay not implemented for equalizer"); } #include "equalizerwindow.moc" diff --git a/src/equalizer/equalizerwindow.h b/src/equalizer/equalizerwindow.h index 073ea3a..ea3e6d2 100644 --- a/src/equalizer/equalizerwindow.h +++ b/src/equalizer/equalizerwindow.h @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client. * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,11 @@ class EqualizerWindow : public BaseWindow ~EqualizerWindow() {} public slots: - void setEnabled (void); + void switchDisplay (void); + + protected: + void activeWindowInEvent (QEvent *event); + void activeWindowOutEvent (QEvent *event); private: MainWindow *m_mw; diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index c26e2f7..dcb541b 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -36,6 +36,7 @@ MainWindow::MainWindow (QWidget *parent) : BaseWindow (parent) { + setObjectName ("MainWindow"); QSettings s; setWindowTitle (App->applicationName ()); @@ -126,6 +127,23 @@ MainWindow::switchDisplay () } +void +MainWindow::activeWindowInEvent (QEvent *event) +{ + m_display->setActive (true); + m_shaded->setActive (true); + BaseWindow::activeWindowInEvent (event); +} + +void +MainWindow::activeWindowOutEvent (QEvent *event) +{ + m_display->setActive (false); + m_shaded->setActive (false); + BaseWindow::activeWindowOutEvent (event); +} + + void MainWindow::raisePL (void) { diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h index 879c750..d4d1dad 100644 --- a/src/mainwindow/mainwindow.h +++ b/src/mainwindow/mainwindow.h @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client. * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,6 +49,10 @@ class MainWindow : public BaseWindow void switchDisplay (); void mouseMoveEvent (QMouseEvent *event); + protected: + void activeWindowInEvent (QEvent *event); + void activeWindowOutEvent (QEvent *event); + private: bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); } void setShaded (bool b) { QSettings s; return s.setValue("MainWindow/shaded", b); } diff --git a/src/mainwindow/skindisplay.cpp b/src/mainwindow/skindisplay.cpp index b6fc614..01e33d0 100644 --- a/src/mainwindow/skindisplay.cpp +++ b/src/mainwindow/skindisplay.cpp @@ -30,15 +30,9 @@ SkinDisplay::SkinDisplay (QWidget *parent) : QWidget(parent) } void -SkinDisplay::enterEvent (QEvent *event) +SkinDisplay::setActive (bool b) { - dynamic_cast(m_tbar)->setActive(true); -} - -void -SkinDisplay::leaveEvent (QEvent *event) -{ - dynamic_cast(m_tbar)->setActive(false); + dynamic_cast(m_tbar)->setActive (b); } void diff --git a/src/mainwindow/skindisplay.h b/src/mainwindow/skindisplay.h index e23e3af..819ea8d 100644 --- a/src/mainwindow/skindisplay.h +++ b/src/mainwindow/skindisplay.h @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client. * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,15 +27,14 @@ class SkinDisplay : public QWidget public: SkinDisplay (QWidget *parent); + void setActive (bool b); + public slots: void fileOpen (void); protected: - void enterEvent (QEvent *event); - void leaveEvent (QEvent *event); - QWidget *m_tbar; - + }; #endif diff --git a/src/playlist/playlistwidget.cpp b/src/playlist/playlistwidget.cpp index 823b2ad..25df4a9 100644 --- a/src/playlist/playlistwidget.cpp +++ b/src/playlist/playlistwidget.cpp @@ -180,7 +180,7 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent) connect (SkinManager::instance (), SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *))); - setActive (underMouse ()); + setActive (isActiveWindow ()); m_closebtn = new PixmapButton (this); m_closebtn->resize (skin->getSize (Skin::BUTTON_PLS_CLOSE)); diff --git a/src/playlist/playlistwindow.cpp b/src/playlist/playlistwindow.cpp index 594cff0..1281c75 100644 --- a/src/playlist/playlistwindow.cpp +++ b/src/playlist/playlistwindow.cpp @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client. * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,18 +100,20 @@ PlaylistWindow::resizeEvent (QResizeEvent *event) } void -PlaylistWindow::enterEvent (QEvent *event) +PlaylistWindow::activeWindowInEvent (QEvent *event) { m_playlist->setActive (true); m_shaded->setActive (true); + BaseWindow::activeWindowInEvent (event); } void -PlaylistWindow::leaveEvent (QEvent *event) +PlaylistWindow::activeWindowOutEvent (QEvent *event) { m_playlist->setActive (false); m_shaded->setActive (false); + BaseWindow::activeWindowOutEvent (event); } #include "playlistwindow.moc" diff --git a/src/playlist/playlistwindow.h b/src/playlist/playlistwindow.h index 7f28cc6..6d6d988 100644 --- a/src/playlist/playlistwindow.h +++ b/src/playlist/playlistwindow.h @@ -1,7 +1,7 @@ /** * This file is a part of Promoe, an XMMS2 Client. * - * Copyright (C) 2005-2008 XMMS2 Team + * Copyright (C) 2005-2010 XMMS2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,9 @@ #ifndef __PLAYLISTWINDOW_H__ #define __PLAYLISTWINDOW_H__ -// Qt classes #include "basewindow.h" +// Qt classes class QEvent; class QResizeEvent; class QPoint; @@ -45,8 +45,8 @@ class PlaylistWindow : public BaseWindow { void switchDisplay (void); protected: - void enterEvent (QEvent *event); - void leaveEvent (QEvent *event); + void activeWindowInEvent (QEvent *event); + void activeWindowOutEvent (QEvent *event); void resizeEvent (QResizeEvent *event); private: