svnno****@sourc*****
svnno****@sourc*****
2009年 7月 20日 (月) 19:24:22 JST
Revision: 2457 http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2457 Author: nogu Date: 2009-07-20 19:24:22 +0900 (Mon, 20 Jul 2009) Log Message: ----------- add load() Modified Paths: -------------- kita/branches/KITA-KDE4/kita/src/libkita/config_xt.kcfg kita/branches/KITA-KDE4/kita/src/mainwindow.cpp kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.cpp kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.h kita/branches/KITA-KDE4/kita/src/prefs/abstractprefpage.h kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.cpp kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.h kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.cpp kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.h kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.cpp kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.h kita/branches/KITA-KDE4/kita/src/prefs/prefs.cpp kita/branches/KITA-KDE4/kita/src/prefs/prefs.h kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.cpp kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.h kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.cpp kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.h Modified: kita/branches/KITA-KDE4/kita/src/libkita/config_xt.kcfg =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/config_xt.kcfg 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/libkita/config_xt.kcfg 2009-07-20 10:24:22 UTC (rev 2457) @@ -76,19 +76,19 @@ <group name="Color"> <entry name="ThreadColor" type="Color"> <label>Thread foreground color.</label> - <default>black</default> + <default>Qt::black</default> </entry> <entry name="ThreadBackground" type="Color"> <label>Thread backgroupd color.</label> - <default>white</default> + <default>Qt::white</default> </entry> <entry name="PopupColor" type="Color"> <label>Popup foreground color.</label> - <default>black</default> + <default>Qt::black</default> </entry> <entry name="PopupBackground" type="Color"> <label>Popup background color.</label> - <default>yellow</default> + <default>Qt::yellow</default> </entry> </group> <group name="Account"> Modified: kita/branches/KITA-KDE4/kita/src/mainwindow.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/mainwindow.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/mainwindow.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -230,6 +230,7 @@ } Preferences* dialog = new Preferences(this); + dialog->load(); connect(dialog, SIGNAL(fontChanged(const QFont&)), SLOT(setFont(const QFont&))); Modified: kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -14,19 +14,14 @@ using namespace Kita; -AbonePrefPage::AbonePrefPage(QWidget *parent) : AbstractPrefPage(parent) +AbonePrefPage::AbonePrefPage(QWidget *parent) +: AbstractPrefPage(parent), m_changed(false) { setupUi(this); - - idAboneText->setText(AboneConfig::aboneIDList().join("\n")); - nameAboneText->setText(AboneConfig::aboneNameList().join("\n")); - wordAboneText->setText(AboneConfig::aboneWordList().join("\n")); - + load(); connect(idAboneText, SIGNAL(textChanged()), SLOT(slotTextChanged())); connect(nameAboneText, SIGNAL(textChanged()), SLOT(slotTextChanged())); connect(wordAboneText, SIGNAL(textChanged()), SLOT(slotTextChanged())); - - m_changed = false; } void AbonePrefPage::slotTextChanged() @@ -54,6 +49,16 @@ m_changed = false; } +void AbonePrefPage::load() +{ + idAboneText->setText(AboneConfig::aboneIDList().join("\n")); + nameAboneText->setText(AboneConfig::aboneNameList().join("\n")); + wordAboneText->setText(AboneConfig::aboneWordList().join("\n")); +} + void AbonePrefPage::reset() { + AboneConfig::self()->useDefaults(true); + load(); + AboneConfig::self()->useDefaults(false); } Modified: kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/aboneprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -24,8 +24,9 @@ bool m_changed; public: AbonePrefPage(QWidget *parent = 0); - void apply(); - void reset(); + virtual void apply(); + virtual void load(); + virtual void reset(); private slots: void slotTextChanged(); Modified: kita/branches/KITA-KDE4/kita/src/prefs/abstractprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/abstractprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/abstractprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -21,6 +21,7 @@ public: explicit AbstractPrefPage(QWidget* parent = 0); virtual void apply() = 0; + virtual void load() = 0; virtual void reset() = 0; signals: Modified: kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -18,8 +18,7 @@ AsciiArtPrefPage::AsciiArtPrefPage(QWidget* parent) : AbstractPrefPage(parent) { setupUi(this); - asciiArtText->setText(AsciiArtConfig::asciiArtList().join("\n")); - asciiArtText->setFont(Config::threadFont()); + load(); connect(asciiArtText, SIGNAL(textChanged()), SIGNAL(changed())); } @@ -31,6 +30,15 @@ AsciiArtConfig::setAsciiArtList(list); } +void AsciiArtPrefPage::load() +{ + asciiArtText->setText(AsciiArtConfig::asciiArtList().join("\n")); + asciiArtText->setFont(Config::threadFont()); +} + void AsciiArtPrefPage::reset() { + AsciiArtConfig::self()->useDefaults(true); + load(); + AsciiArtConfig::self()->useDefaults(false); } Modified: kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/asciiartprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -22,8 +22,9 @@ Q_OBJECT public: AsciiArtPrefPage(QWidget* parent = 0); - void apply(); - void reset(); + virtual void apply(); + virtual void load(); + virtual void reset(); }; } Modified: kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -17,9 +17,11 @@ using namespace Kita; -FacePrefPage::FacePrefPage(QWidget* parent) : AbstractPrefPage(parent) +FacePrefPage::FacePrefPage(QWidget* parent) : AbstractPrefPage(parent), + m_threadFontChanged(false), m_threadColorChanged(false) { setupUi(this); + load(); // font connect(listFontButton, SIGNAL(clicked()), SLOT(slotFontButtonClicked())); @@ -29,17 +31,6 @@ connect(popupFontButton, SIGNAL(clicked()), SLOT(slotPopupFontButtonClicked())); - updateButtons(); - - m_threadFontchanged = false; - m_threadColorChanged = false; - - // color - threadColorButton->setColor(Config::threadColor()); - threadBackgroundColorButton->setColor(Config::threadBackground()); - popupColorButton->setColor(Config::popupColor()); - popupBackgroundColorButton->setColor(Config::popupBackground()); - connect(threadColorButton, SIGNAL(changed(const QColor&)), SIGNAL(changed())); connect(threadBackgroundColorButton, SIGNAL(changed(const QColor&)), @@ -61,11 +52,11 @@ Config::setFont(font); emit fontChanged(font); - if (m_threadFontchanged) { + if (m_threadFontChanged) { QFont threadFont = threadFontButton->font(); Config::setThreadFont(threadFont); } - m_threadFontchanged = false; + m_threadFontChanged = false; QFont popupFont = popupFontButton->font(); Config::setPopupFont(popupFont); @@ -80,6 +71,29 @@ Config::setPopupBackground(popupBackgroundColorButton->color()); } +void FacePrefPage::load() +{ + // font + QFont font = Config::font(); + listFontButton->setText(fontToString(font)); + listFontButton->setFont(font); + + QFont threadFont = Config::threadFont(); + threadFontButton->setText(fontToString(threadFont)); + threadFontButton->setFont(threadFont); + + QFont popupFont = Config::popupFont(); + popupFontButton->setText(fontToString(popupFont)); + popupFontButton->setFont(popupFont); + + // color + threadColorButton->setColor(Config::threadColor()); + threadBackgroundColorButton->setColor(Config::threadBackground()); + popupColorButton->setColor(Config::popupColor()); + popupBackgroundColorButton->setColor(Config::popupBackground()); + +} + void FacePrefPage::reset() { // font @@ -89,7 +103,7 @@ threadFontButton->setText(fontToString(font)); threadFontButton->setFont(font); - m_threadFontchanged = true; + m_threadFontChanged = true; popupFontButton->setText(fontToString(font)); popupFontButton->setFont(font); @@ -102,21 +116,6 @@ m_threadColorChanged = true; } -void FacePrefPage::updateButtons() -{ - QFont font = Config::font(); - listFontButton->setText(fontToString(font)); - listFontButton->setFont(font); - - QFont threadFont = Config::threadFont(); - threadFontButton->setText(fontToString(threadFont)); - threadFontButton->setFont(threadFont); - - QFont popupFont = Config::popupFont(); - popupFontButton->setText(fontToString(popupFont)); - popupFontButton->setFont(popupFont); -} - void FacePrefPage::slotThreadFontButtonClicked() { QFont threadFont = threadFontButton->font(); @@ -125,7 +124,7 @@ threadFontButton->setText(fontToString(threadFont)); threadFontButton->setFont(threadFont); emit changed(); - m_threadFontchanged = true; + m_threadFontChanged = true; } } Modified: kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/faceprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -20,13 +20,14 @@ { Q_OBJECT - bool m_threadFontchanged; + bool m_threadFontChanged; bool m_threadColorChanged; public: FacePrefPage(QWidget* parent = 0); - void apply(); - void reset(); + virtual void apply(); + virtual void load(); + virtual void reset(); private slots: void slotFontButtonClicked(); @@ -34,9 +35,6 @@ void slotThreadFontButtonClicked(); void slotColorChanged(); - private: - void updateButtons(); - signals: void fontChanged(const QFont&); }; Modified: kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -15,12 +15,17 @@ LoginPrefPage::LoginPrefPage(QWidget* parent) : AbstractPrefPage(parent) { setupUi(this); + load(); } void LoginPrefPage::apply() { } +void LoginPrefPage::load() +{ +} + void LoginPrefPage::reset() { } Modified: kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/loginprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -21,8 +21,9 @@ Q_OBJECT public: LoginPrefPage(QWidget* parent = 0); - void apply(); - void reset(); + virtual void apply(); + virtual void load(); + virtual void reset(); }; } Modified: kita/branches/KITA-KDE4/kita/src/prefs/prefs.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/prefs.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/prefs.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -29,66 +29,73 @@ // this is the base class for your preferences dialog. it is now // a Treelist dialog.. but there are a number of other // possibilities (including Tab, Swallow, and just Plain) - m_facePage = new FacePrefPage(0); - addPage(m_facePage, i18n("Face"), "view-list-details"); - connect(m_facePage, SIGNAL(fontChanged(const QFont&)), + FacePrefPage* facePage = new FacePrefPage(0); + addPage(facePage, i18n("Face"), "view-list-details"); + connect(facePage, SIGNAL(fontChanged(const QFont&)), SIGNAL(fontChanged(const QFont&))); + connect(facePage, SIGNAL(changed()), SLOT(slotChanged())); + m_pageList.append(facePage); - m_asciiArtPage = new AsciiArtPrefPage(0); - addPage(m_asciiArtPage, i18n("AsciiArt"), "kita"); + AsciiArtPrefPage* asciiArtPage = new AsciiArtPrefPage(0); + addPage(asciiArtPage, i18n("AsciiArt"), "kita"); + connect(asciiArtPage, SIGNAL(changed()), SLOT(slotChanged())); + m_pageList.append(asciiArtPage); - m_uiPage = new UIPrefPage(0); - addPage(m_uiPage, i18n("User Interface"), "configure"); + UIPrefPage* uiPage = new UIPrefPage(0); + addPage(uiPage, i18n("User Interface"), "configure"); + connect(uiPage, SIGNAL(changed()), SLOT(slotChanged())); + m_pageList.append(uiPage); - m_abonePage = new AbonePrefPage(0); - addPage(m_abonePage, i18n("Abone"), "kita"); + AbonePrefPage* abonePage = new AbonePrefPage(0); + addPage(abonePage, i18n("Abone"), "kita"); + connect(abonePage, SIGNAL(changed()), SLOT(slotChanged())); + m_pageList.append(abonePage); - m_loginPage = new LoginPrefPage(0); - addPage(m_loginPage, i18n("Login"), "network-connect"); + LoginPrefPage* loginPage = new LoginPrefPage(0); + addPage(loginPage, i18n("Login"), "network-connect"); + connect(loginPage, SIGNAL(changed()), SLOT(slotChanged())); + m_pageList.append(loginPage); - m_writePage = new WritePrefPage(0); - addPage(m_writePage, i18n("Write"), "document-edit"); + WritePrefPage* writePage = new WritePrefPage(0); + addPage(writePage, i18n("Write"), "document-edit"); + connect(writePage, SIGNAL(changed()), SLOT(slotChanged())); + m_pageList.append(writePage); +} - connect(m_facePage, SIGNAL(changed()), SLOT(slotChanged())); - connect(m_asciiArtPage, SIGNAL(changed()), SLOT(slotChanged())); - connect(m_uiPage, SIGNAL(changed()), SLOT(slotChanged())); - connect(m_abonePage, SIGNAL(changed()), SLOT(slotChanged())); - connect(m_loginPage, SIGNAL(changed()), SLOT(slotChanged())); - connect(m_writePage, SIGNAL(changed()), SLOT(slotChanged())); - - connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply())); - connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); +void Preferences::load() +{ + for (int i = 0, j = m_pageList.count(); i < j; i++) { + m_pageList.at(i)->load(); + } + enableButtonApply(false); } -void Preferences::slotApply() +void Preferences::apply() { - AbstractPrefPage* page = qobject_cast<AbstractPrefPage*>(currentPage()); - if (page) - page->apply(); + for (int i = 0, j = m_pageList.count(); i < j; i++) { + m_pageList.at(i)->apply(); + } enableButtonApply(false); } -void Preferences::slotDefault() +void Preferences::reset() { - AbstractPrefPage* page = qobject_cast<AbstractPrefPage*>(currentPage()); - if (page) - page->reset(); - enableButtonApply(true); + for (int i = 0, j = m_pageList.count(); i < j; i++) { + m_pageList.at(i)->reset(); + } } -void Preferences::slotChanged() +void Preferences::slotButtonClicked(int button) { - enableButtonApply(true); + if (button == Ok || button == Apply) { + apply(); + } else if (button == Default) { + reset(); + } + KConfigDialog::slotButtonClicked(button); } -void Preferences::slotOk() +void Preferences::slotChanged() { - m_facePage->apply(); - m_asciiArtPage->apply(); - m_uiPage->apply(); - m_abonePage->apply(); - m_loginPage->apply(); - m_writePage->apply(); - - accept(); + enableButtonApply(true); } Modified: kita/branches/KITA-KDE4/kita/src/prefs/prefs.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/prefs.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/prefs.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -11,16 +11,13 @@ #ifndef KITAPREFS_H #define KITAPREFS_H +#include <QtCore/QList> + #include <kconfigdialog.h> namespace Kita { - class AbonePrefPage; - class AsciiArtPrefPage; - class FacePrefPage; - class LoginPrefPage; - class UIPrefPage; - class WritePrefPage; + class AbstractPrefPage; class KDE_EXPORT Preferences : public KConfigDialog { @@ -28,22 +25,18 @@ public: Preferences(QWidget* parent); + void load(); private: + QList<AbstractPrefPage*> m_pageList; + void apply(); + void reset(); Preferences(const Preferences&); Preferences& operator=(const Preferences&); - AbonePrefPage* m_abonePage; - AsciiArtPrefPage* m_asciiArtPage; - FacePrefPage* m_facePage; - LoginPrefPage* m_loginPage; - UIPrefPage* m_uiPage; - WritePrefPage* m_writePage; private slots: + virtual void slotButtonClicked(int button); void slotChanged(); - void slotApply(); - void slotOk(); - void slotDefault(); signals: void fontChanged(const QFont&); Modified: kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -17,6 +17,7 @@ UIPrefPage::UIPrefPage(QWidget* parent) : AbstractPrefPage(parent) { setupUi(this); + load(); connect(editFileAssociation, SIGNAL(leftClickedUrl()), SLOT(slotEditFileAssociation())); } @@ -25,6 +26,10 @@ { } +void UIPrefPage::load() +{ +} + void UIPrefPage::reset() { kcfg_AlwaysUseTab->setChecked(true); Modified: kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/uiprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -21,8 +21,9 @@ Q_OBJECT public: UIPrefPage(QWidget* parent = 0); - void apply(); - void reset(); + virtual void apply(); + virtual void load(); + virtual void reset(); private slots: /// open 'file association setting dialog' Modified: kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.cpp 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.cpp 2009-07-20 10:24:22 UTC (rev 2457) @@ -15,12 +15,17 @@ WritePrefPage::WritePrefPage(QWidget* parent) : AbstractPrefPage(parent) { setupUi(this); + load(); } void WritePrefPage::apply() { } +void WritePrefPage::load() +{ +} + void WritePrefPage::reset() { } Modified: kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.h 2009-07-20 00:47:34 UTC (rev 2456) +++ kita/branches/KITA-KDE4/kita/src/prefs/writeprefpage.h 2009-07-20 10:24:22 UTC (rev 2457) @@ -21,8 +21,9 @@ Q_OBJECT public: WritePrefPage(QWidget* parent = 0); - void apply(); - void reset(); + virtual void apply(); + virtual void load(); + virtual void reset(); }; }