int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: on_actionSettings_triggered(); break; case 1: on_pushButton_3_clicked(); break; case 2: on_btn_delete_clicked(); break; case 3: refresh(); break; case 4: on_pushButton_2_clicked(); break; case 5: about(); break; default: ; } _id -= 6; } return _id; }
void MainWindow::on_actionStart_triggered() { if(m_mcServerPath.isEmpty()) { QMessageBox::information(this, tr("Qt Minecraft Server"), tr("No Minecraft Server File available!\nPlease select a Minecraft Server File at Qt Minecraft Server Settings.")); on_actionSettings_triggered(); return; } if(m_pServerProcess) { QFileInfo mcServerFileInfo = QFileInfo(m_mcServerPath); QString workingDir = mcServerFileInfo.absolutePath(); QString mcServerFile = mcServerFileInfo.fileName(); m_pServerProcess->setWorkingDirectory(workingDir); QStringList arguments; if(m_xms > 0) { arguments.append(QString("-Xms%1M").arg(QString::number(m_xms))); } if(m_xmx > 0) { arguments.append(QString("-Xmx%1M").arg(QString::number(m_xmx))); } arguments.append("-jar"); arguments.append(mcServerFile); arguments.append("nogui"); if(!m_additionalParameters.isEmpty()) { arguments.append(m_additionalParameters); } on_actionSaveServerProperties_triggered(); ui->serverLogTextEdit->append(htmlBlue(tr(">> Starting Java VM in Working Directory: %1...") .arg(QDir::toNativeSeparators(workingDir)))); if(m_useCustomJavaPath) { ui->serverLogTextEdit->append(htmlBlue(tr(">> %1 %2").arg(QDir::toNativeSeparators(m_customJavaPath)) .arg(arguments.join(" ")))); m_pServerProcess->start(m_customJavaPath, arguments, QIODevice::ReadWrite | QIODevice::Unbuffered); } else { ui->serverLogTextEdit->append(htmlBlue(tr(">> java %1").arg(arguments.join(" ")))); m_pServerProcess->start("java", arguments, QIODevice::ReadWrite | QIODevice::Unbuffered); } if(!m_pServerProcess->waitForStarted()) { ui->serverLogTextEdit->append(htmlRed(tr(">> Unable to start Java VM."))); } } }
void MainWindow::initialize() { createActions(); createTrayIcon(); setIcon(); statusLedLabel = new QLabel; if(statusLedLabel) { statusBar()->addWidget(statusLedLabel); statusLedLabel->setPixmap(QPixmap("://images/led-red.png")); } statusLabel = new QLabel; if(statusLabel) { statusBar()->addWidget(statusLabel); statusLabel->setText(tr("Minecraft Server: Stopped")); } ui->actionStart->setEnabled(true); ui->actionStop->setEnabled(false); ui->actionSettings->setEnabled(true); ui->serverPropertiesTextEdit->setEnabled(true); ui->sendCommandButton->setEnabled(false); ui->actionSaveServerProperties->setEnabled(false); if(trayIcon) { trayIcon->show(); } m_pServerProcess = new QProcess(this); connect( m_pServerProcess, SIGNAL(started()), SLOT(onStart()) ); connect( m_pServerProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(onFinish(int,QProcess::ExitStatus)) ); connect( m_pServerProcess, SIGNAL(readyReadStandardOutput()), SLOT(onStandardOutput()) ); connect( m_pServerProcess, SIGNAL(readyReadStandardError()), SLOT(onStandardError()) ); m_pFileSystemWatcher = new QFileSystemWatcher(this); connect( m_pFileSystemWatcher, SIGNAL(fileChanged(QString)), SLOT(onWatchedFileChanged(QString)) ); m_pDirSystemWatcher = new QFileSystemWatcher(this); connect( m_pDirSystemWatcher, SIGNAL(directoryChanged(QString)), SLOT(onWatchedDirChanged(QString)) ); m_pSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "Qt Minecraft Server", "qtmcserver", this); loadSettings(); if(m_mcServerPath.isEmpty()) { on_actionSettings_triggered(); } loadServerProperties(); if(!m_mcServerPath.isEmpty()) { updateWatchedFileSystemPath("", getMinecraftServerPropertiesPath(m_mcServerPath)); updateWatchedDirSystemPath("", getMinecraftServerWorkingDirectoryPath(m_mcServerPath)); } }