Make difference on ShadedDisplay and MainDisplay in settings

This commit is contained in:
Tobias Rundstrom 2006-03-05 15:31:31 -03:00
parent 0498d4d44a
commit 152e1b2be8
6 changed files with 161 additions and 53 deletions

View file

@ -17,7 +17,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
SetupPushButtons (); SetupPushButtons ();
SetupToggleButtons (); SetupToggleButtons ();
m_text = new TextScroller (this, 154, 15); m_text = new TextScroller (this, 154, 15, "main");
m_text->move (109, 23); m_text->move (109, 23);
m_number = new NumberDisplay (this, 33, 11); m_number = new NumberDisplay (this, 33, 11);

View file

@ -10,7 +10,7 @@ SettingsWindow::SettingsWindow (QWidget *parent) : QMainWindow (parent)
setWindowIcon (QIcon (":icon.png")); setWindowIcon (QIcon (":icon.png"));
#endif #endif
resize (400, 300); resize (400, 400);
QWidget *dummy = new QWidget (this); QWidget *dummy = new QWidget (this);
setCentralWidget (dummy); setCentralWidget (dummy);
@ -57,34 +57,121 @@ SettingsTabMain::SettingsTabMain (QWidget *parent) : QWidget (parent)
{ {
QSettings s; QSettings s;
QVBoxLayout *vbox = new QVBoxLayout (this); QWidget *dummy = new QWidget (this);
QWidget *c = new QWidget (this);
QVBoxLayout *vbox = new QVBoxLayout (dummy);
QWidget *c = new QWidget (dummy);
QHBoxLayout *h = new QHBoxLayout (c); QHBoxLayout *h = new QHBoxLayout (c);
vbox->addWidget (c); vbox->addWidget (c);
m_quitonclose = new QCheckBox (tr ("Quit XMMS2D when closing Promoe"), c);
if (s.contains ("promoe/quitonclose"))
s.setValue ("promoe/quitonclose", false);
m_quitonclose->setCheckState (s.value ("promoe/quitonclose").toBool () ? Qt::Checked : Qt::Unchecked);
h->addWidget (m_quitonclose);
c = new QWidget (dummy);
h = new QHBoxLayout (c);
vbox->addWidget (c);
QLabel *l = new QLabel (tr ("Unshaded view"), c);
s.beginGroup ("maindisplay"); QFrame *f = new QFrame (c);
m_scrolltbar = new QCheckBox (tr ("Scroll titlebar"), this); f->setFrameStyle (QFrame::HLine | QFrame::Raised);
h->addWidget (l);
h->addWidget (f, 1);
if (s.value("scrollbar").toBool ()) c = new QWidget (dummy);
m_scrolltbar->setCheckState (Qt::Checked); h = new QHBoxLayout (c);
vbox->addWidget (c);
s.beginGroup ("display_main");
m_mainscroll = new QCheckBox (tr ("Scroll titlebar"), c);
if (s.value("scroll").toBool ())
m_mainscroll->setCheckState (Qt::Checked);
else else
m_scrolltbar->setCheckState (Qt::Unchecked); m_mainscroll->setCheckState (Qt::Unchecked);
h->addWidget (m_scrolltbar); h->addWidget (m_mainscroll);
m_fontsize = new QSpinBox (this); m_mainsize = new QSpinBox (c);
m_fontsize->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); m_mainsize->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
m_fontsize->setMinimum (6); m_mainsize->setMinimum (6);
m_fontsize->setMaximum (20); m_mainsize->setMaximum (20);
m_fontsize->setValue (s.value("fontsize").toInt ()); m_mainsize->setValue (s.value("fontsize").toInt ());
h->addWidget (m_fontsize); h->addWidget (m_mainsize);
QLabel *l = new QLabel (tr ("Titlebar fontsize"), this); l = new QLabel (tr ("Titlebar fontsize"), c);
l->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); l->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
h->addWidget (l); h->addWidget (l);
QFrame *f = new QFrame (this); c = new QWidget (dummy);
h = new QHBoxLayout (c);
vbox->addWidget (c);
m_mainttf = new QCheckBox (tr ("Draw text with TrueType fonts"), dummy);
m_mainttf->setCheckState (s.value ("ttf").toBool () ? Qt::Checked : Qt::Unchecked);
h->addWidget (m_mainttf);
s.endGroup ();
c = new QWidget (dummy);
h = new QHBoxLayout (c);
vbox->addWidget (c);
l = new QLabel (tr ("Shaded view"), c);
f = new QFrame (c);
f->setFrameStyle (QFrame::HLine | QFrame::Raised);
h->addWidget (l);
h->addWidget (f, 1);
c = new QWidget (dummy);
h = new QHBoxLayout (c);
vbox->addWidget (c);
s.beginGroup ("display_shaded");
m_shadescroll = new QCheckBox (tr ("Scroll titlebar"), c);
if (s.value("scroll").toBool ())
m_shadescroll->setCheckState (Qt::Checked);
else
m_shadescroll->setCheckState (Qt::Unchecked);
h->addWidget (m_shadescroll);
m_shadesize = new QSpinBox (c);
m_shadesize->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
m_shadesize->setMinimum (6);
m_shadesize->setMaximum (20);
m_shadesize->setValue (s.value("fontsize").toInt ());
h->addWidget (m_shadesize);
l = new QLabel (tr ("Titlebar fontsize"), c);
l->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
h->addWidget (l);
c = new QWidget (dummy);
h = new QHBoxLayout (c);
vbox->addWidget (c);
m_shadettf = new QCheckBox (tr ("Draw text with TrueType fonts"), dummy);
m_shadettf->setCheckState (s.value ("ttf").toBool () ? Qt::Checked : Qt::Unchecked);
h->addWidget (m_shadettf);
/*
QFrame *f = new QFrame (dummy);
f->setFrameStyle (QFrame::HLine | QFrame::Raised); f->setFrameStyle (QFrame::HLine | QFrame::Raised);
vbox->addWidget (f, 1); vbox->addWidget (f, 1);
@ -97,7 +184,6 @@ SettingsTabMain::SettingsTabMain (QWidget *parent) : QWidget (parent)
m_mainttf->setCheckState (s.value ("mainttf").toBool () ? Qt::Checked : Qt::Unchecked); m_mainttf->setCheckState (s.value ("mainttf").toBool () ? Qt::Checked : Qt::Unchecked);
h->addWidget (m_mainttf); h->addWidget (m_mainttf);
/*
c = new QWidget (this); c = new QWidget (this);
h = new QHBoxLayout (c); h = new QHBoxLayout (c);
@ -106,7 +192,6 @@ SettingsTabMain::SettingsTabMain (QWidget *parent) : QWidget (parent)
m_shadettf = new QCheckBox (tr ("Draw shaded title with TrueType fonts"), this); m_shadettf = new QCheckBox (tr ("Draw shaded title with TrueType fonts"), this);
m_shadettf->setCheckState (s.value ("shadettf").toBool () ? Qt::Checked : Qt::Unchecked); m_shadettf->setCheckState (s.value ("shadettf").toBool () ? Qt::Checked : Qt::Unchecked);
h->addWidget (m_shadettf); h->addWidget (m_shadettf);
*/
f = new QFrame (this); f = new QFrame (this);
f->setFrameStyle (QFrame::HLine | QFrame::Raised); f->setFrameStyle (QFrame::HLine | QFrame::Raised);
@ -117,14 +202,10 @@ SettingsTabMain::SettingsTabMain (QWidget *parent) : QWidget (parent)
vbox->addWidget (c); vbox->addWidget (c);
m_quitonclose = new QCheckBox (tr ("Quit XMMS2D when closing Promoe"));
if (s.contains ("quitonclose"))
s.setValue ("quitonclose", false);
m_quitonclose->setCheckState (s.value ("quitonclose").toBool () ? Qt::Checked : Qt::Unchecked);
h->addWidget (m_quitonclose);
s.endGroup (); s.endGroup ();
*/
} }
@ -132,11 +213,18 @@ void
SettingsTabMain::saveSettings (void) SettingsTabMain::saveSettings (void)
{ {
QSettings s; QSettings s;
s.setValue ("promoe/quitonclose", m_quitonclose->checkState () == Qt::Checked);
s.beginGroup ("maindisplay"); s.beginGroup ("display_main");
s.setValue ("scrollbar", m_scrolltbar->checkState () == Qt::Checked); s.setValue ("scroll", m_mainscroll->checkState () == Qt::Checked);
s.setValue ("fontsize", m_fontsize->value ()); s.setValue ("fontsize", m_mainsize->value ());
s.setValue ("quitonclose", m_quitonclose->checkState () == Qt::Checked); s.setValue ("ttf", m_mainttf->checkState () == Qt::Checked);
s.setValue ("mainttf", m_mainttf->checkState () == Qt::Checked); s.endGroup ();
s.beginGroup ("display_shaded");
s.setValue ("scroll", m_shadescroll->checkState () == Qt::Checked);
s.setValue ("fontsize", m_shadesize->value ());
s.setValue ("ttf", m_shadettf->checkState () == Qt::Checked);
s.endGroup (); s.endGroup ();
} }

View file

@ -19,11 +19,14 @@ class SettingsTabMain : public QWidget {
private: private:
QCheckBox *m_scrolltbar;
QSpinBox *m_fontsize;
QCheckBox *m_quitonclose; QCheckBox *m_quitonclose;
QSpinBox *m_mainsize;
QCheckBox *m_mainttf; QCheckBox *m_mainttf;
QCheckBox *m_mainscroll;
QSpinBox *m_shadesize;
QCheckBox *m_shadettf; QCheckBox *m_shadettf;
QCheckBox *m_shadescroll;
}; };
class SettingsWindow : public QMainWindow { class SettingsWindow : public QMainWindow {

View file

@ -18,7 +18,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
m_number2->move (147, 4); m_number2->move (147, 4);
m_number2->setNumber (0, 2); m_number2->setNumber (0, 2);
m_title = new TextScroller (this, 48, 7); m_title = new TextScroller (this, 48, 7, "shaded");
m_title->move (79, 4); m_title->move (79, 4);
m_title->setText ("Promoe 0.1"); m_title->setText ("Promoe 0.1");

View file

@ -2,7 +2,9 @@
#include "Display.h" #include "Display.h"
#include "TextBar.h" #include "TextBar.h"
TextScroller::TextScroller (QWidget *parent, uint w, uint h) : QWidget (parent) TextScroller::TextScroller (QWidget *parent, uint w,
uint h, const QString &name) :
QWidget (parent)
{ {
XMMSHandler *xmmsh = XMMSHandler::getInstance (); XMMSHandler *xmmsh = XMMSHandler::getInstance ();
Skin *skin = Skin::getInstance (); Skin *skin = Skin::getInstance ();
@ -12,27 +14,26 @@ TextScroller::TextScroller (QWidget *parent, uint w, uint h) : QWidget (parent)
QSettings s; QSettings s;
s.beginGroup ("maindisplay"); s.beginGroup ("display_" + name);
if (!s.contains("scrollbar")) if (!s.contains("scroll"))
s.setValue("scrollbar", true); s.setValue("scroll", true);
if (!s.contains("fontsize")) if (!s.contains("fontsize"))
s.setValue("fontsize", 8); s.setValue("fontsize", 8);
if (!s.contains("mainttf")) if (!s.contains("ttf"))
s.setValue("mainttf", true); s.setValue("ttf", true);
if (!s.contains("shadettf"))
s.setValue("shadettf", true);
m_name = name;
m_h = h; m_h = h;
m_w = w; m_w = w;
m_x_off = 0; m_x_off = 0;
m_x2_off = 0; m_x2_off = 0;
m_fontsize = s.value ("fontsize").toInt (); m_fontsize = s.value ("fontsize").toInt ();
m_ttf = s.value ("mainttf").toBool (); m_ttf = s.value ("ttf").toBool ();
m_text = "Promoe 0.1"; m_text = "Promoe 0.1";
m_scroll = s.value ("scroll").toBool ();
s.endGroup (); s.endGroup ();
@ -54,9 +55,16 @@ void
TextScroller::settingsSaved (void) TextScroller::settingsSaved (void)
{ {
QSettings s; QSettings s;
s.beginGroup ("maindisplay"); s.beginGroup ("display_" + m_name);
m_fontsize = s.value ("fontsize").toInt (); m_fontsize = s.value ("fontsize").toInt ();
m_ttf = s.value ("mainttf").toBool (); m_ttf = s.value ("ttf").toBool ();
if (m_scroll != s.value ("scroll").toBool ()) {
m_x_off = 0;
m_x2_off = 0;
}
m_scroll = s.value ("scroll").toBool ();
s.endGroup (); s.endGroup ();
setText (m_text); setText (m_text);
@ -83,7 +91,7 @@ TextScroller::addOffset ()
} else if (m_x_off < m_pixmap.size().width()) { } else if (m_x_off < m_pixmap.size().width()) {
m_x_off ++; m_x_off ++;
} else { } else {
m_x_off = 1; m_x_off = 0;
m_x2_off = 0; m_x2_off = 0;
} }
@ -101,8 +109,6 @@ TextScroller::setText (QString text)
} else { } else {
drawBitmapFont (text); drawBitmapFont (text);
} }
m_x_off = 1;
m_x2_off = 0;
update (); update ();
} }
@ -116,9 +122,13 @@ TextScroller::drawBitmapFont (QString text)
if (width > m_w) { if (width > m_w) {
temp += QString::fromAscii (" -- "); temp += QString::fromAscii (" -- ");
m_x2_off = m_w / 2;
m_pixmap = QPixmap (width + 6*6, m_h); m_pixmap = QPixmap (width + 6*6, m_h);
m_timer->start (40);
if (m_scroll) {
m_timer->start (40);
} else {
m_timer->stop ();
}
} else { } else {
m_pixmap = QPixmap (m_w, m_h); m_pixmap = QPixmap (m_w, m_h);
} }
@ -166,10 +176,15 @@ TextScroller::drawQtFont (QString text)
if (rect.width() > m_w) { if (rect.width() > m_w) {
temp += QString::fromAscii (" -- "); temp += QString::fromAscii (" -- ");
QRect rect = fM.boundingRect (temp); QRect rect = fM.boundingRect (temp);
m_timer->start (40);
m_x2_off = m_w / 2;
m_pixmap = QPixmap (rect.width(), m_h); m_pixmap = QPixmap (rect.width(), m_h);
if (m_scroll) {
m_timer->start (40);
} else {
m_timer->stop ();
}
} else { } else {
m_pixmap = QPixmap (m_w, m_h); m_pixmap = QPixmap (m_w, m_h);
} }

View file

@ -19,7 +19,7 @@ class TextScroller : public QWidget
Q_OBJECT Q_OBJECT
public: public:
TextScroller (QWidget *parent, uint, uint); TextScroller (QWidget *parent, uint, uint, const QString &);
~TextScroller (); ~TextScroller ();
void setText(QString text); void setText(QString text);
@ -43,9 +43,11 @@ class TextScroller : public QWidget
int m_x2_off; int m_x2_off;
int m_fontsize; int m_fontsize;
bool m_ttf; bool m_ttf;
bool m_scroll;
QTimer *m_timer; QTimer *m_timer;
QString m_text; QString m_text;
QString m_name;
void drawBitmapFont (QString text); void drawBitmapFont (QString text);
void drawQtFont (QString text); void drawQtFont (QString text);