[prev in list] [next in list] [prev in thread] [next in thread]
List: atlantik-devel
Subject: [atlantik-devel] CVS: kdeaddons/atlantikdesigner/designer group.cpp,NONE,1.1 group.h,NONE,1.1 Makefi
From: kde () office ! kde ! org
Date: 2002-06-08 6:07:15
[Download RAW message or body]
Update of /home/kde/kdeaddons/atlantikdesigner/designer
In directory office:/tmp/cvs-serv8384
Modified Files:
Makefile.am designer.cpp designer.h editor.cpp editor.h
Added Files:
group.cpp group.h
Log Message:
add a gui-only (doesn't yet save or load or update the board colors) group editor... \
also doesn't have price editing or rent math stuff
--- NEW FILE: group.cpp ---
#include <qframe.h>
#include <qvgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qstring.h>
#include <qstringlist.h>
#include <kcolorbutton.h>
#include <kdebug.h>
#include <klineeditdlg.h>
#include <klistbox.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
#include "group.h"
GroupEditor::GroupEditor(ConfigEstateGroupList *newList)
: KDialogBase(KDialogBase::Plain, i18n("Group Editor"), Ok|Cancel, Ok, 0, "Group \
Editor", false, true), mylist(*newList) {
setWFlags(WDestructiveClose);
list = newList;
QFrame *page = plainPage();
QHBoxLayout *hlayout = new QHBoxLayout(page, marginHint(), spacingHint());
groups = new KListBox(page);
hlayout->addWidget(groups);
connect(groups, SIGNAL(executed(QListBoxItem *)), this, \
SLOT(updateSettings(QListBoxItem *))); QStringList newgroups;
ConfigEstateGroup *group = 0;
for (group = list->first(); group; group = list->next())
newgroups.append(group->name());
groups->insertStringList(newgroups);
connect(groups, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
QVBoxLayout *vlayout = new QVBoxLayout(hlayout, spacingHint());
colorGroupBox = new QVGroupBox(i18n("&Colors"), page);
vlayout->addWidget(colorGroupBox);
(void) new QLabel(i18n("Foreground"), colorGroupBox);
fgButton = new KColorButton(colorGroupBox, "Foreground Button");
connect(fgButton, SIGNAL(changed(const QColor &)), this, SLOT(fgChanged(const QColor \
&))); connect(fgButton, SIGNAL(changed(const QColor &)), this, SIGNAL(changed()));
(void) new QLabel(i18n("Background"), colorGroupBox);
bgButton = new KColorButton(colorGroupBox, "Background Button");
connect(bgButton, SIGNAL(changed(const QColor &)), this, SLOT(bgChanged(const QColor \
&))); connect(bgButton, SIGNAL(changed(const QColor &)), this, SIGNAL(changed()));
QHBoxLayout *buttonlayout = new QHBoxLayout(vlayout, spacingHint());
removeB = new KPushButton(i18n("&Remove"), page);
buttonlayout->addWidget(removeB);
connect(removeB, SIGNAL(clicked()), this, SLOT(remove()));
KPushButton *addB = new KPushButton(i18n("&Add..."), page);
buttonlayout->addWidget(addB);
connect(addB, SIGNAL(clicked()), this, SLOT(add()));
selectionChanged();
}
void GroupEditor::add()
{
bool ok;
QString name = KLineEditDlg::getText(i18n("Add Group"), i18n("Enter the name of the \
new group below."), QString::null, &ok, this); if (ok)
{
ConfigEstateGroup *group = 0;
for (group = mylist.first(); group; group = mylist.next())
{
if (group->name() == name)
{
KMessageBox::information(this, i18n("That group is already on the list."));
return;
}
}
mylist.append(new ConfigEstateGroup(name));
groups->insertItem(name);
emit changed();
}
}
void GroupEditor::remove()
{
QString curText = groups->currentText();
if (!curText.isNull())
{
groups->removeItem(groups->currentItem());
emit changed();
}
}
void GroupEditor::updateSettings(QListBoxItem *item)
{
ConfigEstateGroup *group = 0;
for (group = mylist.first(); group; group = mylist.next())
if (group->name() == item->text())
break;
fgButton->setColor(group->fgColor());
bgButton->setColor(group->bgColor());
}
ConfigEstateGroup *GroupEditor::currentGroup()
{
QListBoxItem *item = groups->item(groups->currentItem());
if (!item)
return 0;
ConfigEstateGroup *group = 0;
for (group = mylist.first(); group; group = mylist.next())
if (group->name() == item->text())
return group;
return 0;
}
void GroupEditor::fgChanged(const QColor &color)
{
ConfigEstateGroup *group = currentGroup();
if (group)
group->setFgColor(color);
}
void GroupEditor::bgChanged(const QColor &color)
{
ConfigEstateGroup *group = currentGroup();
if (group)
group->setBgColor(color);
}
void GroupEditor::slotOk()
{
*list = mylist;
KDialogBase::slotOk();
}
void GroupEditor::selectionChanged()
{
bool issel = groups->currentItem() >= 0;
colorGroupBox->setEnabled(issel);
removeB->setEnabled(issel);
}
--- NEW FILE: group.h ---
#ifndef GROUP_H
#define GROUP_H
#include <qptrlist.h>
#include <qcolor.h>
#include <kdialogbase.h>
#include <atlantic/estategroup.h>
class KColorButton;
class KListBox;
class KPushButton;
class QListBoxItem;
class QVGroupBox;
class ConfigEstateGroup : public EstateGroup
{
Q_OBJECT
public:
ConfigEstateGroup() : EstateGroup(QString::null) {}
ConfigEstateGroup(const QString &name) : EstateGroup(name) {}
void setFgColor(const QColor &color) { m_fgColor = color; }
void setBgColor(const QColor &color) { m_bgColor = color; }
const QColor &fgColor() { return m_fgColor; }
const QColor &bgColor() { return m_bgColor; }
private:
QColor m_fgColor;
QColor m_bgColor;
};
typedef QPtrList<ConfigEstateGroup> ConfigEstateGroupList;
class GroupEditor : public KDialogBase
{
Q_OBJECT
public:
GroupEditor(ConfigEstateGroupList *);
signals:
void changed();
protected slots:
virtual void slotOk();
private slots:
void updateSettings(QListBoxItem *item);
void fgChanged(const QColor &);
void bgChanged(const QColor &);
void add();
void remove();
void selectionChanged();
private:
KListBox *groups;
KColorButton *fgButton;
KColorButton *bgButton;
QVGroupBox *colorGroupBox;
KPushButton *removeB;
ConfigEstateGroupList *list;
ConfigEstateGroupList mylist;
ConfigEstateGroup *currentGroup();
};
#endif
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am 2002/05/28 22:39:15 1.4
+++ Makefile.am 2002/06/08 06:07:13 1.5
@@ -5,7 +5,7 @@
SUBDIRS =
-atlantikdesigner_SOURCES = boardinfo.cpp designer.cpp editor.cpp main.cpp
+atlantikdesigner_SOURCES = boardinfo.cpp designer.cpp editor.cpp main.cpp group.cpp
KDE_ICON = atlantikdesigner
Index: designer.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/designer.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- designer.cpp 2002/04/25 05:42:21 1.34
+++ designer.cpp 2002/06/08 06:07:13 1.35
@@ -35,7 +35,7 @@
AtlanticDesigner::AtlanticDesigner(QWidget *parent, const char *name) : \
KMainWindow(parent, name) {
- estates.setAutoDelete(true);
+ groups.setAutoDelete(true);
chanceStack.setAutoDelete(true);
ccStack.setAutoDelete(true);
@@ -47,12 +47,13 @@
board = 0;
layout = 0;
- (void) KStdAction::close(this, SLOT(close()), actionCollection());
+ (void) KStdAction::quit(this, SLOT(close()), actionCollection());
(void) KStdAction::open(this, SLOT(open()), actionCollection());
(void) KStdAction::openNew(this, SLOT(openNew()), actionCollection());
(void) KStdAction::save(this, SLOT(save()), actionCollection());
(void) KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
(void) new KAction(i18n("&Edit Gameboard Info..."), 0, this, SLOT(info()), \
actionCollection(), "boardinfo"); + (void) new KAction(i18n("&Edit Groups..."), 0, \
this, SLOT(editGroups()), actionCollection(), "groupeditor");
(void) new KAction(i18n("&Add 4 Squares"), "viewmag+", 0, this, SLOT(larger()), \
actionCollection(), "larger"); (void) new KAction(i18n("&Remove 4 Squares"), \
"viewmag-", 0, this, SLOT(smaller()), actionCollection(), "smaller"); @@ -70,7 +71,7 \
@@ estateAct = new KListAction(i18n("Change Estate"), 0, 0, 0, actionCollection(), \
"estate_num"); connect(estateAct, SIGNAL(activated(int)), SLOT(changeEstate(int)));
- createGUI("designerui.rc");
+ createGUI("atlantikdesignerui.rc");
// these MUST match up to the ones in editor.cpp!
types.append("street");
@@ -670,9 +671,12 @@
{
if (warnClose())
return;
+
saveMainWindowSettings(KGlobal::config(), "DesignerTopLevelWindow");
recentAct->saveEntries(KGlobal::config(), "Designer recent files");
+
e->accept();
+ kapp->quit();
}
void AtlanticDesigner::changeEstate(int index)
@@ -783,6 +787,19 @@
void AtlanticDesigner::doCaption(bool modified)
{
setCaption(filename.isNull()? i18n("Atlantic Gameboard Editor") : filename, \
modified); +}
+
+void AtlanticDesigner::editGroups()
+{
+ if (groupEditor.isNull())
+ {
+ groupEditor = new GroupEditor(&groups);
+ groupEditor->show();
+ }
+ else
+ groupEditor->raise();
+
+ connect(groupEditor, SIGNAL(changed()), this, SLOT(modified()));
}
void AtlanticDesigner::info()
Index: designer.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/designer.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- designer.h 2002/03/27 23:34:47 1.12
+++ designer.h 2002/06/08 06:07:13 1.13
@@ -8,6 +8,7 @@
#include <qguardedptr.h>
#include "boardinfo.h"
+#include "group.h"
#include "editor.h"
class EstateEdit;
@@ -46,6 +47,7 @@
void movePlayer(Estate *);
void setPlayerAtBeginning();
void info();
+ void editGroups();
void up();
void down();
@@ -68,6 +70,7 @@
QGuardedPtr<EstateEdit> editor;
QGuardedPtr<QVBoxLayout> layout;
QGuardedPtr<AtlantikBoard> board;
+ QGuardedPtr<GroupEditor> groupEditor;
EstateList estates;
KListAction *estateAct;
KRecentFilesAction *recentAct;
@@ -75,6 +78,7 @@
CardStack chanceStack;
CardStack ccStack;
BoardInfo boardInfo;
+ ConfigEstateGroupList groups;
QString filename;
Index: editor.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/editor.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- editor.cpp 2002/04/20 12:51:37 1.21
+++ editor.cpp 2002/06/08 06:07:13 1.22
@@ -14,7 +14,6 @@
#include <kdialog.h>
#include <klineeditdlg.h>
#include <kdialogbase.h>
-#include <kcolorbutton.h>
#include <klocale.h>
#include <kpushbutton.h>
@@ -146,16 +145,6 @@
layout->addWidget(new QWidget(this), 2, 0);
layout->setRowStretch(2, 1);
- QHGroupBox *colorGroupBox = new QHGroupBox(i18n("&Colors"), this);
- layout->addWidget(colorGroupBox, 3, 0);
-
- (void) new QLabel(i18n("Foreground"), colorGroupBox);
- fgButton = new KColorButton(colorGroupBox, "Foreground Button");
- connect(fgButton, SIGNAL(changed(const QColor &)), this, \
SIGNAL(somethingChanged()));
- (void) new QLabel(i18n("Background"), colorGroupBox);
- bgButton = new KColorButton(colorGroupBox, "Background Button");
- connect(bgButton, SIGNAL(changed(const QColor &)), this, \
SIGNAL(somethingChanged()));
-
QHBoxLayout *typeLayout = new QHBoxLayout(layout, 6);
QLabel *typeLabel = new QLabel(i18n("Type"), this);
typeLayout->addWidget(typeLabel, 4, 0);
@@ -203,16 +192,9 @@
this->estate = _estate;
- //kdDebug() << "bgcolor name: " << _estate->bgColor().name() << endl;
- //kdDebug() << "setting estate: " << _estate->name() << endl;
-
ready = false;
nameEdit->setText(_estate->name());
typeCombo->setCurrentItem(_estate->type());
- if (_estate->color().isValid())
- fgButton->setColor(_estate->color());
- bgButton->setColor(_estate->bgColor());
- //kdDebug() << "bgcolor name: " << _estate->bgColor().name() << endl;
ready = true;
@@ -236,18 +218,11 @@
estate->setType(curType);
estate->setName(nameEdit->text());
- estate->setColor(fgButton->color());
- estate->setBgColor(bgButton->color());
}
if (curType != Street)
{
- fgButton->setEnabled(false);
- //fgButton->setColor(QColor("zzzzzz"));
- estate->setColor(QColor("zzzzzz"));
}
- else
- fgButton->setEnabled(true);
if (!superficial)
estate->update();
Index: editor.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/editor.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- editor.h 2002/03/27 23:34:47 1.16
+++ editor.h 2002/06/08 06:07:13 1.17
@@ -13,7 +13,6 @@
class QLineEdit;
class QSpinBox;
-class KColorButton;
class KComboBox;
class KPushButton;
@@ -90,8 +89,6 @@
void configure();
private:
- KColorButton *fgButton;
- KColorButton *bgButton;
KComboBox *typeCombo;
QLineEdit *nameEdit;
QWidget *centerWidget;
@@ -106,9 +103,6 @@
QWidget *confDlg;
QWidget *oldConfDlg;
QWidget *reallyOldConfDlg;
-
- QColor fg;
- QColor bg;
EstateType oldType;
_______________________________________________
atlantik-devel mailing list
atlantik-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/atlantik-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic