stif/QtUI/StifQtUI/dlgsetting.cpp
branchRCL_3
changeset 8 cfe32394fcd5
parent 7 8a14024f954a
child 9 7e287c5c61f0
equal deleted inserted replaced
7:8a14024f954a 8:cfe32394fcd5
     1 /*
       
     2  * dlgsetting.cpp
       
     3  *
       
     4  *  Created on: 2010-2-8
       
     5  *      Author: y183zhan
       
     6  */
       
     7 
       
     8 #include "dlgsetting.h"
       
     9 #include <QtGui>
       
    10 
       
    11 DlgSetting::DlgSetting(UiSetting* settingObj, QWidget *parent)
       
    12     : QDialog(parent), setting(settingObj)
       
    13     {
       
    14     SetupUI();
       
    15     }
       
    16 
       
    17 void DlgSetting::SetupUI()
       
    18     {
       
    19     this->setContextMenuPolicy(Qt::NoContextMenu);
       
    20     QGridLayout *mainLayout = new QGridLayout(this);
       
    21     this->setLayout(mainLayout);
       
    22     
       
    23     chkShowoutput = new QCheckBox(this);
       
    24     chkShowoutput->setText(tr("Show output in execution."));
       
    25     chkShowoutput->setChecked(setting->ReadSetting("showoutput") == "true");
       
    26     
       
    27     QWidget *toolWidget = new QWidget(this);
       
    28     QGridLayout *toolLayout = new QGridLayout();
       
    29     
       
    30     toolWidget->setLayout(toolLayout);
       
    31     btnOk = new QPushButton(tr("Ok"), toolWidget);
       
    32     btnOk->setFixedSize(100, 30);
       
    33     QObject::connect(btnOk, SIGNAL(clicked()), this,
       
    34             SLOT(on_btnOk_clicked()));
       
    35     btnCancel = new QPushButton(tr("Cancel"), toolWidget);
       
    36     btnCancel->setFixedSize(100, 30);
       
    37     QObject::connect(btnCancel, SIGNAL(clicked()), this,
       
    38             SLOT(on_btnCancel_clicked()));
       
    39     toolLayout->addWidget(btnOk, 0, 0);
       
    40     toolLayout->addWidget(btnCancel, 0, 1);
       
    41 
       
    42     mainLayout->addWidget(chkShowoutput, 0, 0);
       
    43     mainLayout->addWidget(toolWidget, 2, 0);    
       
    44     }
       
    45 
       
    46 void DlgSetting::on_btnOk_clicked()
       
    47     {
       
    48     if(chkShowoutput->checkState() == Qt::Checked)
       
    49         {
       
    50         setting->SetSetting("showoutput", "true");
       
    51         }
       
    52     else
       
    53         {
       
    54         setting->SetSetting("showoutput", "false");    
       
    55         }
       
    56     this->accept();
       
    57     }
       
    58 
       
    59 void DlgSetting::on_btnCancel_clicked()
       
    60     {
       
    61     this->reject();
       
    62     }