/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#include <qglobal.h>
#include <QMainWindow>
#include <QList>
#include <qtextbrowser.h>
#include <QAction>
#include <QFileDialog>
#include <QMenu>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qtoolbar.h>
#include <qlayout.h>
#include <qsplitter.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qevent.h>
#include <stdlib.h>
#include "lkc.h"
#include "qconf.h"
#include "qconf.moc"
#include "images.c"
#ifdef _
# undef _
# define _ qgettext
#endif
static QApplication *configApp;
static ConfigSettings *configSettings;
QAction *ConfigMainWindow::saveAction;
static inline QString qgettext(const char* str)
{
return QString::fromLocal8Bit(gettext(str));
}
static inline QString qgettext(const QString& str)
{
return QString::fromLocal8Bit(gettext(str.toLatin1()));
}
ConfigSettings::ConfigSettings()
: QSettings("kernel.org", "qconf")
{
}
/**
* Reads a list of integer values from the application settings.
*/
QList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
{
QList<int> result;
QStringList entryList = value(key).toStringList();
QStringList::Iterator it;
for (it = entryList.begin(); it != entryList.end(); ++it)
result.push_back((*it).toInt());
return result;
}
/**
* Writes a list of integer values to the application settings.
*/
bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value)
{
QStringList stringList;
QList<int>::ConstIterator it;
for (it = value.begin(); it != value.end(); ++it)
stringList.push_back(QString::number(*it));
setValue(key, stringList);
return true;
}
/*
* construct a menu entry
*/
void ConfigItem::init(void)
{
}
/*
* destruct a menu entry
*/
ConfigItem::~ConfigItem(void)
{
}
ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
: Parent(parent)
{
connect(this, SIGNAL(editingFinished()), SLOT(hide()));
}
void ConfigLineEdit::show(ConfigItem* i)
{
item = i;
Parent::show();
setFocus();
}
void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
{
switch (e->key()) {
case Qt::Key_Escape:
break;
case Qt::Key_Return:
case Qt::Key_Enter:
parent()->updateList(item);
break;
default:
Parent::keyPressEvent(e);
return;
}
e->accept();
parent()->list->setFocus();
hide();
}
ConfigList::ConfigList(ConfigView* p, const char *name)
: Parent(p)
{
}
ConfigView*ConfigView::viewList;
QAction *ConfigView::showNormalAction;
QAction *ConfigView::showAllAction;
QAction *ConfigView::showPromptAction;
ConfigView::ConfigView(QWidget* parent, const char *name)
: Parent(parent)
{
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(0, 0, 0, 0);
list = new ConfigList(this);
verticalLayout->addWidget(list);
lineEdit = new ConfigLineEdit(this);
lineEdit->hide();
verticalLayout->addWidget(lineEdit);
this->nextView = viewList;
viewList = this;
}
ConfigView::~ConfigView(void)
{
ConfigView** vp;
for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
if (*vp == this) {
*vp = nextView;
break;
}
}
}
void ConfigView::setOptionMode(QAction *act)
{
}
void ConfigView::setShowName(bool b)
{
}
void ConfigView::setShowRange(bool b)
{
}
void ConfigView::setShowData(bool b)
{
}
void ConfigView::updateList(ConfigItem* item)
{
}
void ConfigView::updateListAll(void)
{
}
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
: Parent(parent), sym(0), _menu(0)
{
if (name) {
configSettings->beginGroup(name);
_showDebug = configSettings->value("/showDebug", false).toBool();
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}
}
void ConfigInfoView::saveSettings(void)
{
/*if (name()) {
configSettings->beginGroup(name());
configSettings->setValue("/showDebug", showDebug());