kpilot/lib

uiDialog.cc

00001 /* KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 ** Copyright (C) 2004 by Adriaan de Groot
00005 **
00006 ** This class defines a way to add an "about widget" to a tab widget.
00007 **
00008 ** None of Dan's original code is left.
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU Lesser General Public License as published by
00014 ** the Free Software Foundation; either version 2.1 of the License, or
00015 ** (at your option) any later version.
00016 **
00017 ** This program is distributed in the hope that it will be useful,
00018 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 ** GNU Lesser General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU Lesser General Public License
00023 ** along with this program in a file called COPYING; if not, write to
00024 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 ** MA 02110-1301, USA.
00026 */
00027 
00028 /*
00029 ** Bug reports and questions can be sent to kde-pim@kde.org
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 #include <kactivelabel.h>
00046 
00047 #include "uiDialog.h"
00048 
00049 /* static */ QWidget *UIDialog::aboutPage(QWidget *parent, KAboutData *ad)
00050 {
00051     FUNCTIONSETUP;
00052 
00053     QWidget *w = new QWidget(parent, "aboutpage");
00054 
00055     QString s;
00056     QLabel *text;
00057     KIconLoader *l = KGlobal::iconLoader();
00058     const KAboutData *p = ad ? ad : KGlobal::instance()->aboutData();
00059 
00060     QGridLayout *grid = new QGridLayout(w, 5, 4, SPACING);
00061 
00062     grid->addColSpacing(0, SPACING);
00063     grid->addColSpacing(4, SPACING);
00064 
00065 
00066     QPixmap applicationIcon =
00067         l->loadIcon(QString::fromLatin1(p->appName()),
00068         KIcon::Desktop,
00069         64, KIcon::DefaultState, 0L,
00070         true);
00071 
00072     if (applicationIcon.isNull())
00073     {
00074         applicationIcon = l->loadIcon(QString::fromLatin1("kpilot"),
00075             KIcon::Desktop);
00076     }
00077 
00078     text = new QLabel(w);
00079     // Experiment with a long non-<qt> string. Use that to find
00080     // sensible widths for the columns.
00081     //
00082     text->setText(i18n("Send questions and comments to kdepim-users@kde.org"));
00083     text->adjustSize();
00084 
00085     int linewidth = text->size().width();
00086     int lineheight = text->size().height();
00087 
00088     // Use the label to display the applciation icon
00089     text->setText(QString::null);
00090     text->setPixmap(applicationIcon);
00091     text->adjustSize();
00092     grid->addWidget(text, 0, 1);
00093 
00094 
00095     KActiveLabel *linktext = new KActiveLabel(w);
00096     grid->addRowSpacing(1,kMax(100,6*lineheight));
00097     grid->addRowSpacing(2,kMax(100,6*lineheight));
00098     grid->addColSpacing(2,SPACING+linewidth/2);
00099     grid->addColSpacing(3,SPACING+linewidth/2);
00100     grid->setRowStretch(1,50);
00101     grid->setRowStretch(2,50);
00102     grid->setColStretch(2,50);
00103     grid->setColStretch(3,50);
00104     linktext->setMinimumSize(linewidth,kMax(260,60+12*lineheight));
00105     linktext->setFixedHeight(kMax(260,60+12*lineheight));
00106     linktext->setVScrollBarMode(QScrollView::Auto/*AlwaysOn*/);
00107     text = new QLabel(w);
00108     grid->addMultiCellWidget(text,0,0,2,3);
00109     grid->addMultiCellWidget(linktext,1,2,1,3);
00110 
00111     // Now set the program and copyright information.
00112     s = CSL1("<qt><h3>");
00113     s += p->programName();
00114     s += ' ';
00115     s += p->version();
00116     s += CSL1("</h3>");
00117     s += p->copyrightStatement() + CSL1("<br></qt>");
00118     text->setText(s);
00119 
00120     linktext->append(p->shortDescription() + CSL1("<br>"));
00121 
00122     if (!p->homepage().isEmpty())
00123     {
00124         s = QString::null;
00125         s += CSL1("<a href=\"%1\">").arg(p->homepage());
00126         s += p->homepage();
00127         s += CSL1("</a><br>");
00128         linktext->append(s);
00129     }
00130 
00131     s = QString::null;
00132     s += i18n("Send questions and comments to <a href=\"mailto:%1\">%2</a>.")
00133         .arg( CSL1("kdepim-users@kde.org") )
00134         .arg( CSL1("kdepim-users@kde.org") );
00135     s += ' ';
00136     s += i18n("Send bug reports to <a href=\"mailto:%1\">%2</a>.")
00137         .arg(p->bugAddress())
00138         .arg(p->bugAddress());
00139     s += ' ';
00140     s += i18n("For trademark information, see the "
00141         "<a href=\"help:/kpilot/trademarks.html\">KPilot User's Guide</a>.");
00142     s += CSL1("<br>");
00143     linktext->append(s);
00144     linktext->append(QString::null);
00145 
00146 
00147 
00148     QValueList<KAboutPerson> pl = p->authors();
00149     QValueList<KAboutPerson>::ConstIterator i;
00150 
00151     s = i18n("<b>Authors:</b> ");
00152 
00153     QString comma = CSL1(", ");
00154 
00155     unsigned int count=1;
00156     for (i=pl.begin(); i!=pl.end(); ++i)
00157     {
00158         s.append(CSL1("%1 (<i>%2</i>)%3")
00159             .arg((*i).name())
00160             .arg((*i).task())
00161             .arg(count<pl.count() ? comma : QString::null)
00162             );
00163         count++;
00164     }
00165     linktext->append(s);
00166 
00167     s = QString::null;
00168     pl = p->credits();
00169     if (pl.count()>0)
00170     {
00171         count=1;
00172         s.append(i18n("<b>Credits:</b> "));
00173         for (i=pl.begin(); i!=pl.end(); ++i)
00174         {
00175             s.append(CSL1("%1 (<i>%2</i>)%3")
00176                 .arg((*i).name())
00177                 .arg((*i).task())
00178                 .arg(count<pl.count() ? comma : QString::null)
00179                 );
00180             count++;
00181         }
00182     }
00183     linktext->append(s);
00184     linktext->ensureVisible(0,0);
00185 
00186     w->adjustSize();
00187 
00188     return w;
00189 }
00190 
00191 /* static */ void UIDialog::addAboutPage(QTabWidget *tw,
00192     KAboutData *ad,
00193     bool /* aboutbutton */)
00194 {
00195     FUNCTIONSETUP;
00196 
00197     Q_ASSERT(tw);
00198 
00199     QWidget *w = UIDialog::aboutPage(tw,ad);
00200     QSize sz = w->size();
00201 
00202     if (sz.width() < tw->size().width())
00203     {
00204         sz.setWidth(tw->size().width());
00205     }
00206     if (sz.height() < tw->size().height())
00207     {
00208         sz.setHeight(tw->size().height());
00209     }
00210 
00211     tw->resize(sz);
00212     tw->addTab(w, i18n("About"));
00213     tw->adjustSize();
00214 }
00215 
KDE Home | KDE Accessibility Home | Description of Access Keys