author | zecke <zecke> | 2005-02-14 16:08:36 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 16:08:36 (UTC) |
commit | 0e6780c400fbae2ccd8895e40480adb4273906ae (patch) (side-by-side diff) | |
tree | 1cc48cfef9c0542272da51071ebda0e27b9e3cfc | |
parent | 277adb0af903b8bc2760c20891b664b763b667d9 (diff) | |
download | opie-0e6780c400fbae2ccd8895e40480adb4273906ae.zip opie-0e6780c400fbae2ccd8895e40480adb4273906ae.tar.gz opie-0e6780c400fbae2ccd8895e40480adb4273906ae.tar.bz2 |
Set a Caption
File a Bug and propose a better name
-rw-r--r-- | noncore/net/opierdesktop/qtwin.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/opierdesktop/qtwin.cpp b/noncore/net/opierdesktop/qtwin.cpp index e350bf6..181d275 100644 --- a/noncore/net/opierdesktop/qtwin.cpp +++ b/noncore/net/opierdesktop/qtwin.cpp @@ -1,288 +1,289 @@ /* rdesktop: A Remote Desktop Protocol client. User interface services - X Window System Copyright (C) Matthew Chapman 1999-2002 qt.cpp by Jay Sorg This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "rdesktop.h" #include <qpe/qpeapplication.h> #include <qmainwindow.h> #include <qwidget.h> #include <qpainter.h> #include <qimage.h> #include <qsocketnotifier.h> #include <qscrollview.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qcombobox.h> #include <qlabel.h> #include <qfile.h> #include <qcheckbox.h> #include <qpopupmenu.h> #include "qtwin.h" #include <stdlib.h> uint32 flags; char server[64] = ""; char domain[16] = ""; char password[16] = ""; char shell[128] = ""; char directory[32] = ""; extern int g_width; extern int g_height; extern int server_bpp; extern BOOL fullscreen; extern char username[]; int global_sock; QSocketNotifier* SocketNotifier; QPEApplication* App; QMyMainWindow* MW; QMyScrollView* SV; struct QColorMap { uint32 RGBColors[256]; int NumColors; }; QColorMap* CM; uint8* BS; int clipx; int clipy; int clipcx; int clipcy; struct bitmap { int w; int h; uint8* data; }; BOOL owncolmap = False; //***************************************************************************** void CleanString(QString* Item) { int i; i = Item->length() - 1; while (i >= 0) { if (Item->at(i) == 10 || Item->at(i) == 13) Item->remove(i, 1); i--; } } //***************************************************************************** QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) { + setCaption( tr( "Configuration" ) ); int i, j; char* home; char Text[256]; QString Line; QString ItemName; QString ItemValue; // resize dialog resize(230, 270); // main list box ListBox = new QListBox(this); ListBox->move(10, 10); ListBox->resize(200, 100); connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); // server Label1 = new QLabel(this); Label1->setText("Server Desc"); Label1->move(10, 120); Label1->resize(100, 20); ServerNameEdit = new QLineEdit(this); ServerNameEdit->move(75, 120); ServerNameEdit->resize(100, 20); // username Label2 = new QLabel(this); Label2->setText("User Name"); Label2->move(10, 150); Label2->resize(100, 20); UserNameEdit = new QLineEdit(this); UserNameEdit->move(75, 150); UserNameEdit->resize(100, 20); // ip Label3 = new QLabel(this); Label3->setText("Server IP"); Label3->move(10, 180); Label3->resize(100, 20); IPEdit = new QLineEdit(this); IPEdit->move(75, 180); IPEdit->resize(100, 20); // width and height WidthHeightBox = new QComboBox(this); WidthHeightBox->move(10, 210); WidthHeightBox->resize(100, 20); WidthHeightBox->insertItem("240x320"); WidthHeightBox->insertItem("640x480"); WidthHeightBox->insertItem("800x600"); connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); WidthHeightBox->setCurrentItem(1); WidthEdit = new QLineEdit(this); WidthEdit->move(110, 210); WidthEdit->resize(30, 20); WidthEdit->setText("800"); HeightEdit = new QLineEdit(this); HeightEdit->move(140, 210); HeightEdit->resize(30, 20); HeightEdit->setText("600"); // add to list button AddButton = new QPushButton(this); AddButton->move(180, 120); AddButton->resize(50, 20); AddButton->setText("Add"); connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); // change list item button EditButton = new QPushButton(this); EditButton->move(180, 140); EditButton->resize(50, 20); EditButton->setText("Edit"); connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); // save to file button SaveButton = new QPushButton(this); SaveButton->move(180, 160); SaveButton->resize(50, 20); SaveButton->setText("Save"); connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); // remove an item button RemoveButton = new QPushButton(this); RemoveButton->move(180, 180); RemoveButton->resize(50, 20); RemoveButton->setText("Remove"); connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); // full screen check box FullScreenCheckBox = new QCheckBox(this, "Full Screen"); FullScreenCheckBox->setText("Full Screen"); FullScreenCheckBox->move(10, 230); // ok button OKButton = new QPushButton(this); OKButton->setText("OK"); OKButton->move(100, 240); OKButton->resize(50, 20); connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked())); // cancel button CancelButton = new QPushButton(this); CancelButton->setText("Cancel"); CancelButton->move(160, 240); CancelButton->resize(50, 20); connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked())); for (i = 0; i < 10; i++) { ConnectionList[i] = new QMyConnectionItem; ConnectionList[i]->ServerName = ""; ConnectionList[i]->UserName = ""; ConnectionList[i]->ServerIP = ""; ConnectionList[i]->Width = 0; ConnectionList[i]->Height = 0; ConnectionList[i]->FullScreen = 0; } home = getenv("HOME"); if (home != NULL) { sprintf(Text, "%s/rdesktop.ini", home); QFile* File = new QFile(Text); if (File->open(IO_ReadOnly)) { i = -1; while (!File->atEnd()) { File->readLine(Line, 255); j = Line.find("="); if (j > 0) { ItemName = Line.mid(0, j); CleanString(&ItemName); ItemValue = Line.mid(j + 1); CleanString(&ItemValue); if (ItemName == "Server") { i++; ConnectionList[i]->ServerName = ItemValue; ListBox->insertItem(ItemValue); } else if (ItemName == "UserName") ConnectionList[i]->UserName = ItemValue; else if (ItemName == "Width") ConnectionList[i]->Width = ItemValue.toInt(); else if (ItemName == "Height") ConnectionList[i]->Height = ItemValue.toInt(); else if (ItemName == "IP") ConnectionList[i]->ServerIP = ItemValue; else if (ItemName == "FullScreen") ConnectionList[i]->FullScreen = (ItemValue != "0"); } } } delete File; } } //***************************************************************************** QMyDialog::~QMyDialog() { QMyConnectionItem* Item; int i; for (i = 0; i < 10; i++) { Item = ConnectionList[i]; delete Item; } } //***************************************************************************** void QMyDialog::ComboChanged(int index) { if (index == 0) { WidthEdit->setText("240"); HeightEdit->setText("320"); } if (index == 1) { WidthEdit->setText("640"); HeightEdit->setText("480"); } else if (index == 2) { WidthEdit->setText("800"); HeightEdit->setText("600"); } } //***************************************************************************** void QMyDialog::OKClicked() { ServerName = ServerNameEdit->text(); UserName = UserNameEdit->text(); Width = WidthEdit->text().toInt(); Height = HeightEdit->text().toInt(); ServerIP = IPEdit->text(); FullScreen = FullScreenCheckBox->isChecked(); done(1); } @@ -1419,291 +1420,292 @@ void ui_line(uint8 opcode, int startx, int starty, int endx, for (; dx >= 0; dx--) { set_pixel(startx, starty, pen->colour, opcode); if (p > 0) { startx += incx; starty += incy; p += dpru; } else { startx += incx; p += dpr; } } } else { dpr = dx << 1; dpru = dpr - (dy << 1); p = dpr - dy; for (; dy >= 0; dy--) { set_pixel(startx, starty, pen->colour, opcode); if (p > 0) { startx += incx; starty += incy; p += dpru; } else { starty += incy; p += dpr; } } } redraw(left, top, (right - left) + 1, (bottom - top) + 1); } //***************************************************************************** void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) { struct bitmap* the_glyph; int i, j; the_glyph = (struct bitmap*)glyph; if (the_glyph == NULL) return; for (i = 0; i < the_glyph->h; i++) for (j = 0; j < the_glyph->w; j++) if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8)) set_pixel(x + j, y + i, fgcolour); } #define DO_GLYPH(ttext,idx) \ {\ glyph = cache_get_font (font, ttext[idx]);\ if (!(flags & TEXT2_IMPLICIT_X))\ {\ xyoffset = ttext[++idx];\ if ((xyoffset & 0x80))\ {\ if (flags & TEXT2_VERTICAL) \ y += ttext[idx+1] | (ttext[idx+2] << 8);\ else\ x += ttext[idx+1] | (ttext[idx+2] << 8);\ idx += 2;\ }\ else\ {\ if (flags & TEXT2_VERTICAL) \ y += xyoffset;\ else\ x += xyoffset;\ }\ }\ if (glyph != NULL)\ {\ draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\ if (flags & TEXT2_IMPLICIT_X)\ x += glyph->width;\ }\ } //***************************************************************************** void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, int bgcolour, int fgcolour, uint8 * text, uint8 length) { FONTGLYPH *glyph; int i, j, xyoffset; DATABLOB *entry; if (boxcx > 1) fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); else if (mixmode == MIX_OPAQUE) fill_rect(clipx, clipy, clipcx, clipcy, bgcolour); /* Paint text, character by character */ for (i = 0; i < length;) { switch (text[i]) { case 0xff: if (i + 2 < length) cache_put_text(text[i + 1], text, text[i + 2]); else { error("this shouldn't be happening\n"); exit(1); } /* this will move pointer from start to first character after FF command */ length -= i + 3; text = &(text[i + 3]); i = 0; break; case 0xfe: entry = cache_get_text(text[i + 1]); if (entry != NULL) { if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X))) { if (flags & TEXT2_VERTICAL) y += text[i + 2]; else x += text[i + 2]; } for (j = 0; j < entry->size; j++) DO_GLYPH(((uint8 *) (entry->data)), j); } if (i + 2 < length) i += 3; else i += 2; length -= i; /* this will move pointer from start to first character after FE command */ text = &(text[i]); i = 0; break; default: DO_GLYPH(text, i); i++; break; } } if (boxcx > 1) redraw(boxx, boxy, boxcx, boxcy); else redraw(clipx, clipy, clipcx, clipcy); } //***************************************************************************** void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) { uint8* data; int i, j; data = (uint8*)xmalloc(cx * cy); for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) data[i * cx + j] = get_pixel(x + j, y + i); cache_put_desktop(offset, cx, cy, cx, 1, data); xfree(data); } //***************************************************************************** void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) { uint8* data; int i, j; data = cache_get_desktop(offset, cx, cy, 1); for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) set_pixel(x + j, y + i, data[i * cx + j]); redraw(x, y, cx, cy); } //***************************************************************************** int main(int argc, char** argv) { CM = NULL; BS = NULL; App = new QPEApplication(argc, argv); SV = new QMyScrollView(); App->setMainWidget(SV); SV->showMaximized(); + SV->setCaption( QMyScrollView::tr("Remote Desktop Client (RDP)") ); SV->timer_id = SV->startTimer(1000); App->exec(); delete SV; delete App; if (CM != NULL) xfree(CM); if (BS !=NULL) xfree(BS); return 0; } /* MW = new QMyMainWindow(); MW->resize(width, height); SV->resize(width + 4, height + 4); App->setMainWidget(SV); SV->addChild(MW); MW->setMouseTracking(true); SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); if (fullscreen) SV->showFullScreen(); else SV->showMaximized(); BS = (uint8*)xmalloc(width * height); memset(BS, 0, width * height); clipx = 0; clipy = 0; clipcx = width; clipcy = height; CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); memset(CM, 0, sizeof(struct QColorMap)); SV->timer_id = SV->startTimer(1000); return True; int main(int argc, char ** argv) { uint32 flags; int i, total_params; char server[64] = "192.168.0.164"; char domain[16] = ""; char password[16] = ""; char shell[128] = ""; char directory[32] = ""; char* p; QString param, s1, s2, s3; flags = RDP_LOGON_NORMAL; g_argc = argc; g_argv = argv; if (!ui_init()) return 1; total_params = App->argc(); for (i = 1; (i + 1) < total_params; i = i + 2) { s1 = App->argv()[i]; s2 = App->argv()[i + 1]; if (s1 == "-g") { width = strtol((const char*)s2, &p, 10); if (*p == 'x') height = strtol(p + 1, NULL, 10); } else if (s1 = "-u") strcpy(username, (const char*)s2); } if (i < total_params) strcpy(server, App->argv()[i]); // printf("server %s width %d height %d\n", server, width, height); if (width == 0 || height == 0) { ui_deinit(); return 1; } if (!rdp_connect(server, flags, domain, password, shell, directory)) { ui_deinit(); return 1; } if (ui_create_window()) { ui_main_loop(); ui_destroy_window(); } rdp_disconnect(); ui_deinit(); } */ |