00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "options.h"
00033
00034 #include <qtabwidget.h>
00035 #include <qlabel.h>
00036 #include <qlayout.h>
00037 #include <qhbox.h>
00038 #include <qtextview.h>
00039 #include <qpushbutton.h>
00040
00041 #include <kaboutapplication.h>
00042 #include <kglobal.h>
00043 #include <kinstance.h>
00044 #include <kiconloader.h>
00045
00046 #include "uiDialog.moc"
00047
00048 UIDialog::UIDialog(QWidget * parent, const char *name,
00049 bool modal) :
00050 KDialogBase(parent, name, modal, QString::null,
00051 KDialogBase::Ok | KDialogBase::Cancel,
00052 KDialogBase::Ok, false),
00053 fP(0L)
00054 {
00055 FUNCTIONSETUP;
00056
00057 fMainWidget = makeHBoxMainWidget();
00058 }
00059
00060 UIDialog::~UIDialog()
00061 {
00062 FUNCTIONSETUP;
00063 }
00064
00065 void UIDialog::addAboutPage(bool aboutbutton,KAboutData *ad)
00066 {
00067 FUNCTIONSETUP;
00068 ASSERT(tabWidget());
00069
00070 QWidget *w = new QWidget(tabWidget(), "aboutpage");
00071
00072 QString s;
00073 QLabel *text;
00074 KIconLoader *l = KGlobal::iconLoader();
00075 const KAboutData *p = ad ? ad : KGlobal::instance()->aboutData();
00076
00077 QGridLayout *grid = new QGridLayout(w, 5, 4, SPACING);
00078
00079 grid->addColSpacing(0, SPACING);
00080 grid->addColSpacing(4, SPACING);
00081
00082
00083 #ifdef DEBUG
00084 DEBUGKPILOT << fname
00085 << ": Looking for icon for "
00086 << p->appName()
00087 << endl;
00088 #endif
00089
00090 QPixmap applicationIcon =
00091 l->loadIcon(QString::fromLatin1(p->appName()),
00092 KIcon::Desktop,
00093 0, KIcon::DefaultState, 0L,
00094 true);
00095
00096 if (applicationIcon.isNull())
00097 {
00098 #ifdef DEBUG
00099 DEBUGKPILOT << fname
00100 << ": Looking for icon for "
00101 << "kpilot"
00102 << endl;
00103 #endif
00104 applicationIcon = l->loadIcon(QString::fromLatin1("kpilot"),
00105 KIcon::Desktop);
00106 }
00107
00108 text = new QLabel(w);
00109 text->setPixmap(applicationIcon);
00110 text->adjustSize();
00111 grid->addWidget(text, 0, 1);
00112
00113
00114 text = new QLabel(w);
00115 s = QString::null;
00116 s += p->programName();
00117 s += ' ';
00118 s += p->version();
00119 s += '\n';
00120 s += p->copyrightStatement();
00121 text->setText(s);
00122 grid->addMultiCellWidget(text, 0, 0, 2, 3);
00123
00124 text = new QLabel(w);
00125 s = p->shortDescription();
00126 text->setText(s);
00127 grid->addMultiCellWidget(text, 1, 1, 2, 3);
00128
00129 text = new QLabel(w);
00130
00131
00132
00133 text->setText(i18n("Send questions and comments to kde-pim@kde.org"));
00134 text->adjustSize();
00135 #ifdef DEBUG
00136 DEBUGKPILOT << fname
00137 << ": Text size "
00138 << text->size().width()
00139 << ","
00140 << text->size().height()
00141 << endl;
00142 #endif
00143 grid->addColSpacing(2,SPACING+text->size().width()/2);
00144 grid->addColSpacing(3,SPACING+text->size().width()/2);
00145
00146 s = "<qt>";
00147 if (!p->homepage().isEmpty())
00148 {
00149 s += p->homepage();
00150 s += CSL1("<br>");
00151 }
00152 s += i18n("Send questions and comments to <i>kde-pim@kde.org</i>");
00153 s += CSL1("<br>");
00154 s += i18n("Send bug reports to <i>%1</i>").arg(p->bugAddress());
00155 s += CSL1("</qt>");
00156
00157 text->setText(s);
00158 grid->addMultiCellWidget(text, 2, 2, 2, 3);
00159
00160
00161
00162 if (aboutbutton)
00163 {
00164 QPushButton *but = new QPushButton(i18n("More About"),
00165 w);
00166
00167 connect(but, SIGNAL(clicked()), this, SLOT(showAbout()));
00168 but->adjustSize();
00169 grid->addWidget(but, 4, 2);
00170 grid->setRowStretch(3, 100);
00171 }
00172 else
00173 {
00174 QValueList<KAboutPerson> l = p->authors();
00175 QValueList<KAboutPerson>::ConstIterator i;
00176 s = i18n("<qt><b>Authors:</b> ");
00177
00178 QString comma = CSL1(", ");
00179
00180 unsigned int count=1;
00181 for (i=l.begin(); i!=l.end(); ++i)
00182 {
00183 s.append(CSL1("%1 (<i>%2</i>)%3")
00184 .arg((*i).name())
00185 .arg((*i).task())
00186 .arg(count<l.count() ? comma : QString::null)
00187 );
00188 count++;
00189 }
00190
00191 l = p->credits();
00192 if (l.count()>0)
00193 {
00194 count=1;
00195 s.append(i18n("<br><b>Credits:</b> "));
00196 for (i=l.begin(); i!=l.end(); ++i)
00197 {
00198 s.append(CSL1("%1 (<i>%2</i>)%3")
00199 .arg((*i).name())
00200 .arg((*i).task())
00201 .arg(count<l.count() ? comma : QString::null)
00202 );
00203 count++;
00204 }
00205 }
00206
00207
00208 s.append(CSL1("</qt>"));
00209
00210 text = new QLabel(w);
00211 text->setText(s);
00212 text->adjustSize();
00213
00214 grid->addMultiCellWidget(text,4,4,2,3);
00215
00216 grid->setRowStretch(4,100);
00217 grid->addRowSpacing(5,SPACING);
00218 }
00219
00220
00221 grid->setColStretch(3, 100);
00222
00223 #ifdef DEBUG
00224 DEBUGKPILOT << fname
00225 << ": Size "
00226 << w->size().width()
00227 << ","
00228 << w->size().height()
00229 << endl;
00230 #endif
00231
00232 w->adjustSize();
00233 #ifdef DEBUG
00234 DEBUGKPILOT << fname
00235 << ": Adjusted size "
00236 << w->size().width()
00237 << ","
00238 << w->size().height()
00239 << endl;
00240 #endif
00241
00242 QSize sz = w->size();
00243
00244 if (sz.width() < tabWidget()->size().width())
00245 {
00246 sz.setWidth(tabWidget()->size().width());
00247 }
00248 if (sz.height() < tabWidget()->size().height())
00249 {
00250 sz.setHeight(tabWidget()->size().height());
00251 }
00252
00253 #ifdef DEBUG
00254 DEBUGKPILOT << fname
00255 << ": Final size "
00256 << sz.width()
00257 << ","
00258 << sz.height()
00259 << endl;
00260 #endif
00261
00262 tabWidget()->resize(sz);
00263 tabWidget()->addTab(w, i18n("About"));
00264
00265 }
00266
00267 void UIDialog::setTabWidget(QTabWidget * w)
00268 {
00269 FUNCTIONSETUP;
00270
00271 widget()->resize(w->size());
00272 fP = w;
00273 }
00274
00275 void UIDialog::showAbout()
00276 {
00277 FUNCTIONSETUP;
00278 KAboutApplication *kap = new KAboutApplication(this);
00279
00280 kap->exec();
00281
00282
00283
00284
00285 }
00286
00287 void UIDialog::slotOk()
00288 {
00289 FUNCTIONSETUP;
00290
00291 if (validate())
00292 {
00293 commitChanges();
00294 KDialogBase::slotOk();
00295 }
00296 }