|
Packit Service |
b98cfc |
/*
|
|
Packit Service |
b98cfc |
* qlo10k1 - GUI frontend for ld10k1
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* Copyright (c) 2004 by Peter Zubaj
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
b98cfc |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
b98cfc |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
b98cfc |
* (at your option) any later version.
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
b98cfc |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
b98cfc |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
b98cfc |
* GNU General Public License for more details.
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
b98cfc |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
b98cfc |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
*/
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
#include <qlistbox.h>
|
|
Packit Service |
b98cfc |
#include <qpushbutton.h>
|
|
Packit Service |
b98cfc |
#include <qlineedit.h>
|
|
Packit Service |
b98cfc |
#include <qgroupbox.h>
|
|
Packit Service |
b98cfc |
#include <qmessagebox.h>
|
|
Packit Service |
b98cfc |
#include <qinputdialog.h>
|
|
Packit Service |
b98cfc |
#include <qlineedit.h>
|
|
Packit Service |
b98cfc |
#include "preferences.h"
|
|
Packit Service |
b98cfc |
#include "app_global.h"
|
|
Packit Service |
b98cfc |
#include "strparam.h"
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
PreferencesDlg::PreferencesDlg(StrCardGlobal *glob)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
global = glob;
|
|
Packit Service |
b98cfc |
connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked()));
|
|
Packit Service |
b98cfc |
connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
connect(lbCards, SIGNAL(highlighted(int)), this, SLOT(cardHighlighted(int)));
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
connect(pbUpdate, SIGNAL(clicked()), this, SLOT(updateClicked()));
|
|
Packit Service |
b98cfc |
connect(pbCardAdd, SIGNAL(clicked()), this, SLOT(cardAddClicked()));
|
|
Packit Service |
b98cfc |
connect(pbCardDel, SIGNAL(clicked()), this, SLOT(cardDelClicked()));
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// copy card list
|
|
Packit Service |
b98cfc |
for (unsigned int i = 0; i < global->Cards.count(); i++)
|
|
Packit Service |
b98cfc |
cards.append(new CardParam(global->Cards.at(i)));
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
refreshListBox();
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
if (cards.count() > 1)
|
|
Packit Service |
b98cfc |
pbCardDel->setEnabled(true);
|
|
Packit Service |
b98cfc |
repDirSystem = global->RepDirSystem;
|
|
Packit Service |
b98cfc |
repDirUser = global->RepDirUser;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
leRepSystem->setText(repDirSystem);
|
|
Packit Service |
b98cfc |
leRepUser->setText(repDirUser);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::okClicked()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
unsigned int i;
|
|
Packit Service |
b98cfc |
CardParam *card;
|
|
Packit Service |
b98cfc |
for (i = 0; i < cards.count(); i++)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// test connection
|
|
Packit Service |
b98cfc |
card = cards.at(i);
|
|
Packit Service |
b98cfc |
if (card->testConnection())
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// error
|
|
Packit Service |
b98cfc |
QMessageBox::critical( 0, APP_NAME,
|
|
Packit Service |
b98cfc |
QString("Couldn't connect to socket %1 for card %2").arg(card->CardSocket).arg(card->CardName));
|
|
Packit Service |
b98cfc |
return;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// copy values to global
|
|
Packit Service |
b98cfc |
global->Cards.clear();
|
|
Packit Service |
b98cfc |
for (i = 0; i < cards.count(); i++)
|
|
Packit Service |
b98cfc |
global->Cards.append(new CardParam(cards.at(i)));
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
repDirSystem = leRepSystem->text();
|
|
Packit Service |
b98cfc |
repDirUser = leRepUser->text();
|
|
Packit Service |
b98cfc |
global->RepDirSystem = repDirSystem;
|
|
Packit Service |
b98cfc |
global->RepDirUser = repDirUser;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
done(Accepted);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::cancelClicked()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
done(Rejected);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::refreshListBox(void)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
lbCards->clear();
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
CardParam *card;
|
|
Packit Service |
b98cfc |
QString desc;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
for (unsigned int i = 0; i < cards.count() ;i++)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
card = cards.at(i);
|
|
Packit Service |
b98cfc |
desc = card->CardName + " - " + card->CardSocket;
|
|
Packit Service |
b98cfc |
lbCards->insertItem(desc);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::refreshListBox(int idx)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
CardParam *card;
|
|
Packit Service |
b98cfc |
QString desc;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
card = cards.at(idx);
|
|
Packit Service |
b98cfc |
desc = card->CardName + " - " + card->CardSocket;
|
|
Packit Service |
b98cfc |
lbCards->changeItem(desc, idx);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::cardHighlighted(int index)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
CardParam *card;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
if (index >= 0 && (unsigned int)index < cards.count())
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
card = cards.at(index);
|
|
Packit Service |
b98cfc |
leCardName->setText(card->CardName);
|
|
Packit Service |
b98cfc |
leCardSocket->setText(card->CardSocket);
|
|
Packit Service |
b98cfc |
gbCard->setEnabled(true);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
else
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
leCardName->setText("");
|
|
Packit Service |
b98cfc |
leCardSocket->setText("");
|
|
Packit Service |
b98cfc |
gbCard->setEnabled(false);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::updateClicked()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
int idx = lbCards->currentItem();
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
if (idx >=0 && (unsigned int)idx < cards.count())
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
CardParam *card;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
card = cards.at(idx);
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
card->CardName = leCardName->text();
|
|
Packit Service |
b98cfc |
card->CardSocket = leCardSocket->text();
|
|
Packit Service |
b98cfc |
refreshListBox(idx);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::cardAddClicked()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
CardParam *card = new CardParam();
|
|
Packit Service |
b98cfc |
card->CardName = "Default card";
|
|
Packit Service |
b98cfc |
card->CardSocket = "/tmp/.ld10k1_port";
|
|
Packit Service |
b98cfc |
cards.append(card);
|
|
Packit Service |
b98cfc |
refreshListBox();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void PreferencesDlg::cardDelClicked()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
int idx = lbCards->currentItem();
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
if (idx >= 0)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
cards.remove(idx);
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
if (cards.count() <= 1)
|
|
Packit Service |
b98cfc |
pbCardDel->setEnabled(false);
|
|
Packit Service |
b98cfc |
refreshListBox();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|