Start to move mainwindow widgets into a subdirectory,
get rid of some unneeded includes
This commit is contained in:
parent
efa16e9236
commit
02d2a1a1f4
27 changed files with 43 additions and 41 deletions
77
src/mainwindow/clutterbar.cpp
Normal file
77
src/mainwindow/clutterbar.cpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "clutterbar.h"
|
||||
#include "Skin.h"
|
||||
|
||||
ClutterBar::ClutterBar (QWidget *parent) : PixWidget (parent)
|
||||
{
|
||||
}
|
||||
|
||||
ClutterBar::~ClutterBar ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ClutterBar::setPixmaps(Skin *skin)
|
||||
{
|
||||
m_clutter_on = skin->getItem(Skin::CLUTTER_ON);
|
||||
m_clutter_off = skin->getItem(Skin::CLUTTER_OFF);
|
||||
|
||||
m_clutter_o = skin->getItem(Skin::CLUTTER_O);
|
||||
m_clutter_a = skin->getItem(Skin::CLUTTER_A);
|
||||
m_clutter_i = skin->getItem(Skin::CLUTTER_I);
|
||||
m_clutter_d = skin->getItem(Skin::CLUTTER_D);
|
||||
m_clutter_v = skin->getItem(Skin::CLUTTER_V);
|
||||
|
||||
m_pixmap = m_clutter_on;
|
||||
|
||||
setMinimumSize (m_clutter_on.size ());
|
||||
setMaximumSize (m_clutter_on.size ());
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
ClutterBar::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
int y = event->pos().y();
|
||||
|
||||
if (y > 2 && y < 11) {
|
||||
m_pixmap = m_clutter_o;
|
||||
} else if (y > 10 && y < 19) {
|
||||
m_pixmap = m_clutter_a;
|
||||
} else if (y > 18 && y < 27) {
|
||||
m_pixmap = m_clutter_i;
|
||||
} else if (y > 26 && y < 35) {
|
||||
m_pixmap = m_clutter_d;
|
||||
} else if (y > 34 && y < 43) {
|
||||
m_pixmap = m_clutter_v;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
ClutterBar::mouseReleaseEvent (QMouseEvent *event)
|
||||
{
|
||||
m_pixmap = m_clutter_on;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
51
src/mainwindow/clutterbar.h
Normal file
51
src/mainwindow/clutterbar.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTERBAR_H__
|
||||
#define __CLUTTERBAR_H__
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include "PixWidget.h"
|
||||
|
||||
class ClutterBar : public PixWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClutterBar (QWidget *parent);
|
||||
~ClutterBar ();
|
||||
|
||||
public slots:
|
||||
void setPixmaps(Skin *skin);
|
||||
|
||||
protected:
|
||||
void mousePressEvent (QMouseEvent *event);
|
||||
void mouseReleaseEvent (QMouseEvent *event);
|
||||
|
||||
QPixmap m_clutter_off;
|
||||
QPixmap m_clutter_on;
|
||||
|
||||
QPixmap m_clutter_o;
|
||||
QPixmap m_clutter_a;
|
||||
QPixmap m_clutter_i;
|
||||
QPixmap m_clutter_d;
|
||||
QPixmap m_clutter_v;
|
||||
|
||||
bool enabled;
|
||||
|
||||
int m_ypos;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
299
src/mainwindow/maindisplay.cpp
Normal file
299
src/mainwindow/maindisplay.cpp
Normal file
|
@ -0,0 +1,299 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "XMMSHandler.h"
|
||||
#include "maindisplay.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "TitleBar.h"
|
||||
#include "Button.h"
|
||||
#include "TextBar.h"
|
||||
#include "NumberDisplay.h"
|
||||
#include "TimeDisplay.h"
|
||||
#include "SmallNumberDisplay.h"
|
||||
#include "stereomono.h"
|
||||
#include "PosBar.h"
|
||||
#include "PlayStatus.h"
|
||||
#include "VolumeSlider.h"
|
||||
#include "playlist.h"
|
||||
#include "clutterbar.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
|
||||
MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||
{
|
||||
m_tbar = new TitleBar(this, false);
|
||||
m_tbar->move(0, 0);
|
||||
m_tbar->resize(275, 14);
|
||||
|
||||
m_mw = dynamic_cast<MainWindow *>(parent);
|
||||
|
||||
SetupPushButtons ();
|
||||
SetupToggleButtons ();
|
||||
|
||||
m_text = new TextScroller (this, 154, 10, "main");
|
||||
m_text->move (112, 25);
|
||||
|
||||
m_time = new TimeDisplay(this, 0);
|
||||
connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime()));
|
||||
|
||||
m_kbps = new SmallNumberDisplay (this, 15);
|
||||
m_kbps->move (111, 43);
|
||||
m_kbps->setNumber (128, 3);
|
||||
|
||||
m_khz = new SmallNumberDisplay (this, 10);
|
||||
m_khz->move (156, 43);
|
||||
m_khz->setNumber (44, 2);
|
||||
|
||||
m_stereo = new StereoMono (this);
|
||||
m_stereo->move (212, 41);
|
||||
m_stereo->setStereoMono (0, 0);
|
||||
|
||||
m_clutterbar = new ClutterBar (this);
|
||||
m_clutterbar->move (10, 22);
|
||||
|
||||
m_posbar = new PosBar (this, Skin::POSBAR,
|
||||
Skin::POSBAR_BTN_0,
|
||||
Skin::POSBAR_BTN_1);
|
||||
m_posbar->move (16, 72);
|
||||
|
||||
m_playstatus = new PlayStatus (this);
|
||||
m_playstatus->move (24, 28);
|
||||
|
||||
m_vslider = new Slider(this, Skin::VOLUMEBAR_POS_0, Skin::VOLUMEBAR_POS_27,
|
||||
Skin::VOLBAR_BTN_0, Skin::VOLBAR_BTN_1, 0, 100);
|
||||
m_vslider->move (107, 57);
|
||||
|
||||
m_bslider = new Slider(this, Skin::BALANCE_POS_0, Skin::BALANCE_POS_27,
|
||||
Skin::BALANCE_BTN_0, Skin::BALANCE_BTN_1, -20, 20);
|
||||
m_bslider->move (177, 57);
|
||||
|
||||
XMMSHandler &client = XMMSHandler::getInstance ();
|
||||
connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)),
|
||||
this, SLOT(setMediainfo (const Xmms::PropDict &)));
|
||||
connect (&client, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
|
||||
this, SLOT(setStatus(Xmms::Playback::Status)));
|
||||
// connect (&xmmsh, SIGNAL(playtimeChanged(uint)),
|
||||
// this, SLOT(setPlaytime(uint)));
|
||||
connect (client.cache () , SIGNAL (playtime (uint32_t)),
|
||||
this, SLOT (setPlaytime (uint32_t)));
|
||||
connect (&client, SIGNAL(getVolume(uint)), this, SLOT(updateVolume(uint)));
|
||||
connect (m_vslider, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
|
||||
client.volumeGet();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainDisplay::updateVolume (uint volume)
|
||||
{
|
||||
m_vslider->setValue((int)volume);
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::setVolume (int volume)
|
||||
{
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance();
|
||||
xmmsh.volumeSet((uint)volume);
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::mouseMoveEvent (QMouseEvent *event)
|
||||
{
|
||||
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
||||
PlaylistWindow *pl = mw->getPL ();
|
||||
|
||||
m_mw->move (event->globalPos().x() - m_diffX,
|
||||
event->globalPos().y() - m_diffY);
|
||||
|
||||
if (!pl || !pl->isVisible ())
|
||||
return;
|
||||
|
||||
pl->move (event->globalPos().x() - m_diffX,
|
||||
event->globalPos().y() - m_diffY + size().height());
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::setPixmaps (Skin *skin)
|
||||
{
|
||||
QPalette palette = QPalette();
|
||||
QBrush brush = QBrush(skin->getItem(Skin::MAIN_WINDOW));
|
||||
palette.setBrush(QPalette::Background, brush);
|
||||
setPalette(palette);
|
||||
|
||||
setMaximumSize(QSize(275, 116));
|
||||
setMinimumSize(QSize(275, 116));
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::setStatus (Xmms::Playback::Status status)
|
||||
{
|
||||
if (status == Xmms::Playback::STOPPED) {
|
||||
m_time->setTime(0);
|
||||
m_posbar->setPos (0);
|
||||
m_posbar->hideBar (true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::setPlaytime (uint32_t time)
|
||||
{
|
||||
uint32_t showtime;
|
||||
if (m_mw->isTimemodeReverse()) {
|
||||
uint maxtime = m_posbar->getMax();
|
||||
showtime = -(maxtime - time);
|
||||
} else {
|
||||
showtime = time;
|
||||
}
|
||||
m_time->setTime (showtime);
|
||||
|
||||
// update slider
|
||||
m_posbar->setPos (time);
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||
{
|
||||
QString n;
|
||||
if (info.contains ("title")) {
|
||||
if (info.contains ("artist")) {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("artist").c_str ()) + " - ";
|
||||
}
|
||||
if (info.contains ("album")) {
|
||||
n += QString::fromUtf8 (info.get<std::string> ("album").c_str ()) + " - ";
|
||||
}
|
||||
n += QString::fromUtf8 (info.get<std::string> ("title").c_str ());
|
||||
} else if (info.contains ("channel")) {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("channel").c_str ()) + " - " +
|
||||
QString::fromUtf8 (info.get<std::string> ("title").c_str ());
|
||||
} else {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
|
||||
n = n.section ("/", -1);
|
||||
}
|
||||
m_text->setText (n);
|
||||
|
||||
if (info.contains ("bitrate")) {
|
||||
m_kbps->setNumber (info.get<int32_t> ("bitrate")/1000, 3);
|
||||
} else {
|
||||
m_kbps->setNumber (0, 1);
|
||||
}
|
||||
|
||||
if (info.contains ("samplerate")) {
|
||||
m_khz->setNumber (info.get<int32_t> ("samplerate")/1000, 2);
|
||||
} else {
|
||||
m_khz->setNumber(0, 1);
|
||||
}
|
||||
if (info.contains ("channels") &&
|
||||
info.get<int32_t> ("channels") > 1) {
|
||||
m_stereo->setStereoMono (1, 0);
|
||||
} else {
|
||||
m_stereo->setStereoMono (0, 1);
|
||||
}
|
||||
|
||||
if (info.contains ("duration")) {
|
||||
m_posbar->setMax (info.get<int32_t> ("duration"));
|
||||
m_posbar->hideBar (false);
|
||||
} else {
|
||||
m_posbar->hideBar (true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::SetupToggleButtons (void)
|
||||
{
|
||||
QSettings s;
|
||||
|
||||
m_pls = new ToggleButton (this, Skin::PLS_ON_0, Skin::PLS_ON_1,
|
||||
Skin::PLS_OFF_0, Skin::PLS_OFF_1);
|
||||
m_pls->move(242, 58);
|
||||
if (!s.value ("playlist/hidden").toBool ())
|
||||
m_pls->toggle ();
|
||||
|
||||
connect (m_pls, SIGNAL(clicked()), this, SLOT(togglePL()));
|
||||
|
||||
m_eq = new ToggleButton (this, Skin::EQ_ON_0, Skin::EQ_ON_1,
|
||||
Skin::EQ_OFF_0, Skin::EQ_OFF_1);
|
||||
m_eq->move(219, 58);
|
||||
if (!s.value ("equalizer/hidden").toBool ())
|
||||
m_pls->toggle ();
|
||||
m_eq->setEnabled(false); // FIXME: Disabled for now, equalizer doesn't work yet
|
||||
|
||||
connect (m_eq, SIGNAL(clicked()), this, SLOT(toggleEQ()));
|
||||
|
||||
m_shuffle = new ToggleButton (this, Skin::SHUFFLE_ON_0, Skin::SHUFFLE_ON_1,
|
||||
Skin::SHUFFLE_OFF_0, Skin::SHUFFLE_OFF_1);
|
||||
m_shuffle->move(164, 89);
|
||||
m_shuffle->setEnabled(false); // FIXME: Disabled button for now, not yet implemented
|
||||
|
||||
m_repeat = new ToggleButton (this, Skin::REPEAT_ON_0, Skin::REPEAT_ON_1,
|
||||
Skin::REPEAT_OFF_0, Skin::REPEAT_OFF_1);
|
||||
m_repeat->move(210, 89);
|
||||
m_repeat->setEnabled(false); // FIXME: Disabled button for now, not yet implemented
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::togglePL (void)
|
||||
{
|
||||
m_mw->togglePL(false);
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::toggleEQ (void)
|
||||
{
|
||||
m_mw->toggleEQ(false);
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::toggleTime (void)
|
||||
{
|
||||
m_mw->setTimemodeReverse (!m_mw->isTimemodeReverse());
|
||||
}
|
||||
|
||||
void
|
||||
MainDisplay::SetupPushButtons (void)
|
||||
{
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
|
||||
/* Normal buttons */
|
||||
m_prev = new Button (this, Skin::BTN_PREV_0, Skin::BTN_PREV_1);
|
||||
m_prev->move(16, 88);
|
||||
connect (m_prev, SIGNAL(clicked()), &xmmsh, SLOT(prev()));
|
||||
|
||||
m_play = new Button (this, Skin::BTN_PLAY_0, Skin::BTN_PLAY_1);
|
||||
m_play->move(39, 88);
|
||||
connect (m_play, SIGNAL(clicked()), &xmmsh, SLOT(play()));
|
||||
|
||||
m_pause = new Button (this, Skin::BTN_PAUSE_0, Skin::BTN_PAUSE_1);
|
||||
m_pause->move(62, 88);
|
||||
connect (m_pause, SIGNAL(clicked()), &xmmsh, SLOT(pause()));
|
||||
|
||||
m_stop = new Button (this, Skin::BTN_STOP_0, Skin::BTN_STOP_1);
|
||||
m_stop->move(85, 88);
|
||||
connect (m_stop, SIGNAL(clicked()), &xmmsh, SLOT(stop()));
|
||||
|
||||
m_next = new Button (this, Skin::BTN_NEXT_0, Skin::BTN_NEXT_1);
|
||||
m_next->move(108, 88);
|
||||
connect (m_next, SIGNAL(clicked()), &xmmsh, SLOT(next()));
|
||||
|
||||
m_eject = new Button (this, Skin::BTN_EJECT_0, Skin::BTN_EJECT_1);
|
||||
m_eject->move(136, 89);
|
||||
connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen()));
|
||||
|
||||
}
|
||||
|
||||
MainDisplay::~MainDisplay (void)
|
||||
{
|
||||
}
|
118
src/mainwindow/maindisplay.h
Normal file
118
src/mainwindow/maindisplay.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __MAINDISPLAY_H__
|
||||
#define __MAINDISPLAY_H__
|
||||
|
||||
class MainDisplay;
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
#include <QBrush>
|
||||
#include <QPalette>
|
||||
|
||||
#include "Display.h"
|
||||
/*
|
||||
#include "TitleBar.h"
|
||||
#include "Button.h"
|
||||
#include "TextBar.h"
|
||||
#include "NumberDisplay.h"
|
||||
#include "TimeDisplay.h"
|
||||
#include "SmallNumberDisplay.h"
|
||||
#include "StereoMono.h"
|
||||
#include "Slider.h"
|
||||
#include "PlayStatus.h"
|
||||
#include "VolumeSlider.h"
|
||||
#include "MainWindow.h"
|
||||
*/
|
||||
|
||||
class Button;
|
||||
class ToggleButton;
|
||||
class TextScroller;
|
||||
class TimeDisplay;
|
||||
class SmallNumberDisplay;
|
||||
class StereoMono;
|
||||
class PosBar;
|
||||
class Slider;
|
||||
class PlayStatus;
|
||||
class MainWindow;
|
||||
class ClutterBar;
|
||||
|
||||
class MainDisplay : public SkinDisplay
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainDisplay (QWidget *parent);
|
||||
~MainDisplay ();
|
||||
ToggleButton *GetPls() {return m_pls;};
|
||||
ToggleButton *GetEq() {return m_eq;};
|
||||
|
||||
TextScroller *m_text;
|
||||
TimeDisplay *m_time;
|
||||
|
||||
SmallNumberDisplay *m_kbps;
|
||||
SmallNumberDisplay *m_khz;
|
||||
|
||||
StereoMono *m_stereo;
|
||||
PosBar *m_posbar;
|
||||
Slider *m_vslider;
|
||||
Slider *m_bslider;
|
||||
|
||||
PlayStatus *m_playstatus;
|
||||
MainWindow *getMW(void) { return m_mw; }
|
||||
|
||||
void mouseMoveEvent (QMouseEvent *);
|
||||
|
||||
public slots:
|
||||
void setPixmaps(Skin *skin);
|
||||
void setStatus (Xmms::Playback::Status status);
|
||||
void setPlaytime (uint32_t time);
|
||||
void setMediainfo (const Xmms::PropDict &);
|
||||
void togglePL(void);
|
||||
void toggleEQ(void);
|
||||
void toggleTime(void);
|
||||
void updateVolume (uint volume);
|
||||
void setVolume (int volume);
|
||||
|
||||
protected:
|
||||
void SetupPushButtons (void);
|
||||
void SetupToggleButtons (void);
|
||||
|
||||
Button *m_prev;
|
||||
Button *m_play;
|
||||
Button *m_pause;
|
||||
Button *m_stop;
|
||||
Button *m_next;
|
||||
Button *m_eject;
|
||||
|
||||
ToggleButton *m_pls;
|
||||
ToggleButton *m_eq;
|
||||
ToggleButton *m_shuffle;
|
||||
ToggleButton *m_repeat;
|
||||
|
||||
MainWindow *m_mw;
|
||||
|
||||
ClutterBar *m_clutterbar;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
149
src/mainwindow/mainwindow.cpp
Normal file
149
src/mainwindow/mainwindow.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#ifdef HAVE_SERVERBROWSER
|
||||
#include "ServerBrowser.h"
|
||||
#endif
|
||||
|
||||
#include "playlist.h"
|
||||
#include "maindisplay.h"
|
||||
#include "shadeddisplay.h"
|
||||
#include "equalizer.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QIcon>
|
||||
#include <QPluginLoader>
|
||||
#include <qplugin.h>
|
||||
|
||||
MainWindow::MainWindow (QWidget *parent) : QMainWindow (parent)
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
setGeometry(100, 100, 275, 116);
|
||||
#ifndef _WIN32
|
||||
setWindowIcon (QIcon (":icon.png"));
|
||||
#endif
|
||||
|
||||
if (!settings.contains ("mainwindow/shaded"))
|
||||
setShaded (true);
|
||||
else
|
||||
setShaded (!isShaded ());
|
||||
|
||||
/*
|
||||
* The MainDisplay is the mainwindow non-shaded mode
|
||||
*/
|
||||
m_display = new MainDisplay (this);
|
||||
setCentralWidget (m_display);
|
||||
m_display->show ();
|
||||
|
||||
/*
|
||||
* MainDisplay's shaded mode
|
||||
*/
|
||||
m_shaded = new ShadedDisplay (this);
|
||||
m_shaded->hide ();
|
||||
|
||||
switchDisplay ();
|
||||
|
||||
m_playlistwin = NULL;
|
||||
|
||||
if (!settings.contains ("mainwindow/pos"))
|
||||
settings.setValue ("mainwindow/pos", QPoint (100, 100));
|
||||
|
||||
move (settings.value("mainwindow/pos").toPoint ());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow ()
|
||||
{
|
||||
delete Skin::getInstance ();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::switchDisplay ()
|
||||
{
|
||||
QSettings s;
|
||||
|
||||
if (isShaded ()) {
|
||||
m_shaded->hide ();
|
||||
m_display->show ();
|
||||
resize (275, 116);
|
||||
setShaded (false);
|
||||
} else {
|
||||
m_display->hide ();
|
||||
m_shaded->show ();
|
||||
resize (275, 14);
|
||||
setShaded (true);
|
||||
}
|
||||
|
||||
update ();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::raisePL (void)
|
||||
{
|
||||
m_playlistwin->raise ();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::moveEvent (QMoveEvent *event)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue ("mainwindow/pos", pos ());
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::togglePL (bool UpdateButton)
|
||||
{
|
||||
QSettings s;
|
||||
|
||||
if(UpdateButton)
|
||||
{
|
||||
getMD()->GetPls()->toggle();
|
||||
}
|
||||
|
||||
|
||||
if (s.value ("playlist/hidden").toBool ()) {
|
||||
m_playlistwin->move (s.value("playlist/pos").toPoint ());
|
||||
m_playlistwin->show ();
|
||||
s.setValue ("playlist/hidden", false);
|
||||
} else {
|
||||
m_playlistwin->hide ();
|
||||
s.setValue ("playlist/hidden", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::toggleEQ (bool UpdateButton)
|
||||
{
|
||||
QSettings s;
|
||||
|
||||
if(UpdateButton)
|
||||
{
|
||||
getMD()->GetEq()->toggle();
|
||||
}
|
||||
|
||||
if (s.value ("equalizer/hidden").toBool ()) {
|
||||
m_equalizer->move (s.value("equalizer/pos").toPoint ());
|
||||
m_equalizer->show ();
|
||||
s.setValue ("equalizer/hidden", false);
|
||||
} else {
|
||||
m_equalizer->hide ();
|
||||
s.setValue ("equalizer/hidden", true);
|
||||
}
|
||||
}
|
83
src/mainwindow/mainwindow.h
Normal file
83
src/mainwindow/mainwindow.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __MAINWINDOW_H__
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
class MainWindow;
|
||||
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
#include <QSettings>
|
||||
|
||||
#include "xmmsqt4.h"
|
||||
|
||||
/*
|
||||
#include "Skin.h"
|
||||
#include "MainDisplay.h"
|
||||
#include "ShadedDisplay.h"
|
||||
#include "Playlist.h"
|
||||
*/
|
||||
|
||||
class XmmsQT4;
|
||||
class Skin;
|
||||
class MainDisplay;
|
||||
class ShadedDisplay;
|
||||
class PlaylistWindow;
|
||||
class EqualizerWindow;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow (QWidget *parent);
|
||||
~MainWindow (void);
|
||||
|
||||
MainDisplay *getMD () { return m_display; }
|
||||
ShadedDisplay *getSD () { return m_shaded; }
|
||||
PlaylistWindow *getPL () { return m_playlistwin; }
|
||||
|
||||
void setPL (PlaylistWindow *p) { m_playlistwin = p; }
|
||||
void setEQ (EqualizerWindow *e) { m_equalizer = e; }
|
||||
|
||||
void raisePL (void);
|
||||
void moveEvent (QMoveEvent *event);
|
||||
|
||||
void togglePL (bool UpdateButton);
|
||||
void toggleEQ (bool UpdateButton);
|
||||
bool isTimemodeReverse(void) { QSettings s; return s.value("MainWindow/timemodereverse").toBool(); }
|
||||
void setTimemodeReverse(bool b) { QSettings s; return s.setValue("MainWindow/timemodereverse",b); }
|
||||
|
||||
public slots:
|
||||
void switchDisplay ();
|
||||
|
||||
private:
|
||||
bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); }
|
||||
void setShaded (bool b) { QSettings s; return s.setValue("MainWindow/shaded", b); }
|
||||
MainDisplay *m_display;
|
||||
ShadedDisplay *m_shaded;
|
||||
PlaylistWindow *m_playlistwin;
|
||||
EqualizerWindow *m_equalizer;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
14
src/mainwindow/mainwindow.pri
Normal file
14
src/mainwindow/mainwindow.pri
Normal file
|
@ -0,0 +1,14 @@
|
|||
HEADERS += clutterbar.h \
|
||||
mainwindow.h \
|
||||
maindisplay.h \
|
||||
shadeddisplay.h \
|
||||
stereomono.h
|
||||
|
||||
SOURCES += clutterbar.cpp \
|
||||
mainwindow.cpp \
|
||||
maindisplay.cpp \
|
||||
shadeddisplay.cpp \
|
||||
stereomono.cpp
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
DEPENDPATH += $$PWD
|
123
src/mainwindow/shadeddisplay.cpp
Normal file
123
src/mainwindow/shadeddisplay.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include "shadeddisplay.h"
|
||||
#include "TitleBar.h"
|
||||
#include "Button.h"
|
||||
|
||||
#include "SmallNumberDisplay.h"
|
||||
#include "TextBar.h"
|
||||
|
||||
ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
|
||||
{
|
||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||
|
||||
setMinimumSize (275, 14);
|
||||
setMaximumSize (275, 14);
|
||||
|
||||
m_tbar = new TitleBar(this, true);
|
||||
m_tbar->move (0, 0);
|
||||
|
||||
m_number = new SmallNumberDisplay (this, 10);
|
||||
m_number->move (135, 4);
|
||||
m_number->setNumber (0, 2);
|
||||
|
||||
m_number2 = new SmallNumberDisplay (this, 10);
|
||||
m_number2->move (147, 4);
|
||||
m_number2->setNumber (0, 2);
|
||||
|
||||
m_title = new TextScroller (this, 39, 7, "shaded");
|
||||
m_title->move (79, 4);
|
||||
|
||||
m_prev = new Button (this);
|
||||
m_prev->move(169, 4);
|
||||
m_prev->resize (8, 7);
|
||||
connect (m_prev, SIGNAL(clicked()), &xmmsh, SLOT(prev()));
|
||||
|
||||
m_play = new Button (this);
|
||||
m_play->move(177, 4);
|
||||
m_play->resize (10, 7);
|
||||
connect (m_play, SIGNAL(clicked()), &xmmsh, SLOT(play()));
|
||||
|
||||
m_pause = new Button (this);
|
||||
m_pause->move(187, 4);
|
||||
m_pause->resize (10, 7);
|
||||
connect (m_pause, SIGNAL(clicked()), &xmmsh, SLOT(pause()));
|
||||
|
||||
m_stop = new Button (this);
|
||||
m_stop->move(197, 4);
|
||||
m_stop->resize (9, 7);
|
||||
connect (m_stop, SIGNAL(clicked()), &xmmsh, SLOT(stop()));
|
||||
|
||||
m_next = new Button (this);
|
||||
m_next->move(206, 4);
|
||||
m_next->resize (8, 7);
|
||||
connect (m_next, SIGNAL(clicked()), &xmmsh, SLOT(next()));
|
||||
|
||||
m_eject = new Button (this);
|
||||
m_eject->move(216, 4);
|
||||
m_eject->resize (9, 7);
|
||||
connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen()));
|
||||
|
||||
connect (&xmmsh, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
|
||||
this, SLOT(setStatus(Xmms::Playback::Status)));
|
||||
connect (xmmsh.cache (), SIGNAL (playtime (uint32_t)),
|
||||
this, SLOT ( setPlaytime(uint32_t)));
|
||||
connect (&xmmsh, SIGNAL(currentSong (const Xmms::PropDict &)),
|
||||
this, SLOT(setMediainfo (const Xmms::PropDict &)));
|
||||
}
|
||||
|
||||
void
|
||||
ShadedDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||
{
|
||||
QString n;
|
||||
if (info.contains ("artist") && info.contains ("album") &&
|
||||
info.contains ("title")) {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("artist").c_str ())
|
||||
+ " - " +
|
||||
QString::fromUtf8 (info.get<std::string> ("album").c_str ())
|
||||
+ " - " +
|
||||
QString::fromUtf8 (info.get<std::string> ("title").c_str ());
|
||||
} else {
|
||||
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
|
||||
}
|
||||
m_title->setText (n);
|
||||
}
|
||||
|
||||
void
|
||||
ShadedDisplay::setStatus (Xmms::Playback::Status status)
|
||||
{
|
||||
if (status == Xmms::Playback::STOPPED) {
|
||||
m_number->setNumber (0, 2);
|
||||
m_number2->setNumber (0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadedDisplay::setPlaytime (uint32_t time)
|
||||
{
|
||||
uint sec, min;
|
||||
|
||||
sec = (time / 1000) % 60;
|
||||
min = (time / 1000) / 60;
|
||||
|
||||
m_number2->setNumber (sec, 2);
|
||||
m_number->setNumber (min, 2);
|
||||
}
|
||||
|
||||
|
54
src/mainwindow/shadeddisplay.h
Normal file
54
src/mainwindow/shadeddisplay.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __SHADEDDISPLAY_H__
|
||||
#define __SHADEDDISPLAY_H__
|
||||
|
||||
class ShadedDisplay;
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "Display.h"
|
||||
|
||||
class MainWindow;
|
||||
class Button;
|
||||
class SmallNumberDisplay;
|
||||
class TextScroller;
|
||||
|
||||
class ShadedDisplay : public SkinDisplay
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShadedDisplay (QWidget *parent);
|
||||
~ShadedDisplay () { }
|
||||
|
||||
SmallNumberDisplay *m_number;
|
||||
SmallNumberDisplay *m_number2;
|
||||
TextScroller *m_title;
|
||||
|
||||
private:
|
||||
Button *m_prev;
|
||||
Button *m_play;
|
||||
Button *m_pause;
|
||||
Button *m_stop;
|
||||
Button *m_next;
|
||||
Button *m_eject;
|
||||
|
||||
public slots:
|
||||
void setStatus (Xmms::Playback::Status status);
|
||||
void setPlaytime (uint32_t time);
|
||||
void setMediainfo (const Xmms::PropDict &info);
|
||||
};
|
||||
|
||||
#endif
|
78
src/mainwindow/stereomono.cpp
Normal file
78
src/mainwindow/stereomono.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "stereomono.h"
|
||||
#include "Skin.h"
|
||||
|
||||
StereoMono::StereoMono (QWidget *parent) : PixWidget (parent)
|
||||
{
|
||||
setMinimumSize (56, 12);
|
||||
setMaximumSize (56, 12);
|
||||
|
||||
m_pixmap = QPixmap (56, 12);
|
||||
}
|
||||
|
||||
void
|
||||
StereoMono::setPixmaps (Skin *skin)
|
||||
{
|
||||
m_pixmap_stereo_on = skin->getItem (Skin::STEREO_1);
|
||||
m_pixmap_stereo_off = skin->getItem (Skin::STEREO_0);
|
||||
m_pixmap_mono_on = skin->getItem (Skin::MONO_1);
|
||||
m_pixmap_mono_off = skin->getItem (Skin::MONO_0);
|
||||
|
||||
setStereoMono (m_stereo, m_mono);
|
||||
}
|
||||
|
||||
void
|
||||
StereoMono::drawPixmaps ()
|
||||
{
|
||||
QPainter paint;
|
||||
paint.begin (&m_pixmap);
|
||||
|
||||
paint.drawPixmap (QRect (0, 0, 27, 12),
|
||||
m_pixmap_mono,
|
||||
m_pixmap.rect ());
|
||||
|
||||
paint.drawPixmap (QRect (27, 0, 29, 12),
|
||||
m_pixmap_stereo,
|
||||
m_pixmap.rect ());
|
||||
paint.end ();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
StereoMono::setStereoMono (bool stereo, bool mono)
|
||||
{
|
||||
|
||||
if (stereo) {
|
||||
m_pixmap_stereo = m_pixmap_stereo_on;
|
||||
} else {
|
||||
m_pixmap_stereo = m_pixmap_stereo_off;
|
||||
}
|
||||
|
||||
if (mono) {
|
||||
m_pixmap_mono = m_pixmap_mono_on;
|
||||
} else {
|
||||
m_pixmap_mono = m_pixmap_mono_off;
|
||||
}
|
||||
|
||||
m_stereo = stereo;
|
||||
m_mono = mono;
|
||||
|
||||
drawPixmaps ();
|
||||
|
||||
}
|
||||
|
46
src/mainwindow/stereomono.h
Normal file
46
src/mainwindow/stereomono.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* This file is a part of Prome, an XMMS2 Client.
|
||||
*
|
||||
* Copyright (C) 2005-2007 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __STEREOMONO_H__
|
||||
#define __STEREOMONO_H__
|
||||
|
||||
#include "PixWidget.h"
|
||||
|
||||
class StereoMono : public PixWidget
|
||||
{
|
||||
public:
|
||||
StereoMono (QWidget *parent);
|
||||
~StereoMono () { }
|
||||
|
||||
void setStereoMono (bool, bool);
|
||||
|
||||
public slots:
|
||||
void setPixmaps (Skin *skin);
|
||||
|
||||
private:
|
||||
void drawPixmaps ();
|
||||
bool m_stereo;
|
||||
bool m_mono;
|
||||
|
||||
QPixmap m_pixmap_stereo_on;
|
||||
QPixmap m_pixmap_stereo_off;
|
||||
QPixmap m_pixmap_mono_on;
|
||||
QPixmap m_pixmap_mono_off;
|
||||
|
||||
QPixmap m_pixmap_mono;
|
||||
QPixmap m_pixmap_stereo;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue