void PluginSlider::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	
	QColor color = themer()->get_color("PluginSlider:value");
	QColor background = themer()->get_color("PluginSlider:background");
	
	if (highlight) {
		color = color.light(110);
		background = background.light(105);
	}
	
	// avoid painting at 0, it looks bad...
	if (m_xpos <= 1) m_xpos = 2;
	
	painter.setBrush(background);
        painter.setPen(themer()->get_color("PluginSlider:text"));
	QRectF rect(0.0, 0.0, width() - 0.5, height() - 0.5);
	painter.drawRect(rect);
	painter.fillRect(1, 1, m_xpos - 2, height() - 2, QBrush(color));
	if (m_port->get_hint() == PluginPort::INT_CONTROL) {
		painter.drawText(0, 0, width(), height(), Qt::AlignCenter, QString::number((int)m_value));
	} else {
		painter.drawText(0, 0, width(), height(), Qt::AlignCenter, QString::number(m_value, 'f', 2));
	}
}
void SpectralMeterView::update_background()
{
        PENTER3;
	// draw the background image
	bgPixmap = QPixmap((int)m_boundingRect.width(), (int)m_boundingRect.height());

	QPainter painter(&bgPixmap);
	painter.fillRect(m_boundingRect, m_brushMargin);
	painter.fillRect(m_rect, m_brushBg);
	painter.setFont(themer()->get_font("FFTMeter:fontscale:label"));
	QFontMetrics fm(themer()->get_font("FFTMeter:fontscale:label"));

	QString spm;

	// draw horizontal lines + labels
	for (float i = upper_db; i >= lower_db; i -= 10.0f) {
		float f = db2ypos(i);

		painter.setPen(m_penGrid);
		painter.drawLine(QPointF(m_rect.x(), f), QPointF(m_rect.right(), f));

		painter.setPen(m_penFont);
		spm.sprintf("%2.0f", i);
		painter.drawText(m_rect.right() + 1, (int)f + fm.ascent()/2, spm);
	}

	// draw frequency labels and tickmarks
	float last_pos = 1.0;
	for (int i = 0; i < m_freq_labels.size(); ++i) {
		// check if we have space to draw the labels by checking if the
		// m_rect is borderless
		if (!m_rect.top()) {
			break;
		}

		float f = freq2xpos(m_freq_labels.at(i));

		// check if the freq is in the visible range
		if (!f) {
			continue;
		}

		spm.sprintf("%2.0f", m_freq_labels.at(i));
		float s = (float)fm.width(spm)/2.0f;


		// draw text only if there is enough space for it
		if (((f - s) > last_pos) && ((f + s) < float(m_boundingRect.width()-1))) {
			painter.setPen(m_penFont);
			painter.drawText(QPointF(f - s, m_boundingRect.height() - fm.descent() - 3), spm);
			last_pos = f + s + 1.0;
			painter.setPen(m_penTickMain);
		} else {
			painter.setPen(m_penTickSub);
		}

		painter.drawLine(QPointF(f, m_rect.bottom()), QPointF(f, m_rect.bottom() + 3));
	}
}
Beispiel #3
0
void Traverso::create_interface( )
{
	themer()->load();
	cpointer().add_contextitem(new TTransport());
        TMainWindow* tMainWindow = TMainWindow::instance();
        tMainWindow->show();

	QString projectToLoad = "";
	
	foreach(QString string, QCoreApplication::arguments ()) {
		if (string.contains("project.tpf")) {
			projectToLoad = string;
			break;
		}
	}
	
	// The user clicked on a project.tpf file, start extracting the 
	// baseproject directory, and the project name from the filename.
	if (!projectToLoad.isEmpty()) {
		QFileInfo fi(projectToLoad);
		QDir projectdir(fi.path());
		QDir baseprojectdir(fi.path());
		baseprojectdir.cdUp();
		QString baseprojectdirpath = baseprojectdir.path();
		QString projectdirpath = projectdir.path();
		QString projectname = projectdirpath.mid(baseprojectdirpath.length() + 1, projectdirpath.length());
		
		if (!projectname.isEmpty() && ! baseprojectdirpath.isEmpty()) {
			pm().start(baseprojectdirpath, projectname);
			return;
		}
	}
}
Beispiel #4
0
Traverso::~Traverso()
{
	PENTERDES;
	delete TMainWindow::instance();
	delete themer();
        config().save();
	audiodevice().shutdown();
}
Beispiel #5
0
void
KdmLabel::doPlugActions( bool plug )
{
	if (action) {
		QWidget *w = themer()->widget();
		if (plug)
			w->addAction( action );
		else
			w->removeAction( action );
	}
}
void SpectralMeterView::load_theme_data()
{
	m_brushFg = themer()->get_brush("FFTMeter:foreground", QPoint(0, 0), QPoint(0, m_boundingRect.height()));
	m_brushBg = themer()->get_brush("FFTMeter:background", QPoint(0, 0), QPoint(0, m_boundingRect.height()));
	m_brushMargin = themer()->get_brush("FFTMeter:margin", QPoint(0, 0), QPoint(0, m_rect.height()));
	m_penAvgCurve.setColor(themer()->get_color("FFTMeter:curve:average"));
	m_penTickMain.setColor(themer()->get_color("FFTMeter:tickmarks:main"));
        m_penTickSub.setColor(themer()->get_color("FFTMeter:tickmarks:sub"));
	m_penFont.setColor(themer()->get_color("FFTMeter:text"));
	m_penGrid.setColor(themer()->get_color("FFTMeter:grid"));

        // force the bgPixmap to be recreated on the first paint event.
        bgPixmap = QPixmap();
}
SpectralMeterView::SpectralMeterView(SpectralMeterWidget* widget)
	: MeterView(widget)
{

	m_config = 0;

        m_meter = new SpectralMeter();
        m_meter->init();

	load_configuration();
	
	upper_freq_log = log10(upper_freq);
	lower_freq_log = log10(lower_freq);
	sample_rate = audiodevice().get_sample_rate();
	show_average = false;
	update_average = true;
	sample_weight = 1;

	QFontMetrics fm(themer()->get_font("FFTMeter:fontscale:label"));
	margin_l = 5;
	margin_r = fm.width("-XX") + 5;
	margin_t = fm.ascent()/2 + 5;
	margin_b = fm.ascent() + fm.descent() + 10;
	

	for (int i = 0; i < 4; ++i) {
		m_freq_labels.push_back(10.0f * pow(10.0,i));
		m_freq_labels.push_back(20.0f * pow(10.0,i));
		m_freq_labels.push_back(30.0f * pow(10.0,i));
		m_freq_labels.push_back(40.0f * pow(10.0,i));
		m_freq_labels.push_back(50.0f * pow(10.0,i));
		m_freq_labels.push_back(60.0f * pow(10.0,i));
		m_freq_labels.push_back(70.0f * pow(10.0,i));
		m_freq_labels.push_back(80.0f * pow(10.0,i));
		m_freq_labels.push_back(90.0f * pow(10.0,i));
	}

	connect(themer(), SIGNAL(themeLoaded()), this, SLOT(load_theme_data()), Qt::QueuedConnection);
}
Beispiel #8
0
void
KdmItem::updateThisVisible()
{
    bool show = m_shown;
    if (show && (!m_showType.isNull() || m_minScrWidth || m_minScrHeight)) {
        KdmThemer *thm = themer();
        if ((!m_showType.isNull() &&
             !(thm->typeVisible(m_showType) ^ m_showTypeInvert)) ||
            (thm->widget() &&
             (thm->widget()->width() < m_minScrWidth ||
              thm->widget()->height() < m_minScrHeight)))
        {
            show = false;
        }
    }
    if (m_visible != show) {
        m_visible = show;
        emit needPlacement();
    }
}
Beispiel #9
0
VUMeter::VUMeter(QWidget* parent, AudioBus* bus)
	: QWidget(parent)
{
	setMaximumWidth(MAXIMUM_WIDTH);
	m_minSpace = 0;

	mainlayout = new QVBoxLayout;
	load_theme_data();
	
	QWidget* levelLedLayoutwidget = new QWidget(this);
	levelLedLayout = new QHBoxLayout(levelLedLayoutwidget);
	
	levelLedLayout->setSpacing(0);
	levelLedLayout->setMargin(0);
	levelLedLayout->addSpacing(m_vulayoutspacing);
	
	levelLedLayoutwidget->setLayout(levelLedLayout);
	
	m_minSpace += levelLedLayout->spacing();

	for (int i = 0; i < bus->get_channel_count(); ++i) {
		QWidget* widget = new QWidget(this);
		QVBoxLayout* levellayout = new QVBoxLayout(widget);
		levellayout->setMargin(0);
		levellayout->setSpacing(0);
			
		VUMeterOverLed* led = new VUMeterOverLed(levelLedLayoutwidget);
		VUMeterLevel* level = new VUMeterLevel(levelLedLayoutwidget, bus->get_channel(i));
		m_levels.append(level);
		connect(level, SIGNAL(activate_over_led(bool)), led, SLOT(set_active(bool)));
		
		levellayout->addWidget(led);
		levellayout->addWidget(level, 5);
		
		m_minSpace += level->minimumWidth();
		
		levelLedLayout->addWidget(widget);
		
		if (i < bus->get_channel_count() - 1)  {
			levelLedLayout->addSpacing(m_vulevelspacing);
			m_minSpace += m_vulevelspacing;
		}
	}
		
	// add a ruler with tickmarks and labels
	ruler = new VUMeterRuler(this);
	levelLedLayout->addWidget(ruler);
	m_minSpace += ruler->maximumWidth();
		
	levelLedLayout->addSpacing(m_vulayoutspacing);
	m_minSpace += m_vulayoutspacing;
	
	// add a tooltip showing the channel name
	m_name = bus->get_name();
	m_channels = bus->get_channel_count();
	setToolTip(m_name);
	
	// initialize some stuff
	isActive = false;
	
	setAutoFillBackground(false);
	setAttribute(Qt::WA_OpaquePaintEvent);
	
	channelNameLabel = new QLabel(this);
	channelNameLabel->setFont(m_chanNameFont);
	channelNameLabel->setAlignment(Qt::AlignHCenter);
	
	mainlayout->addSpacing(5);
	mainlayout->addWidget(levelLedLayoutwidget, 5);
	mainlayout->addWidget(channelNameLabel);
	mainlayout->setMargin(m_mainlayoutmargin);
	mainlayout->setSpacing(m_mainlayoutspacing);
	m_minSpace += mainlayout->spacing();
	
	setLayout(mainlayout);

	connect(themer(), SIGNAL(themeLoaded()), this, SLOT(load_theme_data()), Qt::QueuedConnection);
}
Beispiel #10
0
KdmItem::KdmItem(QObject *parent, const QDomNode &node)
    : QObject(parent)
    , boxManager(0)
    , fixedManager(0)
    , myWidget(0)
    , m_showTypeInvert(false)
    , m_minScrWidth(0)
    , m_minScrHeight(0)
    , m_visible(true)
    , m_shown(true)
{
    QDomNode showNode = node.namedItem("show");
    if (!showNode.isNull()) {
        QDomElement sel = showNode.toElement();

        QString modes = sel.attribute("modes");
        if (!modes.isNull() &&
            (modes == "nowhere" ||
             (modes != "everywhere" &&
              !modes.split(",", QString::SkipEmptyParts).contains("console"))))
        {
            m_visible = false;
            return;
        }

        m_showType = sel.attribute("type");
        if (!m_showType.isNull()) {
            if (m_showType[0] == '!') {
                m_showType.remove(0, 1);
                m_showTypeInvert = true;
            }
            if (!m_showType.startsWith("plugin-") &&
                themer()->typeVisible(m_showType) == m_showTypeInvert)
            {
                m_visible = false;
                return;
            }
        }

        m_minScrWidth = sel.attribute("min-screen-width").toInt();
        m_minScrHeight = sel.attribute("min-screen-height").toInt();
    }

    // Set default layout for every item
    currentManager = MNone;
    geom.pos.x.type = geom.pos.y.type =
        geom.size.x.type = geom.size.y.type = DTnone;
    geom.minSize.x.type = geom.minSize.y.type =
        geom.maxSize.x.type = geom.maxSize.y.type = DTpixel;
    geom.minSize.x.val = geom.minSize.y.val = 0;
    geom.maxSize.x.val = geom.maxSize.y.val = 1000000;
    geom.anchor = "nw";
    geom.expand = 0;

    // Set defaults for derived item's properties
    state = Snormal;

    KdmItem *parentItem = qobject_cast<KdmItem *>(parent);
    if (!parentItem)
        style.frame = false, style.guistyle = 0;
    else
        style = parentItem->style;

    // Read the mandatory Pos tag. Other tags such as normal, prelighted,
    // etc.. are read under specific implementations.
    QDomNodeList childList = node.childNodes();
    for (int nod = 0; nod < childList.count(); nod++) {
        QDomNode child = childList.item(nod);
        QDomElement el = child.toElement();
        QString tagName = el.tagName();

        if (tagName == "pos") {
            parseSize(el.attribute("x", QString()), geom.pos.x);
            parseSize(el.attribute("y", QString()), geom.pos.y);
            parseSize(el.attribute("width", QString()), geom.size.x);
            parseSize(el.attribute("height", QString()), geom.size.y);
            parseSize(el.attribute("min-width", QString()), geom.minSize.x);
            parseSize(el.attribute("min-height", QString()), geom.minSize.y);
            parseSize(el.attribute("max-width", QString()), geom.maxSize.x);
            parseSize(el.attribute("max-height", QString()), geom.maxSize.y);
            geom.anchor = el.attribute("anchor", "nw");
            geom.expand = toBool(el.attribute("expand", "false"));
        } else if (tagName == "buddy") {
            buddy = el.attribute("idref", "");
        } else if (tagName == "style") {
            parseStyle(el, style);
        }
    }

    if (!style.font.present)
        parseFont("Sans 14", style.font);

    QDomElement el = node.toElement();
    setObjectName(el.attribute("id", QString::number((ulong)this, 16)));
    isButton = toBool(el.attribute("button", "false"));
    isBackground = toBool(el.attribute("background", "false"));
    QString screen = el.attribute("screen", isBackground ? "all" : "greeter");
    paintOnScreen =
        screen == "greeter" ? ScrGreeter :
        screen == "other" ? ScrOther : ScrAll;

    if (!parentItem)
        // The "toplevel" node (the screen) is really just like a fixed node
        setFixedLayout();
    else
        // Tell 'parent' to add 'me' to its children
        parentItem->addChildItem(this);
}