qtewin.cpp
来自「远程桌面登陆软件 用rdesktop 但不基于Xwindows 可基于(nano」· C++ 代码 · 共 2,176 行 · 第 1/5 页
CPP
2,176 行
return 0; p = src; /* skip escaped needles */ while ((nextval = strchr(p, needle))) { mvp = nextval - 1; /* found backslashed needle */ if (*mvp == '\\' && (mvp > src)) { /* move string one to the left */ while (*(mvp + 1) != (char) 0x00) { *mvp = *(mvp + 1); //*mvp++; } *mvp = (char) 0x00; p = nextval; } else { p = nextval + 1; break; } } /* more args available */ if (nextval) { *nextval = (char) 0x00; return ++nextval; } /* no more args after this, jump to EOS */ nextval = src + strlen(src); return nextval;}/******************************************************************************/void ui_clip_handle_data(unsigned char * data, unsigned int length){ char ClipData[length]; QClipboard *cb = QApplication::clipboard(); QString text; QTextCodec *codec; codec = QTextCodec::codecForName( "sjis" ); sprintf(ClipData,"%s",data); text = codec->toUnicode(ClipData); cb->setText(text);}/******************************************************************************/void ui_clip_request_data(unsigned int){ QClipboard *cb = QApplication::clipboard(); QString text; QCString sjisdata; QTextCodec *codec; codec = QTextCodec::codecForName( "sjis" ); unsigned int length; text = cb->text(); if (text == NULL) { cliprdr_send_data(NULL, 0); return; } text.replace( QRegExp("\x0a"), "\x0d\x0a"); length = (text.length() * 2); char data[length]; sjisdata = codec->fromUnicode(text); sprintf(data,"%s",(const char *)sjisdata); if (g_Clip == True) cliprdr_send_data((uint8 *)data, length + 1); cliprdr_send_simple_native_format_announce(CF_TEXT);}/******************************************************************************/void ui_clip_format_announce(unsigned char *, unsigned int){}/******************************************************************************/void ui_clip_sync(void){ cliprdr_send_simple_native_format_announce(CF_TEXT);}/******************************************************************************/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){ int i, j; char * home; char Text[256]; QFile* File; QString Line; QString ItemName; QString ItemValue; setCaption( ( QTRVER ) ); QGridLayout * MainLayout = new QGridLayout( this ); MainLayout->addMultiCellWidget(TabWidget = new QTabWidget(this), 0,0,0,1); MainLayout->addMultiCellWidget(OKButton = new QPushButton(tr("connect"),this),1,1,0,0); MainLayout->addMultiCellWidget(CancelButton = new QPushButton(tr("cancel"),this),1,1,1,1); TabWidget->insertTab(Tab1 = new QWidget(TabWidget), tr("general")); TabWidget->insertTab(Tab2 = new QWidget(TabWidget), tr("screen")); TabWidget->insertTab(Tab3 = new QWidget(TabWidget), tr("local resource")); TabWidget->insertTab(Tab4 = new QWidget(TabWidget), tr("others")); QGridLayout * Tab1Layout = new QGridLayout(Tab1); Tab1Layout->addMultiCellWidget(ListBox = new QListBox(Tab1),0,2,0,2); Tab1Layout->addWidget(AddButton = new QPushButton(tr("add"),Tab1),3,0); Tab1Layout->addWidget(SaveButton = new QPushButton(tr("save"),Tab1),3,1); Tab1Layout->addWidget(RemoveButton = new QPushButton(tr("del"),Tab1),3,2); Tab1Layout->addWidget(Label1 = new QLabel(tr("Name"),Tab1),4,0); Tab1Layout->addMultiCellWidget(ServerNameEdit = new QLineEdit(Tab1),4,4,1,2); Tab1Layout->addWidget(Label2 = new QLabel(tr("User"),Tab1),5,0); Tab1Layout->addMultiCellWidget(UserNameEdit = new QLineEdit(Tab1),5,5,1,2); Tab1Layout->addWidget(Label3 = new QLabel(tr("Password"),Tab1),6,0); Tab1Layout->addMultiCellWidget(PWDEdit = new QLineEdit(Tab1),6,6,1,2); PWDEdit->setEchoMode(QLineEdit::Password); Tab1Layout->addWidget(Label4 = new QLabel(tr("IP Address"),Tab1),7,0); Tab1Layout->addMultiCellWidget(IPEdit = new QLineEdit(Tab1),7,7,1,2); Tab1Layout->addWidget(Label5 = new QLabel(tr("PortNo"),Tab1),8,0); Tab1Layout->addMultiCellWidget(PortNoEdit = new QLineEdit(Tab1),8,8,1,2); QGridLayout * Tab2Layout = new QGridLayout(Tab2); Tab2Layout->addWidget(WidthHeightBox = new QComboBox(Tab2),0,0); WidthHeightBox->insertItem("640x480"); WidthHeightBox->insertItem("800x600"); WidthHeightBox->insertItem("1024x768"); WidthHeightBox->setCurrentItem(0); Tab2Layout->addWidget(FullScreenCheckBox = new QCheckBox(tr("FullScreen"),Tab2),0,1); Tab2Layout->addWidget(Label6 = new QLabel(tr("Color"),Tab2),1,0); Tab2Layout->addWidget(ColorBox = new QComboBox(Tab2),1,1); ColorBox->insertItem("8bpp"); ColorBox->insertItem("15bpp"); ColorBox->insertItem("16bpp"); //ColorBox->insertItem("24bpp"); Tab2Layout->addWidget(Label8 = new QLabel(tr("RDP5 experience"),Tab2),2,0); Tab2Layout->addWidget(RDP5ExpBox = new QComboBox(Tab2),2,1); RDP5ExpBox->insertItem(tr("modem (28.8Kbps)")); RDP5ExpBox->insertItem(tr("modem (56Kbps)")); RDP5ExpBox->insertItem(tr("broadband (128Kbps - 1.5Mbps)")); RDP5ExpBox->insertItem(tr("LAN (more than 10Mbps)")); RDP5ExpBox->insertItem(tr("custom")); Tab2Layout->addMultiCellWidget(RDP5ExpCheckBox1 = new QCheckBox(tr("wallpaper"),Tab2),3,3,0,1); Tab2Layout->addMultiCellWidget(RDP5ExpCheckBox2 = new QCheckBox(tr("window drag"),Tab2),4,4,0,1); Tab2Layout->addMultiCellWidget(RDP5ExpCheckBox3 = new QCheckBox(tr("menu animation"),Tab2),5,5,0,1); Tab2Layout->addMultiCellWidget(RDP5ExpCheckBox4 = new QCheckBox(tr("desktop theme"),Tab2),6,6,0,1); QGridLayout * Tab3Layout = new QGridLayout(Tab3); Tab3Layout->addWidget(Label7 = new QLabel(tr("Keyboard"),Tab3),0,0); Tab3Layout->addMultiCellWidget(KBDBox = new QComboBox(Tab3),0,0,1,2); KBDBox->insertItem(tr("Japanese")); KBDBox->insertItem(tr("English")); Tab3Layout->addWidget(Label12 = new QLabel(tr("Sound"),Tab3),1,0); Tab3Layout->addMultiCellWidget(SoundBox = new QComboBox(Tab3),1,1,1,2); SoundBox->insertItem(tr("disable sound")); SoundBox->insertItem(tr("enable sound on zaurus")); SoundBox->insertItem(tr("enable sound on remote machine")); Tab3Layout->addWidget(Label13 = new QLabel(tr("Disk"),Tab3),2,0); Tab3Layout->addMultiCellWidget(DiskBox = new QComboBox(Tab3),2,2,1,2); DiskBox->insertItem(tr("disable redirect")); DiskBox->insertItem(tr("'/home/zaurus/Documents' to 'home'")); DiskBox->insertItem(tr("'/mnt/card' to 'SD'")); DiskBox->insertItem(tr("both redirect")); DiskBox->insertItem(tr("specifies")); Tab3Layout->addMultiCellWidget(DiskEdit = new QLineEdit(Tab3),3,3,0,2); DiskEdit->setText(""); Tab3Layout->addWidget(Label9 = new QLabel(tr("bitmap cache"),Tab3),4,0); Tab3Layout->addMultiCellWidget(CacheBox = new QComboBox(Tab3),4,4,1,2); CacheBox->insertItem(tr("disable cache")); CacheBox->insertItem(tr("enable cache")); CacheBox->insertItem(tr("cache to '~/'")); CacheBox->insertItem(tr("cache to '/mnt/card'")); CacheBox->insertItem(tr("cache to '/home/zaurus/Documents'")); CacheBox->setCurrentItem(1); Tab3Layout->addMultiCellWidget(Label10 = new QLabel(tr(" 8bpp cache file:0KB"),Tab3),5,5,0,1); Tab3Layout->addWidget(DelCache1Button = new QPushButton(tr("del"),Tab3),5,2); Tab3Layout->addMultiCellWidget(Label11 = new QLabel(tr("16bpp cache file:0KB"),Tab3),6,6,0,1); Tab3Layout->addWidget(DelCache2Button = new QPushButton(tr("del"),Tab3),6,2); QGridLayout * Tab4Layout = new QGridLayout(Tab4); Tab4Layout->addWidget(CtrlCheck = new QCheckBox(tr("Ctrl key of Zaurus is enable"),Tab4),0,0); Tab4Layout->addWidget(OKCheck = new QCheckBox(tr("Enter key is allocated in OK key"),Tab4),1,0); Tab4Layout->addWidget(LeftCheck = new QCheckBox(tr("left-handed mode"),Tab4),2,0); Tab4Layout->addWidget(ConsoleCheck = new QCheckBox(tr("attach to console"),Tab4),3,0); Tab4Layout->addWidget(EncCheck = new QCheckBox(tr("disable encryption from client to server"),Tab4),4,0); Tab4Layout->addWidget(CompCheck = new QCheckBox(tr("rdp compression"),Tab4),5,0); MainLayout->activate(); connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); connect(RDP5ExpBox, SIGNAL(activated(int)), this, SLOT(RDP5ExpComboChanged(int))); connect(CacheBox, SIGNAL(activated(int)), this, SLOT(CacheChanged(int))); connect(DelCache1Button, SIGNAL(clicked()), this, SLOT(DelCache1())); connect(DelCache2Button, SIGNAL(clicked()), this, SLOT(DelCache2())); connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked())); connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked())); sprintf(Text, "/home/zaurus/.rdesktop/cache/pstcache_2_1"); File = new QFile(Text); CacheSize11 = File->size(); delete File; sprintf(Text, "/home/zaurus/.rdesktop/cache/pstcache_2_2"); File = new QFile(Text); CacheSize12 = File->size(); delete File; sprintf(Text, "/mnt/card/.rdesktop/cache/pstcache_2_1"); File = new QFile(Text); CacheSize21 = File->size(); delete File; sprintf(Text, "/mnt/card/.rdesktop/cache/pstcache_2_2"); File = new QFile(Text); CacheSize22 = File->size(); delete File; sprintf(Text, "/home/zaurus/Documents/.rdesktop/cache/pstcache_2_1"); File = new QFile(Text); CacheSize31 = File->size(); delete File; sprintf(Text, "/home/zaurus/Documents/.rdesktop/cache/pstcache_2_2"); File = new QFile(Text); CacheSize32 = File->size(); delete File; ServerName = ""; UserName = ""; Password = ""; ServerIP = ""; PortNo = 3389; WidthHeight = 0; FullScreen = 0; Color = 0; RDP5Exp = 0; RDP5Exp1 = 0; RDP5Exp2 = 0; RDP5Exp3 = 0; RDP5Exp4 = 0; KBD = 0; Ctrl = 0; OK = 0; Left = 0; Enc = 0; Comp = 0; Sound = 0; Disk = 0; DiskArg = ""; Console = 0; Cache = 1; for (i = 0; i < 10; i++) { ConnectionList[i] = new QMyConnectionItem; ConnectionList[i]->ServerName = ""; ConnectionList[i]->UserName = ""; ConnectionList[i]->Password = ""; ConnectionList[i]->ServerIP = ""; ConnectionList[i]->PortNo = 3389; ConnectionList[i]->WidthHeight = 0; ConnectionList[i]->FullScreen = 0; ConnectionList[i]->Color = 0; ConnectionList[i]->RDP5Exp = 0; ConnectionList[i]->RDP5Exp1 = 0; ConnectionList[i]->RDP5Exp2 = 0; ConnectionList[i]->RDP5Exp3 = 0; ConnectionList[i]->RDP5Exp4 = 0; ConnectionList[i]->KBD = 0; ConnectionList[i]->Ctrl = 0; ConnectionList[i]->OK = 0; ConnectionList[i]->Left = 0; ConnectionList[i]->Enc = 0; ConnectionList[i]->Comp = 0; ConnectionList[i]->Sound = 0; ConnectionList[i]->Disk = 0; ConnectionList[i]->DiskArg = ""; ConnectionList[i]->Console = 0; ConnectionList[i]->Cache = 1; } 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 == "Password") ConnectionList[i]->Password = ItemValue; else if (ItemName == "IP") ConnectionList[i]->ServerIP = ItemValue; else if (ItemName == "Port") ConnectionList[i]->PortNo = ItemValue.toInt(); else if (ItemName == "WidthHeight") ConnectionList[i]->WidthHeight = ItemValue.toInt(); else if (ItemName == "FullScreen") ConnectionList[i]->FullScreen = (ItemValue != "0"); else if (ItemName == "Color") ConnectionList[i]->Color = ItemValue.toInt(); else if (ItemName == "RDP5Experience") ConnectionList[i]->RDP5Exp = ItemValue.toInt(); else if (ItemName == "RDP5Exp1") ConnectionList[i]->RDP5Exp1 = (ItemValue != "0"); else if (ItemName == "RDP5Exp2") ConnectionList[i]->RDP5Exp2 = (ItemValue != "0"); else if (ItemName == "RDP5Exp3") ConnectionList[i]->RDP5Exp3 = (ItemValue != "0"); else if (ItemName == "RDP5Exp4") ConnectionList[i]->RDP5Exp4 = (ItemValue != "0"); else if (ItemName == "Caching") ConnectionList[i]->Cache = ItemValue.toInt(); else if (ItemName == "KeyboardType") ConnectionList[i]->KBD = ItemValue.toInt(); else if (ItemName == "Sound") ConnectionList[i]->Sound = ItemValue.toInt(); else if (ItemName == "Disk") ConnectionList[i]->Disk = ItemValue.toInt(); else if (ItemName == "DiskArg") ConnectionList[i]->DiskArg = ItemValue; else if (ItemName == "CtrlKeyMode") ConnectionList[i]->Ctrl = (ItemValue != "0"); else if (ItemName == "OKKeyMode") ConnectionList[i]->OK = (ItemValue != "0"); else if (ItemName == "LeftHandedMode") ConnectionList[i]->Left = (ItemValue != "0"); else if (ItemName == "ConsoleSession") ConnectionList[i]->Console = (ItemValue != "0"); else if (ItemName == "PacketEncryption") ConnectionList[i]->Enc = (ItemValue != "0"); else if (ItemName == "Compression") ConnectionList[i]->Comp = (ItemValue != "0"); } } } delete File; }}/******************************************************************************/QMyDialog::~QMyDialog(){ QMyConnectionItem * Item; int i; for (i = 0; i < 10; i++) { Item = ConnectionList[i]; delete Item; }}/******************************************************************************/void QMyDialog::RDP5ExpComboChanged(int index){ if (index == 0) { RDP5Exp1 = 0; RDP5Exp2 = 0; RDP5Exp3 = 0; RDP5Exp4 = 0; } if (index == 1) { RDP5Exp1 = 0; RDP5Exp2 = 0; RDP5Exp3 = 0; RDP5Exp4 = 1; } if (index == 2) { RDP5Exp1 = 0; RDP5Exp2 = 1; RDP5Exp3 = 1; RDP5Exp4 = 1; } if (index == 3) { RDP5Exp1 = 1; RDP5Exp2 = 1; RDP5Exp3 = 1; RDP5Exp4 = 1; } if (index == 4) { RDP5Exp1 = 0; RDP5Exp2 = 0; RDP5Exp3 = 0; RDP5Exp4 = 1; } RDP5ExpCheckBox1->setChecked(RDP5Exp1); RDP5ExpCheckBox2->setChecked(RDP5Exp2); RDP5ExpCheckBox3->setChecked(RDP5Exp3); RDP5ExpCheckBox4->setChecked(RDP5Exp4);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?