Skip to content

Commit deed24c

Browse files
committed
set up tabs
1 parent 5bf3ed6 commit deed24c

File tree

1 file changed

+68
-10
lines changed

1 file changed

+68
-10
lines changed

src/app/StartScreen.hpp

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <QApplication>
88
#include <QDesktopServices>
9+
#include <QIcon>
910
#include <QKeyEvent>
1011
#include <QLabel>
1112
#include <QNetworkAccessManager>
@@ -15,7 +16,10 @@
1516
#include <QPixmap>
1617
#include <QPointer>
1718
#include <QSettings>
19+
#include <QSplitter>
20+
#include <QTabWidget>
1821
#include <QTextLayout>
22+
#include <QVBoxLayout>
1923

2024
#include <score_git_info.hpp>
2125

@@ -265,6 +269,7 @@ class StartScreen : public QWidget
265269
void exitApp() W_SIGNAL(exitApp)
266270

267271
void addLoadCrashedSession();
272+
void setupTabs();
268273

269274
protected:
270275
void paintEvent(QPaintEvent* event) override;
@@ -273,6 +278,7 @@ class StartScreen : public QWidget
273278
private:
274279
QPixmap m_background;
275280
InteractiveLabel* m_crashLabel{};
281+
QTabWidget* tabWidget;
276282
};
277283
struct StartScreenLink
278284
{
@@ -293,26 +299,46 @@ struct StartScreenLink
293299
StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget* parent)
294300
: QWidget(parent)
295301
{
302+
QWidget* headerWidget = new QWidget(this);
303+
QHBoxLayout* headerLayout = new QHBoxLayout(headerWidget);
304+
headerLayout->setContentsMargins(10, 10, 10, 0);
305+
306+
QLabel* logoLabel = new QLabel(headerWidget);
307+
308+
QPixmap placeholderPixmap(300, 100); //TODO: replace placeholder with logo
309+
placeholderPixmap.fill(Qt::gray);
310+
logoLabel->setPixmap(placeholderPixmap);
311+
logoLabel->setFixedSize(placeholderPixmap.size());
312+
313+
headerLayout->addWidget(logoLabel, 0, Qt::AlignLeft);
314+
315+
tabWidget = new QTabWidget(this);
316+
317+
setupTabs();
318+
319+
QVBoxLayout* mainLayout = new QVBoxLayout(this);
320+
mainLayout->addWidget(headerWidget);
321+
mainLayout->addWidget(tabWidget);
322+
setLayout(mainLayout);
323+
296324
// Workaround until https://bugreports.qt.io/browse/QTBUG-103225 is fixed
297325
#if defined(__APPLE__)
298326
static constexpr double font_factor = 96. / 72.;
299327
#else
300328
static constexpr double font_factor = 1.;
301329
#endif
302-
QFont f("Ubuntu", 14 * font_factor, QFont::Light);
330+
QFont f("Ubuntu", 14 * font_factor, QFont::Light);
303331
f.setHintingPreference(QFont::HintingPreference::PreferFullHinting);
304332
f.setStyleStrategy(QFont::PreferAntialias);
305333

306-
QFont titleFont("Montserrat", 14 * font_factor, QFont::DemiBold);
334+
QFont titleFont("Montserrat", 14 * font_factor, QFont::DemiBold);
307335
titleFont.setHintingPreference(QFont::HintingPreference::PreferFullHinting);
308336
titleFont.setStyleStrategy(QFont::PreferAntialias);
309337

310338
this->setEnabled(true);
311339
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); //| Qt::WindowStaysOnTopHint);
312340
setWindowModality(Qt::ApplicationModal);
313341

314-
m_background = score::get_pixmap(":/startscreen/startscreensplash.png");
315-
316342
if(QPainter painter; painter.begin(&m_background))
317343
{
318344
painter.setRenderHint(QPainter::Antialiasing, true);
@@ -326,7 +352,8 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
326352
}
327353

328354
// Weird code here is because the window size seems to scale only to integer ratios.
329-
setFixedSize(m_background.size() / std::floor(qApp->devicePixelRatio()));
355+
// setFixedSize(m_background.size() / std::floor(qApp->devicePixelRatio()));
356+
setFixedSize(600, 500);
330357

331358
{
332359
// new version
@@ -350,10 +377,11 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
350377
label->move(280, 170);
351378
label->show();
352379
}
353-
}, [] {}};
380+
},
381+
[] {}};
354382
}
355383

356-
float label_x = 300;
384+
float label_x = 50;
357385
float label_y = 215;
358386

359387
{ // recent files
@@ -404,7 +432,7 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
404432
m_crashLabel, &score::InteractiveLabel::labelPressed, this,
405433
&score::StartScreen::loadCrashedSession);
406434

407-
label_x = 510;
435+
label_x = 310;
408436
label_y = 215;
409437
{ // Create new
410438
InteractiveLabel* label = new InteractiveLabel{titleFont, qApp->tr("New"), "", this};
@@ -433,7 +461,8 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
433461
QSettings settings;
434462
auto library_path = settings.value("Library/RootPath").toString();
435463
InteractiveLabel* label = new InteractiveLabel{
436-
titleFont, qApp->tr("Examples"), "https://github.com/ossia/score-examples", this};
464+
titleFont, qApp->tr("Examples"), "https://github.com/ossia/score-examples",
465+
this};
437466
label->setPixmaps(
438467
score::get_pixmap(":/icons/load_examples_off.png"),
439468
score::get_pixmap(":/icons/load_examples_on.png"));
@@ -479,6 +508,35 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
479508
}
480509
}
481510

511+
void StartScreen::setupTabs()
512+
{
513+
514+
QWidget* homeTab = new QWidget;
515+
QVBoxLayout* homeLayout = new QVBoxLayout;
516+
QLabel* homeLabel = new QLabel("Create new score");
517+
homeLayout->addWidget(homeLabel);
518+
homeTab->setLayout(homeLayout);
519+
520+
QWidget* learnTab = new QWidget;
521+
QVBoxLayout* learnLayout = new QVBoxLayout;
522+
QLabel* learnLabel = new QLabel("Browse examples");
523+
learnLayout->addWidget(learnLabel);
524+
learnTab->setLayout(learnLayout);
525+
526+
QWidget* communityTab = new QWidget;
527+
QVBoxLayout* communityLayout = new QVBoxLayout;
528+
QLabel* communityLabel = new QLabel("Get Involved");
529+
communityLayout->addWidget(communityLabel);
530+
communityTab->setLayout(communityLayout);
531+
532+
// Add tabs to the QTabWidget
533+
tabWidget->addTab(homeTab, QIcon(":/icons/home_icon.png"), "Home");
534+
tabWidget->addTab(learnTab, QIcon(":/icons/learn_icon.png"), "Learn");
535+
tabWidget->addTab(communityTab, QIcon(":/icons/community_icon.png"), "Community");
536+
537+
tabWidget->setTabPosition(QTabWidget::West); // Tabs clickable from the left
538+
}
539+
482540
void StartScreen::addLoadCrashedSession()
483541
{
484542
m_crashLabel->show();
@@ -489,7 +547,7 @@ void StartScreen::addLoadCrashedSession()
489547
void StartScreen::paintEvent(QPaintEvent* event)
490548
{
491549
QPainter painter(this);
492-
painter.drawPixmap(0, 0, m_background);
550+
painter.fillRect(rect(), Qt::black);
493551
}
494552

495553
void StartScreen::keyPressEvent(QKeyEvent* event)

0 commit comments

Comments
 (0)