Ejemplo n.º 1
0
UI_CancelSavewindow::UI_CancelSavewindow(const char *title, const char *str,
                                         const char *button1txt, const char *button2txt,
                                         int *button_nr)
{
  int i,
      len,
      max=0,
      labelwidth = 0,
      labelheight = 25;

  buttonnr = button_nr;

  len = strlen(str);

  for(i=0; i<len; i++)
  {
    if(str[i]=='\n')
    {
      labelheight += 20;
      if(max>labelwidth) labelwidth = max;
      max = 0;
    }
    else
    {
      max++;
    }
  }

  if(max>labelwidth) labelwidth = max;

  labelwidth *= 6;
  labelwidth += 10;
  if(labelwidth<260)  labelwidth = 260;

  MessageDialog = new QDialog;

  MessageDialog->setMinimumSize(labelwidth + 40, labelheight + 85);
  MessageDialog->setMaximumSize(labelwidth + 40, labelheight + 85);
  MessageDialog->setWindowTitle(title);
  MessageDialog->setModal(true);
  MessageDialog->setAttribute(Qt::WA_DeleteOnClose, true);

  Label1 = new QLabel(MessageDialog);
  Label1->setGeometry(20, 20, labelwidth, labelheight);
  Label1->setAlignment(Qt::AlignLeft | Qt::AlignTop);
  Label1->setText(str);

  pushButton1 = new QPushButton(MessageDialog);
  pushButton1->setGeometry(20, labelheight + 40, 100, 25);
  pushButton1->setText(button1txt);

  pushButton2 = new QPushButton(MessageDialog);
  pushButton2->setGeometry(140, labelheight + 40, 100, 25);
  pushButton2->setText(button2txt);

  QObject::connect(pushButton1, SIGNAL(clicked()), this, SLOT(button1Clicked()));
  QObject::connect(pushButton2, SIGNAL(clicked()), this, SLOT(button2Clicked()));

  MessageDialog->exec();
}
Ejemplo n.º 2
0
LyXFileDialog::LyXFileDialog(QString const & title,
			     QString const & path,
			     QStringList const & filters,
			     FileDialog::Button const & b1,
			     FileDialog::Button const & b2)
				 // FIXME replace that with guiApp->currentView()
	: QFileDialog(qApp->focusWidget(), title, path)
{
	setNameFilters(filters);
	setWindowTitle(title);
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
	setOption(QFileDialog::DontUseNativeDialog);

	QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();

	if (!b1.first.isEmpty()) {
		b1_dir_ = b1.second;
		QToolButton * tb = new QToolButton(this);
		connect(tb, SIGNAL(clicked()), this, SLOT(button1Clicked()));
		tb->setText(b1.first);
		layout.at(0)->addWidget(tb);
	}

	if (!b2.first.isEmpty()) {
		b2_dir_ = b2.second;
		QToolButton * tb = new QToolButton(this);
		connect(tb, SIGNAL(clicked()), this, SLOT(button2Clicked()));
		tb->setText(b2.first);
		layout.at(0)->addWidget(tb);
	}
}
Ejemplo n.º 3
0
nineButtonSelector::nineButtonSelector(	QPixmap _button0_on,
					QPixmap _button0_off,
					QPixmap _button1_on,
					QPixmap _button1_off,
					QPixmap _button2_on,
					QPixmap _button2_off,
					QPixmap _button3_on,
					QPixmap _button3_off,
					QPixmap _button4_on,
					QPixmap _button4_off,
					QPixmap _button5_on,
					QPixmap _button5_off,
					QPixmap _button6_on,
					QPixmap _button6_off,
					QPixmap _button7_on,
					QPixmap _button7_off,
					QPixmap _button8_on,
					QPixmap _button8_off,
					Uint8 _default,
					Uint32 _x, Uint32 _y,
					QWidget * _parent ):
	QWidget( _parent ),
	IntModelView( new nineButtonSelectorModel(0, 8, _default, NULL, 
				QString::null, true ), this )
{
	setFixedSize( 50, 50 );
	move( _x, _y );

	// TODO: use a generic approach using QSignalMapper

	m_button = new pixmapButton( this, NULL );
	m_button->move( 1, 1 );
	m_button->setActiveGraphic( _button0_on );
	m_button->setInactiveGraphic( _button0_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button0Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 18, 1 );
	m_button->setActiveGraphic( _button1_on );
	m_button->setInactiveGraphic( _button1_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button1Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 35, 1 );
	m_button->setActiveGraphic( _button2_on );
	m_button->setInactiveGraphic( _button2_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button2Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 1, 18 );
	m_button->setActiveGraphic( _button3_on );
	m_button->setInactiveGraphic( _button3_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button3Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 18, 18 );
	m_button->setActiveGraphic( _button4_on );
	m_button->setInactiveGraphic( _button4_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button4Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 35, 18 );
	m_button->setActiveGraphic( _button5_on );
	m_button->setInactiveGraphic( _button5_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button5Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 1, 35 );
	m_button->setActiveGraphic( _button6_on );
	m_button->setInactiveGraphic( _button6_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button6Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 18, 35 );
	m_button->setActiveGraphic( _button7_on );
	m_button->setInactiveGraphic( _button7_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button7Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 35, 35 );
	m_button->setActiveGraphic( _button8_on );
	m_button->setInactiveGraphic( _button8_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button8Clicked() ) );
	m_buttons.append( m_button );
	
	m_lastBtn = m_buttons[_default];
	m_lastBtn->setChecked( true );
}
/**
 * 左侧按钮切换页面tabwidget界面类实现
 * @author fanxiang
 * @version 1.0.0
 * @date 2013-08-18
 */
TabWidgetManager::TabWidgetManager(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TabWidgetManager)
{
    ui->setupUi(this);
    QIcon icon;
    icon.addFile(QString::fromUtf8(":image/icon.png"), QSize(), QIcon::Normal, QIcon::Off);
    this->setWindowIcon(icon);

    // 【注意】,此处添加widget为了是窗口布局随大窗口缩放而改变
    // 【注意!】ui->gridLayout为自己在Ui设计器中命名的Layout,该Layout中包含QStackedWidget
    ui->gridLayout->addWidget(ui->page1, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page2, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page3, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page4, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page5, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page6, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page7, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page8, 0, 1, 1, 1);

    BackupDatabaseWidget *widgetbackupdb = new BackupDatabaseWidget(ui->page3);

    WidgetOne *widget2 = new WidgetOne(ui->page1);
    InputBridgeWidget * widget3 = new InputBridgeWidget(ui->page2);
    SelectAvaliableTunnelWidget *widget4 = new SelectAvaliableTunnelWidget(ui->page4);
    SynthesisCorrectWidget * widget56 = new SynthesisCorrectWidget(ui->page5);
    SelectHistoricalTunnelDataWidget *widget7 = new SelectHistoricalTunnelDataWidget(ui->page7);
    OutputClearanceWidget *widget8 = new OutputClearanceWidget(ui->page8);

    QGridLayout *layout1 = new QGridLayout();
    layout1->addWidget(widget2);
    ui->page1->setLayout(layout1);

    QGridLayout *layout8 = new QGridLayout();
    layout8->addWidget(widget3);
    ui->page2->setLayout(layout8);

    QGridLayout *layout7 = new QGridLayout();
    layout7->addWidget(widgetbackupdb);
    ui->page3->setLayout(layout7);

    QGridLayout *layout2 = new QGridLayout();
    layout2->addWidget(widget4);
    ui->page4->setLayout(layout2);

    QGridLayout *layout3 = new QGridLayout();
    layout3->addWidget(widget56);
    ui->page5->setLayout(layout3);

    QGridLayout *layout6 = new QGridLayout();
    layout6->addWidget(widget7);
    ui->page7->setLayout(layout6);

    QGridLayout *layout4 = new QGridLayout();
    layout4->addWidget(widget8);
    ui->page8->setLayout(layout4);

    /************************************/
    // 鼠标点击信号槽
    connect(ui->button1, SIGNAL(clicked()), this, SLOT(button1Clicked()));
    connect(ui->button2, SIGNAL(clicked()), this, SLOT(button2Clicked()));
    connect(ui->button3, SIGNAL(clicked()), this, SLOT(button3Clicked()));
    connect(ui->button4, SIGNAL(clicked()), this, SLOT(button4Clicked()));
    connect(ui->button5, SIGNAL(clicked()), this, SLOT(button5Clicked()));
    connect(ui->button6, SIGNAL(clicked()), this, SLOT(button6Clicked()));
    connect(ui->button7, SIGNAL(clicked()), this, SLOT(button7Clicked()));
    connect(ui->button8, SIGNAL(clicked()), this, SLOT(button8Clicked()));

    // 界面间通信信号槽
    connect(widget7, SIGNAL(updateOutput(SingleOrMultiSelectionMode, CurveType)), widget8, SLOT(updateClearanceTableModel(SingleOrMultiSelectionMode, CurveType)));
    connect(widget2, SIGNAL(signalBridgeToEdit(int, QString)), widget3, SLOT(slotBridgeToEdit(int, QString)));
    connect(widget4, SIGNAL(signalSelectedTunnelToEdit(int, QString, bool)), widget56, SLOT(slotSelectedTunnelToSynthesis(int, QString, bool)));
	// 关闭窗口信号槽,告知数据库可能需要备份
    connect(this, SIGNAL(my_close()), widgetbackupdb, SLOT(checkIfExport()));

    // 按钮切换界面信号槽
    connect(widget7, SIGNAL(updateOutput(SingleOrMultiSelectionMode, CurveType)), this, SLOT(button8Clicked()));
    connect(widget2, SIGNAL(signalBridgeToEdit(int, QString)), this, SLOT(button2Clicked()));
    connect(widget8, SIGNAL(backToSelectionSignal()), this, SLOT(button7Clicked()));
    connect(widget3, SIGNAL(signalEndEdit()), this, SLOT(button1Clicked()));
    connect(widget4, SIGNAL(signalSelectedTunnelToEdit(int, QString, bool)), this, SLOT(button5Clicked()));
    connect(widget56, SIGNAL(toTabCorrect()), this, SLOT(button6Clicked()));
    connect(widget56, SIGNAL(toTabSynthesis()), this, SLOT(button5Clicked()));
    connect(widget56, SIGNAL(finish()), this, SLOT(button4Clicked()));

    /************关于流程控制*************/
    // 开始时禁止点击按钮功能
    ui->button2->setEnabled(false);
    ui->button5->setEnabled(false);
    ui->button6->setEnabled(false);
    ui->button8->setEnabled(false);

    // 显示第一个界面
	button3Clicked();
}