18 qDebug(
"us_win: invalid global memory" );
29 vlgray.setColor( QPalette::Base, QColor( 0xe0, 0xe0, 0xe0 ) );
32 setWindowIcon( us3_icon );
45 QLabel* newLabel =
new QLabel( labelString,
this );
47 newLabel->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
48 newLabel->setAlignment ( Qt::AlignVCenter | Qt::AlignLeft );
49 newLabel->setMargin ( 2 );
50 newLabel->setAutoFillBackground(
true );
66 QLabel* newLabel =
us_label( labelString, fontAdjust, weight );
77 QLabel* newLabel =
us_label( labelString, fontAdjust, weight );
79 newLabel->setAlignment ( Qt::AlignCenter );
80 newLabel->setFrameStyle( QFrame::WinPanel | QFrame::Raised );
81 newLabel->setMidLineWidth( 2 );
93 QPushButton* button =
new QPushButton( tr( labelString.toAscii() ),
this );
100 button->setAutoDefault(
false );
101 button->setEnabled( enabled );
109 QTextEdit* te =
new QTextEdit(
this );
115 te->setFrameStyle ( WinPanel | Sunken );
116 te->setAcceptRichText(
true );
117 te->setReadOnly (
true );
127 QLineEdit* le =
new QLineEdit(
this );
134 le->setAutoFillBackground(
true );
146 le->setPalette (
vlgray );
147 le->setReadOnly(
true );
153 le->setReadOnly(
false );
162 te->setPalette (
vlgray );
163 te->setReadOnly(
true );
169 te->setReadOnly(
false );
176 QListWidget* lw =
new QListWidget;
178 lw->setAutoFillBackground(
true );
188 const QString& text, QCheckBox*& cb,
bool state )
195 QFontMetrics fm( font );
197 QLabel* lb_spacer =
new QLabel;
198 lb_spacer->setFixedWidth ( fm.width(
"w" ) );
199 lb_spacer->setAutoFillBackground(
true );
200 lb_spacer->setPalette ( p );
202 cb =
new QCheckBox( text.toAscii(), this );
203 cb->setFont ( font );
204 cb->setPalette ( p );
205 cb->setChecked ( state );
206 cb->setAutoFillBackground(
true );
208 QGridLayout* layout =
new QGridLayout;
209 layout->setContentsMargins( 0, 0, 0, 0 );
210 layout->setSpacing ( 0 );
212 layout->addWidget( lb_spacer, 0, 0 );
213 layout->addWidget( cb , 0, 1 );
220 const QString& text, QRadioButton*& rb,
bool state )
227 QFontMetrics fm( font );
229 QLabel* lb_spacer =
new QLabel;
230 lb_spacer->setFixedWidth ( fm.width(
"w" ) );
231 lb_spacer->setAutoFillBackground(
true );
232 lb_spacer->setPalette ( p );
234 rb =
new QRadioButton( text.toAscii(), this );
235 rb->setAutoFillBackground(
true );
236 rb->setFont ( font );
237 rb->setPalette ( p );
238 rb->setChecked ( state );
240 QGridLayout* layout =
new QGridLayout;
241 layout->setSpacing ( 0 );
242 layout->setContentsMargins( 0, 0, 0, 0 );
244 layout->addWidget( lb_spacer, 0, 0 );
245 layout->addWidget( rb , 0, 1 );
253 QProgressBar* pb =
new QProgressBar;
255 pb->setRange( low, high );
256 pb->setValue( value );
258 pb->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
260 pb->setAutoFillBackground(
true );
272 QComboBox* cb =
new QComboBox(
this );
275 cb->setAutoFillBackground(
true );
285 QLCDNumber* lcd =
new QLCDNumber( digits );
287 lcd->setSegmentStyle( QLCDNumber::Filled );
288 lcd->setMode ( QLCDNumber::Dec );
289 lcd->display ( value );
290 lcd->setAutoFillBackground(
true );
301 QwtCounter* counter =
new QwtCounter;
303 QList< QObject* > children = counter->children();
304 QStyle *btnstyle =
new QPlastiqueStyle();
306 for (
int jj = 0; jj < children.size(); jj++ )
308 QWidget* cwidg = (QWidget*)children.at( jj );
309 QString clname = cwidg->metaObject()->className();
311 if ( !clname.isEmpty() && clname.contains(
"Button" ) )
313 cwidg->setStyle( btnstyle );
318 QFontMetrics fm( vfont );
319 counter->setNumButtons( buttons );
320 counter->setRange ( low, high );
321 counter->setValue ( value );
323 counter->setFont ( vfont );
324 counter->setAutoFillBackground(
true );
327 int ncv = int( log10( value ) ) + 1;
328 int nch = int( log10( high ) ) + 1;
329 ncv = ( ncv > 0 ) ? ncv : ( 4 - ncv );
330 nch = ( nch > 0 ) ? nch : ( 4 - nch );
331 nch = qMax( nch, ncv );
332 int widv = fm.width( QString(
"12345678901234" ).left( ncv ) );
333 int widh = fm.width( QString(
"12345678901234" ).left( nch ) );
334 counter->adjustSize();
335 int mwidth = counter->width() + widh - widv;
336 counter->resize ( mwidth, counter->height() );
337 counter->setMinimumWidth( mwidth - fm.width(
"A" ) );
343 const QString& y_axis )
345 QwtPlot* plot =
new QwtPlot;
346 plot->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
347 plot->setAutoReplot(
false );
348 plot->setTitle ( title );
350 plot->setAxisTitle( QwtPlot::xBottom, x_axis );
351 plot->setAxisTitle( QwtPlot::yLeft , y_axis );
353 plot->setAutoFillBackground(
true );
362 QwtPlotGrid* grid =
new QwtPlotGrid;
363 grid->enableXMin (
true );
366 grid->attach ( plot );
373 QwtPlotCurve* curve =
new QwtPlotCurve( title );
376 curve->setYAxis ( QwtPlot::yLeft );
377 curve->attach ( plot );
384 QwtPlotPicker* pick =
new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft,
387 pick->setSelectionFlags( QwtPicker::PointSelection );
388 pick->setTrackerMode ( QwtPicker::AlwaysOn );
389 pick->setRubberBand ( QwtPicker::CrossRubberBand );
392 pick->setRubberBandPen ( c );
393 pick->setTrackerPen ( c );
400 if ( event->button() == Qt::RightButton )
407 QListWidget::mousePressEvent( event );
416 QFont ffont(
"monospace", fsize );
417 QFont tfont(
"monospace", fsize );
418 QFontInfo finfo( tfont );
422 const char* preffam[] = {
426 "DejaVu LGC San Mono",
440 const int pfsize =
sizeof( preffam ) /
sizeof( preffam[ 0 ] );
442 for (
int ii = 0; ii < pfsize; ii++ )
444 family = QString( preffam[ ii ] );
445 tfont = QFont( family );
446 finfo = QFontInfo( tfont );
447 fmatch = finfo.exactMatch();
448 ffixed = finfo.fixedPitch();
449 if ( fmatch && ffixed )
453 if ( family.contains(
"New" ) ||
454 family.contains(
"FreeM" ) )
455 ffont = QFont( family, fsize, QFont::DemiBold );
467 QTabWidget* newtw =
new QTabWidget(
this );
469 newtw->setAutoFillBackground(
true );
494 QString list_fname =
"etc_belongs_list.txt";
495 QDir().mkpath( wetc_dname );
496 QDir ietc_dir( ietc_dname );
497 QDir wetc_dir( wetc_dname );
500 QDir::Filters ffilt = QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot;
501 QList< QFileInfo > ie_files = ietc_dir.entryInfoList( ffilt );
502 QList< QFileInfo > we_files = wetc_dir.entryInfoList( ffilt );
503 QStringList keep_files;
504 QStringList copy_files;
505 QStringList link_files;
506 QStringList dir_names;
507 QStringList ietc_files;
508 QStringList wetc_files;
509 int niefs = ie_files.size();
510 int nwefs = we_files.size();
512 for (
int ii = 0; ii < niefs; ii++ )
513 ietc_files << ie_files[ ii ].fileName();
515 for (
int ii = 0; ii < nwefs; ii++ )
516 wetc_files << we_files[ ii ].fileName();
518 QFile lfile( ietc_dname + list_fname );
520 if ( lfile.open( QIODevice::ReadOnly | QIODevice::Text ) )
522 bool keep_file =
false;
523 bool copy_file =
false;
524 bool link_file =
false;
525 bool dir_file =
false;
527 QTextStream ts( &lfile );
528 while( ! ts.atEnd() )
530 QString fline = ts.readLine();
532 if ( fline.startsWith(
"#" ) )
534 keep_file = copy_file = link_file = dir_file =
false;
535 if ( fline.contains(
"List of files" ) )
537 else if ( fline.contains(
"List of directories" ) )
539 else if ( fline.contains(
"COPY" ) )
541 else if ( fline.contains(
"LINK" ) )
547 QString filename = fline.section(
" ", 0, 0 ).simplified();
549 keep_files << filename;
550 else if ( copy_file )
551 copy_files << filename;
552 else if ( link_file )
553 link_files << filename.replace(
"@",
"" );
555 dir_names << filename.replace(
"/",
"" );
561 int nkeepf = keep_files.size();
562 int ncopyf = copy_files.size();
563 int nlinkf = link_files.size();
564 int nsdir = dir_names .size();
565 qDebug() <<
"niefs nwefs" << niefs << nwefs <<
"nkeep/copy/link/dirf"
566 << nkeepf << ncopyf << nlinkf << nsdir;
569 for (
int ii = 0; ii < niefs; ii++ )
571 QString filename = ietc_files[ ii ];
573 if ( filename.contains(
"somo" ) )
576 bool in_wetc = wetc_files.contains( filename );
578 if ( keep_files.contains( filename ) )
580 qDebug() <<
"KEEP " << filename;
583 else if ( copy_files.contains( filename ) )
585 qDebug() <<
"COPY " << filename;
590 qDebug() <<
" ietc cksum+size " << icksum;
591 qDebug() <<
" wetc cksum+size " << wcksum;
593 if ( icksum != wcksum )
596 qDebug() <<
" FILE COPY" << nfcopy;
597 QFile( wetc_dname + filename ).remove();
599 QFile( ietc_dname + filename ).copy(
600 wetc_dname + filename );
605 qDebug() <<
" not present in" << wetc_dname;
607 qDebug() <<
" FILE COPY" << nfcopy;
608 QFile( ietc_dname + filename ).copy(
609 wetc_dname + filename );
613 else if ( link_files.contains( filename ) )
615 qDebug() <<
"LINK " << filename;
616 QString sltarg = ie_files[ ii ].symLinkTarget();
617 qDebug() <<
" ietc sltarg " << sltarg;
623 qDebug() <<
" ietc cksum+size " << icksum;
624 qDebug() <<
" wetc cksum+size " << wcksum;
626 if ( icksum != wcksum )
629 qDebug() <<
" FILE COPY" << nfcopy;
630 QFile( wetc_dname + filename ).remove();
632 QFile( sltarg ).copy( wetc_dname + filename );
637 qDebug() <<
" not present in" << wetc_dname;
639 qDebug() <<
" FILE COPY" << nfcopy;
640 QFile( sltarg ).copy( wetc_dname + filename );
644 else if ( dir_names.contains( filename ) )
646 qDebug() <<
"SDIR " << filename;
649 else if ( filename.contains(
"~" ) )
651 qDebug() <<
"DELE " << filename;
653 qDebug() <<
" FILE DELE" << nfdele;
654 QFile( ietc_dname + filename ).remove();
659 qDebug() <<
"MOVE " << filename;
661 qDebug() <<
" FILE MOVE" << nfmove;
665 QFile( wetc_dname + filename ).remove();
668 QFile( ietc_dname + filename ).rename(
669 wetc_dname + filename );
673 int nfmods = nfmove + nfcopy + nfdele;
675 if ( nfmods > 0 && report )
677 QString msg = tr(
"%1 files were moved, copied, or deleted from"
678 "<br/> <b>%2</b>.<br/>"
679 "Examine possible new or replaced files in"
680 "<br/> <b>%3</b>." )
681 .arg( nfmods ).arg( ietc_dname ).arg( wetc_dname );
682 QMessageBox::information(
this, tr(
"Etc Directory Cleaned" ), msg );
692 QButtonGroup* group =
new QButtonGroup;
697 group->addButton(
rb_db );
702 ( state ==
Disk ) ?
rb_disk->setChecked(
true ) :
rb_db->setChecked(
true );
705 setContentsMargins( 0, 0, 0, 0 );
707 addLayout( db_layout );
708 addLayout( disk_layout );
710 connect(
rb_db, SIGNAL( toggled(
bool ) ), SLOT(
rb_changed(
bool ) ) );
715 return rb_db->isChecked();
721 rb_db->setChecked(
true );
722 connect(
rb_db, SIGNAL( toggled(
bool ) ), SLOT(
rb_changed(
bool ) ) );
727 rb_db ->disconnect();
729 connect(
rb_db, SIGNAL( toggled(
bool ) ), SLOT(
rb_changed(
bool ) ) );
739 const QString& text, QRadioButton*& rb,
bool state )
746 QFontMetrics fm( font );
748 QLabel* lb_spacer =
new QLabel;
749 lb_spacer->setFixedWidth ( fm.width(
"w" ) );
750 lb_spacer->setAutoFillBackground(
true );
751 lb_spacer->setPalette ( p );
753 rb =
new QRadioButton( text.toAscii() );
754 rb->setAutoFillBackground(
true );
755 rb->setFont ( font );
756 rb->setPalette ( p );
757 rb->setChecked ( state );
759 QGridLayout* layout =
new QGridLayout;
760 layout->setSpacing ( 0 );
761 layout->setContentsMargins( 0, 0, 0, 0 );
763 layout->addWidget( lb_spacer, 0, 0 );
764 layout->addWidget( rb , 0, 1 );