Esempio n. 1
0
MainWindow::MainWindow()
    : cancelledFlag(false),
      isCcliveFlag(false),
      trayIcon(0),
      trayIconMenu(0),
      restoreAction(0)
{
/*
 The word "English" is not meant to be translated literally.
 Instead, replace "English" with the target translation language,
 e.g. "Suomi", "Deutch", etc. abby uses this word in the
 preferences dialog to select current language.
*/
    const QString lang = tr("English");

    setupUi(this);

    // Dialogs. Be extravagant about system memory.
    prefs   = new PreferencesDialog (this);
    rss     = new RSSDialog         (this);
    scan    = new ScanDialog        (this);
    format  = new FormatDialog      (this);

    // Settings.
    readSettings();
    setProxy();

    // Process.
    connect(&process, SIGNAL( started() ),
        this, SLOT( onProcStarted() ));

    connect(&process, SIGNAL( error(QProcess::ProcessError) ),
        this, SLOT( onProcError(QProcess::ProcessError) ));

    // NOTE: Merge stdout/stderr from c/clive
    connect(&process, SIGNAL( readyReadStandardOutput() ),
        this, SLOT( onProcStdoutReady() ));

    connect(&process, SIGNAL( readyReadStandardError() ),
        this, SLOT( onProcStdoutReady() ));

    connect(&process, SIGNAL( finished(int, QProcess::ExitStatus) ),
        this, SLOT( onProcFinished(int, QProcess::ExitStatus) ));

    // Misc.
    connect(linksList, SIGNAL( itemDoubleClicked(QListWidgetItem *) ),
        this, SLOT( onItemDoubleClicked(QListWidgetItem *) ));

    // Parse.
    if (parseCcliveVersionOutput())
        parseCcliveHostsOutput();

    // Widget voodoo.
    updateWidgets           (true);

#ifdef WIN32
    streamBox ->setHidden(true);
    streamSpin->setHidden(true);
#endif

    setAcceptDrops(true);
    createTrayIcon();
}
Esempio n. 2
0
// -----------------------------------------------------------------
// configuration
// -----------------------------------------------------------------
void Qaul::QaulConfigure(void)
{
    // init
    if(qaulConfigureCounter == 0)
    {
        // everything is fine
        Qaullib_ConfigStart();
        qaulConfigureCounter = 10;
    }

    // check autorization
    if(qaulConfigureCounter == 10)
    {
        qaulConfigureCounter = 20;
    }

    // configure wifi
    // search interface
    if(qaulConfigureCounter == 20)
    {
        qDebug() << "[configure] search interface";
        if(QaulWifiGetInterface()) qaulConfigureCounter = 21;
        else
        {
            qDebug() << "no wifi interface found";
            // TODO: display error screen
        }
    }

    // configure interface
    if(qaulConfigureCounter == 21)
    {
        qDebug() << "[configure] configure interface";
        qaulConfigureCounter = 22;
        // open console with sudo
        qDebug() << "open console";
        qaulConfigProcess = new QProcess(this);
        connect(qaulConfigProcess, SIGNAL(started()), this, SLOT(QaulWifiConfigure()));
        connect(qaulConfigProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(QaulConfigureProcessRead()));
        qaulConfigProcess->start("pkexec /bin/bash");
    }

    // wifi configures
    // wait 2 seconds
    if(qaulConfigureCounter == 29) QaulConfigureDelay(2000);

    // check if username is set
    if(qaulConfigureCounter == 30)
    {
        qDebug() << "[configure] check username";
        if(Qaullib_ExistsUsername()) qaulConfigureCounter = 40;
        else
        {
            qaulConfigureCounter--;
            QaulConfigureDelay(500);
        }
    }

    // start olsrd
    if(qaulConfigureCounter == 40)
    {
        qDebug() << "[configure] start olsrd";
        qaulConfigureCounter = 41;
        QaulOlsrdStart();
    }

    if(qaulConfigureCounter == 44) QaulConfigureDelay(2000);

    // connect ipc
    if(qaulConfigureCounter == 45)
    {
        qDebug() << "[configure] connect ipc";
        Qaullib_IpcConnect();
        qaulConfigureCounter = 46;
    }

    // start captive portal
    if(qaulConfigureCounter == 46)
    {
        Qaullib_SetConfVoIP();
        Qaullib_UDP_StartServer();
        Qaullib_CaptiveStart();
        QaulConfigureFirewall();
        qaulConfigureCounter = 50;
    }

    // start timers & finish
    if(qaulConfigureCounter == 50)
    {
        qDebug() << "[configure] timers & finish";
        QaulStartTimers();
        Qaullib_ConfigurationFinished();

        qaulConfigureCounter = 60;
    }

    // finished
}
Esempio n. 3
0
// -------------------------------------------------------------------------
bool SpiceDialog::loadSpiceNetList(const QString& s)
{
    Comp->withSim = false;
    if(s.isEmpty()) return false;
    QFileInfo FileInfo(QucsSettings.QucsWorkDir, s);

    NodesList->clear();
    PortsList->clear();
    textStatus = 0;
    Line = Error = "";

    QString preprocessor = PrepCombo->currentText();
    if (preprocessor != "none")
    {
        bool piping = true;
        QString script;
#ifdef __MINGW32__
        QString interpreter = "tinyperl.exe";
#else
        QString interpreter = "perl";
#endif
        if (preprocessor == "ps2sp")
        {
            script = "ps2sp";
        }
        else if (preprocessor == "spicepp")
        {
            script = "spicepp.pl";
        }
        else if (preprocessor == "spiceprm")
        {
            script = "spiceprm";
            piping = false;
        }
        script = QucsSettings.BinDir + script;
        QString spiceCommand;
        SpicePrep = new QProcess(this);
        spiceCommand+=interpreter + " ";
        spiceCommand+=script + " ";
        spiceCommand+=FileInfo.filePath() + " ";

        QFile PrepFile;
        QFileInfo PrepInfo(QucsSettings.QucsWorkDir, s + ".pre");
        QString PrepName = PrepInfo.filePath();

        if (!piping)
        {
            spiceCommand += PrepName + " ";
            connect(SpicePrep, SIGNAL(readyReadStandardOutput()), SLOT(slotSkipOut()));
            connect(SpicePrep, SIGNAL(readyReadStandardError()), SLOT(slotGetPrepErr()));
        }
        else
        {
            connect(SpicePrep, SIGNAL(readyReadStandardOutput()), SLOT(slotGetPrepOut()));
            connect(SpicePrep, SIGNAL(readyReadStandardError()), SLOT(slotGetPrepErr()));
        }

        QMessageBox *MBox = new QMessageBox(tr("Info"),
                                            tr("Preprocessing SPICE file \"%1\".").arg(FileInfo.filePath()),
                                            QMessageBox::NoIcon, QMessageBox::Abort,
                                            QMessageBox::NoButton, QMessageBox::NoButton, this, 0, true,
                                            Qt::WStyle_DialogBorder |  Qt::WDestructiveClose);

        connect(SpicePrep, SIGNAL(finished(int, QProcess::ExitStatus)), MBox, SLOT(close()));

        if (piping)
        {
            PrepFile.setName(PrepName);
            if(!PrepFile.open(QIODevice::WriteOnly))
            {
                QMessageBox::critical(this, tr("Error"),
                                      tr("Cannot save preprocessed SPICE file \"%1\".").
                                      arg(PrepName));
                return false;
            }
            prestream = new QTextStream(&PrepFile);
        }
        SpicePrep->start(spiceCommand);
        if ((SpicePrep->state() != QProcess::Starting) && (SpicePrep->state() != QProcess::Running))
        {
            QMessageBox::critical(this, tr("Error"),
                                  tr("Cannot execute \"%1\".").arg(interpreter + " " + script));
            if (piping)
            {
                PrepFile.close();
                delete prestream;
            }
            return false;
        }
        //SpicePrep->closeStdin();

        MBox->exec();
        delete SpicePrep;
        if (piping)
        {
            PrepFile.close();
            delete prestream;
        }

        if(!Error.isEmpty())
        {
            QMessageBox::critical(this, tr("SPICE Preprocessor Error"), Error);
            return false;
        }
        FileInfo = QFileInfo(QucsSettings.QucsWorkDir, s + ".pre");
    }

    // Now do the spice->qucs netlist conversion using the qucsconv program ...
    QucsConv = new QProcess(this);

    QString QucsconvCmd = QucsSettings.BinDir + "qucsconv -if spice -of qucs -i " +
                          FileInfo.filePath();
    qDebug () << QucsconvCmd;
    connect(QucsConv, SIGNAL(readyReadStandardOutput()), SLOT(slotGetNetlist()));
    connect(QucsConv, SIGNAL(readyReadStandardError()), SLOT(slotGetError()));

    QMessageBox *MBox = new QMessageBox(tr("Info"),
                                        tr("Converting SPICE file \"%1\".").arg(FileInfo.filePath()),
                                        QMessageBox::NoIcon, QMessageBox::Abort,
                                        QMessageBox::NoButton, QMessageBox::NoButton, this, 0, true,
                                        Qt::WStyle_DialogBorder |  Qt::WDestructiveClose);

    connect(QucsConv, SIGNAL(finished(int, QProcess::ExitStatus)), MBox, SLOT(close()));

    QucsConv->start(QucsconvCmd);

    if((QucsConv->state() != QProcess::Starting) && (QucsConv->state()!=QProcess::Running))
    {
        QMessageBox::critical(this, tr("Error"),
                              tr("Cannot execute \"%1\".").arg(QucsSettings.BinDir + "qucsconv"));
        return false;
    }
    //QucsConv->closeStdin();

    MBox->exec();
    delete QucsConv;

    if(!Error.isEmpty())
        QMessageBox::critical(this, tr("QucsConv Error"), Error);

    Property *pp = Comp->Props.at(1);
    if(!pp->Value.isEmpty())
    {
        PortsList->clear();
        PortsList->insertStringList(QStringList::split(',', pp->Value));
    }

    QString tmp;
    Q3ListBoxItem *pi;
    for(unsigned int i=0; i<PortsList->count(); i++)
    {
        tmp = PortsList->text(i).remove(0, 4);
        PortsList->changeItem(tmp, i);

        pi = NodesList->findItem(tmp, Qt::CaseSensitive | QKeySequence::ExactMatch);
        if(pi) delete pi;
        else PortsList->removeItem(i--);
    }
    return true;
}
Esempio n. 4
0
void MaximaSession::login()
{
    qDebug()<<"login";
    if (m_process)
        m_process->deleteLater();
#ifndef Q_OS_WIN
    m_process=new KPtyProcess(this);
    m_process->setPtyChannels(KPtyProcess::StdinChannel|KPtyProcess::StdoutChannel);
    m_process->pty()->setEcho(false);
#else
    m_process=new KProcess(this);
    m_process->setOutputChannelMode(KProcess::SeparateChannels);
#endif

    m_process->setProgram(MaximaSettings::self()->path().toLocalFile());

    m_process->start();

    connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(restartMaxima()));

#ifndef Q_OS_WIN
    connect(m_process->pty(), SIGNAL(readyRead()), this, SLOT(readStdOut()));
#else
    connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStdOut()));
#endif
    connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readStdErr()));
    connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(reportProcessError(QProcess::ProcessError)));

    QString initFile=QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/maximabackend/cantor-initmaxima.lisp"));
    qDebug()<<"initFile: "<<initFile;
    QString cmd=initCmd.arg(initFile);
    qDebug()<<"sending cmd: "<<cmd<<endl;

#ifndef Q_OS_WIN
    m_process->pty()->write(cmd.toUtf8());
#else
    m_process->write(cmd.toUtf8());
#endif

    Cantor::Expression* expr=evaluateExpression(QLatin1String("print(____END_OF_INIT____);"),
                                                Cantor::Expression::DeleteOnFinish);

    expr->setInternal(true);
    //check if we actually landed in the queue and there wasn't some
    //error beforehand instead
    if(m_expressionQueue.contains(dynamic_cast<MaximaExpression*>(expr)))
    {
        //move this expression to the front
        m_expressionQueue.prepend(m_expressionQueue.takeLast());
    }

    //reset the typesetting state
    setTypesettingEnabled(isTypesettingEnabled());


    m_initState=MaximaSession::Initializing;

    if(!MaximaSettings::self()->autorunScripts().isEmpty()){
        QString autorunScripts = MaximaSettings::self()->autorunScripts().join(QLatin1String("\n"));
        evaluateExpression(autorunScripts, MaximaExpression::DeleteOnFinish);
    }

    runFirstExpression();

}
Esempio n. 5
0
void Connection::connectPPTP(QString serverIP, QString inUsername, QString inPassword)
{
    if (process_)
    {
        process_->waitForFinished();
        delete process_;
        process_ = NULL;
    }
    process_ = new QProcess(this);

    QString strPath;
    strPath += "pkexec pppd ";
    strPath += "pty \"pptp pl-vpn-00.glbls.net --nolaunchpppd --nobuffer\" ";
    strPath += "user next ";
    strPath += "password \"next\" ";
    strPath += "linkname poland ";
    strPath += "lock ";
    strPath += "refuse-pap ";
    strPath += "refuse-chap ";
    strPath += "refuse-mschap ";
    strPath += "refuse-eap ";
    strPath += "usepeerdns ";
    strPath += "nodeflate ";
    strPath += "nobsdcomp ";
    strPath += "noauth ";
    strPath += "nopcomp ";
    strPath += "noaccomp ";
    strPath += "require-mppe-128 ";
    strPath += "defaultroute ";
    strPath += "replacedefaultroute ";

    strPath += "debug dump nodetach";

    QObject::connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadStandardOutput()));
    QObject::connect(process_, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(onFinished()));
    process_->start(strPath);

    //process.start("pkexec pppd call aaa debug dump nodetach");
    //process.waitForFinished();
    //qDebug() << process.readAllStandardOutput();



    /*if (!m_pptpServiceId)
        m_pptpServiceId = initService( kSCNetworkInterfaceTypePPTP
                                     , m_pptpServiceName );
    if (!m_pptpServiceId)
        return;

    std::string username = inUsername.toStdString();
    std::string password = inPassword.toStdString();
    std::string hostname = serverIP.toStdString();


    CFStringRef cfUsername = CFStringCreateWithCString( NULL
                                                      , username.c_str()
                                                      , kCFStringEncodingUTF8 );
    CFStringRef cfPassword = CFStringCreateWithCString( NULL
                                                      , password.c_str()
                                                      , kCFStringEncodingUTF8 );
    CFStringRef cfHostname = CFStringCreateWithCString( NULL
                                                      , hostname.c_str()
                                                      , kCFStringEncodingUTF8 );
   CFIndex index = 0;
    const void *pppKeys[3], *pppVals[3];
    pppKeys[index] = (void*) kSCPropNetPPPAuthName;
    pppVals[index] = (void*) cfUsername;
    index++;
    pppKeys[index] = (void*) kSCPropNetPPPAuthPassword;
    pppVals[index] = (void*) cfPassword;
    index++;
    pppKeys[index] = (void*) kSCPropNetPPPCommRemoteAddress;
    pppVals[index] = (void*) cfHostname;
    index++;

    CFDictionaryRef pppDialOptions;
    pppDialOptions = CFDictionaryCreate( NULL
                                       , pppKeys
                                       , pppVals
                                       , index
                                       , &kCFTypeDictionaryKeyCallBacks
                                       , &kCFTypeDictionaryValueCallBacks );
    CFStringRef     keys[] = { kSCEntNetPPP   };
    CFDictionaryRef vals[] = { pppDialOptions };

    CFDictionaryRef optionsForDial;
    optionsForDial = CFDictionaryCreate( NULL
                                       , (const void **) &keys
                                       , (const void **) &vals
                                       , 1
                                       , &kCFTypeDictionaryKeyCallBacks
                                       , &kCFTypeDictionaryValueCallBacks );
    bConnected_ = false;

    if (m_connection)
    {
        SCNetworkConnectionUnscheduleFromRunLoop(m_connection, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
        CFRelease(m_connection);
        m_connection = NULL;
    }

    m_connection = initConnection( m_pptpServiceId, optionsForDial );*/
}
Utilities::Process::Process(QObject *parent) :
    QProcess(parent)
{
    connect( this, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
    connect( this, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));
}
Esempio n. 7
0
KateBuildView::KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw)
    : QObject (mw)
    , m_buildWidget(0)
    , m_outputWidgetWidth(0)
    , m_proc(0)
    , m_buildCancelled(false)
    , m_displayModeBeforeBuild(1)
    // NOTE this will not allow spaces in file names.
    // e.g. from gcc: "main.cpp:14: error: cannot convert ‘std::string’ to ‘int’ in return"
    , m_filenameDetector(QStringLiteral("(([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+):([0-9]+)(.*)"))
    // e.g. from icpc: "main.cpp(14): error: no suitable conversion function from "std::string" to "int" exists"
    , m_filenameDetectorIcpc(QStringLiteral("(([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+)\\(([0-9]+)\\)(:.*)"))
    , m_filenameDetectorGccWorked(false)
    , m_newDirDetector(QStringLiteral("make\\[.+\\]: .+ `.*'"))
{
    m_win=mw;

    KXMLGUIClient::setComponentName (QLatin1String("katebuild"), i18n ("Kate Build Plugin"));
    setXMLFile(QLatin1String("ui.rc"));

    m_toolView  = mw->createToolView(plugin, QStringLiteral("kate_plugin_katebuildplugin"),
                                      KTextEditor::MainWindow::Bottom,
                                      QIcon::fromTheme(QStringLiteral("application-x-ms-dos-executable")),
                                      i18n("Build Output"));

    QAction *a = actionCollection()->addAction(QStringLiteral("select_target"));
    a->setText(i18n("Select Target..."));
    connect(a, SIGNAL(triggered(bool)), this, SLOT(slotSelectTarget()));

    a = actionCollection()->addAction(QStringLiteral("build_default_target"));
    a->setText(i18n("Build Default Target"));
    connect(a, SIGNAL(triggered(bool)), this, SLOT(slotBuildDefaultTarget()));

    a = actionCollection()->addAction(QStringLiteral("build_previous_target"));
    a->setText(i18n("Build Previous Target"));
    connect(a, SIGNAL(triggered(bool)), this, SLOT(slotBuildPreviousTarget()));

    a = actionCollection()->addAction(QStringLiteral("stop"));
    a->setText(i18n("Stop"));
    connect(a, SIGNAL(triggered(bool)), this, SLOT(slotStop()));

    a = actionCollection()->addAction(QStringLiteral("goto_next"));
    a->setText(i18n("Next Error"));
    actionCollection()->setDefaultShortcut(a, Qt::CTRL+Qt::ALT+Qt::Key_Right);
    connect(a, SIGNAL(triggered(bool)), this, SLOT(slotNext()));

    a = actionCollection()->addAction(QStringLiteral("goto_prev"));
    a->setText(i18n("Previous Error"));
    actionCollection()->setDefaultShortcut(a, Qt::CTRL+Qt::ALT+Qt::Key_Left);
    connect(a, SIGNAL(triggered(bool)), this, SLOT(slotPrev()));


    m_buildWidget = new QWidget(m_toolView);
    m_buildUi.setupUi(m_buildWidget);
    m_targetsUi = new TargetsUi(this, m_buildUi.u_tabWidget);
    m_buildUi.u_tabWidget->insertTab(0, m_targetsUi, i18nc("Tab label", "Target Settings"));
    m_buildUi.u_tabWidget->setCurrentWidget(m_targetsUi);

    m_buildWidget->installEventFilter(this);

    m_buildUi.buildAgainButton->setVisible(true);
    m_buildUi.cancelBuildButton->setVisible(true);
    m_buildUi.buildStatusLabel->setVisible(true);
    m_buildUi.buildAgainButton2->setVisible(false);
    m_buildUi.cancelBuildButton2->setVisible(false);
    m_buildUi.buildStatusLabel2->setVisible(false);
    m_buildUi.extraLineLayout->setAlignment(Qt::AlignRight);
    m_buildUi.cancelBuildButton->setEnabled(false);
    m_buildUi.cancelBuildButton2->setEnabled(false);

    connect(m_buildUi.errTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
            SLOT(slotErrorSelected(QTreeWidgetItem*)));

    m_buildUi.plainTextEdit->setReadOnly(true);
    slotDisplayMode(FullOutput);

    connect(m_buildUi.displayModeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotDisplayMode(int)));

    connect(m_buildUi.buildAgainButton, SIGNAL(clicked()), this, SLOT(slotBuildPreviousTarget()));
    connect(m_buildUi.cancelBuildButton, SIGNAL(clicked()), this, SLOT(slotStop()));
    connect(m_buildUi.buildAgainButton2, SIGNAL(clicked()), this, SLOT(slotBuildPreviousTarget()));
    connect(m_buildUi.cancelBuildButton2, SIGNAL(clicked()), this, SLOT(slotStop()));

    connect(m_targetsUi->newTarget, SIGNAL(clicked()), this, SLOT(targetSetNew()));
    connect(m_targetsUi->copyTarget, SIGNAL(clicked()), this, SLOT(targetOrSetCopy()));
    connect(m_targetsUi->deleteTarget, SIGNAL(clicked()), this, SLOT(targetDelete()));

    connect(m_targetsUi->addButton, SIGNAL(clicked()), this, SLOT(slotAddTargetClicked()));
    connect(m_targetsUi->buildButton, SIGNAL(clicked()), this, SLOT(slotBuildActiveTarget()));
    connect(m_targetsUi, SIGNAL(enterPressed()), this, SLOT(slotBuildActiveTarget()));

    m_proc = new KProcess();

    m_proc->setOutputChannelMode(KProcess::SeparateChannels);
    connect(m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotProcExited(int,QProcess::ExitStatus)));
    connect(m_proc, SIGNAL(readyReadStandardError()),this, SLOT(slotReadReadyStdErr()));
    connect(m_proc, SIGNAL(readyReadStandardOutput()),this, SLOT(slotReadReadyStdOut()));


    connect(m_win, SIGNAL(unhandledShortcutOverride(QEvent*)), this, SLOT(handleEsc(QEvent*)));

    m_toolView->installEventFilter(this);

    m_win->guiFactory()->addClient(this);

    // watch for project plugin view creation/deletion
    connect(m_win, SIGNAL(pluginViewCreated (const QString &, QObject *))
        , this, SLOT(slotPluginViewCreated (const QString &, QObject *)));

    connect(m_win, SIGNAL(pluginViewDeleted (const QString &, QObject *))
        , this, SLOT(slotPluginViewDeleted (const QString &, QObject *)));

    // update once project plugin state manually
    m_projectPluginView = m_win->pluginView (QStringLiteral("kateprojectplugin"));
    slotProjectMapChanged ();
}
Esempio n. 8
0
// --------------------------------------------------------------------------------------------
CMapQMAPExport::CMapQMAPExport(const CMapSelectionRaster& mapsel, QWidget * parent)
: QDialog(parent)
, mapsel(mapsel)
, tainted(false)
, has_map2jnx(false)
, totalNumberOfStates(0)
{
    setupUi(this);

    connect(toolPath, SIGNAL(clicked()), this, SLOT(slotOutputPath()));
    connect(pushExport, SIGNAL(clicked()), this, SLOT(slotStart()));
    connect(pushCancel, SIGNAL(clicked()), this, SLOT(slotCancel()));
    connect(pushDetails, SIGNAL(clicked()), this, SLOT(slotDetails()));
    connect(radioQLM, SIGNAL(toggled(bool)), this, SLOT(slotQLMToggled(bool)));
    connect(radioJNX, SIGNAL(toggled(bool)), this, SLOT(slotBirdsEyeToggled(bool)));
    connect(radioGCM, SIGNAL(toggled(bool)), this, SLOT(slotGCMToggled(bool)));
    connect(radioRMAP, SIGNAL(toggled(bool)), this, SLOT(slotRMAPToggled(bool)));
    connect(radioRMP, SIGNAL(toggled(bool)), this, SLOT(slotRMPToggled(bool)));

    connect(&cmd, SIGNAL(readyReadStandardError()), this, SLOT(slotStderr()));
    connect(&cmd, SIGNAL(readyReadStandardOutput()), this, SLOT(slotStdout()));
    connect(&cmd, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotFinished(int,QProcess::ExitStatus)));

    connect(toolGeoTiffProjWizard, SIGNAL(clicked()), this, SLOT(slotSetupProj()));
    connect(toolGeoTiffFromMap, SIGNAL(clicked()), this, SLOT(slotSetupProjFromMap()));

    connect(toolMagellanCopyright, SIGNAL(clicked()), this, SLOT(slotSelectCopyright()));

    SETTINGS;
    labelPath->setText(cfg.value("path/export","./").toString());

    CMapDB::map_t mapData = CMapDB::self().getMapData(mapsel.mapkey);
    linePrefix->setText(QString("%1_%2_%3").arg(mapData.description).arg(mapsel.lon1 * RAD_TO_DEG).arg(mapsel.lat1 * RAD_TO_DEG));
    linePrefix->setCursorPosition(0);
    lineDescription->setText(mapData.description);
    lineDescription->setCursorPosition(0);

    radioRMAP->show();
    radioRMAP->setEnabled(true);

    comboRmapProjection->addItem("Mercator(WGS 84)", "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
    comboRmapProjection->addItem("EPSG:4326, LongLat(WGS 84)", "+init=epsg:4326");
    comboRmapProjection->addItem("EPSG:31467, GK3 (DHDN)", "+init=epsg:31467");
    comboRmapProjection->addItem("EPSG:31468, GK4 (DHDN)", "+init=epsg:31468");

#ifdef WIN32
    path_map2jnx        = QCoreApplication::applicationDirPath()+QDir::separator()+"map2jnx.exe";
    QFile file_map2jnx(path_map2jnx);
    has_map2jnx         = file_map2jnx.exists();
    path_map2gcm        = QCoreApplication::applicationDirPath()+QDir::separator()+"map2gcm.exe";
    path_cache2gtiff    = QCoreApplication::applicationDirPath()+QDir::separator()+"cache2gtiff.exe";
    path_map2rmap       = QCoreApplication::applicationDirPath()+QDir::separator()+"map2rmap.exe";
    path_map2rmp        = QCoreApplication::applicationDirPath()+QDir::separator()+"map2rmp.exe";
#else
#if defined(Q_OS_MAC)
    // MacOS X: applications are stored in the bundle folder
    path_map2gcm        = QString("%1/Resources/map2gcm").arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), ""));
    path_map2jnx        = QString("%1/Resources/map2jnx").arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), ""));
    path_cache2gtiff    = QString("%1/Resources/cache2gtiff").arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), ""));
    path_map2rmap       = QString("%1/Resources/map2rmap").arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), ""));
    path_map2rmp        = QString("%1/Resources/map2rmp").arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), ""));
#else
    path_map2gcm        = "map2gcm";
    path_map2jnx        = MAP2JNX;
    path_cache2gtiff    = "cache2gtiff";
    path_map2rmap       = "map2rmap";
    path_map2rmp        = "map2rmp";
#endif
    QProcess proc1;
    proc1.start(path_map2jnx, QStringList());
    proc1.waitForFinished();
    has_map2jnx = proc1.error() == QProcess::UnknownError;
#endif
    groupBirdsEye->hide();
    groupJPEG->hide();
    groupDevice->hide();
    groupRMAP->hide();
    groupMagellanRmp->hide();

    spinJpegQuality->setValue(cfg.value("map/export/jnx/quality",75).toInt());
    comboJpegSubsampling->setCurrentIndex(comboJpegSubsampling->findText(cfg.value("map/export/jnx/subsampling","411").toString()));
    spinProductId->setValue(cfg.value("map/export/jnx/productid",0).toInt());
    lineProductName->setText(cfg.value("map/export/jnx/productname","BirdsEye").toString());
    lineCopyright->setText(cfg.value("map/export/jnx/copyright","None").toString());

    lineMagellanProvider->setText(cfg.value("map/export/rmp/provider", tr("Please enter a string")).toString());
    lineMagellanProduct->setText(cfg.value("map/export/rmp/product", tr("Please enter a string")).toString());
    copyright = cfg.value("map/export/rmp/copyright", tr("")).toString();
    labelMagellanCopyright->setText(QFileInfo(copyright).fileName());

    radioQLM->setChecked(cfg.value("map/export/qlm", true).toBool());
    radioGCM->setChecked(cfg.value("map/export/gcm", false).toBool());
    radioRMAP->setChecked(cfg.value("map/export/rmap", false).toBool());
    radioRMP->setChecked(cfg.value("map/export/rmp", false).toBool());

    if (has_map2jnx)
    {
        radioJNX->setChecked(cfg.value("map/export/jnx", false).toBool());
    }
    else
    {
        radioJNX->hide();
    }

    checkOverview2x->setChecked(cfg.value("map/export/over2x", true).toBool());
    checkOverview4x->setChecked(cfg.value("map/export/over4x", true).toBool());
    checkOverview8x->setChecked(cfg.value("map/export/over8x", true).toBool());
    checkOverview16x->setChecked(cfg.value("map/export/over16x", true).toBool());

    lineStreamingLevels->setText(cfg.value("map/export/stream/levels", "1 ").toString());
    if(lineStreamingLevels->text().isEmpty())
    {
        lineStreamingLevels->setText("1 ");
    }

    lineGeoTiffProjection->setText(cfg.value("map/export/qlm/proj","+proj=longlat +a=6378137.0000 +b=6356752.3142 +towgs84=0,0,0,0,0,0,0,0 +units=m  +no_defs").toString());
    lineGeoTiffProjection->setCursorPosition(0);

    checkProjection->setChecked(cfg.value("map/export/qlm/proj_enable").toBool());

    progressBar->setMinimum(0);
    progressBar->setMaximum(100);
    progressBar->setValue(0);
    progressBar->resize(300, progressBar->height());

    if(cfg.value("map/export/hidedetails", true).toBool())
    {
        textBrowser->hide();
    }
    else
    {
        textBrowser->show();
    }

    if(mapsel.subtype == IMapSelection::eGDAL)
    {
        labelWarnStream->hide();
        groupStreaming->hide();
    }
    else
    {
        labelWarnStream->show();
        groupStreaming->show();
    }

    QFont f = font();
    f.setFamily("Mono");
    textBrowser->setFont(f);

    adjustSize();

}
MangaListWidget::MangaListWidget(QWidget* parent):
  QWidget(parent),
  _scansDirectory(Utils::getScansDirectory()),
  _currentChaptersListOnWeb(),
  _chaptersToCheck(),
  _currentIndex(),
  _editOn(false),
  _coverHasToBeSet(false) {


  /// Available chapters process

  _checkAvailableChaptersProcess = new QProcess(this);
  connect(_checkAvailableChaptersProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(checkAvailableChapterIsDone(int,QProcess::ExitStatus)));
  connect(_checkAvailableChaptersProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));


  /// Top buttons

  _markReadButton = new QPushButton;
  _markReadButton->setIcon(QIcon(Utils::getIconsPath()+"/check.gif"));
  _markReadButton->setFixedWidth(37);
  connect(_markReadButton, SIGNAL(clicked()), this, SLOT(markRead()));

  _markUnreadButton = new QPushButton;
  _markUnreadButton->setIcon(QIcon(Utils::getIconsPath()+"/uncheck.gif"));
  _markUnreadButton->setFixedWidth(37);
  connect(_markUnreadButton, SIGNAL(clicked()), this, SLOT(markUnread()));

  _downloadButton = new QPushButton;
  _downloadButton->setIcon(QIcon(Utils::getIconsPath()+"/download.gif"));
  _downloadButton->setFixedWidth(37);
  connect(_downloadButton, SIGNAL(clicked()), this, SLOT(goToDownload()));

  _addMangaButton = new QPushButton;
  _addMangaButton->setIcon(QIcon(Utils::getIconsPath()+"/plus.png"));
  _addMangaButton->setFixedWidth(37);
  connect(_addMangaButton, SIGNAL(clicked()), this, SLOT(addManga()));

  _checkNewChaptersButton = new QPushButton;
  _checkNewChaptersButton->setIcon(QIcon(Utils::getIconsPath()+"/checkChapters.png"));
  _checkNewChaptersButton->setFixedWidth(37);
  connect(_checkNewChaptersButton, SIGNAL(clicked()), this, SLOT(decorateMangaNames()));

  QHBoxLayout* buttonsLayout = new QHBoxLayout;
  buttonsLayout->addWidget(_markReadButton);
  buttonsLayout->addWidget(_markUnreadButton);
  buttonsLayout->addWidget(_downloadButton);
  buttonsLayout->addWidget(_addMangaButton);
  buttonsLayout->addWidget(_checkNewChaptersButton);
  buttonsLayout->setAlignment(Qt::AlignHCenter);


  /// Manga information

  QPixmap pixmap(Utils::getIconsPath()+"/setCover.png");

  _mangaPreviewLabel = new QLabel;
  _mangaPreviewLabel->setFixedHeight(400);
  _mangaPreviewLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
  _mangaPreviewLabel->setStyleSheet("margin: 20px;");
  _mangaPreviewLabel->setAttribute(Qt::WA_Hover);
  _mangaPreviewLabel->installEventFilter(this);
  _mangaPreviewLabel->setPixmap(pixmap);

  _genreLabel = new QLabel;
  _genreLabel->setFont(QFont("Monospace", 8));
  _authorLabel = new QLabel;
  _authorLabel->setFont(QFont("Monospace", 8));
  _artistLabel = new QLabel;
  _artistLabel->setFont(QFont("Monospace", 8));
  _publisherLabel = new QLabel;
  _publisherLabel->setFont(QFont("Monospace", 8));
  _magazineLabel = new QLabel;
  _magazineLabel->setFont(QFont("Monospace", 8));
  _startDateLabel = new QLabel;
  _startDateLabel->setFont(QFont("Monospace", 8));

  _editMangaInfoButton = new QPushButton("Edit");
  _editMangaInfoButton->setCheckable(true);
  _editMangaInfoButton->setFixedWidth(100);
  connect(_editMangaInfoButton, SIGNAL(toggled(bool)), this, SLOT(toggleEditMangaInfo(bool)));

  QFormLayout* genreLayout = new QFormLayout;
  genreLayout->addRow("Genre:", _genreLabel);
  QFormLayout* authorLayout = new QFormLayout;
  authorLayout->addRow("Author:", _authorLabel);
  QFormLayout* artistLayout = new QFormLayout;
  artistLayout->addRow("Artist:", _artistLabel);
  QFormLayout* publisherLayout = new QFormLayout;
  publisherLayout->addRow("Publisher:", _publisherLabel);
  QFormLayout* magazineLayout = new QFormLayout;
  magazineLayout->addRow("Magazine:", _magazineLabel);
  QFormLayout* startDateLayout = new QFormLayout;
  startDateLayout->addRow("Start date:", _startDateLabel);

  QVBoxLayout* mangaInfoLayout = new QVBoxLayout;
  mangaInfoLayout->addWidget(_mangaPreviewLabel);
  mangaInfoLayout->addLayout(genreLayout);
  mangaInfoLayout->addLayout(authorLayout);
  mangaInfoLayout->addLayout(artistLayout);
  mangaInfoLayout->addLayout(publisherLayout);
  mangaInfoLayout->addLayout(magazineLayout);
  mangaInfoLayout->addLayout(startDateLayout);
  mangaInfoLayout->addWidget(_editMangaInfoButton);
  mangaInfoLayout->setAlignment(Qt::AlignTop);

  QGroupBox* mangaInfoGroupBox = new QGroupBox("Information");
  mangaInfoGroupBox->setLayout(mangaInfoLayout);
  mangaInfoGroupBox->setFixedWidth(350);
  mangaInfoGroupBox->setAlignment(Qt::AlignLeft);


  /// Chapters model

  _model = new QStandardItemModel;
  initModel();


  /// Chapters view

  _chapterInfoWidget = new ChapterInfoWidget;

  _view = new QColumnView;
  QList<int> widths;
  widths << 300 << 400 << 400;
  _view->setColumnWidths(widths);
  _view->setResizeGripsVisible(false);
  _view->setFixedWidth(1102);
  _view->setSelectionMode(QAbstractItemView::ExtendedSelection);
  _view->setModel(_model);
  _view->setPreviewWidget(_chapterInfoWidget);
  connect(_view, SIGNAL(updatePreviewWidget(QModelIndex)), this, SLOT(updateChaptersInfo(QModelIndex)));
  connect(_view, SIGNAL(clicked(QModelIndex)), this, SLOT(updateMangaInfo(QModelIndex)));
  connect(_view, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(goToRead(QModelIndex)));

  QHBoxLayout* listLayout = new QHBoxLayout;
  listLayout->addWidget(mangaInfoGroupBox);
  listLayout->addWidget(_view);

  QStringList headerLabels;
  headerLabels << "Manga";
  _model->setHorizontalHeaderLabels(headerLabels);


  /// Set current index to first manga if any

  _view->setCurrentIndex(_model->index(0, 0));
  updateMangaInfo(_model->index(0, 0));


  /// Main layout

  QLabel* titleLabel = new QLabel("Manga List");
  titleLabel->setFont(QFont("", 18, 99));

  QVBoxLayout* mainLayout = new QVBoxLayout;
  mainLayout->addWidget(titleLabel);
  mainLayout->addLayout(buttonsLayout);
  mainLayout->addLayout(listLayout);

  setLayout(mainLayout);


  /// Schedule a new available manga check every thirty minutes

  QTimer* timer = new QTimer(this);
  connect(timer, SIGNAL(timeout()), this, SLOT(decorateMangaNames()));
  timer->start(1000*60*30);
}
Esempio n. 10
0
void ArchiverProcess::init_connections() {
    connect(this,SIGNAL(error(UnixProcess::ProcessError)),this,SLOT(onError(UnixProcess::ProcessError)));
    connect(this,SIGNAL(finished(int,UnixProcess::ExitStatus)),this,SLOT(onFinished(int,UnixProcess::ExitStatus)),Qt::QueuedConnection);
    connect(this,SIGNAL(readyReadStandardError()),this,SLOT(onReadyReadStandardError()));
    connect(this,SIGNAL(readyReadStandardOutput()),this,SLOT(onReadyReadStandardOutput()));
}
Esempio n. 11
0
// for multicurrency implementation see comments marked ##### in salesOrder.ui.h
void arWorkBench::processYourPay()
{
  QDomDocument odoc;
  // Build the order
  QDomElement root = odoc.createElement("order");
  odoc.appendChild(root);
  QDomElement elem, sub;
  
  // add the 'credit card'
  elem = odoc.createElement("creditcard");

  QString work_month;
  work_month.setNum(_ccard_month_expired);
  if (work_month.length() == 1)
    work_month = "0" + work_month;
  sub = odoc.createElement("cardexpmonth");
  sub.appendChild(odoc.createTextNode(work_month));
  elem.appendChild(sub);

  QString work_year;
  work_year.setNum(_ccard_year_expired);
  work_year = work_year.right(2);
  sub = odoc.createElement("cardexpyear");
  sub.appendChild(odoc.createTextNode(work_year));
  elem.appendChild(sub);

  sub = odoc.createElement("cardnumber");
  sub.appendChild(odoc.createTextNode(_ccard_number));
  elem.appendChild(sub);

  root.appendChild(elem);
  
  // Build 'merchantinfo'
  elem = odoc.createElement("merchantinfo");

  sub = odoc.createElement("configfile");
  sub.appendChild(odoc.createTextNode(configfile));
  elem.appendChild(sub);
  
  root.appendChild(elem);
  
  // Build 'orderoptions'
  elem = odoc.createElement("orderoptions");

  sub = odoc.createElement("ordertype");
  sub.appendChild(odoc.createTextNode("POSTAUTH"));
  elem.appendChild(sub);
  
  sub = odoc.createElement("result");
  sub.appendChild(odoc.createTextNode("LIVE"));
  elem.appendChild(sub);
  
  root.appendChild(elem);
  
  // Build 'payment'
  elem = odoc.createElement("payment");

  QString tmp;
  sub = odoc.createElement("chargetotal");
  sub.appendChild(odoc.createTextNode(tmp.setNum(_CCAmount->baseValue(), 'f', 2))); // ##### localValue()?
  elem.appendChild(sub);

  root.appendChild(elem);
  
  // Build 'transaction details'
  elem = odoc.createElement("transactiondetails");

  sub = odoc.createElement("oid");
  sub.appendChild(odoc.createTextNode(_backrefnum));
  elem.appendChild(sub);

  root.appendChild(elem);
  
  // Process the order
  saved_order = odoc.toString();
  
  if (_metrics->boolean("CCTest"))
  {
    _metrics->set("CCOrder", saved_order);
  }
  
  proc = new QProcess( this );
  QString curl_path;
#ifdef Q_WS_WIN
  curl_path = qApp->applicationDirPath() + "\\curl";
#elif defined Q_WS_MACX
  curl_path = "/usr/bin/curl";
#elif defined Q_WS_X11
  curl_path = "/usr/bin/curl";
#endif
  
  QStringList curl_args;
  curl_args.append( "-k" );
  curl_args.append( "-d" );
  curl_args.append( saved_order );
  curl_args.append( "-E" );
  curl_args.append( pemfile );
  
  _port.setNum(port);
  doServer = "https://" + _metrics->value("CCServer") + ":" + _port;
  
  curl_args.append( doServer );
  
  QString proxy_login;
  QString proxy_server;
  
  if(_metrics->boolean("CCUseProxyServer"))
  {
    proxy_login =  _metricsenc->value("CCProxyLogin") + ":" + _metricsenc->value("CCPassword") ;
    proxy_server = _metrics->value("CCProxyServer") + ":" + _metrics->value("CCProxyPort");
    curl_args.append( "-x" );
    curl_args.append( proxy_server );
    curl_args.append( "-U" );
    curl_args.append( proxy_login );
  }
  
  _response = "";
  
  connect( proc, SIGNAL(readyReadStandardOutput()),
           this, SLOT(readFromStdout()) );
  
  QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
  _editPreauth->setEnabled(FALSE);
  
  proc->start(curl_path, curl_args);
  if ( !proc->waitForStarted() ) 
  {
    QMessageBox::critical( 0,
                  tr("Fatal error"),
                  tr("Could not start the %1 command.").arg(curl_path),
                  tr("Quit") );
    return;
  }
  
  while (proc->state() == QProcess::Running)
    qApp->processEvents();
  
  _editPreauth->setEnabled(TRUE);
  QApplication::restoreOverrideCursor();
  
  _response =  "<myroot>" + _response + "</myroot>";
  
  QString whyMe;
  
  if (_metrics->boolean("CCTest"))
  {
    whyMe = _ccard_number + "  " + _response;
    _metrics->set("CCTestMe", whyMe);
    _metrics->set("CCOrder", saved_order);
  }
  
  /*if (_metrics->boolean("CCTest"))
  {
    QMessageBox::information(this, tr("YourPay"), tr("The return code was ") + _response, QMessageBox::Ok);
  }*/
  QDomDocument doc;
  doc.setContent(_response);
  QDomNode node;
  root = doc.documentElement();
  
  QString _r_avs;
  QString _r_ordernum;
  QString _r_error;
  QString _r_approved;
  QString _r_code;
  QString _r_score;
  QString _r_shipping;
  QString _r_tax;
  QString _r_tdate;
  QString _r_ref;
  QString _r_message;
  QString _r_time;
  
  node = root.firstChild();
  while ( !node.isNull() ) {
    if ( node.isElement() && node.nodeName() == "r_avs" ) {
      QDomElement r_avs = node.toElement();
      _r_avs = r_avs.text();
    }
    if ( node.isElement() && node.nodeName() == "r_ordernum" ) {
      QDomElement r_ordernum = node.toElement();
      _r_ordernum = r_ordernum.text();
    }
    if ( node.isElement() && node.nodeName() == "r_error" ) {
      QDomElement r_error = node.toElement();
      _r_error = r_error.text();
    }
    if ( node.isElement() && node.nodeName() == "r_approved" ) {
      QDomElement r_approved = node.toElement();
      _r_approved = r_approved.text();
    }
    if ( node.isElement() && node.nodeName() == "r_code" ) {
      QDomElement r_code = node.toElement();
      _r_code = r_code.text();
    }
    if ( node.isElement() && node.nodeName() == "r_message" ) {
      QDomElement r_message = node.toElement();
      _r_message = r_message.text();
    }
    if ( node.isElement() && node.nodeName() == "r_time" ) {
      QDomElement r_time = node.toElement();
      _r_time = r_time.text();
    }
    if ( node.isElement() && node.nodeName() == "r_ref" ) {
      QDomElement r_ref = node.toElement();
      _r_ref = r_ref.text();
    }
    if ( node.isElement() && node.nodeName() == "r_tdate" ) {
      QDomElement r_tdate = node.toElement();
      _r_tdate = r_tdate.text();
    }
    if ( node.isElement() && node.nodeName() == "r_tax" ) {
      QDomElement r_tax = node.toElement();
      _r_tax = r_tax.text();
    }
    if ( node.isElement() && node.nodeName() == "r_shipping" ) {
      QDomElement r_shipping = node.toElement();
      _r_shipping = r_shipping.text();
    }
    if ( node.isElement() && node.nodeName() == "r_score") {
      QDomElement r_score = node.toElement();
      _r_score = r_score.text();
    }
    node = node.nextSibling();
  }
  
  q.prepare( "UPDATE ccpay"
             "   SET ccpay_amount = :ccpay_amount, "
             "       ccpay_auth = FALSE, "
             "       ccpay_status = :ccpay_status, "
             "       ccpay_curr_id = :ccpay_curr_id "
             " WHERE ccpay_id = :ccpay_id;" );
  q.bindValue(":ccpay_id", _preauth->id());
  q.bindValue(":ccpay_amount",_CCAmount->baseValue());    // ##### localValue()?
  q.bindValue(":ccpay_curr_id",_CCAmount->baseId());      // ##### id()?
  
  doDollars = 0;
  
  if (_r_approved == "APPROVED")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction was approved\n") + _r_ref, QMessageBox::Ok);  q.bindValue(":ccpay_status","C");
    doDollars = _CCAmount->baseValue();                   // ##### localValue()?
  }
  
  if (_r_approved == "DENIED")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction was denied\n") + _r_message, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved == "DUPLICATE")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction is a duplicate\n") + _r_message, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved == "DECLINED")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction is a declined\n") + _r_error, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved == "FRAUD")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction is denied because of possible fraud\n") + _r_error, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved.length() == 0 || _r_approved.isNull() || _r_approved.isEmpty())
  {
    QMessageBox::information(this, tr("YourPay"),
                             tr("<p>No Approval Code<br>%1<br>%2<br>%3")
                               .arg(_r_error).arg(_r_message).arg(_response),
                               QMessageBox::Ok);
    q.bindValue(":ccpay_status","X");
  }
  
  q.exec();
  
  //We need to a charge here to do a cash receipt
  //  We need some logic for a successful charge and for a non-successful charge
  if (doDollars > 0)
  {
// This is a sucessful charge
    q.prepare("INSERT INTO cashrcpt (cashrcpt_id,"
              " cashrcpt_cust_id,"
              " cashrcpt_amount,"
              " cashrcpt_curr_id,"
              " cashrcpt_fundstype, "
              " cashrcpt_docnumber,"
              " cashrcpt_bankaccnt_id,"
              " cashrcpt_notes,"
              "  cashrcpt_distdate) "
              "VALUES (nextval('cashrcpt_cashrcpt_id_seq'), :cashrcpt_cust_id,"
              "       :cashrcpt_amount, :cashrcpt_curr_id, :cashrcpt_fundstype,"
              "       :cashrcpt_docnumber, :cashrcpt_bankaccnt_id,"
              "       :cashrcpt_notes, current_date);");
    q.bindValue(":cashrcpt_cust_id",_cust->id());
    q.bindValue(":cashrcpt_amount",doDollars);
    q.bindValue(":cashrcpt_curr_id", _CCAmount->baseId());      // ##### id()?
    q.bindValue(":cashrcpt_fundstype",_ccard_type);
    q.bindValue(":cashrcpt_docnumber",_backrefnum);
    q.bindValue(":cashrcpt_bankaccnt_id",_metrics->value("CCDefaultBank").toInt());
    q.bindValue(":cashrcpt_notes","Converted Pre-auth");
    q.exec();
  }
  
  //Clean up
  sFillCashrcptList();
  sFillAropenCMList();
  sFillAropenList();
  sFillPreauthList();
  _CCAmount->clear();
    
}
Esempio n. 12
0
void ATSkeletonWindow::connectTunnel( Tunnel_c &tunnel )
{
 	Tunnel_c *pt = &tunnel;
 
 	AddToLog( tunnel, "Connecting tunnel %s...", qPrintable( pt->strName ) );
 	AddToLog( tunnel, "Host: %s - Tunnel: %d:%s:%d", qPrintable( pt->strSSHHost ), pt->iLocalPort, qPrintable( pt->strRemoteHost ), pt->iRemotePort );
 
 	if ( pt->strSSHHost.isEmpty() )
 	{
 		AddToLog( tunnel, "Error: Tunnel %s has no host, please check the settings.", qPrintable( pt->strName ) );
 		return;
 	}
 
 #ifdef WIN32
 	QString strPlink = "plink.exe";
 
 	// Check that the executable is found
 	{
 		QDir dir( argv0 );
 		dir.cdUp();
 		if ( !dir.exists( strPlink ) )
 		{
 			const char *ptr = argv0, *ptr2 = argv0;
 			while ( *ptr2 ) { if ( *ptr2 == '\\' ) ptr = ptr2+1; ptr2++; }
 			AddToLog( tunnel, "Error: Could not find %s, please check that it is in the same directory as %s.", qPrintable( strPlink ), ptr );
 			return;
 		}
 	}
 #else
 	QString strPlink = "ssh";
 #endif
 
 	if ( pt->pProcess != NULL ) return; // already connected?

	if ( tunnel.twi ) tunnel.twi->setIcon( 0, QPixmap( ":connecting.png" ) );
  	//QTreeWidgetItem *twi = getTreeItemFromTunnelIndex( iTunnelIndex );
  	//if ( twi ) twi->setIcon( 0, QPixmap( ":connecting.png" ) );
 
 	ATASSERT( pt->pConnector == NULL );
 	pt->pConnector = new ATTunnelConnector_c( this, &tunnel );
 
 	pt->pProcess = new QProcess;
 	pt->pProcess->setProcessChannelMode( QProcess::MergedChannels );
 
 	QString strCommand;
 
 	strCommand += strPlink + " ";
 	strCommand += "-v ";
 
 #ifdef _WIN32
 	QStringList strListSSHHost = pt->strSSHHost.split( ':', QString::SkipEmptyParts );
 	if ( strListSSHHost.count() == 1 ) strListSSHHost << "22";
 
 	strCommand += strListSSHHost.at(0) + " -P " + strListSSHHost.at(1) + " ";
 #else
 	strCommand += pt->strSSHHost + " ";
 #endif
 
 	if ( !pt->strUsername.isEmpty() ) strCommand += QString( "-l %1 " ).arg( pt->strUsername );
 
 	if ( pt->bCompression ) strCommand += "-C ";
 
 	strCommand += ( pt->iSSH1or2 == 1 ) ? "-1 " : "-2 ";
 
 	if ( pt->iDirection == 0 ) // Local -> Remote
 	{
 		IF_NWIN32( strCommand += "-g " );
 		strCommand += QString( "-L %1:%2:%3 " ).arg( pt->iLocalPort ).arg( pt->strRemoteHost).arg( pt->iRemotePort );		
 	}
 	else // Remote -> Local
 	{
 		strCommand += QString( "-R %1:%2:%3 " ).arg( pt->iLocalPort ).arg( pt->strRemoteHost).arg( pt->iRemotePort );		
 	}
 
 	if ( !pt->strSSHKeyFile.isEmpty() ) strCommand += QString( "-i %1 " ).arg( pt->strSSHKeyFile );
 
 	strCommand += pt->strExtraArguments;
 
 	ATVERIFY( connect( pt->pProcess, SIGNAL( readyReadStandardOutput() ), pt->pConnector, SLOT( slotProcessReadStandardOutput() ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( readyReadStandardError() ), pt->pConnector, SLOT( slotProcessReadStandardError() ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( error(QProcess::ProcessError) ), pt->pConnector, SLOT( slotProcessError(QProcess::ProcessError) ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( finished(int, QProcess::ExitStatus) ), pt->pConnector, SLOT( slotProcessFinished(int, QProcess::ExitStatus) ) ) );
 	ATVERIFY( connect( pt->pConnector, SIGNAL( finished(Tunnel_c*) ), this, SLOT( slotConnectorFinished(Tunnel_c*) ), Qt::QueuedConnection ) );
 
 	AddToLog( tunnel, "%s", qPrintable( strCommand ) );
 
 	pt->pProcess->start( strCommand );
}
Esempio n. 13
0
CamlDevWindow::CamlDevWindow(QString wd, QWidget *parent) :
QMainWindow(parent)
{
   
   this->camlProcess = new QProcess(this);
   this->camlStarted = false;
   this->currentFile = "";
   this->cwd = wd;
   this->unsavedChanges = false;
   this->programTitle = "LemonCaml";
   /* The window title and icon */
   this->setWindowTitle(this->programTitle + " - " + "untitled");
   this->setWindowIcon(QIcon(":/progicon.png"));
   
   this->settings = new QSettings("Cocodidou", "LemonCaml");
   this->globalSettings = new QSettings(QSettings::SystemScope, "Cocodidou", "LemonCaml");
   
   /* The main window elements : two text-areas and a splitter */
   this->centralBox = new QVBoxLayout();
   this->split = new QSplitter(Qt::Horizontal,this);
   
   this->inputZone = new InputZone();
   this->inputZone->setTabStopWidth(20);
   this->inputZone->setAcceptRichText(false);
   
   this->resize(settings->value("Size/y",800).toInt(), settings->value("Size/x",600).toInt());
   this->move(settings->value("Pos/x",0).toInt(), settings->value("Pos/y",0).toInt());
   this->setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint));
   
#ifndef WIN32
   QString defaultFont = "Andale Mono,10,-1,5,50,0,0,0,0,0";
#else
   QString defaultFont = "Courier New,10,-1,5,50,0,0,0,0,0";
#endif
   
   QString iFont = settings->value("Input/Font", defaultFont).toString();
   QFont inputFont;
   inputFont.fromString(iFont);
   this->inputZone->setFont(inputFont);
   
   this->outputZone = new QTextEdit(this);
   this->outputZone->setReadOnly(true);
   this->outputZone->setTabStopWidth(20);
   
   QString kwfileloc = settings->value("General/keywordspath", (globalSettings->value("General/keywordspath", "./keywords").toString())).toString();
   
   QFile kwfile(kwfileloc);
   QStringList kwds;
   
   if(kwfile.open(QIODevice::ReadOnly | QIODevice::Text))
   {
      QTextStream kstream(&kwfile);
      QString st = kstream.readLine(256);
      while(st != "")
      {
         kwds << st;
         st = kstream.readLine(256);
      }
      kwfile.close();
   }
   else
   {
      QMessageBox::warning(this, tr("Warning"), tr("Unable to open the keywords file. There will likely be no syntax highlighting."));
   }
   this->hilit = new highlighter(inputZone->document(), &kwds, this->settings);
   bool isHighlighting = (settings->value("Input/syntaxHighlight",1).toInt() == 1);
   
   if(!isHighlighting)
   {
      this->hilit->setDocument(NULL);
   }


   
   QString oFont = settings->value("Output/Font", defaultFont).toString();
   QFont outputFont;
   outputFont.fromString(oFont);
   this->outputZone->setFont(outputFont);
   

   
   /* Find/Replace */
   
   this->find = new findReplace(inputZone, hilit);
   split->addWidget(this->inputZone);
   split->addWidget(this->outputZone);
   split->showMaximized();
   
   centralBox->addWidget(split);
   centralBox->addWidget(find);
   if(!centralBox->setStretchFactor(split, 100))
      qDebug() << "There will be a problem with Find/replace!";

   centralBox->setContentsMargins(0,0,0,0);
   
   /* a wrapper widget */
   QWidget *window = new QWidget();
   window->setLayout(centralBox);
   window->setContentsMargins(0,0,0,0);

   
   this->setCentralWidget(window);
   
   find->setVisible(false);
   
   if(settings->value("Input/indentOnFly",0).toInt() == 1)
      inputZone->setHandleEnter(true);
   
   /* the printer*/
   this->printer = new QPrinter(QPrinter::HighResolution);
   
   /* The actions */
   this->actionNew = new QAction(tr("New"),this);
   this->actionNew->setIcon(QIcon(":/new.png"));
   this->actionNew->setShortcut(QKeySequence(QKeySequence::New));
   this->actionOpen = new QAction(tr("Open"),this);
   this->actionOpen->setIcon(QIcon(":/open.png"));
   this->actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
   this->actionSaveAs = new QAction(tr("Save As"),this);
   this->actionSaveAs->setIcon(QIcon(":/saveas.png"));
   this->actionSaveAs->setShortcut(QKeySequence(QKeySequence::SaveAs));
   this->actionSave = new QAction(tr("Save"),this);
   this->actionSave->setIcon(QIcon(":/save.png"));
   this->actionSave->setShortcut(QKeySequence(QKeySequence::Save));
   this->actionAutoIndent = new QAction(tr("Indent code"),this);
   this->actionAutoIndent->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
   this->actionFollowCursor = new QAction(tr("Indent code while typing"),this);
   this->actionFollowCursor->setCheckable(true);
   this->actionFollowCursor->setChecked(inputZone->getHandleEnter());
   this->actionFollowCursor->setIcon(QIcon(":/autoindent.png"));
   this->actionPrint = new QAction(tr("Print"),this);
   this->actionPrint->setIcon(QIcon(":/print.png"));
   this->actionPrint->setShortcut(QKeySequence(QKeySequence::Print));
   this->actionClearOutput = new QAction(tr("Clear output"),this);
   this->actionQuit = new QAction(tr("Quit"),this);
   this->actionQuit->setIcon(QIcon(":/exit.png"));
   this->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
   
   this->actionUndo = new QAction(tr("Undo"),this);
   this->actionUndo->setIcon(QIcon(":/undo.png"));
   this->actionUndo->setShortcut(QKeySequence(QKeySequence::Undo));
   this->actionRedo = new QAction(tr("Redo"),this);
   this->actionRedo->setIcon(QIcon(":/redo.png"));
   this->actionRedo->setShortcut(QKeySequence(QKeySequence::Redo));
   this->actionDelete = new QAction(tr("Delete"),this);
   this->actionChangeInputFont = new QAction(tr("Change Input Font"),this);
   this->actionChangeOutputFont = new QAction(tr("Change Output Font"),this);
   
   this->actionSendCaml = new QAction(tr("Send Code to Caml"),this);
   this->actionSendCaml->setIcon(QIcon(":/sendcaml.png"));
   this->actionSendCaml->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return));
   this->actionInterruptCaml = new QAction(tr("Interrupt Caml"),this);
   this->actionInterruptCaml->setIcon(QIcon(":/interrupt.png"));
   this->actionStopCaml = new QAction(tr("Stop Caml"),this);
   this->actionStopCaml->setIcon(QIcon(":/stopcaml.png"));
   this->actionShowSettings = new QAction(tr("Settings"),this);
   this->actionShowSettings->setShortcut(QKeySequence(QKeySequence::Preferences));
   
   this->actionAbout = new QAction(tr("About LemonCaml..."),this);
   this->actionAboutQt = new QAction(tr("About Qt..."),this);
   
   this->actionHighlightEnable = new QAction(tr("Enable syntax highlighting"), this);
   this->actionHighlightEnable->setIcon(QIcon(":/highlight.png"));
   this->actionHighlightEnable->setCheckable(true);
   this->actionHighlightEnable->setChecked(isHighlighting);
   
   this->actionZoomIn = new QAction(tr("Zoom in"), this);
   this->actionZoomIn->setShortcut(QKeySequence(QKeySequence::ZoomIn));
   this->actionZoomOut = new QAction(tr("Zoom out"), this);
   this->actionZoomOut->setShortcut(QKeySequence(QKeySequence::ZoomOut));
   this->actionFind = new QAction(tr("Find/Replace..."), this);
   this->actionFind->setShortcut(QKeySequence(QKeySequence::Find));
   this->actionFind->setIcon(QIcon(":/find.png"));
   this->actionFind->setCheckable(true);
   this->actionFind->setChecked(false);
   
   /* The toolbar */
   this->toolbar = new QToolBar(tr("Tools"),this);
   this->toolbar->addAction(actionNew);
   this->toolbar->addAction(actionOpen);
   this->toolbar->addAction(actionSave);
   this->toolbar->addAction(actionSaveAs);
   this->toolbar->addAction(actionPrint);
   this->toolbar->addSeparator();
   this->toolbar->addAction(actionUndo);
   this->toolbar->addAction(actionRedo);
   this->toolbar->addSeparator();
   this->toolbar->addAction(actionSendCaml);
   this->toolbar->addAction(actionInterruptCaml);
   this->toolbar->addAction(actionStopCaml);
   this->toolbar->addAction(actionHighlightEnable);
   this->toolbar->addAction(actionFollowCursor);
   this->addToolBar(this->toolbar);
   
   /* The menubar */
   this->menuFile = this->menuBar()->addMenu(tr("File"));
   this->menuFile->addAction(actionNew);
   this->menuFile->addAction(actionOpen);
   this->menuRecent = this->menuFile->addMenu(tr("Recent files"));
   this->menuFile->addAction(actionSave);
   this->menuFile->addAction(actionSaveAs);
   this->menuFile->addAction(actionPrint);
   this->menuFile->addAction(actionQuit);
   
   this->menuEdit = this->menuBar()->addMenu(tr("Edit"));
   this->menuEdit->addAction(actionUndo);
   this->menuEdit->addAction(actionRedo);
   this->menuEdit->addAction(actionDelete);
   this->menuEdit->addSeparator();
   this->menuEdit->addAction(actionAutoIndent);
   this->menuEdit->addAction(actionFollowCursor);
   this->menuEdit->addSeparator();
   this->menuEdit->addAction(actionFind);
   this->menuEdit->addAction(actionClearOutput);
   this->menuEdit->addAction(actionHighlightEnable);
   this->menuEdit->addAction(actionChangeInputFont);
   this->menuEdit->addAction(actionChangeOutputFont);
   this->menuEdit->addAction(actionZoomIn);
   this->menuEdit->addAction(actionZoomOut);
   
   this->menuCaml = this->menuBar()->addMenu(tr("Caml"));
   this->menuCaml->addAction(actionSendCaml);
   this->menuCaml->addAction(actionInterruptCaml);
   this->menuCaml->addAction(actionStopCaml);
   this->menuCaml->addAction(actionShowSettings);
   
   this->menuHelp = this->menuBar()->addMenu(tr("Help"));
   this->menuHelp->addAction(actionAbout);
   this->menuHelp->addAction(actionAboutQt);
   

   
   /* Connections */
   connect(inputZone,SIGNAL(returnPressed()),this,SLOT(handleLineBreak()));
   
   connect(actionSendCaml,SIGNAL(triggered()),this,SLOT(sendCaml()));
   connect(camlProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readCaml()));
   connect(camlProcess,SIGNAL(readyReadStandardError()),this,SLOT(readCamlErrors()));
   connect(camlProcess,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(updateCamlStatus(QProcess::ProcessState)));
   connect(actionStopCaml,SIGNAL(triggered()),this,SLOT(stopCaml()));
   connect(camlProcess,SIGNAL(started()),this,SLOT(camlOK()));
   connect(actionInterruptCaml,SIGNAL(triggered()),this,SLOT(interruptCaml()));
   
   
   connect(actionSave,SIGNAL(triggered()),this,SLOT(save()));
   connect(actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs()));
   connect(actionOpen,SIGNAL(triggered()),this,SLOT(open()));
   connect(inputZone,SIGNAL(textChanged()),this,SLOT(textChanged()));
   connect(actionNew,SIGNAL(triggered()),this,SLOT(newFile()));
   connect(actionClearOutput,SIGNAL(triggered()),this->outputZone,SLOT(clear()));
   connect(actionChangeInputFont,SIGNAL(triggered()),this,SLOT(changeInputFont()));
   connect(actionChangeOutputFont,SIGNAL(triggered()),this,SLOT(changeOutputFont()));
   connect(actionQuit,SIGNAL(triggered()),this,SLOT(close()));
   connect(actionPrint,SIGNAL(triggered()),this,SLOT(print()));
   connect(actionUndo,SIGNAL(triggered()),this->inputZone,SLOT(undo()));
   connect(actionRedo,SIGNAL(triggered()),this->inputZone,SLOT(redo()));
   connect(actionDelete,SIGNAL(triggered()),this->inputZone,SLOT(paste()));
   connect(actionShowSettings,SIGNAL(triggered()),this,SLOT(showSettings()));
   connect(actionHighlightEnable,SIGNAL(toggled(bool)),this,SLOT(toggleHighlightOn(bool)));
   connect(actionAutoIndent,SIGNAL(triggered()),this,SLOT(autoIndentCode()));
   connect(actionFollowCursor,SIGNAL(triggered(bool)),this,SLOT(toggleAutoIndentOn(bool)));
   
   connect(actionZoomIn,SIGNAL(triggered()),this,SLOT(zoomIn()));
   connect(actionZoomOut,SIGNAL(triggered()),this,SLOT(zoomOut()));
   connect(actionFind,SIGNAL(triggered(bool)),this,SLOT(triggerFindReplace(bool)));
   connect(find,SIGNAL(hideRequest(bool)),this,SLOT(triggerFindReplace(bool)));
   
   connect(inputZone, SIGNAL(unindentKeyStrokePressed()), this, SLOT(unindent()));
   
   connect(actionAbout,SIGNAL(triggered()),this,SLOT(about()));
   connect(actionAboutQt,SIGNAL(triggered()),this,SLOT(aboutQt()));
   
   this->generateRecentMenu();
   this->populateRecent();
   
   this->highlightTriggered = false;
   fillIndentWords(&indentWords);
   
   //Draw trees?
   this->drawTrees = (settings->value("General/drawTrees",0).toInt() == 1)?true:false;
   this->graphCount = 0;
   
   this->startCamlProcess();
}
Esempio n. 14
0
HgCloneDialog::HgCloneDialog(const QString &directory, QWidget *parent):
    KDialog(parent, Qt::Dialog),
    m_cloned(false),
    m_terminated(true),
    m_workingDirectory(directory)
{
    // dialog properties
    this->setCaption(i18nc("@title:window", 
                "<application>Hg</application> Clone"));
    this->setButtons(KDialog::Ok | KDialog::Cancel);
    this->setDefaultButton(KDialog::Ok);
    this->setButtonText(KDialog::Ok, i18nc("@action:button", "Clone"));
    this->enableButtonOk(false);


    //////////////
    // Setup UI //
    //////////////

    QGroupBox *urlGroup = new QGroupBox(i18n("URLs"));
    QGridLayout *urlLayout = new QGridLayout;
    QLabel *sourceLabel = new QLabel(i18nc("@label", "Source"));
    QLabel *destLabel = new QLabel(i18nc("@lobel", "Destination"));
    KPushButton *m_browse_dest = new KPushButton(i18nc("@button", "Browse"));
    KPushButton *m_browse_source = new KPushButton(i18nc("@button", "Browse"));
    m_source = new KLineEdit;
    m_destination = new KLineEdit;
    urlLayout->addWidget(sourceLabel, 0, 0);
    urlLayout->addWidget(m_source, 0, 1);
    urlLayout->addWidget(m_browse_source, 0, 2);
    urlLayout->addWidget(destLabel, 1, 0);
    urlLayout->addWidget(m_destination, 1, 1);
    urlLayout->addWidget(m_browse_dest, 1, 2);
    urlGroup->setLayout(urlLayout);

    // Options Group
    QGroupBox *optionGroup = new QGroupBox(i18nc("@label", "Options"));
    QVBoxLayout *optionLayout = new QVBoxLayout;

    m_optNoUpdate = new QCheckBox(i18n("Do not update the new working directory."));
    m_optUsePull = new QCheckBox(i18n("Use pull protocol to copy metadata."));
    m_optUseUncmprdTrans = new QCheckBox(i18n("Use uncompressed transfer."));
    m_optNoVerifyServCert = new QCheckBox(i18n("Do not verify server certificate (ignoring web.cacerts config)."));

    optionLayout->addWidget(m_optNoUpdate);
    optionLayout->addWidget(m_optUsePull);
    optionLayout->addWidget(m_optUseUncmprdTrans);
    optionLayout->addWidget(m_optNoVerifyServCert);
    optionGroup->setLayout(optionLayout);
    // end options

    QFrame *frame = new QFrame;
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(urlGroup);
    mainLayout->addWidget(optionGroup);
    mainLayout->addStretch();
    frame->setLayout(mainLayout);
    
    m_stackLayout = new  QStackedLayout;
    m_outputEdit = new KTextEdit;
    m_outputEdit->setReadOnly(true);
    m_outputEdit->setFontFamily(QLatin1String("Monospace"));
    m_stackLayout->addWidget(frame);
    m_stackLayout->addWidget(m_outputEdit);

    QFrame *mainFrame = new QFrame;
    mainFrame->setLayout(m_stackLayout);
    m_stackLayout->setCurrentIndex(0);

    setMainWidget(mainFrame);
    // Load saved settings
    FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self();
    this->setInitialSize(QSize(settings->cloneDialogWidth(),
                               settings->cloneDialogHeight()));
    
    connect(this, SIGNAL(finished()), this, SLOT(saveGeometry()));
    connect(m_source, SIGNAL(textChanged(const QString&)), 
                this, SLOT(slotUpdateOkButton()));
    connect(m_browse_dest, SIGNAL(clicked()),
                this, SLOT(slotBrowseDestClicked()));
    connect(m_browse_source, SIGNAL(clicked()),
                this, SLOT(slotBrowseSourceClicked()));
    connect(&m_process, SIGNAL(started()), this, SLOT(slotCloningStarted()));
    connect(&m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
                this, SLOT(slotCloningFinished(int, QProcess::ExitStatus)));
    connect(&m_process, SIGNAL(readyReadStandardOutput()),
                this, SLOT(slotUpdateCloneOutput()));
}
Esempio n. 15
0
void LSThread::run()/*{{{*/
{
	m_process = new QProcess();
	connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processMessages()));
	connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(processErrors()));
	qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
	connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(relayExit(int, QProcess::ExitStatus)));

	if(config.lsClientStartLS)
	{
		bool rv = pingLinuxsampler();
		if(debugMsg)
			qDebug("LSThread::run: Launching linuxsampler ");
		if(!rv && !m_versionError)
		{
			QString lscmd("linuxsampler");
			if(!config.lsClientLSPath.isEmpty())
				lscmd = config.lsClientLSPath;
			QStringList lsargs = lscmd.split(" ");
			lscmd = lsargs.takeFirst();
			if(lsargs.isEmpty() || !lsargs.contains("--lscp-addr"))
				lsargs << "--lscp-addr" << "127.0.0.1";
			if(lsargs.isEmpty())
			{
				m_process->start(lscmd);
			}
			else
			{
				m_process->start(lscmd, lsargs);
			}
			if(!m_process->waitForStarted())
			{
				qDebug("LSThread::run: FATAL: LinuxSampler startup FAILED");
				m_state = ProcessError;
				gSamplerStarted = false;
				emit startupFailed();
				return;
			}
			sleep(1);
			int retry = 0;
			rv = pingLinuxsampler();
			while(!rv && !m_versionError && retry < 5)
			{
				sleep(1);
				rv = pingLinuxsampler();
				++retry;
			}
		}
		else if(m_versionError)
		{//We have a 
			qDebug("LSThread::run: FATAL: Found running linuxsampler but version is unsupported");
			gSamplerStarted = false;
			emit startupFailed();
			return;
		}
		m_versionError = false;
		if(rv && debugMsg)
			qDebug("LSThread::run: LinuxSampler startup complete");
		else if(!rv)
			qDebug("LSThread::run: FATAL: LinuxSampler startup FAILED");
		if(rv)
		{
			m_state = ProcessRunning;
			emit startupSuccess();
			gSamplerStarted = true;
			exec();
			if(m_process->state() == QProcess::Running)
			{
				m_process->terminate();
				m_process->waitForFinished();
			}
			m_state = ProcessNotRunning;
		}
		else
		{
			m_process->terminate();
			m_process->waitForFinished();
			m_state = ProcessError;
			gSamplerStarted = false;
			emit startupFailed();
		}
	}
	else
	{
		m_state = ProcessNotRequested;
		gSamplerStarted = false;
		emit startupSuccess();
	}
}/*}}}*/
Esempio n. 16
0
// ------------------------------------------------------------------------
void ImportDialog::slotImport()
{
  MsgText->clear();
  if (OutputEdit->text().isEmpty())
    return;

  ImportButt->setDisabled(true);
  AbortButt->setDisabled(false);

  QFile File(QucsSettings.QucsWorkDir.filePath(OutputEdit->text()));
  if(File.exists())
    if(QMessageBox::information(this, tr("Info"),
          tr("Output file already exists!")+"\n"+tr("Overwrite it?"),
          tr("&Yes"), tr("&No"), 0,1,1))
      {
	ImportButt->setDisabled(false);
	AbortButt->setDisabled(true);
	return;
      }

  QFileInfo Info(ImportEdit->text());
  QString Suffix = Info.extension();
  QString Program;
  QStringList CommandLine;

  Program = QucsSettings.Qucsconv;
  CommandLine  << "-if";
  
  if((Suffix == "citi") || (Suffix == "cit"))
    CommandLine << "citi";
  else if(Suffix == "vcd")
    CommandLine << "vcd";
  else if(Suffix == "asc")
    CommandLine << "zvr";
  else if(Suffix == "mdl")
    CommandLine << "mdl";
  else if(Suffix == "csv")
    CommandLine << "csv";
  else if(Suffix == "dat")
    CommandLine << "qucsdata";
  else if(Suffix == "cir")
    CommandLine << "spice";
  else for(;;) {
    if(Suffix.at(0) == 's')
      if(Suffix.at(2) == 'p')
        if(Suffix.length() == 3)
          if(Suffix.at(1).isDigit()) {
            CommandLine << "touchstone";
            break;
          }

    MsgText->append(tr("ERROR: Unknown file format! Please check file name extension!"));
    return;
  }

  CommandLine << "-of";
  switch(OutType->currentItem()) {
  case 0:
    CommandLine << "qucsdata";
    break;
  case 1:
    CommandLine << "touchstone";
    if (!OutputData->text().isEmpty())
      CommandLine << "-d" << OutputData->text();
    break;
  case 2:
    CommandLine << "csv";
    if (!OutputData->text().isEmpty())
      CommandLine << "-d" << OutputData->text();
    break;
  case 3:
    CommandLine << "qucslib";
    break;
  case 4:
    CommandLine << "qucs";
    break;
  case 5:
    CommandLine << "matlab";
    break;
  default:
    CommandLine << "qucsdata";
    break;
  }

  CommandLine << "-i" << ImportEdit->text()
              << "-o" << QucsSettings.QucsWorkDir.filePath(OutputEdit->text());

  Process.blockSignals(false);

  disconnect(&Process, 0, 0, 0);
  connect(&Process, SIGNAL(readyReadStandardError()), SLOT(slotDisplayErr()));
  connect(&Process, SIGNAL(readyReadStandardOutput()), SLOT(slotDisplayMsg()));
  connect(&Process, SIGNAL(finished(int)), SLOT(slotProcessEnded(int)));

  MsgText->append(tr("Running command line:")+"\n");
  MsgText->append(Program + CommandLine.join(" "));
  MsgText->append("\n");

  qDebug() << "Command:" << Program << CommandLine.join(" ");
  Process.start(Program, CommandLine);
  
  if(!Process.Running)
    MsgText->append(tr("ERROR: Cannot start converter!"));
}
Esempio n. 17
0
int main(int argc, char *argv[])
{
	Q_INIT_RESOURCE(asebaqtabout);
	QApplication app(argc, argv);
	QCoreApplication::setOrganizationName(ASEBA_ORGANIZATION_NAME);
	QCoreApplication::setOrganizationDomain(ASEBA_ORGANIZATION_DOMAIN);
	app.setApplicationName("Playground");


	// Translation support
	QTranslator qtTranslator;
	qtTranslator.load("qt_" + QLocale::system().name());
	app.installTranslator(&qtTranslator);

	QTranslator translator;
	translator.load(QString(":/asebaplayground_") + QLocale::system().name());
	app.installTranslator(&translator);

	QTranslator aboutTranslator;
	aboutTranslator.load(QString(":/qtabout_") + QLocale::system().name());
	app.installTranslator(&aboutTranslator);

	// create document
	QDomDocument domDocument("aseba-playground");
	QString sceneFileName;

	// Get cmd line arguments
	bool ask = true;
	if (argc > 1)
	{
		sceneFileName = argv[1];
		ask = false;
	}

	// Try to load xml config file
	do
	{
		if (ask)
		{
			QString lastFileName = QSettings("EPFL-LSRO-Mobots", "Aseba Playground").value("last file").toString();
			sceneFileName = QFileDialog::getOpenFileName(0, app.tr("Open Scenario"), lastFileName, app.tr("playground scenario (*.playground)"));
		}
		ask = true;

		if (sceneFileName.isEmpty())
		{
			std::cerr << "You must specify a valid setup scenario on the command line or choose one in the file dialog." << std::endl;
			exit(1);
		}

		QFile file(sceneFileName);
		if (file.open(QIODevice::ReadOnly))
		{
			QString errorStr;
			int errorLine, errorColumn;
			if (!domDocument.setContent(&file, false, &errorStr, &errorLine, &errorColumn))
			{
				QMessageBox::information(0, "Aseba Playground",
										app.tr("Parse error at file %1, line %2, column %3:\n%4")
										.arg(sceneFileName)
										.arg(errorLine)
										.arg(errorColumn)
										.arg(errorStr));
			}
			else
			{
				QSettings("EPFL-LSRO-Mobots", "Aseba Playground").setValue("last file", sceneFileName);
				break;
			}
		}
	}
	while (true);

	// Scan for colors
	typedef QMap<QString, Enki::Color> ColorsMap;
	ColorsMap colorsMap;
	QDomElement colorE = domDocument.documentElement().firstChildElement("color");
	while (!colorE.isNull())
	{
		colorsMap[colorE.attribute("name")] = Enki::Color(
			colorE.attribute("r").toDouble(),
			colorE.attribute("g").toDouble(),
			colorE.attribute("b").toDouble()
		);

		colorE = colorE.nextSiblingElement ("color");
	}

	// Scan for areas
	typedef QMap<QString, Enki::Polygon> AreasMap;
	AreasMap areasMap;
	QDomElement areaE = domDocument.documentElement().firstChildElement("area");
	while (!areaE.isNull())
	{
		Enki::Polygon p;
		QDomElement pointE = areaE.firstChildElement("point");
		while (!pointE.isNull())
		{
			p.push_back(Enki::Point(
				pointE.attribute("x").toDouble(),
				pointE.attribute("y").toDouble()
			));
			pointE = pointE.nextSiblingElement ("point");
		}
		areasMap[areaE.attribute("name")] = p;
		areaE = areaE.nextSiblingElement ("area");
	}

	// Create the world
	QDomElement worldE = domDocument.documentElement().firstChildElement("world");
	Enki::Color worldColor(Enki::Color::gray);
	if (!colorsMap.contains(worldE.attribute("color")))
		std::cerr << "Warning, world walls color " << worldE.attribute("color").toStdString() << " undefined\n";
	else
		worldColor = colorsMap[worldE.attribute("color")];
	Enki::World::GroundTexture groundTexture;
	if (worldE.hasAttribute("groundTexture"))
	{
		const QString groundTextureFileName(QFileInfo(sceneFileName).absolutePath() + QDir::separator() + worldE.attribute("groundTexture"));
		QImage image(groundTextureFileName);
		if (!image.isNull())
		{
			// flip vertically as y-coordinate is inverted in an image
			image = image.mirrored();
			// convert to a specific format and copy the underlying data to Enki
			image = image.convertToFormat(QImage::Format_ARGB32);
			groundTexture.width = image.width();
			groundTexture.height = image.height();
			const uint32_t* imageData(reinterpret_cast<const uint32_t*>(image.constBits()));
			std::copy(imageData, imageData+image.width()*image.height(), std::back_inserter(groundTexture.data));
			// Note: this works in little endian, in big endian data should be swapped
		}
		else
		{
			qDebug() << "Could not load ground texture file named" << groundTextureFileName;
		}
	}
	Enki::World world(
		worldE.attribute("w").toDouble(),
		worldE.attribute("h").toDouble(),
		worldColor,
		groundTexture
	);

	// Create viewer
	Enki::PlaygroundViewer viewer(&world, worldE.attribute("energyScoringSystemEnabled", "false").toLower() == "true");
	if (Enki::simulatorEnvironment)
		qDebug() << "A simulator environment already exists, replacing";
	Enki::simulatorEnvironment.reset(new Enki::PlaygroundSimulatorEnvironment(sceneFileName, viewer));

	// Zeroconf support to advertise targets
#ifdef ZEROCONF_SUPPORT
	Aseba::QtZeroconf zeroconf;
#endif // ZEROCONF_SUPPORT

	// Scan for camera
	QDomElement cameraE = domDocument.documentElement().firstChildElement("camera");
	if (!cameraE.isNull())
	{
		const double largestDim(qMax(world.h, world.w));
		viewer.setCamera(
			QPointF(
				cameraE.attribute("x", QString::number(world.w / 2)).toDouble(),
				cameraE.attribute("y", QString::number(0)).toDouble()
			),
			cameraE.attribute("altitude", QString::number(0.85 * largestDim)).toDouble(),
			cameraE.attribute("yaw", QString::number(-M_PI/2)).toDouble(),
			cameraE.attribute("pitch", QString::number((3*M_PI)/8)).toDouble()
		);
	}

	// Scan for walls
	QDomElement wallE = domDocument.documentElement().firstChildElement("wall");
	while (!wallE.isNull())
	{
		Enki::PhysicalObject* wall = new Enki::PhysicalObject();
		if (!colorsMap.contains(wallE.attribute("color")))
			std::cerr << "Warning, color " << wallE.attribute("color").toStdString() << " undefined\n";
		else
			wall->setColor(colorsMap[wallE.attribute("color")]);
		wall->pos.x = wallE.attribute("x").toDouble();
		wall->pos.y = wallE.attribute("y").toDouble();
		wall->setRectangular(
			wallE.attribute("l1").toDouble(),
			wallE.attribute("l2").toDouble(),
			wallE.attribute("h").toDouble(),
			!wallE.attribute("mass").isNull() ? wallE.attribute("mass").toDouble() : -1 // normally -1 because immobile
		);
		if (! wallE.attribute("angle").isNull())
			wall->angle = wallE.attribute("angle").toDouble(); // radians
		world.addObject(wall);

		wallE  = wallE.nextSiblingElement ("wall");
	}

	// Scan for cylinders
	QDomElement cylinderE = domDocument.documentElement().firstChildElement("cylinder");
	while (!cylinderE.isNull())
	{
		Enki::PhysicalObject* cylinder = new Enki::PhysicalObject();
		if (!colorsMap.contains(cylinderE.attribute("color")))
			std::cerr << "Warning, color " << cylinderE.attribute("color").toStdString() << " undefined\n";
		else
			cylinder->setColor(colorsMap[cylinderE.attribute("color")]);
		cylinder->pos.x = cylinderE.attribute("x").toDouble();
		cylinder->pos.y = cylinderE.attribute("y").toDouble();
		cylinder->setCylindric(
			cylinderE.attribute("r").toDouble(), 
			cylinderE.attribute("h").toDouble(),
			!cylinderE.attribute("mass").isNull() ? cylinderE.attribute("mass").toDouble() : -1 // normally -1 because immobile
		);
		world.addObject(cylinder);

		cylinderE = cylinderE.nextSiblingElement("cylinder");
	}

	// Scan for feeders
	QDomElement feederE = domDocument.documentElement().firstChildElement("feeder");
	while (!feederE.isNull())
	{
		Enki::EPuckFeeder* feeder = new Enki::EPuckFeeder;
		feeder->pos.x = feederE.attribute("x").toDouble();
		feeder->pos.y = feederE.attribute("y").toDouble();
		world.addObject(feeder);

		feederE = feederE.nextSiblingElement ("feeder");
	}
	// TODO: if needed, custom color to feeder

	// Scan for doors
	typedef QMap<QString, Enki::SlidingDoor*> DoorsMap;
	DoorsMap doorsMap;
	QDomElement doorE = domDocument.documentElement().firstChildElement("door");
	while (!doorE.isNull())
	{
		Enki::SlidingDoor *door = new Enki::SlidingDoor(
			Enki::Point(
				doorE.attribute("closedX").toDouble(),
				doorE.attribute("closedY").toDouble()
			),
			Enki::Point(
				doorE.attribute("openedX").toDouble(),
				doorE.attribute("openedY").toDouble()
			),
			Enki::Point(
				doorE.attribute("l1").toDouble(),
				doorE.attribute("l2").toDouble()
			),
			doorE.attribute("h").toDouble(),
			doorE.attribute("moveDuration").toDouble()
		);
		if (!colorsMap.contains(doorE.attribute("color")))
			std::cerr << "Warning, door color " << doorE.attribute("color").toStdString() << " undefined\n";
		else
			door->setColor(colorsMap[doorE.attribute("color")]);
		doorsMap[doorE.attribute("name")] = door;
		world.addObject(door);

		doorE = doorE.nextSiblingElement ("door");
	}

	// Scan for activation, and link them with areas and doors
	QDomElement activationE = domDocument.documentElement().firstChildElement("activation");
	while (!activationE.isNull())
	{
		if (areasMap.find(activationE.attribute("area")) == areasMap.end())
		{
			std::cerr << "Warning, area " << activationE.attribute("area").toStdString() << " undefined\n";
			activationE = activationE.nextSiblingElement ("activation");
			continue;
		}

		if (doorsMap.find(activationE.attribute("door")) == doorsMap.end())
		{
			std::cerr << "Warning, door " << activationE.attribute("door").toStdString() << " undefined\n";
			activationE = activationE.nextSiblingElement ("activation");
			continue;
		}

		const Enki::Polygon& area = *areasMap.find(activationE.attribute("area"));
		Enki::Door* door = *doorsMap.find(activationE.attribute("door"));

		Enki::DoorButton* activation = new Enki::DoorButton(
			Enki::Point(
				activationE.attribute("x").toDouble(),
				activationE.attribute("y").toDouble()
			),
			Enki::Point(
				activationE.attribute("l1").toDouble(),
				activationE.attribute("l2").toDouble()
			),
			area,
			door
		);

		world.addObject(activation);

		activationE = activationE.nextSiblingElement ("activation");
	}

	// load all robots in one loop
	std::map<std::string, RobotType> robotTypes {
		{ "thymio2", { "Thymio II", createRobotSingleVMNode<Enki::DashelAsebaThymio2> } },
		{ "e-puck", { "E-Puck", createRobotSingleVMNode<Enki::DashelAsebaFeedableEPuck> } },
	};
	QDomElement robotE = domDocument.documentElement().firstChildElement("robot");
	unsigned asebaServerCount(0);
	while (!robotE.isNull())
	{
		const auto type(robotE.attribute("type", "thymio2"));
		auto typeIt(robotTypes.find(type.toStdString()));
		if (typeIt != robotTypes.end())
		{
			// retrieve informations
			const auto& cppTypeName(typeIt->second.prettyName);
			const auto qTypeName(QString::fromStdString(cppTypeName));
			auto& countOfThisType(typeIt->second.number);
			const auto qRobotNameRaw(robotE.attribute("name", QString("%1 %2").arg(qTypeName).arg(countOfThisType)));
			const auto qRobotNameFull(QObject::tr("%2 on %3").arg(qRobotNameRaw).arg(QHostInfo::localHostName()));
			const auto cppRobotName(qRobotNameFull.toStdString());
			const unsigned port(robotE.attribute("port", QString("%1").arg(ASEBA_DEFAULT_PORT+asebaServerCount)).toUInt());
			const int16_t nodeId(robotE.attribute("nodeId", "1").toInt());

			// create
			const auto& creator(typeIt->second.factory);
#ifdef ZEROCONF_SUPPORT
			auto robot(creator(zeroconf, port, cppRobotName, cppTypeName, nodeId));
#else // ZEROCONF_SUPPORT
			auto robot(creator(port, cppRobotName, cppTypeName, nodeId));
#endif // ZEROCONF_SUPPORT
			asebaServerCount++;
			countOfThisType++;

			// setup in the world
			robot->pos.x = robotE.attribute("x").toDouble();
			robot->pos.y = robotE.attribute("y").toDouble();
			robot->angle = robotE.attribute("angle").toDouble();
			world.addObject(robot);

			// log
			viewer.log(app.tr("New robot %0 of type %1 on port %2").arg(qRobotNameRaw).arg(qTypeName).arg(port), Qt::white);
		}
		else
			viewer.log("Error, unknown robot type " + type, Qt::red);

		robotE = robotE.nextSiblingElement ("robot");
	}

	// Scan for external processes
	QList<QProcess*> processes;
	QDomElement procssE(domDocument.documentElement().firstChildElement("process"));
	while (!procssE.isNull())
	{
		QString command(procssE.attribute("command"));
		// create process
		processes.push_back(new QProcess());
		processes.back()->setProcessChannelMode(QProcess::MergedChannels);
		processes.back()->setWorkingDirectory(QFileInfo(sceneFileName).canonicalPath());
		// make sure it is killed when we close the window
		QObject::connect(processes.back(), SIGNAL(started()), &viewer, SLOT(processStarted()));
		QObject::connect(processes.back(), SIGNAL(error(QProcess::ProcessError)), &viewer, SLOT(processError(QProcess::ProcessError)));
		QObject::connect(processes.back(), SIGNAL(readyReadStandardOutput()), &viewer, SLOT(processReadyRead()));
		QObject::connect(processes.back(), SIGNAL(finished(int, QProcess::ExitStatus)), &viewer, SLOT(processFinished(int, QProcess::ExitStatus)));
		// check whether it is a relative command
		bool isRelative(false);
		if (!command.isEmpty() && command[0] == ':')
		{
			isRelative = true;
			command = command.mid(1);
		}
		// process the command into its components
		QStringList args(command.split(" ", QString::SkipEmptyParts));
		if (args.size() == 0)
		{
			viewer.log(app.tr("Missing program in command"), Qt::red);
		}
		else
		{
			const QString program(QDir::toNativeSeparators(args[0]));
			args.pop_front();
			if (isRelative)
				processes.back()->start(QCoreApplication::applicationDirPath() + QDir::separator() + program, args, QIODevice::ReadOnly);
			else
				processes.back()->start(program, args, QIODevice::ReadOnly);
		}
		procssE = procssE.nextSiblingElement("process");
	}

	// Show and run
	viewer.setWindowTitle(app.tr("Aseba Playground - Simulate your robots!"));
	viewer.show();

	// If D-Bus is used, register the viewer object
	#ifdef HAVE_DBUS
	new Enki::EnkiWorldInterface(&viewer);
	QDBusConnection::sessionBus().registerObject("/world", &viewer);
	QDBusConnection::sessionBus().registerService("ch.epfl.mobots.AsebaPlayground");
	#endif // HAVE_DBUS

	// Run the application
	const int exitValue(app.exec());

	// Stop and delete ongoing processes
	foreach(QProcess*process,processes)
	{
		process->terminate();
		if (!process->waitForFinished(1000))
			process->kill();
		delete process;
	}
Esempio n. 18
0
bool KviKvsProcessAsyncOperation::start()
{
    QStringList args;
    QString szcmd;

    if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_NOSHELL)
    {
        args = m_pData->szCommandline.split(" ",QString::SkipEmptyParts);
    } else {
        QString szShell = m_pData->szShell;
        if(szShell.isEmpty())
        {
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
            // [01:26:00] <PragmaOff> btw, what is qt_winunicode ?
            // [01:26:12] <kode54> Qt export specific to win32
            // [01:26:27] <kode54> bool which indicates whether system is Unicode (NT) or not
            // [01:26:58] <kode54> not sure if that's documented, but it is a public export
            //
            // [02:50:21] <kode54> if ( QApplication::winVersion() & Qt::WV_NT_based )
            // [02:50:41] <kode54> I see another implementation using that, maybe it is the official way of detecting that :[
            szShell = !(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) ? "cmd.exe /c" : "command.com /c";
            // Thnx kode54 :)
#else
            szShell = "sh -c";
#endif
        }
        args = szShell.split(" ",QString::SkipEmptyParts);
        args.append(m_pData->szCommandline);
    }

    m_pProcess = new QProcess(this);

    if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDOUT)
    {
        connect(m_pProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readStdout()));
    } else {
        m_pProcess->closeReadChannel(QProcess::StandardOutput);
    }

    if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDERR)
    {
        connect(m_pProcess,SIGNAL(readyReadStandardError()),this,SLOT(readStderr()));
    } else {
        m_pProcess->closeReadChannel(QProcess::StandardError);
    }

    connect(m_pProcess,SIGNAL(finished(int)),this,SLOT(processExited(int)));

    if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTARTED)
    {
        connect(m_pProcess,SIGNAL(started()),this,SLOT(processStarted()));
    }

    szcmd = args.takeFirst();
    m_pProcess->start(szcmd, args);

    if(m_pProcess->state()==QProcess::NotRunning)
    {
        return false;
    }

    if(m_pData->iMaxRunTime > 0)
    {
        m_pRunTimeTimer = new QTimer(this);
        connect(m_pRunTimeTimer,SIGNAL(timeout()),this,SLOT(maxRunTimeExpired()));
        m_pRunTimeTimer->start(m_pData->iMaxRunTime);
    }

    if(m_pData->iPingTimeout > 0)
    {
        m_pPingTimer = new QTimer(this);
        connect(m_pPingTimer,SIGNAL(timeout()),this,SLOT(ping()));
        m_pPingTimer->start(m_pData->iPingTimeout);
    }

    return true;
}
png2gifs_gui::~png2gifs_gui()
{
    disconnect(&proc, SIGNAL(readyReadStandardOutput()),this, SLOT(consoleMessage()) );
    delete ui;
}
Esempio n. 20
0
    } else {
        connect(d->m_connection.data(), SIGNAL(connected()), SLOT(handleConnected()));
        if (d->m_connection->state() == SshConnection::Unconnected)
            d->m_connection->connectToHost();
    }
}

void SshRemoteProcessRunner::handleConnected()
{
    QTC_ASSERT(d->m_state == Connecting, return);
    setState(Connected);

    d->m_process = d->m_connection->createRemoteProcess(d->m_command);
    connect(d->m_process.data(), SIGNAL(started()), SLOT(handleProcessStarted()));
    connect(d->m_process.data(), SIGNAL(closed(int)), SLOT(handleProcessFinished(int)));
    connect(d->m_process.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdout()));
    connect(d->m_process.data(), SIGNAL(readyReadStandardError()), SLOT(handleStderr()));
    if (d->m_runInTerminal)
        d->m_process->requestTerminal(d->m_terminal);
    d->m_process->start();
}

void SshRemoteProcessRunner::handleConnectionError(Utils::SshError error)
{
    d->m_lastConnectionError = error;
    d->m_lastConnectionErrorString = d->m_connection->errorString();
    handleDisconnected();
    emit connectionError();
}

void SshRemoteProcessRunner::handleDisconnected()
void SshRemoteProcessRunner::handleStdout()
{
    d->m_stdout += d->m_process->readAllStandardOutput();
    emit readyReadStandardOutput();
}
Esempio n. 22
0
VDWindow::VDWindow(QWidget *parent) : QWidget(parent)
{
    QHBoxLayout *boxLayout = new QHBoxLayout();

    setLayout(boxLayout);

    toolbar = new QToolBar("Toolbar", this);
    QIcon icon_break(":/icon-break");
    action_break = new QAction(icon_break, "Break main", 0);
    toolbar->addAction(action_break);
    QIcon icon_run(":/icon-run");
    action_run = new QAction(icon_run, "Run", 0);
    toolbar->addAction(action_run);
    QIcon icon_stepin(":/icon-stepin");
    action_stepin = new QAction(icon_stepin, "Step in", 0);
    toolbar->addAction(action_stepin);
    QIcon icon_stepover(":/icon-stepover");
    action_stepover = new QAction(icon_stepover, "Step over", 0);
    toolbar->addAction(action_stepover);
    QIcon icon_stepout(":/icon-stepout");
    action_stepout = new QAction(icon_stepout, "Step out", 0);
    toolbar->addAction(action_stepout);
    QIcon icon_listlocals(":/icon-listlocals");
    action_listlocals = new QAction(icon_listlocals, "List locals", 0);
    toolbar->addAction(action_listlocals);
    QIcon icon_stop(":/icon-stop");
    action_stop = new QAction(icon_stop, "Interrupt", 0);
    toolbar->addAction(action_stop);
    QIcon icon_quit(":/icon-quit");
    action_quit = new QAction(icon_quit, "Quit", 0);
    toolbar->addAction(action_quit);

    toolbar->addSeparator();
    boxLayout->setMenuBar(toolbar);

    splitter = new QSplitter(this);
    boxLayout->addWidget(splitter);

    m_debug_output = new QPlainTextEdit("Text", this);
    m_debug_output->setGeometry(10, 50, 500, 200);
    m_debug_output->appendPlainText("Startup text.");
    splitter->addWidget(m_debug_output);
    view = new QGraphicsView(this);
    splitter->addWidget(view);

    scene = new QGraphicsScene();
    view->setScene(scene);
    QPixmap image;
    item = scene->addPixmap(image);
    view->show();

    //QBrush blueBrush(Qt::blue);
    //QPen outlinePen(Qt::black);
    //QGraphicsRectItem *rect = scene->addRect(10, 10, 100, 100, outlinePen, blueBrush);
    //rect->setFlag(QGraphicsItem::ItemIsMovable);

    program = "gdb testapp -iex \"set auto-load safe-path /\" --interpreter=mi2";
    process = new QProcess();

    process->setProcessChannelMode(QProcess::MergedChannels);
    process->setWorkingDirectory("/home/ilze/Documents");
    process->start(program);
    appExecuting = false;

    parser = new GDBMIParser(m_debug_output, this);
    writer = new GDBMIWriter(process);
    varList = new VDVariableList(parser, writer, this);

    connect(process, SIGNAL (readyReadStandardOutput()), this, SLOT (slotOutputRecieved()));

    connect(action_break, SIGNAL (triggered()), this, SLOT (slotButtonClickedBreakMain()));
    connect(action_run, SIGNAL (triggered()), this, SLOT (slotButtonClickedRun()));
    connect(action_stepin, SIGNAL (triggered()), this, SLOT (slotButtonClickedStepin()));
    connect(action_stepover, SIGNAL (triggered()), this, SLOT (slotButtonClickedStepover()));
    connect(action_stepout, SIGNAL (triggered()), this, SLOT (slotButtonClickedStepout()));
    connect(action_listlocals, SIGNAL (triggered()), this, SLOT (slotButtonClickedListLocals()));
    connect(action_stop, SIGNAL (triggered()), this, SLOT (slotButtonClickedStop()));
    connect(action_quit, SIGNAL (triggered()), this, SLOT (slotButtonClickedQuit()));
    connect(this, SIGNAL(signalImageParced()), this, SLOT(slotImageParced()));
}
Esempio n. 23
0
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));
    }
}
Esempio n. 24
0
MainWindow::MainWindow()
  : m_settings(QString::fromAscii("Doxygen.org"), QString::fromAscii("Doxywizard"))
{
  QMenu *file = menuBar()->addMenu(tr("File"));
  file->addAction(tr("Open..."), 
                  this, SLOT(openConfig()), Qt::CTRL+Qt::Key_O);
  m_recentMenu = file->addMenu(tr("Open recent"));
  file->addAction(tr("Save"), 
                  this, SLOT(saveConfig()), Qt::CTRL+Qt::Key_S);
  file->addAction(tr("Save as..."), 
                  this, SLOT(saveConfigAs()), Qt::SHIFT+Qt::CTRL+Qt::Key_S);
  file->addAction(tr("Quit"),  
                  this, SLOT(quit()), Qt::CTRL+Qt::Key_Q);

  QMenu *settings = menuBar()->addMenu(tr("Settings"));
  settings->addAction(tr("Reset to factory defaults"),
                  this,SLOT(resetToDefaults()));
  settings->addAction(tr("Use current settings at startup"),
                  this,SLOT(makeDefaults()));
  settings->addAction(tr("Clear recent list"),
                  this,SLOT(clearRecent()));

  QMenu *help = menuBar()->addMenu(tr("Help"));
  help->addAction(tr("Online manual"), 
                  this, SLOT(manual()), Qt::Key_F1);
  help->addAction(tr("About"), 
                  this, SLOT(about()) );

  m_expert = new Expert;
  m_wizard = new Wizard(m_expert->modelData());

  // ----------- top part ------------------
  QWidget *topPart = new QWidget;
  QVBoxLayout *rowLayout = new QVBoxLayout(topPart);

  // select working directory
  QHBoxLayout *dirLayout = new QHBoxLayout;
  m_workingDir = new QLineEdit;
  m_selWorkingDir = new QPushButton(tr("Select..."));
  dirLayout->addWidget(m_workingDir);
  dirLayout->addWidget(m_selWorkingDir);

  //------------- bottom part --------------
  QWidget *runTab = new QWidget;
  QVBoxLayout *runTabLayout = new QVBoxLayout(runTab);

  // run doxygen
  QHBoxLayout *runLayout = new QHBoxLayout;
  m_run = new QPushButton(tr("Run doxygen"));
  m_run->setEnabled(false);
  m_runStatus = new QLabel(tr("Status: not running"));
  m_saveLog = new QPushButton(tr("Save log..."));
  m_saveLog->setEnabled(false);
  QPushButton *showSettings = new QPushButton(tr("Show configuration"));
  runLayout->addWidget(m_run);
  runLayout->addWidget(m_runStatus);
  runLayout->addStretch(1);
  runLayout->addWidget(showSettings);
  runLayout->addWidget(m_saveLog);

  // output produced by doxygen
  runTabLayout->addLayout(runLayout);
  runTabLayout->addWidget(new QLabel(tr("Output produced by doxygen")));
  QGridLayout *grid = new QGridLayout;
  m_outputLog = new QTextEdit;
  m_outputLog->setReadOnly(true);
  m_outputLog->setFontFamily(QString::fromAscii("courier"));
  m_outputLog->setMinimumWidth(600);
  grid->addWidget(m_outputLog,0,0);
  grid->setColumnStretch(0,1);
  grid->setRowStretch(0,1);
  QHBoxLayout *launchLayout = new QHBoxLayout;
  m_launchHtml = new QPushButton(tr("Show HTML output"));
  launchLayout->addWidget(m_launchHtml);

  launchLayout->addStretch(1);
  grid->addLayout(launchLayout,1,0);
  runTabLayout->addLayout(grid);

  m_tabs = new QTabWidget;
  m_tabs->addTab(m_wizard,tr("Wizard"));
  m_tabs->addTab(m_expert,tr("Expert"));
  m_tabs->addTab(runTab,tr("Run"));

  rowLayout->addWidget(new QLabel(tr("Step 1: Specify the working directory from which doxygen will run")));
  rowLayout->addLayout(dirLayout);
  rowLayout->addWidget(new QLabel(tr("Step 2: Configure doxygen using the Wizard and/or Expert tab, then switch to the Run tab to generate the documentation")));
  rowLayout->addWidget(m_tabs);

  setCentralWidget(topPart);
  statusBar()->showMessage(tr("Welcome to Doxygen"),messageTimeout);

  m_runProcess = new QProcess;
  m_running = false;
  m_timer = new QTimer;

  // connect signals and slots
  connect(m_tabs,SIGNAL(currentChanged(int)),SLOT(selectTab(int)));
  connect(m_selWorkingDir,SIGNAL(clicked()),SLOT(selectWorkingDir()));
  connect(m_recentMenu,SIGNAL(triggered(QAction*)),SLOT(openRecent(QAction*)));
  connect(m_workingDir,SIGNAL(returnPressed()),SLOT(updateWorkingDir()));
  connect(m_runProcess,SIGNAL(readyReadStandardOutput()),SLOT(readStdout()));
  connect(m_runProcess,SIGNAL(finished(int, QProcess::ExitStatus)),SLOT(runComplete()));
  connect(m_timer,SIGNAL(timeout()),SLOT(readStdout()));
  connect(m_run,SIGNAL(clicked()),SLOT(runDoxygen()));
  connect(m_launchHtml,SIGNAL(clicked()),SLOT(showHtmlOutput()));
  connect(m_saveLog,SIGNAL(clicked()),SLOT(saveLog()));
  connect(showSettings,SIGNAL(clicked()),SLOT(showSettings()));
  connect(m_expert,SIGNAL(changed()),SLOT(configChanged()));
  connect(m_wizard,SIGNAL(done()),SLOT(selectRunTab()));
  connect(m_expert,SIGNAL(done()),SLOT(selectRunTab()));

  loadSettings();
  updateLaunchButtonState();
  m_modified = false;
  updateTitle();
  m_wizard->refresh();
}
Esempio n. 25
0
Connector::Connector() : m_username(""), m_passSara(""), m_passvnc(""), m_hours(""), m_minutes(""), m_seconds(""), output(new QTextEdit), process(new QProcess(this)) 
{
    setupOutputBox() ;
    connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(writeToOutput())) ;
}
Esempio n. 26
0
            connect (mapProc, SIGNAL (readyReadStandardError ()), this, SLOT (slotMapReadyReadStandardError ()));
            connect (mapProc, SIGNAL (readyReadStandardOutput ()), this, SLOT (slotMapReadyReadStandardOutput ()));
            connect (mapProc, SIGNAL (error (QProcess::ProcessError)), this, SLOT (slotMapError (QProcess::ProcessError)));

            mapProc->start ("areaCheck", arguments);
        }
        else
        {
            arguments += "--file";
            arguments += pfm_def->area;


            connect (mapProc, SIGNAL (finished (int, QProcess::ExitStatus)), this,
                     SLOT (slotMapDone (int, QProcess::ExitStatus)));
            connect (mapProc, SIGNAL (readyReadStandardError ()), this, SLOT (slotMapReadyReadStandardError ()));
            connect (mapProc, SIGNAL (readyReadStandardOutput ()), this, SLOT (slotMapReadyReadStandardOutput ()));
            connect (mapProc, SIGNAL (error (QProcess::ProcessError)), this, SLOT (slotMapError (QProcess::ProcessError)));

            mapProc->start ("areaCheck", arguments);
        }
    }
}



void
pfmPage::slotAreaPFM ()
{
    QStringList         files, filters;
    QString             file;
    NV_INT32            hnd;
Esempio n. 27
-1
  connect(_sizeOption, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
  connect(_formats, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
  connect(_sizeOption, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
  connect(_sizeOption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableWidthHeight()));
  connect(_xSize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
  connect(_ySize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
  connect(_saveLocation, SIGNAL(changed(QString)), this, SLOT(changed()));
  connect(_saveLocation, SIGNAL(changed(QString)), this, SLOT(enableApply()));
  connect(_script, SIGNAL(textChanged(QString)), this, SLOT(enableApply()));

  connect(_close, SIGNAL(clicked()), this, SLOT(close()));
  connect(_apply, SIGNAL(clicked()), this, SLOT(apply()));

  _proc = new QProcess(this);
  connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(scriptStdErr()));
  connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(scriptStdOut()));
  connect(_proc, SIGNAL(started()), this, SLOT(scriptStarted()));
  connect(_proc, SIGNAL(finished(int)), this, SLOT(scriptFinished(int)));
  connect(_rerunScript, SIGNAL(clicked()), this, SLOT(runScript()));
  connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(scriptError(QProcess::ProcessError)));

  _saveLocation->setMode(QFileDialog::Directory);

  QFileInfo info(_saveLocation->file());
  bool valid = info.isDir() && info.isWritable();
  _apply->setEnabled(valid);

  _scriptRunning->clear();

}