Files
qt-creator/src/plugins/coreplugin/versiondialog.cpp

81 lines
2.5 KiB
C++
Raw Normal View History

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
2008-12-02 15:08:31 +01:00
2008-12-02 12:01:29 +01:00
#include "versiondialog.h"
#include "coreicons.h"
#include "coreplugintr.h"
#include "coreicons.h"
#include "icore.h"
2008-12-02 12:01:29 +01:00
#include <utils/algorithm.h>
#include <utils/appinfo.h>
#include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h>
2008-12-09 15:25:01 +01:00
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/utilsicons.h>
2008-12-02 12:01:29 +01:00
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QGuiApplication>
#include <QKeyEvent>
#include <QLabel>
#include <QPushButton>
2008-12-02 12:01:29 +01:00
2008-12-09 15:25:01 +01:00
using namespace Core;
using namespace Core::Internal;
2008-12-02 15:08:31 +01:00
VersionDialog::VersionDialog(QWidget *parent)
: QDialog(parent)
2008-12-02 12:01:29 +01:00
{
// We need to set the window icon explicitly here since for some reason the
// application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME)
if (Utils::HostOsInfo::isLinuxHost())
setWindowIcon(Icons::QTCREATORLOGO_BIG.icon());
2008-12-02 12:01:29 +01:00
setWindowTitle(Tr::tr("About %1").arg(QGuiApplication::applicationDisplayName()));
2008-12-02 12:01:29 +01:00
auto logoLabel = new QLabel;
logoLabel->setPixmap(Icons::QTCREATORLOGO_BIG.pixmap());
auto copyRightLabel = new QLabel(ICore::aboutInformationHtml());
2008-12-02 12:01:29 +01:00
copyRightLabel->setWordWrap(true);
copyRightLabel->setOpenExternalLinks(true);
copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
QPushButton *copyButton = buttonBox->addButton(Tr::tr("Copy and Close"),
QDialogButtonBox::ApplyRole);
2008-12-02 12:01:29 +01:00
using namespace Layouting;
Column {
Row {
Column { logoLabel, st },
Column { copyRightLabel },
},
buttonBox,
}.attachTo(this);
layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(copyButton, &QPushButton::pressed, this, [this] {
Utils::setClipboardAndSelection(ICore::aboutInformationCompact());
accept();
});
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
2008-12-02 12:01:29 +01:00
}
bool VersionDialog::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride) {
auto ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;
}
}
return QDialog::event(event);
}