Skip to content

Commit

Permalink
Merge pull request TrenchBroom#3918 from TrenchBroom/3913-build-info-…
Browse files Browse the repository at this point in the history
…string

3913: Don't wrap build info string
  • Loading branch information
kduske authored Nov 14, 2021
2 parents 4f6be0d + 69212bc commit 6efad9f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ macro(GET_BUILD_PLATFORM PLATFORM_NAME)
message(ERROR "Unsupported CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}")
endif()
elseif(APPLE)
set(${PLATFORM_NAME} "MacOSX")
set(${PLATFORM_NAME} "macOS")
elseif(UNIX)
set(${PLATFORM_NAME} "Linux")
else()
Expand Down
29 changes: 12 additions & 17 deletions common/src/View/AppInfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,30 @@
#include <QStringBuilder>
#include <QVBoxLayout>

namespace TrenchBroom {
namespace View {
namespace TrenchBroom::View {
AppInfoPanel::AppInfoPanel(QWidget* parent)
: QWidget(parent) {
: QWidget{parent} {
createGui();
}

void AppInfoPanel::createGui() {
QPixmap appIconImage = IO::loadPixmapResource("AppIcon.png");
QLabel* appIcon = new QLabel();
QLabel* appIcon = new QLabel{};
appIcon->setPixmap(appIconImage);

QLabel* appName = new QLabel(tr("TrenchBroom"));
QLabel* appName = new QLabel{tr("TrenchBroom")};
makeHeader(appName);

BorderLine* appLine = new BorderLine(BorderLine::Direction::Horizontal);
QLabel* appClaim = new QLabel(tr("Level Editor"));
BorderLine* appLine = new BorderLine{BorderLine::Direction::Horizontal};
QLabel* appClaim = new QLabel{tr("Level Editor")};

ClickableLabel* version = new ClickableLabel(QString(tr("Version ")) % getBuildVersion());
ClickableLabel* build = new ClickableLabel(QString(tr("Build ")) % getBuildIdStr());
ClickableLabel* qtVersion =
new ClickableLabel(QString(tr("Qt ")) % QString::fromLocal8Bit(qVersion()));
ClickableLabel* version = new ClickableLabel{tr("Version ") % getBuildVersion()};
ClickableLabel* build = new ClickableLabel{tr("Build ") % getBuildIdStr()};
ClickableLabel* qtVersion = new ClickableLabel{tr("Qt ") % QString::fromLocal8Bit(qVersion())};

makeInfo(version);
makeInfo(build);
makeInfo(qtVersion);
build->setWordWrap(true);
build->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

const auto tooltip = tr("Click to copy to clipboard");
Expand All @@ -70,7 +67,7 @@ void AppInfoPanel::createGui() {
connect(build, &ClickableLabel::clicked, this, &AppInfoPanel::versionInfoClicked);
connect(qtVersion, &ClickableLabel::clicked, this, &AppInfoPanel::versionInfoClicked);

auto* layout = new QVBoxLayout();
auto* layout = new QVBoxLayout{};
layout->setContentsMargins(20, 20, 20, 20);
layout->setSpacing(2);
layout->addStretch();
Expand All @@ -88,9 +85,7 @@ void AppInfoPanel::createGui() {

void AppInfoPanel::versionInfoClicked() {
QClipboard* clipboard = QApplication::clipboard();
const QString str =
QString("TrenchBroom ") % getBuildVersion() % QString(" Build ") % getBuildIdStr();
const QString str = tr("TrenchBroom ") % getBuildVersion() % tr(" Build ") % getBuildIdStr();
clipboard->setText(str);
}
} // namespace View
} // namespace TrenchBroom
} // namespace TrenchBroom::View
6 changes: 2 additions & 4 deletions common/src/View/AppInfoPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

#include <QWidget>

namespace TrenchBroom {
namespace View {
namespace TrenchBroom::View {
class AppInfoPanel : public QWidget {
Q_OBJECT
public:
Expand All @@ -33,5 +32,4 @@ class AppInfoPanel : public QWidget {

void versionInfoClicked();
};
} // namespace View
} // namespace TrenchBroom
} // namespace TrenchBroom::View
47 changes: 22 additions & 25 deletions common/src/View/WelcomeWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@
#include <QHBoxLayout>
#include <QPushButton>

namespace TrenchBroom {
namespace View {
namespace TrenchBroom::View {
WelcomeWindow::WelcomeWindow()
: QMainWindow(nullptr, Qt::Dialog)
, // Qt::Dialog window flag causes the window to be centered on Ubuntu
m_recentDocumentListBox(nullptr)
, m_createNewDocumentButton(nullptr)
, m_openOtherDocumentButton(nullptr) {
: QMainWindow{nullptr, Qt::Dialog} // Qt::Dialog flag centers window on Ubuntu
, m_recentDocumentListBox{nullptr}
, m_createNewDocumentButton{nullptr}
, m_openOtherDocumentButton{nullptr} {
createGui();
}

void WelcomeWindow::createGui() {
setWindowIconTB(this);
setWindowTitle("Welcome to TrenchBroom");

m_recentDocumentListBox = new RecentDocumentListBox();
m_recentDocumentListBox = new RecentDocumentListBox{};
m_recentDocumentListBox->setToolTip("Double click on a file to open it");
m_recentDocumentListBox->setFixedWidth(300);
m_recentDocumentListBox->setSizePolicy(
Expand All @@ -57,19 +55,19 @@ void WelcomeWindow::createGui() {
m_recentDocumentListBox, &RecentDocumentListBox::loadRecentDocument, this,
&WelcomeWindow::openDocument);

auto* innerLayout = new QHBoxLayout();
innerLayout->setContentsMargins(QMargins());
auto* innerLayout = new QHBoxLayout{};
innerLayout->setContentsMargins(QMargins{});
innerLayout->setSpacing(0);

auto* appPanel = createAppPanel();

innerLayout->addWidget(appPanel, 0, Qt::AlignTop);
innerLayout->addWidget(new BorderLine(BorderLine::Direction::Vertical), 0);
innerLayout->addWidget(new BorderLine{BorderLine::Direction::Vertical}, 0);
innerLayout->addWidget(m_recentDocumentListBox, 1);

auto* container = new QWidget();
auto* outerLayout = new QVBoxLayout();
outerLayout->setContentsMargins(QMargins());
auto* container = new QWidget{};
auto* outerLayout = new QVBoxLayout{};
outerLayout->setContentsMargins(QMargins{});
outerLayout->setSpacing(0);

outerLayout->addLayout(innerLayout);
Expand All @@ -82,28 +80,28 @@ void WelcomeWindow::createGui() {
}

QWidget* WelcomeWindow::createAppPanel() {
auto* appPanel = new QWidget();
auto* infoPanel = new AppInfoPanel(appPanel);
auto* appPanel = new QWidget{};
auto* infoPanel = new AppInfoPanel{appPanel};

m_createNewDocumentButton = new QPushButton("New map...");
m_createNewDocumentButton = new QPushButton{"New map..."};
m_createNewDocumentButton->setToolTip("Create a new map document");
m_openOtherDocumentButton = new QPushButton("Browse...");
m_openOtherDocumentButton = new QPushButton{"Browse..."};
m_openOtherDocumentButton->setToolTip("Open an existing map document");

connect(
m_createNewDocumentButton, &QPushButton::clicked, this, &WelcomeWindow::createNewDocument);
connect(
m_openOtherDocumentButton, &QPushButton::clicked, this, &WelcomeWindow::openOtherDocument);

auto* buttonLayout = new QHBoxLayout();
auto* buttonLayout = new QHBoxLayout{};
buttonLayout->setContentsMargins(0, 0, 0, 0);
buttonLayout->setSpacing(LayoutConstants::WideHMargin);
buttonLayout->addStretch();
buttonLayout->addWidget(m_createNewDocumentButton);
buttonLayout->addWidget(m_openOtherDocumentButton);
buttonLayout->addStretch();

auto* outerLayout = new QVBoxLayout();
auto* outerLayout = new QVBoxLayout{};
outerLayout->setContentsMargins(0, 0, 0, 0);
outerLayout->setSpacing(0);
outerLayout->addWidget(infoPanel, 0, Qt::AlignHCenter);
Expand All @@ -116,14 +114,14 @@ QWidget* WelcomeWindow::createAppPanel() {
}

void WelcomeWindow::createNewDocument() {
TrenchBroomApp& app = TrenchBroomApp::instance();
auto& app = TrenchBroomApp::instance();
if (!app.newDocument()) {
show();
}
}

void WelcomeWindow::openOtherDocument() {
const QString pathStr = QFileDialog::getOpenFileName(
const auto pathStr = QFileDialog::getOpenFileName(
nullptr, tr("Open Map"), fileDialogDefaultDirectory(FileDialogDir::Map),
"Map files (*.map);;Any files (*.*)");
const auto path = IO::pathFromQString(pathStr);
Expand All @@ -135,10 +133,9 @@ void WelcomeWindow::openOtherDocument() {
}

void WelcomeWindow::openDocument(const IO::Path& path) {
TrenchBroomApp& app = TrenchBroomApp::instance();
auto& app = TrenchBroomApp::instance();
if (!app.openDocument(path)) {
show();
}
}
} // namespace View
} // namespace TrenchBroom
} // namespace TrenchBroom::View

0 comments on commit 6efad9f

Please sign in to comment.