📄 tabdialog.cpp
字号:
#include "tabdialog.h"#include <qapplication.h>#include <qvbox.h>#include <qlabel.h>#include <qlineedit.h>#include <qdatetime.h>#include <qcheckbox.h>#include <qlistbox.h>#include <qbuttongroup.h>#include <qlayout.h>#include <qradiobutton.h>#include <qcheckbox.h>#include <qgroupbox.h>#include <qpushbutton.h>#include <qtoolbutton.h>#include <qslider.h>#include <qvalidator.h>#include <qcombobox.h>#include <qmessagebox.h>#include <qapplication.h>#include <qdir.h>#include <qstyle.h>#include <qstylefactory.h>TabDialog::TabDialog( QWidget *parent, const char *name, const QString &_filename ) : QTabDialog( parent, name ), filename( _filename ), fileinfo( filename ){ setupTab1(); setupTab2(); setupTab3(); connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( close() ) );}void TabDialog::setupTab1(){ QVBox * tab1 = new QVBox( this ); QButtonGroup * gb1 = new QButtonGroup( 2, QGroupBox::Horizontal, tr("General option"), tab1 ); tab1->setMargin( 5 ); gb1->setFlat( TRUE ); (void)new QLabel( tr("Number Of Threads:"), gb1 ); QLineEdit *edtThreads = new QLineEdit( "4", gb1 ); edtThreads->setValidator( new QIntValidator( edtThreads ) ); edtThreads->setFocus(); (void)new QLabel( tr("Retry Delay(Sec):"), gb1 ); QLineEdit *edtRdt = new QLineEdit( "10", gb1 ); edtRdt->setValidator( new QIntValidator( edtRdt ) ); (void)new QLabel( tr("TimeOut Period(Sec):"), gb1 ); QLineEdit *edtTp = new QLineEdit( "30", gb1 ); edtTp->setValidator( new QIntValidator( edtTp ) ); (void)new QLabel( tr("Path to download the files"), gb1 ); QLineEdit *edtpath = new QLineEdit( fileinfo.dirPath( TRUE ), gb1 ); (void)new QLabel( tr("Language"), gb1 ); QComboBox * combo1 = new QComboBox( FALSE, gb1 ); combo1->insertItem( tr("English") ); combo1->insertItem( tr("Chinese") ); connect( combo1, SIGNAL( activated( int ) ), this, SLOT( slotLangChanged(int ) ) ); (void)new QLabel( tr("Style"), gb1 ); QComboBox * combo2 = new QComboBox( FALSE, gb1 ); QStringList list = QStyleFactory::keys(); list.sort(); for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { QString style = *it; combo2->insertItem( style ); } connect( combo2, SIGNAL( activated( int ) ), this, SLOT( slotStyleChanged(int ) ) ); QButtonGroup *gb2 = new QButtonGroup( 1, QGroupBox::Horizontal, tr("HTTP && FTP option"), tab1); gb2->setFlat( TRUE ); gb2->setExclusive( TRUE ); QRadioButton *rb11 = new QRadioButton( " Use Pasv for FTP transfer ", gb2 ); rb11->setChecked( TRUE ); (void)new QRadioButton( " Ask the HTTP proxy not to cache requests " "between sessions", gb2 ); addTab( tab1, tr("General") );}void TabDialog::setupTab2(){ QVBox *tab2 = new QVBox( this ); tab2->setMargin( 5 ); // QButtonGroup * gb1 = new QButtonGroup( 2, QGroupBox::Horizontal, tr("HTTP Proxy"), tab2 ); gb1->setFlat( TRUE ); QButtonGroup * gb2 = new QButtonGroup( 2, QGroupBox::Horizontal, tr("FTP Proxy"), tab2 ); gb2->setFlat( TRUE ); QLabel * textLabel1 = new QLabel( gb1, tr("textLabel1") ); textLabel1->setText( tr( "Hostname" ) ); QLineEdit * lineEdit1 = new QLineEdit( gb1, tr("lineEdit1") ); QLabel * textLabel2 = new QLabel( gb1, "textLabel2" ); textLabel2->setText( tr( "Hostport" ) ); QLineEdit * lineEdit2 = new QLineEdit( gb1, "lineEdit2" ); QLabel *textLabel3 = new QLabel( gb1, "textLabel3" ); textLabel3->setText( tr( "Username" ) ); QLineEdit * lineEdit3 = new QLineEdit( gb1, "lineEdit3" ); QLabel *textLabel4 = new QLabel( gb1, "textLabel4" ); textLabel4->setText( tr( "Password" ) ); QLineEdit *lineEdit4 = new QLineEdit( gb1, "lineEdit4" ); lineEdit4->setEchoMode( QLineEdit::Password ); QLabel *textLabel5 = new QLabel( gb2, "textLabel5" ); textLabel5->setText( tr( "Hostname" ) ); QLineEdit *lineEdit5 = new QLineEdit( gb2, "lineEdit5" ); QLabel *textLabel6 = new QLabel( gb2, "textLabel6" ); textLabel6->setText( tr( "Hostport" ) ); QLineEdit *lineEdit6 = new QLineEdit( gb2, "lineEdit6" ); QLabel * textLabel7 = new QLabel( gb2, "textLabel7" ); textLabel7->setText( tr( "Username" ) ); QLineEdit *lineEdit7 = new QLineEdit( gb2, "lineEdit7" ); QLabel *textLabel8 = new QLabel( gb2, "textLabel8" ); textLabel8->setText( tr( "Password" ) ); QLineEdit *lineEdit8 = new QLineEdit( gb2, "lineEdit8" ); lineEdit8->setEchoMode( QLineEdit::Password ); addTab( tab2, tr("Proxy") );}void TabDialog::setupTab3(){ QVBox *tab3 = new QVBox( this ); tab3->setMargin( 5 ); tab3->setSpacing( 5 );// (void)new QLabel( QString( " %1 with:" ).arg( filename ), tab3 ); addTab( tab3, tr("Other") );}void TabDialog::slotLangChanged( int i ){ extern QTranslator ts; QString base = QDir("lang/").absPath(); QString qmfile; switch (i) { case 0: qmfile = "dget.qm"; break; case 1: qmfile = "dget_CN.qm"; break; } qApp->removeTranslator(&ts); ts.load(qmfile, base); qApp->installTranslator(&ts);}void TabDialog::slotStyleChanged( int i ){ QString style; switch (i) { case 0: style = "CDE"; break; case 1: style = "Motif"; break; case 2: style = "MotifPlus"; break; case 3: style = "Platinum"; break; case 4: style = "SGI"; break; case 5: style = "Windows"; break; } QStyle * s = QStyleFactory::create( style ); if ( s ) QApplication::setStyle( s );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -