ScreenLogin::ScreenLogin(QWidget *parent, ScreenManager *manager, const QPoint &pos) : CatanScreen(parent, manager, pos), ui(new Ui::ScreenLogin) { ui->setupUi(this); w_login = new LoginWidget(this); connect( w_login, SIGNAL(connectToServer(QHostAddress&,quint16)), this, SLOT(connectToServer(QHostAddress&,quint16))); connect( net::Connection, SIGNAL(disconnected()), w_login ,SLOT(enableConnectButton())); connect( net::Connection, SIGNAL(error(QAbstractSocket::SocketError)), w_login ,SLOT(enableConnectButton())); connect( net::Connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); connect( net::Connection, SIGNAL(disconnected()), this, SLOT(onDisconnect())); connect( net::Connection, SIGNAL(readyForUse()), this, SLOT(onConnectionReady())); }
void MainWindow::toggleInputType(QAbstractButton *rbtn) { if (rbtn == rbtnNetwork) { serverNameLineEdit->setEnabled(true); serverPortLineEdit->setEnabled(true); enableConnectButton(); DBPathLineEdit->setEnabled(false); tbtnBrowse_DBPath->setEnabled(false); tbtnLoad->setEnabled(false); } else if (rbtn == rbtnFromFile) { serverNameLineEdit->setEnabled(false); serverPortLineEdit->setEnabled(false); tbtnConnect->setEnabled(false); DBPathLineEdit->setEnabled(true); tbtnBrowse_DBPath->setEnabled(true); enableLoadButton(); } }
int Conexionftp::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: conexionfinished(); break; case 1: putcorrected(); break; case 2: puterror((*reinterpret_cast< QString(*)>(_a[1]))); break; case 3: conexionestablished(); break; case 4: commandfinish((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break; case 5: updateDataTransferProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break; case 6: stateChange((*reinterpret_cast< int(*)>(_a[1]))); break; case 7: enableConnectButton(); break; default: ; } _id -= 8; } return _id; }
//![0] void FtpWindow::connectOrDisconnect() { if (ftp) { ftp->abort(); ftp->deleteLater(); ftp = 0; //![0] fileList->setEnabled(false); cdToParentButton->setEnabled(false); downloadButton->setEnabled(false); connectButton->setEnabled(true); connectButton->setText(tr("Connect")); #ifndef QT_NO_CURSOR setCursor(Qt::ArrowCursor); #endif statusLabel->setText(tr("Please enter the name of an FTP server.")); return; } #ifndef QT_NO_CURSOR setCursor(Qt::WaitCursor); #endif if (!networkSession || !networkSession->isOpen()) { if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { if (!networkSession) { // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } networkSession = new QNetworkSession(config, this); connect(networkSession, SIGNAL(opened()), this, SLOT(connectToFtp())); connect(networkSession, SIGNAL(error(QNetworkSession::SessionError)), this, SLOT(enableConnectButton())); } connectButton->setEnabled(false); statusLabel->setText(tr("Opening network session.")); networkSession->open(); return; } } connectToFtp(); }
Client::Client(QWidget *parent) : QDialog(parent) { hostLabel = new QLabel(tr("&Server name:")); portLabel = new QLabel(tr("S&erver port:")); nameLabel = new QLabel(tr("&Client name:")); // Find out which IP to connect to QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); // Use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); break; } } // If we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); hostLineEdit = new QLineEdit(ipAddress); portLineEdit = new QLineEdit; clientNameLineEdit = new QLineEdit; portLineEdit->setValidator(new QIntValidator(1, 65535, this)); hostLabel->setBuddy(hostLineEdit); portLabel->setBuddy(portLineEdit); nameLabel->setBuddy(clientNameLineEdit); connectButton = new QPushButton(tr("Connect")); connectButton->setDefault(true); connectButton->setEnabled(false); // Make the quit button exit chat sessions quitButton = new QPushButton(tr("Quit")); buttonBox = new QDialogButtonBox; buttonBox->addButton(connectButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); secureSocket = new QSslSocket(this); // Special slot to handle errors with the certificates // in particular the fact that they are self-signed connect(secureSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(handleSSLError(QList<QSslError>))); // Connect signals to slots for the chat window connect(hostLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableConnectButton())); connect(portLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableConnectButton())); connect(clientNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableConnectButton())); connect(connectButton, SIGNAL(clicked()), this, SLOT(connectToChatServer())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); connect(secureSocket, SIGNAL(readyRead()), this, SLOT(messageComing())); connect(secureSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(hostLabel, 0, 0); mainLayout->addWidget(hostLineEdit, 0, 1); mainLayout->addWidget(portLabel, 1, 0); mainLayout->addWidget(portLineEdit, 1, 1); mainLayout->addWidget(nameLabel, 2, 0); mainLayout->addWidget(clientNameLineEdit, 2, 1); mainLayout->addWidget(buttonBox, 3, 0, 1, 2); setLayout(mainLayout); QVBoxLayout* vlay = new QVBoxLayout(); vlay->addWidget(&clientChatLog); vlay->addWidget(&clientMessage); closeChatWindow.setText("Quit"); vlay->addWidget(&closeChatWindow); chatWindow.setLayout(vlay); connect(&clientMessage, SIGNAL(returnPressed()), this, SLOT(sendMessage())); connect(&userList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(clientSelected(QListWidgetItem*))); setWindowTitle(tr("Secure Chatp2p Client")); portLineEdit->setFocus(); connect(&closeChatWindow, SIGNAL(clicked()), this, SLOT(closeChat())); }
FtpWindow::FtpWindow(QWidget *parent) : QDialog(parent), ftp(0), networkSession(0) { ftpServerLabel = new QLabel(tr("Ftp &server:")); ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); ftpServerLabel->setBuddy(ftpServerLineEdit); statusLabel = new QLabel(tr("Please enter the name of an FTP server.")); #ifdef Q_OS_SYMBIAN // Use word wrapping to fit the text on screen statusLabel->setWordWrap( true ); #endif fileList = new QTreeWidget; fileList->setEnabled(false); fileList->setRootIsDecorated(false); fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); fileList->header()->setStretchLastSection(false); connectButton = new QPushButton(tr("Connect")); connectButton->setDefault(true); cdToParentButton = new QPushButton; cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); cdToParentButton->setEnabled(false); downloadButton = new QPushButton(tr("Download")); downloadButton->setEnabled(false); quitButton = new QPushButton(tr("Quit")); buttonBox = new QDialogButtonBox; buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); progressDialog = new QProgressDialog(this); connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(processItem(QTreeWidgetItem*,int))); connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(enableDownloadButton())); connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); connect(connectButton, SIGNAL(clicked()), this, SLOT(connectOrDisconnect())); connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget(ftpServerLabel); topLayout->addWidget(ftpServerLineEdit); #ifndef Q_OS_SYMBIAN topLayout->addWidget(cdToParentButton); topLayout->addWidget(connectButton); #else // Make app better lookin on small screen QHBoxLayout *topLayout2 = new QHBoxLayout; topLayout2->addWidget(cdToParentButton); topLayout2->addWidget(connectButton); #endif QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); #ifdef Q_OS_SYMBIAN // Make app better lookin on small screen mainLayout->addLayout(topLayout2); #endif mainLayout->addWidget(fileList); mainLayout->addWidget(statusLabel); mainLayout->addWidget(buttonBox); setLayout(mainLayout); QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } networkSession = new QNetworkSession(config, this); connect(networkSession, SIGNAL(opened()), this, SLOT(enableConnectButton())); connectButton->setEnabled(false); statusLabel->setText(tr("Opening network session.")); qDebug() << "Opening session..."; networkSession->open(); } setWindowTitle(tr("FTP")); }
FtpDialog::FtpDialog(QWidget *parent, QString pathToVideoFile, QString videoFileName) : QDialog(parent) { m_pathToVideoFile = pathToVideoFile; m_videoFileName = videoFileName; ftp = NULL; ftpServerLabel = new QLabel(tr("Ftp &server:"), this); //ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com", this); ftpServerLineEdit = new QLineEdit("127.0.0.1", this); ftpServerLabel->setBuddy(ftpServerLineEdit); statusLabel = new QLabel(tr("Please enter the name of an FTP server."), this); statusLabel->setWordWrap(true); fileList = new QTreeWidget(this); fileList->setEnabled(false); fileList->setRootIsDecorated(false); fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); fileList->header()->setStretchLastSection(false); connectButton = new QPushButton(tr("Connect"), this); connectButton->setDefault(true); cdToParentButton = new QPushButton(this); cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); cdToParentButton->setEnabled(false); uploadButton = new QPushButton(tr("Upload"), this); uploadButton->setEnabled(false); quitButton = new QPushButton(tr("Quit"), this); QHBoxLayout * buttonBoxLayout = new QHBoxLayout; buttonBoxLayout->addWidget(uploadButton); buttonBoxLayout->addWidget(quitButton); /*buttonBox = new QDialogButtonBox(this); buttonBox->addButton(uploadButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);*/ progressDialog = new QProgressDialog(this); connect(quitButton, SIGNAL(clicked()), this, SLOT(reject())); connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectOrDisconnect())); connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(processItem(QTreeWidgetItem*,int))); //connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(enableDownloadButton())); connect(uploadButton, SIGNAL(clicked()), this, SLOT(uploadFile())); connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); /* connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));*/ QHBoxLayout * topLayout = new QHBoxLayout; topLayout->addWidget(ftpServerLabel); topLayout->addWidget(ftpServerLineEdit); topLayout->addWidget(cdToParentButton); topLayout->addWidget(connectButton); QVBoxLayout * mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); mainLayout->addWidget(fileList); mainLayout->addWidget(statusLabel); //mainLayout->addWidget(buttonBox); mainLayout->addLayout(buttonBoxLayout); setLayout(mainLayout); QNetworkConfigurationManager manager; //qDebug() << manager.capabilities() << "end"; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } networkSession = new QNetworkSession(config, this); connect(networkSession, SIGNAL(opened()), this, SLOT(enableConnectButton())); connectButton->setEnabled(false); quitButton->setEnabled(false); statusLabel->setText(tr("Opening network session.")); networkSession->open(); } setWindowTitle(tr("FTP")); }