1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/***************************************************************************
osdiface.cpp - description
-------------------
begin : Sun Mar 17 2002
copyright : (C) 2002 by Vladimir Shutoff
email : vovan@shutoff.ru
***************************************************************************/
/***************************************************************************
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qspinbox.h>
#include <qlabel.h>
#include "fontedit.h"
#include "misc.h"
#include "qcolorbutton.h"
#include "osdiface.h"
#include "osd.h"
using namespace SIM;
OSDIface::OSDIface(QWidget *parent, void *d, OSDPlugin *plugin)
: OSDIfaceBase(parent)
{
m_plugin = plugin;
OSDUserData *data = (OSDUserData*)d;
#ifndef WIN32
chkFading->setChecked(false);
chkFading->hide();
#endif
cmbPos->insertItem(i18n("Left-bottom"));
cmbPos->insertItem(i18n("Left-top"));
cmbPos->insertItem(i18n("Right-bottom"));
cmbPos->insertItem(i18n("Right-top"));
cmbPos->insertItem(i18n("Center-bottom"));
cmbPos->insertItem(i18n("Center-top"));
cmbPos->insertItem(i18n("Center"));
cmbPos->setCurrentItem(data->Position.toULong());
spnOffs->setMinValue(0);
spnOffs->setMaxValue(500);
spnOffs->setValue(data->Offset.toULong());
spnTimeout->setMinValue(1);
spnTimeout->setMaxValue(60);
spnTimeout->setValue(data->Timeout.toULong());
btnColor->setColor(data->Color.toULong());
if (data->Font.str().isEmpty()){
edtFont->setFont(FontEdit::font2str(plugin->getBaseFont(font()), false));
}else{
edtFont->setFont(data->Font.str());
}
chkShadow->setChecked(data->Shadow.toBool());
chkFading->setChecked(data->Fading.toBool());
if (data->Background.toBool()){
chkBackground->setChecked(true);
btnBgColor->setColor(data->BgColor.toULong());
}else{
chkBackground->setChecked(false);
}
bgToggled(data->Background.toBool());
connect(chkBackground, SIGNAL(toggled(bool)), this, SLOT(bgToggled(bool)));
unsigned nScreens = screens();
if (nScreens <= 1){
lblScreen->hide();
cmbScreen->hide();
}else{
for (unsigned i = 0; i < nScreens; i++)
cmbScreen->insertItem(QString::number(i));
unsigned curScreen = data->Screen.toULong();
if (curScreen >= nScreens)
curScreen = 0;
cmbScreen->setCurrentItem(curScreen);
}
}
void OSDIface::bgToggled(bool bState)
{
if (bState){
btnBgColor->setEnabled(true);
return;
}
btnBgColor->setColor(colorGroup().base());
btnBgColor->setEnabled(false);
}
void OSDIface::apply(void *d)
{
OSDUserData *data = (OSDUserData*)d;
data->Position.asULong() = cmbPos->currentItem();
data->Offset.asULong() = spnOffs->text().toULong();
data->Timeout.asULong() = spnTimeout->text().toULong();
data->Color.asULong() = btnColor->color().rgb();
QString f = edtFont->getFont();
QString base = FontEdit::font2str(m_plugin->getBaseFont(font()), false);
if (f == base)
f = "";
data->Font.str() = f;
data->Shadow.asBool() = chkShadow->isChecked();
data->Fading.asBool() = chkFading->isChecked();
data->Background.asBool() = chkBackground->isChecked();
if (data->Background.toBool()){
data->BgColor.asULong() = btnBgColor->color().rgb();
}else{
data->BgColor.asULong() = 0;
}
unsigned nScreens = screens();
if (nScreens <= 1){
data->Screen.asULong() = 0;
}else{
data->Screen.asULong() = cmbScreen->currentItem();
}
}
#ifndef NO_MOC_INCLUDES
#include "osdiface.moc"
#endif
|