예제 #1
0
DateTimeFormatter *DateTimeFormat::createFormatterForStyle(string style) {
    if (style == NULL || style.size() != 2) {
        throw IllegalArgumentException("Invalid style specification: " + style);
    }
    int dateStyle = selectStyle(style.at(0));
    int timeStyle = selectStyle(style.at(1));
    if (dateStyle == NONE && timeStyle == NONE) {
        throw IllegalArgumentException("Style '--' is invalid");
    }
    return createFormatterForStyleIndex(dateStyle, timeStyle);
}
예제 #2
0
void MainWindow::initActions()
{
    m_sessionNew = new QAction(this);
    m_sessionNew->setShortcut( tr( "Ctrl+N" ) );
    connect ( m_sessionNew , SIGNAL ( triggered() ), this , SLOT ( newSession() ) );

    m_sessionList = new QAction(this);
    m_sessionList->setShortcut( tr( "Ctrl+L" ) );
    connect ( m_sessionList , SIGNAL ( triggered() ), this , SLOT ( sessionList() ) );

    m_closeFullScreenAction = new QAction(this);
    m_closeFullScreenAction -> setIcon( QIcon( ":/shellicons/Restore") );
    connect ( m_closeFullScreenAction , SIGNAL ( triggered() ), this , SLOT ( showNormal() ) );

    //TODO: Fix fullscreen action behaviour
    m_fullScreenAction = new QAction(this);
    m_fullScreenAction -> setIcon( QIcon( ":/icons/FullScreen") );
    m_fullScreenAction->setShortcut( tr( "F11" ) );
    connect ( m_fullScreenAction, SIGNAL ( triggered() ), this , SLOT ( fullScreen() ) );
  
    m_quitAction = new QAction(this);
    m_quitAction->setShortcut(tr("Ctrl+Q"));
    m_quitAction -> setIcon( QIcon( ":/icons/Quit") );

    connect ( m_quitAction, SIGNAL ( triggered() ), this , SLOT ( close() ) );

    m_updateAllMonitorsActions = new QAction(this);
    m_updateAllMonitorsActions->setShortcut( tr("F5") );
    connect ( m_updateAllMonitorsActions, SIGNAL ( triggered() ),this, SLOT ( update() ) );

    m_selectStyleAction = new QAction(this);
    connect ( m_selectStyleAction , SIGNAL (triggered()), this , SLOT ( selectStyle() ) );

    m_preferencesAction = new QAction( this );
    connect ( m_preferencesAction, SIGNAL ( triggered() ),this, SLOT ( showPreferences() ) );

    aboutAction = new QAction(this);
    aboutQtAction = new QAction(this);
    connect ( aboutAction, SIGNAL ( triggered () ), this, SLOT ( aboutDialog() ) );
    connect ( aboutQtAction, SIGNAL ( triggered () ), qApp, SLOT ( aboutQt() ) );
}
예제 #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_settings(new QSettings(this))
{
    ui->setupUi(this);

    // Centring splitter handle
    const int half = ui->splitter->width() / 2 - ui->splitter->handleWidth();
    ui->splitter->setSizes({half, half});
    ui->controlComboBox->setFocusProxy(ui->plainTextEdit);

    setupActions();
    loadSettings();

    // Create now to avoid crash when styles are loaded
    m_qmlStyler = new StylerQmlObject(ui->quickWidget->engine(), this);

    findBuiltInStyles();

    connect(ui->controlComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
            this, &MainWindow::selectControl);
    connect(ui->styleComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
            this, &MainWindow::selectStyle);
    connect(ui->plainTextEdit, &QPlainTextEdit::textChanged, [this]() {
        if (ui->plainTextEdit->document()->isModified())
            updateModifiedMark(m_currentControlName, true);
    });

    ui->plainTextEdit->document()->setDefaultFont(QFont(QStringLiteral("Monospace"), 10));
    new QMLSyntaxHighlighter(ui->plainTextEdit->document());

    if (ui->styleComboBox->count())
        selectStyle(0);

    ui->quickWidget->rootContext()
            ->setContextProperty(QStringLiteral("__qcStyler"), m_qmlStyler);

    ui->quickWidget->setSource(QStringLiteral("qrc:/preview/main.qml"));
}