void ContactAvatarWidget::openAvatarPreview()
    {
        auto layout = new QHBoxLayout();

        auto spacerLeft = new QSpacerItem(Utils::scale_value(12), 1, QSizePolicy::Expanding);
        layout->addSpacerItem(spacerLeft);

        auto croppedAvatar = infoForSetAvatar_.croppedImage;
        auto previewAvatarWidget = new AvatarPreview(croppedAvatar, nullptr);
        previewAvatarWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
        layout->addWidget(previewAvatarWidget);

        auto spacerRight = new QSpacerItem(Utils::scale_value(12), 1, QSizePolicy::Expanding);
        layout->addSpacerItem(spacerRight);

        auto avatarPreviewHost = new QWidget();
        avatarPreviewHost->setLayout(layout);

        Ui::GeneralDialog previewDialog(avatarPreviewHost, Utils::InterConnector::instance().getMainWindow());
        previewDialog.addHead();
        previewDialog.addLabel(QT_TRANSLATE_NOOP("avatar_upload", "Preview"));

        previewDialog.addButtonsPair(QT_TRANSLATE_NOOP("popup_window", "BACK"), QT_TRANSLATE_NOOP("popup_window", "SAVE"), true);

        QObject::connect(&previewDialog, &GeneralDialog::leftButtonClicked, this, &ContactAvatarWidget::cropAvatar, Qt::QueuedConnection);

        if (previewDialog.showInPosition(-1, -1))
        {
            SetVisibleSpinner(true);
            postSetAvatarToCore(croppedAvatar);
        }
    }
Exemple #2
0
LabelLayout::LabelLayout(analyzer_header *header, bool enable_reorder, bool enable_drag, FilterTabWidget *filters, QWidget *parent) : QHBoxLayout(parent)
{
    setSizeConstraint(QLayout::SetMinAndMaxSize);

    if(enable_reorder && enable_drag)
    {
        m_spacer_l = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding);
        addSpacerItem(m_spacer_l);
    }
    else m_spacer_l = NULL;

    m_spacer_r = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding);
    addSpacerItem(m_spacer_r);

    m_header = header;
    m_enableReorder = enable_reorder;
    m_enableDrag = enable_drag;
    if(m_enableReorder)
        ((QWidget*)parent)->setAcceptDrops(true);

    quint16 len = m_header->hasLen() ? m_header->length : m_header->packet_length;
    lenChanged(len);

    m_filterWidget = filters;

    QTimer *freeTimer = new QTimer(this);
    freeTimer->start(1000);
    connect(freeTimer, SIGNAL(timeout()), SLOT(freeLabels()));
}
Exemple #3
0
MapWidget::SelectMapWidget::SelectMapWidget() {
    
    // Init components
    gridLayout = new QGridLayout(this);
    nextMapBtn = new QPushButton();
    previousMapBtn = new QPushButton();
    titleLabel = new QLabel("Select map");
    mapLabel = new QLabel();
    
    // Add maps
    for (auto& map : Config::GetInstance().GetMaps())
        mapLabels.push_back(map->GetName());

    mapLabel->setText(mapLabels[currentMap].c_str());
    mapLabel->setObjectName("map_label");

    // Add id
    titleLabel->setObjectName("global_h2");
    nextMapBtn->setObjectName("right_arrow");
    previousMapBtn->setObjectName("left_arrow");

    // Connect buttons
    connect(nextMapBtn, &QPushButton::clicked, [=]() {
        currentMap = (++currentMap) % mapLabels.size();
        qDebug(("Next map: " + std::to_string(currentMap)).c_str());
        mapLabel->setText(mapLabels[currentMap].c_str());
    });

    // Connect buttons
    connect(previousMapBtn, &QPushButton::clicked, [=]() {
        currentMap == 0 ? currentMap = mapLabels.size() - 1 : --currentMap;
        qDebug(("Previous map: " + std::to_string(currentMap)).c_str());
        mapLabel->setText(mapLabels[currentMap].c_str());
    });

    // Set layout
    setLayout(gridLayout);

    // Add components
    gridLayout->addWidget(titleLabel, 0, 0, 1, 3, Qt::AlignCenter);
    gridLayout->addWidget(previousMapBtn, 1, 0, Qt::AlignRight);
    gridLayout->addWidget(mapLabel, 1, 1, Qt::AlignCenter);
    gridLayout->addWidget(nextMapBtn, 1, 2, Qt::AlignLeft);

    // Add map components
    auto vLayout = new QVBoxLayout();
    auto hLayout = new QHBoxLayout();
    loadMapButton = new QPushButton("Load Custom Map ...");
    useCustomMap = new QCheckBox();
    useCustomMapLabel = new QLabel("Use Custom Map");
    selectedFileLabel = new QLabel("<b>Selected File:</b>");

    loadMapButton->setObjectName("mapButton");
    useCustomMap->setObjectName("mapButton");
    useCustomMapLabel->setObjectName("mapButton");
    selectedFileLabel->setObjectName("mapFileLabel");
    selectedFileLabel->setWordWrap(true);
    selectedFileLabel->setVisible(false);
    loadMapButton->setEnabled(false);
    loadMapButton->setVisible(false);

    vLayout->addSpacerItem(new QSpacerItem(0, 20));
    vLayout->addSpacerItem(new QSpacerItem(0, 100));

    useCustomMap->setFixedSize(50, 50);
    hLayout->addWidget(useCustomMap);
    hLayout->addWidget(useCustomMapLabel);
    vLayout->addLayout(hLayout);

    vLayout->addSpacerItem(new QSpacerItem(0, 20));
    vLayout->addWidget(loadMapButton);
    vLayout->addSpacerItem(new QSpacerItem(0, 20));
    vLayout->addWidget(selectedFileLabel);

    gridLayout->addLayout(vLayout, 2, 0, 1, 3);

    connect(useCustomMap, &QCheckBox::clicked, [=](bool checked)
    {
        loadMapButton->setEnabled(checked);
        loadMapButton->setVisible(checked);
        selectedFileLabel->setVisible(checked);
        useCustomMapSelected = checked;
    });

    connect(loadMapButton, &QPushButton::clicked, [=]()
    {
        auto oldMapFileName = customMapFileName;
        customMapFileName = QFileDialog::getOpenFileName(
            this, "Map File Location", "Resources/config/map", "XML Files (*.xml)");

        if (customMapFileName.isEmpty() && !oldMapFileName.isEmpty())
            customMapFileName = oldMapFileName;

        QString mapFile;
        if (!customMapFileName.isEmpty())
        {
            auto split = customMapFileName.split('/');
            mapFile = split[split.size() - 1];
        }
        selectedFileLabel->setText("<b>Selected File:</b> " + (customMapFileName.isEmpty() ?
                                   "<font color='red'><b>NONE</b></font>" :
                                   "<font color='black'><b>" + mapFile + "</b></font>"));
    });
}
Exemple #4
0
AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent), d(new Data) {
    d->ui.setupUi(this);

    auto link = [] (const char *url) -> QString
        { return "<a href=\""_a % _L(url) % "\">"_a % _L(url) % "</a>"_a; };
    d->ui.app_name->setText(cApp.displayName());
#define UI_LABEL_ARG(label, arg) d->ui.label->setText(d->ui.label->text().arg)
    UI_LABEL_ARG(version, arg(_L(cApp.version())));
    UI_LABEL_ARG(qt_info, arg(_L(qVersion()), _L(QT_VERSION_STR)));
    UI_LABEL_ARG(copyright, arg(QDate::currentDate().year()).arg(tr("Lee, Byoung-young")));
    UI_LABEL_ARG(contacts, arg(link("http://bomi-player.github.io") % "<br>"_a).
                 arg(link("http://twitter.com/bomi_player") % "<br>"_a).
                 arg(link("https://github.com/xylosper/bomi/issues") % "<br>"_a).
                 arg("<a href=\"mailto:[email protected]\">[email protected]</a><br>"_a));
    UI_LABEL_ARG(ivan, arg(_L("https://plus.google.com/u/1/117118228830713086299/posts")));
#undef UI_LABEL_ARG
    d->ui.license->setText(
       u"This program is free software; "
        "you can redistribute it and/or modify it under the terms of "
        "the GNU General Public License "
        "as published by ""the Free Software Foundation; "
        "either version 2 of the License, "
        "or (at your option) any later version.<br><br>"

        "This program is distributed in the hope that it will be useful, "
        "but WITHOUT ANY WARRANTY; without even the implied warranty of "
        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
        "See the GNU General Public License for more details.<br><br>"

        "You should have received a copy of "
        "the GNU General Public License along with this program; "
        "if not, see <a href=\"http://www.gnu.org/licenses\">"
        "http://www.gnu.org/licenses</a>."_q
    );

    auto show = [this] ()
    {
        QDialog dlg(this);
        auto text = new QTextBrowser(&dlg);
        auto close = new QPushButton(tr("Close"), &dlg);
        auto vbox = new QVBoxLayout(&dlg);
        vbox->addWidget(text);
        auto hbox = new QHBoxLayout;
        hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
        hbox->addWidget(close);
        hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
        vbox->addLayout(hbox);
        connect(close, &QPushButton::clicked, &dlg, &QDialog::accept);

        const QString fileName(u":/gpl.html"_q);
        QFile file(fileName);
        file.open(QFile::ReadOnly | QFile::Text);
        text->setHtml(QString::fromLatin1(file.readAll()));
        dlg.resize(500, 400);
        dlg.exec();
    };
    connect(d->ui.view_gpl, &QPushButton::clicked, this, show);

    adjustSize();
}