// SquidPrefsDialog.cpp: implementation of the SquidPrefsDialog class. // ////////////////////////////////////////////////////////////////////// #include <qcolordialog.h> #include <qgroupbox.h> #include <qlayout.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qwhatsthis.h> #include <math.h> #include "SquidMainWindow.h" #include "SquidPrefsDialog.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// SquidPrefsDialog::SquidPrefsDialog( SquidMainWindow* parent ) : QDialog( parent ), smw( parent ) { setCaption( "SQUID Settings" ); QVBoxLayout* vlayout = new QVBoxLayout( this, 20, -1 ); QGroupBox* abox = new QGroupBox( 2, Horizontal, "Application Settings", this ); vlayout->addWidget( abox ); bkswatch = new QLabel( "Background Color", abox ); bkswatch->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); QRgb col = smw->BGColor(); bgcol = col; bkswatch->setBackgroundColor( col ); col = ~col == col ? 0 : ~col ; QPushButton* bkbutton = new QPushButton( "Change...", abox ); bkbutton->setFixedSize( bkbutton->sizeHint() ); connect( bkbutton, SIGNAL( clicked() ), this, SLOT( ChooseBGColor() ) ); QLabel* bsizel = new QLabel ( "Blend images with area <", abox ); QLineEdit* bsizee = new QLineEdit ( QString::number( smw->BlendSize() ), abox ); connect ( bsizee, SIGNAL( textChanged( const QString& ) ), this, SLOT( ChooseBlendSize( const QString& ) ) ); blendsize = smw->BlendSize(); QGroupBox* dbox = new QGroupBox( 3, Horizontal, "Diff Settings", this ); vlayout->addWidget( dbox ); QFrame* dtolf = new QFrame( dbox ); QGridLayout* dtlayout = new QGridLayout( dtolf ); tol1 = new QFrame( dtolf ); tol2 = new QFrame( dtolf ); tol3 = new QFrame( dtolf ); tol4 = new QFrame( dtolf ); tol1->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); tol2->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); tol3->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); tol4->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); tol1->setBackgroundColor( QColor( 0, 0, 0 ) ); dtlayout->addWidget( tol1, 0, 0 ); dtlayout->addWidget( tol2, 0, 1 ); dtlayout->addWidget( tol3, 1, 0 ); dtlayout->addWidget( tol4, 1, 1 ); tol1->resize( 25, 25 ); tol2->resize( 25, 25 ); tol3->resize( 25, 25 ); tol4->resize( 25, 25 ); dtolf->setFixedSize( 50, 50 ); dtolf->show(); QLabel* dtl = new QLabel( " These colors\nare considered\n \"identical\".", dbox ); QSlider* dtsli = new QSlider( 0, 9999, 100, smw->DiffTol(), Horizontal, dbox ); connect( dtsli, SIGNAL( valueChanged( int ) ), this, SLOT( ChooseDiffTol( int ) ) ); ChooseDiffTol( smw->DiffTol() ); dbox->addSpace( 0 ); QLabel* mbl1 = new QLabel( "Min. diff area", dbox ); QLineEdit* mbe = new QLineEdit ( QString::number( smw->MinBlock() ), dbox ); connect( mbe, SIGNAL( textChanged( const QString& ) ), this, SLOT( ChooseMinBlock( const QString& ) ) ); minblock = smw->MinBlock(); QHBoxLayout* buttons = new QHBoxLayout( vlayout ); QPushButton* ok = new QPushButton( "Save", this ); buttons->addWidget( ok ); ok->setFixedSize( ok->sizeHint() ); QPushButton* no = new QPushButton( "Cancel", this ); buttons->addWidget( no ); no->setFixedSize( no->sizeHint() ); ok->setAutoDefault( true ); ok->setFocus(); connect( ok, SIGNAL( clicked() ), this, SLOT( ExportSettings() ) ); connect( no, SIGNAL( clicked() ), this, SLOT( reject() ) ); QString wabox = QString ( "<b></b>These settings affect the entire application. " ); wabox += "<br> <br> "; wabox += "The background color is used in the middle pane to mask out "; wabox += "identical pixels if the <b>Subtract Identical</b> option has "; wabox += "been selected, as well as in the side panes to indicate 'missing' "; wabox += "sections if the images are different dimensions. " ; wabox += "<br> <br>" ; wabox += "The slider in the middle pane will 'blend' the two images if the "; wabox += "combined image is under a certain size. If the area of the image "; wabox += "in pixels exceeds the number given here, a much faster 'stipple'"; wabox += "effect will be used instead to mix the images."; QWhatsThis::add( abox, wabox ); QString wdbox = QString ( "These settings affect the <b>Subtract Identical</b> and <b>Highlight Diffs</b> features." ); wdbox += "<br> <br>"; wdbox += "The slider controls how 'strict' the RGB comparison will be when "; wdbox += "determining whether two pixels are 'identical' or not. Identical "; wdbox += "pixels are masked out when the <b>Subtract Diffs</b> feature is "; wdbox += "used, and non-identical pixels are used to determine the bounding "; wdbox += "boxes generated by the <b>Highlight Diffs</b> feature. "; wdbox += "<br> <br>"; wdbox += "Diff bounding boxes will only be displayed if their areas meet or "; wdbox += "exceed, in pixels, the number entered here."; QWhatsThis::add( dbox, wdbox ); setFixedSize( sizeHint() ); setMaximumWidth( 400 ); show(); } void SquidPrefsDialog::ChooseBGColor() { QRgb foo = QColorDialog::getRgba ( bkswatch->backgroundColor().rgb(), NULL, this ); bkswatch->setBackgroundColor( foo ); bgcol = foo; foo = ~foo == foo ? 0 : ~foo ; bkswatch->setPaletteForegroundColor( foo ); } void SquidPrefsDialog::ChooseBlendSize( const QString& area ) { bool ok; int size = area.toInt( &ok ); if ( ok ) blendsize = area.toInt(); } void SquidPrefsDialog::ChooseDiffTol( int tol ) { difftol = tol; int f; f = sqrt( tol / 3.0 ); tol2->setBackgroundColor( QColor( f, f, f ) ); f = sqrt( tol / 2.0 ); tol3->setBackgroundColor( QColor( f, f, 0 ) ); f = sqrt( tol / 1.0 ); tol4->setBackgroundColor( QColor( 0, 0, f ) ); } void SquidPrefsDialog::ChooseMinBlock( const QString& area ) { bool ok; int size = area.toInt( &ok ); if ( ok ) minblock = area.toInt(); } void SquidPrefsDialog::ExportSettings() { smw->SetDiffTol( difftol ); smw->SetBlendSize( blendsize ); smw->SetBGColor( bgcol ); smw->SetMinBlock( minblock ); accept(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2401 | Sam Stafford |
Rename SID to SQUID - avoids conflicts with another program. Also lets me use cool squid icon. |
||
//guest/sam_stafford/sid/src/SidPrefsDialog.cpp | |||||
#2 | 2054 | Sam Stafford | "What's This?" messages added to the settings dialog. | ||
#1 | 2050 | Sam Stafford | Settings. |