KNewStuff
ghns.cpp
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #include <iostream>
00022 
00023 #include <qlayout.h>
00024 #include <qfile.h>
00025 #include <qtextstream.h>
00026 #include <qlabel.h>
00027 
00028 #include <kaboutdata.h>
00029 #include <kapplication.h>
00030 #include <kdebug.h>
00031 #include <klocale.h>
00032 #include <kcmdlineargs.h>
00033 #include <kprocess.h>
00034 #include <kdialog.h>
00035 
00036 #include "knewstuffgeneric.h"
00037 
00038 #include "ghns.h"
00039 
00040 using namespace std;
00041 
00042 GhnsWidget::GhnsWidget()
00043 {
00044   mWallpapers = new KNewStuffGeneric( "kdesktop/wallpaper", this );
00045 
00046   QBoxLayout *topLayout = new QVBoxLayout( this );
00047   topLayout->setMargin( KDialog::marginHint() );
00048   topLayout->setSpacing( KDialog::spacingHint() );
00049 
00050   topLayout->addWidget( new QLabel( i18n("Get hot new stuff:"), this ) );
00051 
00052   QPushButton *button = new QPushButton( "Wallpapers", this );
00053   topLayout->addWidget( button );
00054   connect( button, SIGNAL( clicked() ), SLOT( downloadWallpapers() ) );
00055 
00056   topLayout->addSpacing( 5 );
00057 
00058   QBoxLayout *buttonLayout = new QHBoxLayout( topLayout );
00059 
00060   buttonLayout->addStretch();
00061 
00062   QPushButton *closeButton = new QPushButton( "Close", this );
00063   buttonLayout->addWidget( closeButton );
00064   connect( closeButton, SIGNAL( clicked() ), kapp, SLOT( quit() ) );
00065 }
00066 
00067 GhnsWidget::~GhnsWidget()
00068 {
00069   delete mWallpapers;
00070 }
00071 
00072 void GhnsWidget::downloadWallpapers()
00073 {
00074   kdDebug() << "downloadWallpapers()" << endl;
00075 
00076   mWallpapers->download();
00077 }
00078 
00079 int main(int argc,char **argv)
00080 {
00081   KAboutData aboutData("ghns","Get Hot New Stuff","0.1");
00082   KCmdLineArgs::init(argc,argv,&aboutData);
00083 
00084   KApplication app;
00085 
00086   GhnsWidget wid;
00087   app.setMainWidget( &wid );
00088   wid.show();
00089 
00090   app.exec();
00091 }
00092 
00093 #include "ghns.moc"