SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), commonSetting(new CommonSetting(this)), shortcutSetting(new ShortcutSetting(this)), willExit(false) { QTabWidget *tab = new QTabWidget(this); tab->addTab(commonSetting, tr("Common")); QWidget *assocWidget = creatAssociationWidget(); if (assocWidget) tab->addTab(assocWidget, tr("File Association")); tab->addTab(shortcutSetting, tr("Keyboard")); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(tab); setLayout(layout); setWindowTitle(Global::ProjectName()); connect(commonSetting, SIGNAL(clickClose()), SLOT(close())); connect(shortcutSetting, SIGNAL(clickClose()), SLOT(close())); }
SettingWidget::SettingWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SettingWidget) { ui->setupUi(this); showDialogCheckBox = ui->showDialogCheckBox; antialiasModeCombo = ui->antialiasModeCombo; timerSpinBox = ui->timerSpinBox; colorButton = ui->colorButton; colorEdit = ui->colorEdit; colorCheckBox = ui->colorCheckBox; colorLabel = ui->colorLabel; buttonBox = ui->buttonBox; initUIvalue(); connect(showDialogCheckBox, SIGNAL(stateChanged(int)), SLOT(showDialogChange(int))); connect(antialiasModeCombo, SIGNAL(currentIndexChanged(int)), SLOT(antialiasModeChange(int))); connect(colorButton, SIGNAL(clicked()), SLOT(setColor())); connect(colorCheckBox, SIGNAL(stateChanged(int)), SLOT(bgColorEnable(int))); connect(timerSpinBox, SIGNAL(valueChanged(int)), SLOT(timerIntervalChange(int))); QPushButton *button = buttonBox->addButton(QDialogButtonBox::Close); button->setDefault(true); connect(button, SIGNAL(clicked()), SIGNAL(clickClose())); button = buttonBox->addButton(QDialogButtonBox::RestoreDefaults); connect(button, SIGNAL(clicked()), SLOT(restoreDefaults())); }
void ShortcutSetting::setupViews() { table = ui->tableWidget; table->setColumnCount(2); QStringList headers; headers << tr("Function") << tr("Key Sequence"); table->setHorizontalHeaderLabels(headers); label = ui->label; lineEdit = ui->lineEdit; lineEdit->setContextMenuPolicy(Qt::NoContextMenu); QSize size = QSize(lineEdit->sizeHint().height(), lineEdit->sizeHint().height()); button = new QPushButton(this); button->setIcon(QIcon(":/Delete2")); button->setFixedSize(size); button->setFocusPolicy(Qt::NoFocus); // Otherwise if get focus, it will show a rect round button. button->setFlat(true); button->setCursor(QCursor(Qt::PointingHandCursor)); connect(button, SIGNAL(clicked()), SLOT(removeShortcut())); const int RightMargin = 8; QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->setContentsMargins(0, 0, 0, 0); buttonLayout->addStretch(); buttonLayout->addWidget(button); buttonLayout->addSpacing(RightMargin); lineEdit->setLayout(buttonLayout); // Setting the input rect, protects the text from covered by the button. lineEdit->setTextMargins(0, 1, size.width() + RightMargin, 1); lineEdit->installEventFilter(this); label->setEnabled(false); lineEdit->setEnabled(false); button->hide(); QDialogButtonBox *buttonBox = ui->buttonBox; QPushButton *button = buttonBox->addButton(QDialogButtonBox::Close); connect(button, SIGNAL(clicked()), SIGNAL(clickClose())); }
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint), sw(this) { connect(&sw, SIGNAL(clickClose()), SLOT(close())); QTabWidget *tab = new QTabWidget(this); tab->addTab(&sw, tr("Common")); if(FileAssoc::isSupportAssociation()){ QGridLayout *gl = new QGridLayout; const int CountOfColumn = 3; QStringList formatList = QString(SUPPORT_FORMAT).remove("*.").split(' '); QCheckBox *cb; for(int i = 0, size = formatList.size(); i < size; ++i){ cb = new QCheckBox(formatList.at(i)); //! before connect(). otherwise it will launch the function changeAssociation(bool). cb->setChecked(FileAssoc::checkAssociation(formatList.at(i))); connect(cb, SIGNAL(toggled(bool)), SLOT(changeAssociation(bool))); gl->addWidget(cb, i / CountOfColumn, i % CountOfColumn); } QWidget *assocWidget = new QWidget(this); assocWidget->setLayout(gl); tab->addTab(assocWidget, tr("File Association")); } QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(tab); setLayout(layout); setWindowTitle(GlobalStr::PROJECT_NAME()); }
/* * Constructs a AboutForm as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ AboutForm::AboutForm( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "AboutForm" ); pVBox=new QVBox(this); pVBox->setGeometry(0,0,450,370); pHBox=new QHBox(pVBox); pixmapLabel = new QLabel( pHBox, "pixmapLabel" ); pixmapLabel->setPixmap( QPixmap::fromMimeSource( "euneurone.png" ) ); titleLabel = new QLabel( pHBox, "titleLabel" ); tabWidget = new QTabWidget( pVBox, "tabWidget" ); tabWidget->setGeometry( QRect( 0, 0, 470, 180 ) ); tabWidget->setTabPosition( QTabWidget::Top ); tab = new QGroupBox(2, Qt::Horizontal, tabWidget, "tab" ); textLabel4 = new QLabel( tab, "textLabel4" ); tab->addSpace(0); textLabel5 = new QLabel( tab, "textLabel5" ); textLabel3 = new QLabel( tab, "textLabel3" ); textLabel2 = new QLabel( tab, "textLabel2" ); textLabel1 = new QLabel( tab, "textLabel1" ); textLabel6 = new QLabel( tab, "textLabel6" ); textLabel7 = new QLabel( tab, "textLabel7" ); tabWidget->insertTab( tab, "" ); textEdit = new QTextEdit( tabWidget, "textEdit" ); textEdit->setGeometry( QRect( 0, 0, 192, 128 ) ); textEdit->setReadOnly(true); tabWidget->insertTab( textEdit, "" ); urlLabel = new QLabel( pVBox, "urlLabel" ); urlLabel->setAlignment(Qt::AlignHCenter); urlLabel->setGeometry( QRect( 20, 190, 430, 30 ) ); urlLabel->setCursor(Qt::PointingHandCursor); warrentyLabel = new QLabel( pVBox, "warrentyLabel" ); warrentyLabel->setAlignment(Qt::AlignHCenter|Qt::WordBreak); warrentyLabel->setGeometry( QRect( 20, 220, 430, 180 ) ); pHBox=new QHBox(pVBox); QLabel *pl1=new QLabel(pHBox); pl1->setGeometry( QRect( 20, 220, 0, 0 ) ); closeButton = new QPushButton( pHBox, "closeButton" ); closeButton->setFixedSize( 100, 30 ); closeButton->setDefault( TRUE ); QLabel *pl2=new QLabel(pHBox); pl2->setGeometry( QRect( 20, 220, 0, 0 ) ); languageChange(); setMinimumSize(450, 380); setMaximumSize(450, 380); resize( QSize(450, 380).expandedTo(minimumSizeHint()) ); QDesktopWidget *d = QApplication::desktop(); int w = d->width(); // returns desktop width int h = d->height(); // returns desktop height move((w/2)-(width()/2),(h/2)-(height()/2)); //center dialog connect( closeButton, SIGNAL( clicked() ), this, SLOT( clickClose() ) ); }