6
6
7
7
#include < QApplication>
8
8
#include < QDesktopServices>
9
+ #include < QIcon>
9
10
#include < QKeyEvent>
10
11
#include < QLabel>
11
12
#include < QNetworkAccessManager>
15
16
#include < QPixmap>
16
17
#include < QPointer>
17
18
#include < QSettings>
19
+ #include < QSplitter>
20
+ #include < QTabWidget>
18
21
#include < QTextLayout>
22
+ #include < QVBoxLayout>
19
23
20
24
#include < score_git_info.hpp>
21
25
@@ -265,6 +269,7 @@ class StartScreen : public QWidget
265
269
void exitApp() W_SIGNAL(exitApp)
266
270
267
271
void addLoadCrashedSession();
272
+ void setupTabs ();
268
273
269
274
protected:
270
275
void paintEvent (QPaintEvent* event) override ;
@@ -273,6 +278,7 @@ class StartScreen : public QWidget
273
278
private:
274
279
QPixmap m_background;
275
280
InteractiveLabel* m_crashLabel{};
281
+ QTabWidget* tabWidget;
276
282
};
277
283
struct StartScreenLink
278
284
{
@@ -293,26 +299,46 @@ struct StartScreenLink
293
299
StartScreen::StartScreen (const QPointer<QRecentFilesMenu>& recentFiles, QWidget* parent)
294
300
: QWidget(parent)
295
301
{
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
+
296
324
// Workaround until https://bugreports.qt.io/browse/QTBUG-103225 is fixed
297
325
#if defined(__APPLE__)
298
326
static constexpr double font_factor = 96 . / 72 .;
299
327
#else
300
328
static constexpr double font_factor = 1 .;
301
329
#endif
302
- QFont f (" Ubuntu" , 14 * font_factor, QFont::Light);
330
+ QFont f (" Ubuntu" , 14 * font_factor, QFont::Light);
303
331
f.setHintingPreference (QFont::HintingPreference::PreferFullHinting);
304
332
f.setStyleStrategy (QFont::PreferAntialias);
305
333
306
- QFont titleFont (" Montserrat" , 14 * font_factor, QFont::DemiBold);
334
+ QFont titleFont (" Montserrat" , 14 * font_factor, QFont::DemiBold);
307
335
titleFont.setHintingPreference (QFont::HintingPreference::PreferFullHinting);
308
336
titleFont.setStyleStrategy (QFont::PreferAntialias);
309
337
310
338
this ->setEnabled (true );
311
339
setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); // | Qt::WindowStaysOnTopHint);
312
340
setWindowModality (Qt::ApplicationModal);
313
341
314
- m_background = score::get_pixmap (" :/startscreen/startscreensplash.png" );
315
-
316
342
if (QPainter painter; painter.begin (&m_background))
317
343
{
318
344
painter.setRenderHint (QPainter::Antialiasing, true );
@@ -326,7 +352,8 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
326
352
}
327
353
328
354
// 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 );
330
357
331
358
{
332
359
// new version
@@ -350,10 +377,11 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
350
377
label->move (280 , 170 );
351
378
label->show ();
352
379
}
353
- }, [] {}};
380
+ },
381
+ [] {}};
354
382
}
355
383
356
- float label_x = 300 ;
384
+ float label_x = 50 ;
357
385
float label_y = 215 ;
358
386
359
387
{ // recent files
@@ -404,7 +432,7 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
404
432
m_crashLabel, &score::InteractiveLabel::labelPressed, this ,
405
433
&score::StartScreen::loadCrashedSession);
406
434
407
- label_x = 510 ;
435
+ label_x = 310 ;
408
436
label_y = 215 ;
409
437
{ // Create new
410
438
InteractiveLabel* label = new InteractiveLabel{titleFont, qApp->tr (" New" ), " " , this };
@@ -433,7 +461,8 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
433
461
QSettings settings;
434
462
auto library_path = settings.value (" Library/RootPath" ).toString ();
435
463
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 };
437
466
label->setPixmaps (
438
467
score::get_pixmap (" :/icons/load_examples_off.png" ),
439
468
score::get_pixmap (" :/icons/load_examples_on.png" ));
@@ -479,6 +508,35 @@ StartScreen::StartScreen(const QPointer<QRecentFilesMenu>& recentFiles, QWidget*
479
508
}
480
509
}
481
510
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
+
482
540
void StartScreen::addLoadCrashedSession ()
483
541
{
484
542
m_crashLabel->show ();
@@ -489,7 +547,7 @@ void StartScreen::addLoadCrashedSession()
489
547
void StartScreen::paintEvent (QPaintEvent* event)
490
548
{
491
549
QPainter painter (this );
492
- painter.drawPixmap ( 0 , 0 , m_background );
550
+ painter.fillRect ( rect (), Qt::black );
493
551
}
494
552
495
553
void StartScreen::keyPressEvent (QKeyEvent* event)
0 commit comments