summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
authorllornkcor <llornkcor>2004-06-15 10:18:36 (UTC)
committer llornkcor <llornkcor>2004-06-15 10:18:36 (UTC)
commitc711eea6fb1fa136cd62dc8b7134ee72968c8a53 (patch) (unidiff)
tree5f467c8abff45e468c4b119122553c1eef7f3beb /noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
parent83b4b2d2670b63a2a540006cea2ea8808100d308 (diff)
downloadopie-c711eea6fb1fa136cd62dc8b7134ee72968c8a53.zip
opie-c711eea6fb1fa136cd62dc8b7134ee72968c8a53.tar.gz
opie-c711eea6fb1fa136cd62dc8b7134ee72968c8a53.tar.bz2
start download, fix dialogs
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/NetworkDialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
index 6e6b707..d629449 100644
--- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
@@ -41,115 +41,115 @@ QPushButton* buttonCancel;
41static netbuf *conn = NULL; 41static netbuf *conn = NULL;
42 42
43static int log_progress(netbuf *ctl, int xfered, void *arg) { 43static int log_progress(netbuf *ctl, int xfered, void *arg) {
44 int fsz = *(int *)arg; 44 int fsz = *(int *)arg;
45 int pct = (xfered * 100) / fsz; 45 int pct = (xfered * 100) / fsz;
46 printf("%3d%%\r", pct); 46 printf("%3d%%\r", pct);
47 fflush(stdout); 47 fflush(stdout);
48 ProgressBar1->setProgress(xfered); 48 ProgressBar1->setProgress(xfered);
49 qApp->processEvents(); 49 qApp->processEvents();
50 50
51 return 1; 51 return 1;
52} 52}
53 53
54NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL) 54NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL)
55 : QDialog( parent, name, modal, fl ) 55 : QDialog( parent, name, modal, fl )
56{ 56{
57 57
58 ftp_host = netL[0]; 58 ftp_host = netL[0];
59 networkUrl = strUrl = netL[0]; 59 networkUrl = strUrl = netL[0];
60 60
61 dir = ftp_base_dir = netL[1]; 61 dir = ftp_base_dir = netL[1];
62 localFileName = netL[2]; 62 localFileName = netL[2];
63 s_partialFileName = netL[3]; 63 s_partialFileName = netL[3];
64 64
65 resize(240,110); 65 resize(240,120);
66 66
67 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 67 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
68// autoOk = autoDownload; 68// autoOk = autoDownload;
69// if( networkUrl.find("ftp",0,false)== -1 ) { 69// if( networkUrl.find("ftp",0,false)== -1 ) {
70// if ( !name ) 70// if ( !name )
71// setName( "HTTP NetworkDialog" ); 71// setName( "HTTP NetworkDialog" );
72// setCaption( tr( "HTTP Download ) ); 72// setCaption( tr( "HTTP Download ) );
73// qInitNetworkProtocols(); // registers ftp protocol // for now 73// qInitNetworkProtocols(); // registers ftp protocol // for now
74// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); 74// QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> );
75// } else { 75// } else {
76 if ( !name ) 76 if ( !name )
77 setName( "FTP NetworkDialog" ); 77 setName( "FTP NetworkDialog" );
78 setCaption(tr("FTP Download")); 78 setCaption(tr("FTP Download"));
79// } 79// }
80 initDialog(); //opens file to be written 80 initDialog(); //opens file to be written
81} 81}
82 82
83NetworkDialog::~NetworkDialog() { 83NetworkDialog::~NetworkDialog() {
84} 84}
85 85
86void NetworkDialog::initDialog() { 86void NetworkDialog::initDialog() {
87 87
88 totalBytesDownloaded=0; 88 totalBytesDownloaded=0;
89 warnLabel = new QLabel( this, "TextLabel" ); 89 warnLabel = new QLabel( this, "TextLabel" );
90 warnLabel ->setText( tr( "Push Ok to download file...." ) ); 90 warnLabel ->setText( tr( "Push Ok to download file...." ) );
91 TextLabel3 = new QLabel( this, "TextLabel3" ); 91 TextLabel3 = new QLabel( this, "TextLabel3" );
92 TextLabel3->setText( ""); 92 TextLabel3->setText( "");
93 QWidget* Layout1 = new QWidget( this, "Layout1" ); 93 QWidget* Layout1 = new QWidget( this, "Layout1" );
94 94
95 hbox = new QHBoxLayout(Layout1); 95 hbox = new QHBoxLayout(Layout1);
96 hbox->setMargin(4); 96 hbox->setMargin(4);
97 97
98 ProgressBar1 = new QProgressBar( Layout1, "ProgressBar1" ); 98 ProgressBar1 = new QProgressBar( Layout1, "ProgressBar1" );
99 ProgressBar1->setProgress(0); 99 ProgressBar1->setProgress(0);
100 hbox->addWidget(ProgressBar1,10,AlignCenter); 100 hbox->addWidget(ProgressBar1,10,AlignCenter);
101 101
102 hbox->addStretch(1); 102 // hbox->addStretch(1);
103 buttonOk = new QPushButton( Layout1, "buttonOk" ); 103// buttonOk = new QPushButton( Layout1, "buttonOk" );
104 buttonOk->setText( tr( "&OK" ) ); 104// buttonOk->setText( tr( "&OK" ) );
105 hbox->addWidget(buttonOk,0,AlignRight); 105// hbox->addWidget(buttonOk,0,AlignRight);
106 hbox->addSpacing(5); 106// hbox->addSpacing(5);
107 buttonCancel = new QPushButton( Layout1, "buttonCancel" ); 107 buttonCancel = new QPushButton( Layout1, "buttonCancel" );
108 buttonCancel->setText( tr( "&Cancel" ) ); 108 buttonCancel->setText( tr( "&Cancel" ) );
109 buttonCancel->setAutoDefault( TRUE ); 109 buttonCancel->setAutoDefault( TRUE );
110 buttonCancel->setDefault( TRUE ); 110 buttonCancel->setDefault( TRUE );
111 hbox->addWidget(buttonCancel,0,AlignRight); 111 hbox->addWidget(buttonCancel,0,AlignRight);
112 112
113 ProgressBar1->setFixedSize(140,22); 113 ProgressBar1->setFixedSize(150,25);
114 buttonOk->setFixedSize(35,22); 114// buttonOk->setFixedSize(35,22);
115 buttonCancel->setFixedSize(35,22); 115 buttonCancel->setFixedSize(50,25);
116 warnLabel ->setGeometry( QRect( 5,1,230,25)); 116 warnLabel ->setGeometry( QRect( 5,1,230,25));
117 TextLabel3->setGeometry( QRect( 5,20,230,25)); 117 TextLabel3->setGeometry( QRect( 5,20,230,25));
118 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!! 118 Layout1->setGeometry( QRect(1,60,235,50)); //TODO check these!!
119 119
120// timer= new QTimer(this,"vu timer"); 120// timer= new QTimer(this,"vu timer");
121// connectionTimer=new QTimer(this,"connectionTimeout"); 121// connectionTimer=new QTimer(this,"connectionTimeout");
122 122
123 connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk())); 123// connect(buttonOk,SIGNAL(clicked()),this,SLOT(doOk()));
124 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); 124 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
125// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot())); 125// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot()));
126// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot())); 126// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot()));
127 if(autoOk) { 127// if(autoOk) {
128 owarn << "XXXXXXXXXXXXXXXXXXXXXXXX" << oendl; 128// buttonOk->setDown(true);
129 buttonOk->setDown(true); 129 QTimer::singleShot( 1000, this, SLOT( doOk() ));
130 doOk(); 130// }
131 } 131
132} 132}
133 133
134void NetworkDialog::timeSlot() { 134void NetworkDialog::timeSlot() {
135 135
136// if(timerProgess < 19 && posTimer) { 136// if(timerProgess < 19 && posTimer) {
137// ProgressBar1->setProgress(timerProgess); 137// ProgressBar1->setProgress(timerProgess);
138// timerProgess++; 138// timerProgess++;
139// } else if(timerProgess > 19 && posTimer) { 139// } else if(timerProgess > 19 && posTimer) {
140// ProgressBar1->setProgress(timerProgess); 140// ProgressBar1->setProgress(timerProgess);
141// timerProgess++; 141// timerProgess++;
142// posTimer=FALSE; 142// posTimer=FALSE;
143// } 143// }
144// if(timerProgess > 1 &&!posTimer) { 144// if(timerProgess > 1 &&!posTimer) {
145// ProgressBar1->setProgress(timerProgess); 145// ProgressBar1->setProgress(timerProgess);
146// timerProgess--; 146// timerProgess--;
147// } else if(timerProgess > 1 &&!posTimer){ 147// } else if(timerProgess > 1 &&!posTimer){
148// ProgressBar1->setProgress(timerProgess); 148// ProgressBar1->setProgress(timerProgess);
149// timerProgess--; 149// timerProgess--;
150// posTimer=TRUE; 150// posTimer=TRUE;
151// } 151// }
152// // odebug << "timer event" << oendl; 152// // odebug << "timer event" << oendl;
153// qApp->processEvents(); 153// qApp->processEvents();
154// repaint(); 154// repaint();
155} 155}