Ejemplo n.º 1
0
TagEditor::TagEditor(QWidget *parent) : QMainWindow(parent){
    setupUi(this); // this sets up GUI


    QHBoxLayout *hl = static_cast<QHBoxLayout*>(tabWidget->widget(1)->layout());
    scriptEditor_ = new CodeEditor;
    hl->addWidget(scriptEditor_);


    TreeWidget_ = new TreeWidget(this);
    ListWidgetFrame->layout()->addWidget(TreeWidget_);
    createActions();

    QFileSystemModel *model = new QFileSystemModel;
    TreeView->setModel(model);

    guiSettings = Global::guiSettings();
    readSettings();    
    setGUIStyle( style );


    //initialize scriptengine
    qScriptRegisterSequenceMetaType< QList<QFileInfo> >(&engine_);
    qScriptRegisterMetaType<QFileInfo>(&engine_, toQFileInfo,fromQFileInfo);
    engine_.globalObject().setProperty("Tag",engine_.newFunction(constructTag) );



}
Ejemplo n.º 2
0
void AgrosApplication::setStyle()
{
    QSettings settings;

    // first run
    if (settings.value("General/GUIStyle").value<QString>().isEmpty())
    {
        QString styleName = "";
        QStringList styles = QStyleFactory::keys();

#ifdef Q_WS_X11
        // kde 4
        if (getenv("KDE_SESSION_VERSION") != NULL)
        {
            if (styles.contains("Oxygen"))
                styleName = "Oxygen";
            else
                styleName = "Plastique";
        }
        // gtk+
        if (styleName == "")
            styleName = "GTK+";
#endif

#ifdef Q_WS_WIN
        if (styles.contains("WindowsVista"))
            styleName = "WindowsVista";
        else if (styles.contains("WindowsXP"))
            styleName = "WindowsXP";
        else
            styleName = "Windows";
#endif

#ifdef Q_WS_MAC
        styleName = "Aqua";
#endif

        settings.setValue("General/GUIStyle", styleName);
    }

    // setting gui style
    setGUIStyle(settings.value("General/GUIStyle").value<QString>());

    // init indicator (ubuntu - unity, windows - overlay icon, macosx - ???)
    Indicator::init();
}
Ejemplo n.º 3
0
void ConfigComputerDialog::save()
{
    // gui style
    Agros2D::configComputer()->setValue(Config::Config_GUIStyle, cmbGUIStyle->currentText());
    setGUIStyle(cmbGUIStyle->currentText());

    // language
    if (Agros2D::configComputer()->value(Config::Config_Locale).toString() != cmbLanguage->currentText())
        QMessageBox::warning(QApplication::activeWindow(),
                             tr("Language change"),
                             tr("Interface language has been changed. You must restart the application."));
    Agros2D::configComputer()->setValue(Config::Config_Locale, cmbLanguage->currentText());

    // show result in line edit value widget
    Agros2D::configComputer()->setValue(Config::Config_ShowResults, chkLineEditValueShowResult->isChecked());

    // development
    Agros2D::configComputer()->setValue(Config::Config_LinearSystemSave, chkDiscreteSaveMatrixRHS->isChecked());
    Agros2D::configComputer()->setValue(Config::Config_LinearSystemFormat, (Hermes::Algebra::MatrixExportFormat) cmbDumpFormat->itemData(cmbDumpFormat->currentIndex(), Qt::UserRole).toInt());

    // number of threads
    Agros2D::configComputer()->setValue(Config::Config_NumberOfThreads, txtNumOfThreads->value());

    // cache size
    Agros2D::configComputer()->setValue(Config::Config_CacheSize, txtCacheSize->value());

    // std log
    Agros2D::configComputer()->setValue(Config::Config_LogStdOut, chkLogStdOut->isChecked());

    // workspace
    Agros2D::configComputer()->setValue(Config::Config_ShowGrid, chkShowGrid->isChecked());
    Agros2D::configComputer()->setValue(Config::Config_ShowRulers, chkShowRulers->isChecked());
    Agros2D::configComputer()->setValue(Config::Config_ShowAxes, chkShowAxes->isChecked());

    Agros2D::configComputer()->setValue(Config::Config_RulersFontFamily, cmbRulersFont->itemData(cmbRulersFont->currentIndex()).toString());
    Agros2D::configComputer()->setValue(Config::Config_RulersFontPointSize, txtRulersFontSizes->value());
    Agros2D::configComputer()->setValue(Config::Config_PostFontFamily, cmbPostFont->itemData(cmbPostFont->currentIndex()).toString());
    Agros2D::configComputer()->setValue(Config::Config_PostFontPointSize, txtPostFontSizes->value());

    // save
    Agros2D::configComputer()->save();
}
Ejemplo n.º 4
0
void ConfigDialog::save()
{
    logMessage("ConfigDialog::save()");

    // gui style
    Util::config()->guiStyle = cmbGUIStyle->currentText();
    setGUIStyle(cmbGUIStyle->currentText());

    // language
    if (Util::config()->language != cmbLanguage->currentText())
        QMessageBox::warning(QApplication::activeWindow(),
                                 tr("Language change"),
                                 tr("Interface language has been changed. You must restart the application."));
    Util::config()->language = cmbLanguage->currentText();

    // default physic field
    Util::config()->defaultPhysicField = (PhysicField) cmbDefaultPhysicField->itemData(cmbDefaultPhysicField->currentIndex()).toInt();

    // collaboration server
    QString collaborationServerUrl = txtCollaborationServerURL->text();
    if (!collaborationServerUrl.startsWith("http://"))
        collaborationServerUrl = QString("http://%1").arg(collaborationServerUrl);

    if (!collaborationServerUrl.endsWith("/"))
        collaborationServerUrl = QString("%1/").arg(collaborationServerUrl);

    Util::config()->collaborationServerURL = collaborationServerUrl;

    // check version
    Util::config()->checkVersion = chkCheckVersion->isChecked();

    // show convergence chart
    Util::config()->showConvergenceChart = chkShowConvergenceChart->isChecked();

    // logs
    Util::config()->enabledApplicationLog = chkEnabledApplicationLog->isChecked();
    Util::config()->enabledProgressLog = chkEnabledProgressLog->isChecked();

    // show result in line edit value widget
    Util::config()->lineEditValueShowResult = chkLineEditValueShowResult->isChecked();

    // mesh
    Util::config()->angleSegmentsCount = txtMeshAngleSegmentsCount->value();
    Util::config()->curvilinearElements = chkMeshCurvilinearElements->isChecked();

    // delete files
    Util::config()->deleteTriangleMeshFiles = chkDeleteTriangleMeshFiles->isChecked();
    Util::config()->deleteHermes2DMeshFile = chkDeleteHermes2DMeshFile->isChecked();

    // color
    Util::config()->colorBackground = colorBackground->color();
    Util::config()->colorGrid = colorGrid->color();
    Util::config()->colorCross = colorCross->color();
    Util::config()->colorNodes = colorNodes->color();
    Util::config()->colorEdges = colorEdges->color();
    Util::config()->colorLabels = colorLabels->color();
    Util::config()->colorContours = colorContours->color();
    Util::config()->colorVectors = colorVectors->color();
    Util::config()->colorInitialMesh = colorInitialMesh->color();
    Util::config()->colorSolutionMesh = colorSolutionMesh->color();
    Util::config()->colorHighlighted = colorHighlighted->color();
    Util::config()->colorSelected = colorSelected->color();

    // adaptivity
    Util::config()->maxDofs = txtMaxDOFs->value();
    //Util::config()->isoOnly = chkIsoOnly->isChecked();
    Util::config()->convExp = txtConvExp->value();
    Util::config()->threshold = txtThreshold->value();
    Util::config()->strategy = cmbStrategy->itemData(cmbStrategy->currentIndex()).toInt();
    Util::config()->meshRegularity = cmbMeshRegularity->itemData(cmbMeshRegularity->currentIndex()).toInt();
    Util::config()->projNormType = (ProjNormType) cmbProjNormType->itemData(cmbProjNormType->currentIndex()).toInt();

    // command argument
    Util::config()->commandTriangle = txtArgumentTriangle->text();
    Util::config()->commandFFmpeg = txtArgumentFFmpeg->text();

    // global script
    Util::config()->globalScript = txtGlobalScript->toPlainText();

    // save
    Util::config()->save();
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    // start application
    QString str = QString("\n\n%1: Field").
            arg(QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss.zzz"));

    QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
    QDir("/").mkpath(location);
    appendToFile(location, str);

    // register message handler
    // TODO: qInstallMsgHandler(logOutput);

    ArgosApplication a(argc, argv);
    // QApplication a(argc, argv);

#ifdef VERSION_BETA
    bool beta = true;
#else
    bool beta = false;
#endif

    a.setWindowIcon(icon("field"));
    a.setApplicationVersion(versionString(VERSION_MAJOR, VERSION_MINOR, VERSION_SUB, VERSION_GIT, VERSION_YEAR, VERSION_MONTH, VERSION_DAY, beta));
    a.setOrganizationName("hpfem.org");
    a.setOrganizationDomain("hpfem.org");
    a.setApplicationName("Field");

#ifdef Q_WS_MAC
    // don't show icons in menu
    a.setAttribute(Qt::AA_DontShowIconsInMenus, true);
#endif

    // parameters
    QStringList args = QCoreApplication::arguments();
    if (args.count() == 2)
    {
        if (args.contains( "--help") || args.contains("/help"))
        {
            cout << "field [fileName (*.fld; *.py) | -run fileName (*.py) | --help | --verbose]" << endl;
            exit(0);
            return 0;
        }
    }

    QSettings settings;

    // first run
    if (settings.value("General/GUIStyle").value<QString>().isEmpty())
    {
        QString styleName = "";
        QStringList styles = QStyleFactory::keys();

#ifdef Q_WS_X11
        // kde 3
        if (getenv("KDE_FULL_SESSION") != NULL)
            styleName = "Plastique";
        // kde 4
        if (getenv("KDE_SESSION_VERSION") != NULL)
        {
            if (styles.contains("Oxygen"))
                styleName = "Oxygen";
            else
                styleName = "Plastique";
        }
        // gtk+
        if (styleName == "")
            styleName = "GTK+";
#endif

#ifdef Q_WS_WIN
        if (styles.contains("WindowsVista"))
            styleName = "WindowsVista";
        else if (styles.contains("WindowsXP"))
            styleName = "WindowsXP";
        else
            styleName = "Windows";
#endif


#ifdef Q_WS_MAC
        styleName = "Aqua";
#endif

        settings.setValue("General/GUIStyle", styleName);
    }

    // setting gui style
    setGUIStyle(settings.value("General/GUIStyle").value<QString>());

    // language
    QString locale = settings.value("General/Language", QLocale::system().name()).value<QString>();
    setLanguage(locale);

    // init indicator (ubuntu - unity, windows - overlay icon, macosx - ???)
    Indicator::init();

    MainWindow w;
    w.show();

    return a.exec();
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
    try
    {
        // command line info
        TCLAP::CmdLine cmd("Agros2D", ' ', versionString().toStdString());

        TCLAP::SwitchArg remoteArg("r", "remote-server", "Run remote server", false);
        TCLAP::ValueArg<std::string> problemArg("p", "problem", "Open problem", false, "", "string");
        TCLAP::ValueArg<std::string> scriptArg("s", "script", "Open script", false, "", "string");
        TCLAP::SwitchArg executeArg("x", "execute", "Execute problem or script", false);

        cmd.add(remoteArg);
        cmd.add(problemArg);
        cmd.add(scriptArg);
        cmd.add(executeArg);

        // parse the argv array.
        cmd.parse(argc, argv);

        CleanExit cleanExit;
        AgrosApplication a(argc, argv);
        // setting gui style
        setGUIStyle(Agros2D::configComputer()->value(Config::Config_GUIStyle).toString());
        // language
        setLocale(Agros2D::configComputer()->value(Config::Config_Locale).toString());
        a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));

        // init indicator (ubuntu - unity, windows - overlay icon, macosx - ???)
        Indicator::init();

        MainWindow w;

        // run remote server
        if (remoteArg.getValue())
        {
            a.runRemoteServer();
        }

        if (!problemArg.getValue().empty())
        {
            if (QFile::exists(QString::fromStdString(problemArg.getValue())))
            {
                QFileInfo info(QString::fromStdString(problemArg.getValue()));
                if (info.suffix() == "a2d")
                {
                    w.setStartupProblemFilename(QString::fromStdString(problemArg.getValue()));

                    if (executeArg.getValue())
                        w.setStartupExecute(true);
                }
                else
                {
                    std::cout << QObject::tr("Unknown suffix.").toStdString() << std::endl;
                }
            }
        }
        else if (!scriptArg.getValue().empty())
        {
            if (QFile::exists(QString::fromStdString(scriptArg.getValue())))
            {
                QFileInfo info(QString::fromStdString(scriptArg.getValue()));
                if (info.suffix() == "py")
                {
                    w.setStartupScriptFilename(QString::fromStdString(scriptArg.getValue()));

                    if (executeArg.getValue())
                        w.setStartupExecute(true);
                }
                else
                {
                    std::cout << QObject::tr("Unknown suffix.").toStdString() << std::endl;
                }
            }
        }

        w.show();

        return a.exec();
    }
    catch (TCLAP::ArgException &e)
    {
        std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
        return 1;
    }    
}