summaryrefslogtreecommitdiffstats
path: root/src/gui/programmerdlg.cpp
blob: a2186b4424ca8fe1f0f42946c6f549dc70122fc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/***************************************************************************
 *   Copyright (C) 2005 by David Saxton                                    *
 *   david@bluehaze.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "language.h"
#include "microselectwidget.h"
#include "picprogrammer.h"
#include "port.h"
#include "programmerdlg.h"
#include "programmerwidget.h"
#include "src/core/ktlconfig.h"

#include <kcombobox.h>
#include <kguiitem.h>
#include <klocale.h>
#include <kstdguiitem.h>

ProgrammerDlg::ProgrammerDlg( const QString & picID, QWidget *parent, const char *name )
	: KDialogBase( parent, name, true, i18n("PIC Programmer"), Ok|Cancel )
{
	// Change the "Ok" button to a "Burn" button
	KGuiItem burnItem = KStdGuiItem::ok();
	burnItem.setText( i18n("Burn") );
	setButtonOK( burnItem );
	
	m_bAccepted = false;
	m_pProgrammerWidget = new ProgrammerWidget( this );
	m_pProgrammerSettings = new PicProgrammerSettings;
	
	// Setup the list of programmers
	KComboBox * programmerCombo = m_pProgrammerWidget->m_pProgrammerProgram;
	QStringList programmerNames = m_pProgrammerSettings->configNames( false );
	programmerCombo->insertStringList( programmerNames );
	programmerCombo->setSizeLimit( programmerNames.size() );
	programmerCombo->setCurrentText( KTLConfig::picProgrammerProgram() );
	
	// Sets up the list of ports
	m_pProgrammerWidget->m_pPicProgrammerPort->insertStringList( Port::ports( Port::ExistsAndRW ) );
	m_pProgrammerWidget->m_pPicProgrammerPort->setCurrentText( KTLConfig::picProgrammerPort() );
	
	// Set the pic type to the one requested
	if ( !picID.isEmpty() )
		m_pProgrammerWidget->m_pMicroSelect->setMicro( picID );
	
	setMainWidget( m_pProgrammerWidget );
}


ProgrammerDlg::~ProgrammerDlg()
{
}


void ProgrammerDlg::initOptions( ProcessOptions * options )
{
	if ( !options )
		return;
	
	options->m_picID = m_pProgrammerWidget->m_pMicroSelect->micro();
	options->m_port = m_pProgrammerWidget->m_pPicProgrammerPort->currentText();
	options->m_program = m_pProgrammerWidget->m_pProgrammerProgram->currentText();
}


void ProgrammerDlg::accept()
{
	m_bAccepted = true;
	hide();
}


void ProgrammerDlg::reject()
{
	m_bAccepted = false;
}


MicroSelectWidget * ProgrammerDlg::microSelect( ) const
{
	return m_pProgrammerWidget->m_pMicroSelect;
}


#include "programmerdlg.moc"