[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Fri Sep 7 20:49:12 CEST 2007
SVN commit 709532 by treat:
* No more restore defaults by default.
* Respect apply button for ViewItemDialog.
* Little redesign to hopefully simplify and make clear.
M +10 -21 dialog.cpp
M +3 -6 dialog.h
M +1 -1 dialog.ui
M +4 -9 dialogpage.cpp
M +3 -5 dialogpage.h
M +0 -16 dialogtab.cpp
M +7 -7 dialogtab.h
M +3 -3 filltab.cpp
M +0 -3 filltab.h
M +6 -6 stroketab.cpp
M +0 -3 stroketab.h
M +2 -2 viewitemdialog.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/dialog.cpp #709531:709532
@@ -38,9 +38,8 @@
void Dialog::addDialogPage(DialogPage *page) {
- connect(page, SIGNAL(modified(bool)), this, SLOT(modified(bool)));
+ connect(page, SIGNAL(modified()), this, SLOT(modified()));
connect(this, SIGNAL(apply()), page, SIGNAL(apply()));
- connect(this, SIGNAL(restoreDefaults()), page, SIGNAL(restoreDefaults()));
QListWidgetItem *item = new QListWidgetItem(page->pageIcon(), page->pageTitle(), _listWidget);
_listWidget->addItem(item);
_stackedWidget->addWidget(page);
@@ -48,21 +47,10 @@
}
-void Dialog::accept() {
- modified(false);
- QDialog::accept();
-}
-
-
-void Dialog::reject() {
- modified(false);
- QDialog::reject();
-}
-
-
void Dialog::setVisible(bool visible) {
_listWidget->setVisible(_itemHash.count() > 2);
+ _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
QDialog::setVisible(visible);
}
@@ -77,11 +65,15 @@
void Dialog::buttonClicked(QAbstractButton *button) {
QDialogButtonBox::StandardButton std = _buttonBox->standardButton(button);
switch(std) {
+ case QDialogButtonBox::Ok:
+ emit ok();
+ break;
case QDialogButtonBox::Apply:
+ _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
emit apply();
break;
- case QDialogButtonBox::RestoreDefaults:
- emit restoreDefaults();
+ case QDialogButtonBox::Cancel:
+ emit cancel();
break;
default:
break;
@@ -89,11 +81,8 @@
}
-void Dialog::modified(bool isModified) {
- Q_UNUSED(isModified)
-/*FIXME
- _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(isModified);
- _buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(isModified);*/
+void Dialog::modified() {
+ _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/dialog.h #709531:709532
@@ -34,13 +34,10 @@
void addDialogPage(DialogPage *page);
- public Q_SLOTS:
- virtual void accept();
- virtual void reject();
-
Q_SIGNALS:
+ void ok();
void apply();
- void restoreDefaults();
+ void cancel();
protected:
void setVisible(bool visible);
@@ -48,7 +45,7 @@
private Q_SLOTS:
void selectPageForItem(QListWidgetItem *item);
void buttonClicked(QAbstractButton *button);
- void modified(bool isModified);
+ void modified();
private:
QHash<QListWidgetItem*, DialogPage*> _itemHash;
--- branches/work/kst/portto4/kst/src/libkstapp/dialog.ui #709531:709532
@@ -51,7 +51,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
- <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
+ <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
--- branches/work/kst/portto4/kst/src/libkstapp/dialogpage.cpp #709531:709532
@@ -27,18 +27,13 @@
void DialogPage::addDialogTab(DialogTab *tab) {
- connect(tab, SIGNAL(modified(bool)), this, SIGNAL(modified(bool)));
- connect(this, SIGNAL(apply()), tab, SLOT(apply()));
- connect(this, SIGNAL(restoreDefaults()), tab, SLOT(restoreDefaults()));
+ connect(this, SIGNAL(ok()), tab, SIGNAL(ok()));
+ connect(this, SIGNAL(apply()), tab, SIGNAL(apply()));
+ connect(this, SIGNAL(cancel()), tab, SIGNAL(cancel()));
+ connect(tab, SIGNAL(modified()), this, SIGNAL(modified()));
_tab->addTab(tab, tab->tabTitle());
}
-
-void DialogPage::showEvent(QShowEvent *event) {
- restoreDefaults();
- QWidget::showEvent(event);
}
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/dialogpage.h #709531:709532
@@ -38,13 +38,11 @@
void addDialogTab(DialogTab *tab);
Q_SIGNALS:
+ void ok();
void apply();
- void restoreDefaults();
- void modified(bool isModified);
+ void cancel();
+ void modified();
- protected:
- virtual void showEvent(QShowEvent *event);
-
private:
QString _pageTitle;
QPixmap _pageIcon;
--- branches/work/kst/portto4/kst/src/libkstapp/dialogtab.cpp #709531:709532
@@ -21,22 +21,6 @@
DialogTab::~DialogTab() {
}
-
-void DialogTab::apply() {
- emit modified(false);
}
-
-void DialogTab::restoreDefaults() {
- emit modified(false);
-}
-
-
-void DialogTab::showEvent(QShowEvent *event) {
- restoreDefaults();
- QWidget::showEvent(event);
-}
-
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/dialogtab.h #709531:709532
@@ -24,21 +24,21 @@
{
Q_OBJECT
public:
+ typedef QMap<QString, QVariant> ValueMap;
+
DialogTab(QWidget *parent);
virtual ~DialogTab();
QString tabTitle() const { return _tabTitle; }
void setTabTitle(const QString &tabTitle) { _tabTitle = tabTitle; }
- public Q_SLOTS:
- virtual void apply();
- virtual void restoreDefaults();
-
Q_SIGNALS:
- void modified(bool isModified);
+ void ok();
+ void apply();
+ void cancel();
- protected:
- virtual void showEvent(QShowEvent *event);
+ //subclasses must emit...
+ void modified();
private:
QString _tabTitle;
--- branches/work/kst/portto4/kst/src/libkstapp/filltab.cpp #709531:709532
@@ -35,9 +35,9 @@
_style->addItem("FDiagPattern", Qt::FDiagPattern);
_style->addItem("DiagCrossPattern", Qt::DiagCrossPattern);
- connect(_color, SIGNAL(changed(const QColor &)), this, SIGNAL(changed()));
- connect(_style, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
- connect(_gradientEditor, SIGNAL(changed(const QGradient &)), this, SIGNAL(changed()));
+ connect(_color, SIGNAL(changed(const QColor &)), this, SIGNAL(modified()));
+ connect(_style, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_gradientEditor, SIGNAL(changed(const QGradient &)), this, SIGNAL(modified()));
//FIXME gradient editor is disabled for now as it is not ready
_gradientEditor->setEnabled(false);
--- branches/work/kst/portto4/kst/src/libkstapp/filltab.h #709531:709532
@@ -33,9 +33,6 @@
QGradient gradient() const;
void setGradient(const QGradient &gradient);
-
-Q_SIGNALS:
- void changed();
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/stroketab.cpp #709531:709532
@@ -52,12 +52,12 @@
_capStyle->addItem("SquareCap", Qt::SquareCap);
_capStyle->addItem("RoundCap", Qt::RoundCap);
- connect(_style, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
- connect(_width, SIGNAL(valueChanged(double)), this, SIGNAL(changed()));
- connect(_brushColor, SIGNAL(changed(const QColor &)), this, SIGNAL(changed()));
- connect(_brushStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
- connect(_joinStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
- connect(_capStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
+ connect(_style, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_width, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
+ connect(_brushColor, SIGNAL(changed(const QColor &)), this, SIGNAL(modified()));
+ connect(_brushStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_joinStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_capStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
}
--- branches/work/kst/portto4/kst/src/libkstapp/stroketab.h #709531:709532
@@ -42,9 +42,6 @@
Qt::PenCapStyle capStyle() const;
void setCapStyle(Qt::PenCapStyle style);
-
-Q_SIGNALS:
- void changed();
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.cpp #709531:709532
@@ -49,8 +49,8 @@
_fillTab = new FillTab(this);
_strokeTab = new StrokeTab(this);
- connect(_fillTab, SIGNAL(changed()), this, SLOT(fillChanged()));
- connect(_strokeTab, SIGNAL(changed()), this, SLOT(strokeChanged()));
+ connect(_fillTab, SIGNAL(apply()), this, SLOT(fillChanged()));
+ connect(_strokeTab, SIGNAL(apply()), this, SLOT(strokeChanged()));
DialogPage *page = new DialogPage(this);
page->setPageTitle(tr("Appearance"));
More information about the Kst
mailing list