QLayout * BoggleWindow::setUpTextEntry() {
    textEntry = new QLineEdit();
    connect(textEntry, SIGNAL(returnPressed()), this, SLOT(textEntrySubmitted()));
	startButton = new QPushButton("Start");
	connect(startButton, SIGNAL(pressed()), this, SLOT(startButtonPressed()));
	doneButton = new QPushButton("Done");
	doneButton->setEnabled(false);
	connect(doneButton, SIGNAL(pressed()), this, SLOT(doneButtonPressed()));
	QHBoxLayout * layout = new QHBoxLayout();
	layout->addWidget(textEntry);
	layout->addWidget(startButton);
	layout->addWidget(doneButton);
	return layout;
}
Example #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("PCL viewer");
    qvtkWidget = new QVTKWidget;
    ui->verticalLayout->addWidget(qvtkWidget);
    //qvtkWidget = vtkRenderer::New();
    cloud.reset (new PointCloudT);
    grabberThread = new QThread();
    grabber = new Grabber();
    grabber->moveToThread(grabberThread);
    grabberThread->start();
    grabber->initCamera();
    connect(ui->startButton, SIGNAL(released()), this, SLOT(startButtonPressed()) );
    connect(ui->updateButton, SIGNAL(released()), this, SLOT(updateButtonPressed()) );
    connect(grabber, SIGNAL(currentFrames(int)), ui->framesLabel, SLOT(setNum(int)));
    connect(ui->drawButton, SIGNAL(released()), this, SLOT(drawSomething()));
    connect(ui->viewButton_1, SIGNAL(released()), this, SLOT(view_1()));
    connect(ui->viewButton_2, SIGNAL(released()), this, SLOT(view_2()));
    connect(ui->viewButton_3, SIGNAL(released()), this, SLOT(view_3()));
    connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_3, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_4, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_5, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_6, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_7, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_8, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_9, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_10, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_11, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    connect(ui->horizontalSlider_12, SIGNAL(valueChanged(int)), this, SLOT(view_2()));
    //QString fileName = "res/";
    //QImage Image = QImage(fileName,"PNM");
    //int width = Image.width();
    //ui->label->setPixmap(QPixmap::fromImage(image));
}
Example #3
0
MainWindow::MainWindow(bool verbose, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //initialisation
    verboseOutput = verbose;
    if (verboseOutput) {
        qDebug() << "Verbose Enabled.";
    }
#ifdef Q_OS_WIN
    jsonconfigFile = QCoreApplication::applicationDirPath() + "/gui-config.json";
#else
    QDir ssConfigDir = QDir::homePath() + "/.config/shadowsocks";
    jsonconfigFile = ssConfigDir.absolutePath() + "/gui-config.json";
    if (!ssConfigDir.exists()) {
        ssConfigDir.mkpath(ssConfigDir.absolutePath());
    }
#endif
    m_conf = new Configuration(jsonconfigFile);

    ui->laddrEdit->setValidator(&ipv4addrValidator);
    ui->lportEdit->setValidator(&portValidator);
    ui->methodComboBox->addItems(SSValidator::supportedMethod);
    ui->profileComboBox->addItems(m_conf->getProfileList());
    ui->sportEdit->setValidator(&portValidator);
    ui->stopButton->setEnabled(false);

    ui->autohideCheck->setChecked(m_conf->isAutoHide());
    ui->autostartCheck->setChecked(m_conf->isAutoStart());
    ui->debugCheck->setChecked(m_conf->isDebug());
#ifdef Q_OS_LINUX
    ui->translucentCheck->setVisible(false);
#else
    ui->translucentCheck->setChecked(m_conf->isTranslucent());
    if(m_conf->isTranslucent()) {
        this->setAttribute(Qt::WA_TranslucentBackground);
    }
    ui->tfoCheckBox->setVisible(false);
#endif
    ui->relativePathCheck->setChecked(m_conf->isRelativePath());

    //desktop systray
    systrayMenu.addAction(tr("Show"), this, SLOT(showWindow()));
    systrayMenu.addAction(tr("Start"), this, SLOT(startButtonPressed()));
    systrayMenu.addAction(tr("Stop"), this, SLOT(stopButtonPressed()));
    systrayMenu.addAction(tr("Exit"), this, SLOT(close()));
    systrayMenu.actions().at(2)->setEnabled(false);
#ifdef Q_OS_WIN
    systray.setIcon(QIcon(":/icon/black_icon.png"));
#else
    systray.setIcon(QIcon(":/icon/mono_icon.png"));
#endif
    systray.setToolTip(QString("Shadowsocks-Qt5"));
    systray.setContextMenu(&systrayMenu);
#ifdef Q_OS_LINUX
    isUbuntuUnity = (QString(getenv("XDG_CURRENT_DESKTOP")).compare("Unity", Qt::CaseInsensitive) == 0);
    if (!isUbuntuUnity) {
        systray.show();
    }
#else
    systray.show();
#endif

    //Windows Extras
#ifdef Q_OS_WIN
    QtWin::enableBlurBehindWindow(this);
    QtWin::extendFrameIntoClientArea(this, -1, -1, -1, -1);
    //smaller margins
    ui->verticalLayout->setMargin(4);//centralwidget
#endif

    //Move to the center of the screen
    this->move(QApplication::desktop()->screen()->rect().center() - this->rect().center());

    /*
     * SIGNALs and SLOTs
     */
    connect(&ss_local, &SS_Process::readReadyProcess, this, &MainWindow::onReadReadyProcess);
    connect(&ss_local, &SS_Process::sigstart, this, &MainWindow::processStarted);
    connect(&ss_local, &SS_Process::sigstop, this, &MainWindow::processStopped);
    connect(&systray, &QSystemTrayIcon::activated, this, &MainWindow::systrayActivated);

    connect(ui->backendToolButton, &QToolButton::clicked, this, &MainWindow::onBackendToolButtonPressed);

    /*
     * I believe there's bug. see https://bugreports.qt-project.org/browse/QTBUG-41863
     * before it's fixed, let's use old way to work around.
     *
    connect(ui->profileComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MainWindow::onCurrentProfileChanged);
    */
    connect(ui->profileComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentProfileChanged(int)));

    connect(ui->backendTypeCombo, &QComboBox::currentTextChanged, this, &MainWindow::backendTypeChanged);
    connect(ui->addProfileButton, &QToolButton::clicked, this, &MainWindow::addProfileDialogue);
    connect(ui->delProfileButton, &QToolButton::clicked, this, &MainWindow::deleteProfile);
    connect(ui->startButton, &QPushButton::clicked, this, &MainWindow::startButtonPressed);
    connect(ui->stopButton, &QPushButton::clicked, this, &MainWindow::stopButtonPressed);
    connect(ui->shareButton, &QPushButton::clicked, this, &MainWindow::onShareButtonClicked);

    connect(this, &MainWindow::configurationChanged, this, &MainWindow::onConfigurationChanged);
    connect(ui->customArgEdit, &QLineEdit::textChanged, this, &MainWindow::onCustomArgsEditFinished);
    connect(ui->laddrEdit, &QLineEdit::textChanged, this, &MainWindow::laddrEditFinished);
    connect(ui->lportEdit, &QLineEdit::textChanged, this, &MainWindow::lportEditFinished);
    connect(ui->methodComboBox, &QComboBox::currentTextChanged, this, &MainWindow::methodChanged);
    connect(ui->pwdEdit, &QLineEdit::textChanged, this, &MainWindow::pwdEditFinished);
    connect(ui->serverEdit, &QLineEdit::textChanged, this, &MainWindow::serverEditFinished);
    connect(ui->sportEdit, &QLineEdit::textChanged, this, &MainWindow::sportEditFinished);
    connect(ui->timeoutSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MainWindow::timeoutChanged);
#ifdef Q_OS_LINUX
    connect(ui->tfoCheckBox, &QCheckBox::toggled, this, &MainWindow::tcpFastOpenChanged);
#endif
    connect(ui->profileEditButtonBox, &QDialogButtonBox::clicked, this, &MainWindow::profileEditButtonClicked);

    connect(ui->autohideCheck, &QCheckBox::stateChanged, this, &MainWindow::autoHideToggled);
    connect(ui->autostartCheck, &QCheckBox::stateChanged, this, &MainWindow::autoStartToggled);
    connect(ui->debugCheck, &QCheckBox::stateChanged, this, &MainWindow::debugToggled);
    connect(ui->translucentCheck, &QCheckBox::toggled, this, &MainWindow::transculentToggled);
    connect(ui->relativePathCheck, &QCheckBox::toggled, this, &MainWindow::relativePathToggled);
    connect(ui->miscSaveButton, &QPushButton::clicked, this, &MainWindow::saveConfig);
    connect(ui->aboutButton, &QPushButton::clicked, this, &MainWindow::aboutButtonClicked);

    //update current configuration
    ui->profileComboBox->setCurrentIndex(m_conf->getIndex());
    /*
     * If there is no gui-config file, or the index is 0, then the function above wouldn't emit signal.
     * Therefore, we have to emit a signal manually.
     */
    if (m_conf->getIndex() <= 0) {
        emit ui->profileComboBox->currentIndexChanged(m_conf->getIndex());
    }
}