File: mainwindow.cpp

package info (click to toggle)
qwt 6.1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 23,808 kB
  • sloc: cpp: 57,687; xml: 182; makefile: 32
file content (50 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (8)
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
#include <qlayout.h>
#include "tunerfrm.h"
#include "ampfrm.h"
#include "mainwindow.h"

MainWindow::MainWindow():
    QWidget()
{
    TunerFrame *frmTuner = new TunerFrame( this );
    frmTuner->setFrameStyle( QFrame::Panel | QFrame::Raised );

    AmpFrame *frmAmp = new AmpFrame( this );
    frmAmp->setFrameStyle( QFrame::Panel | QFrame::Raised );

    QVBoxLayout *layout = new QVBoxLayout( this );
    layout->setMargin( 0 );
    layout->setSpacing( 0 );
    layout->addWidget( frmTuner );
    layout->addWidget( frmAmp );

    connect( frmTuner, SIGNAL( fieldChanged( double ) ),
        frmAmp, SLOT( setMaster( double ) ) );

    frmTuner->setFreq( 90.0 );

    setPalette( QPalette( QColor( 192, 192, 192 ) ) );
    updateGradient();
}

void MainWindow::resizeEvent( QResizeEvent * )
{
    // Qt 4.7.1: QGradient::StretchToDeviceMode is buggy on X11
    updateGradient();
}

void MainWindow::updateGradient()
{
    QPalette pal = palette();

    const QColor buttonColor = pal.color( QPalette::Button );
    const QColor midLightColor = pal.color( QPalette::Midlight );

    QLinearGradient gradient( rect().topLeft(), rect().topRight() );
    gradient.setColorAt( 0.0, midLightColor );
    gradient.setColorAt( 0.7, buttonColor );
    gradient.setColorAt( 1.0, buttonColor );

    pal.setBrush( QPalette::Window, gradient );
    setPalette( pal );
}