comparison installer.cpp @ 84:e77bcf5caedd

Some layout & text tweaks
author Chris Cannam
date Wed, 26 Feb 2020 13:27:02 +0000
parents 66a22cdbb50c
children bdd4317e43de
comparison
equal deleted inserted replaced
83:66a22cdbb50c 84:e77bcf5caedd
509 switch (status) { 509 switch (status) {
510 case RelativeStatus::New: return QObject::tr("Not yet installed"); 510 case RelativeStatus::New: return QObject::tr("Not yet installed");
511 case RelativeStatus::Same: return QObject::tr("Already installed"); 511 case RelativeStatus::Same: return QObject::tr("Already installed");
512 case RelativeStatus::Upgrade: return QObject::tr("Update"); 512 case RelativeStatus::Upgrade: return QObject::tr("Update");
513 case RelativeStatus::Downgrade: return QObject::tr("Newer version installed"); 513 case RelativeStatus::Downgrade: return QObject::tr("Newer version installed");
514 case RelativeStatus::TargetNotLoadable: return QObject::tr("<unknown>"); 514 case RelativeStatus::TargetNotLoadable: return QObject::tr("Installed version not working");
515 default: return {}; 515 default: return {};
516 } 516 }
517 } 517 }
518 518
519 RelativeStatus 519 RelativeStatus
620 getUserApprovedPluginLibraries(vector<LibraryInfo> libraries, 620 getUserApprovedPluginLibraries(vector<LibraryInfo> libraries,
621 QString targetDir) 621 QString targetDir)
622 { 622 {
623 QDialog dialog; 623 QDialog dialog;
624 624
625 int fontHeight = QFontMetrics(dialog.font()).height();
626 int dpratio = dialog.devicePixelRatio();
627
625 auto mainLayout = new QGridLayout; 628 auto mainLayout = new QGridLayout;
626 mainLayout->setSpacing(0); 629 mainLayout->setSpacing(0);
627 dialog.setLayout(mainLayout); 630 dialog.setLayout(mainLayout);
628 631
629 int mainRow = 0; 632 int mainRow = 0;
631 auto selectionFrame = new QWidget; 634 auto selectionFrame = new QWidget;
632 mainLayout->addWidget(selectionFrame, mainRow, 0); 635 mainLayout->addWidget(selectionFrame, mainRow, 0);
633 ++mainRow; 636 ++mainRow;
634 637
635 auto selectionLayout = new QGridLayout; 638 auto selectionLayout = new QGridLayout;
639 selectionLayout->setContentsMargins(0, 0, 0, 0);
640 selectionLayout->setSpacing(fontHeight / 6);
636 selectionFrame->setLayout(selectionLayout); 641 selectionFrame->setLayout(selectionLayout);
642
637 int selectionRow = 0; 643 int selectionRow = 0;
644 int checkColumn = 0;
645 int titleColumn = 1;
646 int statusColumn = 2;
647 int infoColumn = 3;
638 648
639 selectionLayout->addWidget 649 selectionLayout->addWidget
640 (new QLabel(QObject::tr("<b>Vamp Plugin Pack</b> v%1") 650 (new QLabel(QObject::tr("<b>Vamp Plugin Pack</b> v%1")
641 .arg(PACK_VERSION)), 651 .arg(PACK_VERSION)),
642 selectionRow, 1); 652 selectionRow, titleColumn, 1, 3);
643 ++selectionRow; 653 ++selectionRow;
644 654
645 selectionLayout->addWidget 655 selectionLayout->addWidget
646 (new QLabel(QObject::tr("Select the plugin libraries to install:")), 656 (new QLabel(QObject::tr("Select the plugin libraries to install:")),
647 selectionRow, 1, 1, 3); 657 selectionRow, titleColumn, 1, 3);
648 ++selectionRow; 658 ++selectionRow;
649 659
650 auto checkAll = new QCheckBox; 660 auto checkAll = new QCheckBox;
651 checkAll->setChecked(true); 661 checkAll->setChecked(true);
652 selectionLayout->addWidget(checkAll, selectionRow, 0, Qt::AlignHCenter); 662 selectionLayout->addWidget
663 (checkAll, selectionRow, checkColumn, Qt::AlignHCenter);
653 ++selectionRow; 664 ++selectionRow;
654 665
655 auto checkArrow = new QLabel("&#9660;"); 666 auto checkArrow = new QLabel("&#9660;");
656 checkArrow->setTextFormat(Qt::RichText); 667 checkArrow->setTextFormat(Qt::RichText);
657 selectionLayout->addWidget(checkArrow, selectionRow, 0, Qt::AlignHCenter); 668 selectionLayout->addWidget
669 (checkArrow, selectionRow, checkColumn, Qt::AlignHCenter);
658 ++selectionRow; 670 ++selectionRow;
659 671
660 map<QString, QCheckBox *> checkBoxMap; // filename -> checkbox 672 map<QString, QCheckBox *> checkBoxMap; // filename -> checkbox
661 map<QString, LibraryInfo> libFileInfo; // filename -> info 673 map<QString, LibraryInfo> libFileInfo; // filename -> info
662 map<QString, RelativeStatus> statuses; // filename -> status 674 map<QString, RelativeStatus> statuses; // filename -> status
668 }); 680 });
669 for (auto info: libraries) { 681 for (auto info: libraries) {
670 orderedInfo[info.title] = info; 682 orderedInfo[info.title] = info;
671 } 683 }
672 684
673 int fontHeight = QFontMetrics(checkArrow->font()).height();
674 int dpratio = dialog.devicePixelRatio();
675
676 QPixmap infoMap(fontHeight * dpratio, fontHeight * dpratio); 685 QPixmap infoMap(fontHeight * dpratio, fontHeight * dpratio);
677 QPixmap moreMap(fontHeight * dpratio * 2, fontHeight * dpratio * 2); 686 QPixmap moreMap(fontHeight * dpratio * 2, fontHeight * dpratio * 2);
678 infoMap.fill(Qt::transparent); 687 infoMap.fill(Qt::transparent);
679 moreMap.fill(Qt::transparent); 688 moreMap.fill(Qt::transparent);
680 QSvgRenderer renderer(QString(":icons/scalable/info.svg")); 689 QSvgRenderer renderer(QString(":icons/scalable/info.svg"));
693 }; 702 };
694 703
695 for (auto ip: orderedInfo) { 704 for (auto ip: orderedInfo) {
696 705
697 auto cb = new QCheckBox; 706 auto cb = new QCheckBox;
698 selectionLayout->addWidget(cb, selectionRow, 0, Qt::AlignHCenter); 707 selectionLayout->addWidget
708 (cb, selectionRow, checkColumn, Qt::AlignHCenter);
699 709
700 LibraryInfo info = ip.second; 710 LibraryInfo info = ip.second;
701 711
702 auto shortLabel = new QLabel(info.title); 712 auto shortLabel = new QLabel(info.title);
703 selectionLayout->addWidget(shortLabel, selectionRow, 1); 713 selectionLayout->addWidget(shortLabel, selectionRow, titleColumn);
704 714
705 RelativeStatus relativeStatus = getRelativeStatus(info, targetDir); 715 RelativeStatus relativeStatus = getRelativeStatus(info, targetDir);
706 auto statusLabel = new QLabel(relativeStatusLabel(relativeStatus)); 716 auto statusLabel = new QLabel(relativeStatusLabel(relativeStatus));
707 selectionLayout->addWidget(statusLabel, selectionRow, 2); 717 selectionLayout->addWidget(statusLabel, selectionRow, statusColumn);
708 cb->setChecked(shouldCheck(relativeStatus)); 718 cb->setChecked(shouldCheck(relativeStatus));
709 719
710 auto infoButton = new QToolButton; 720 auto infoButton = new QToolButton;
711 infoButton->setAutoRaise(true); 721 infoButton->setAutoRaise(true);
712 infoButton->setIcon(infoMap); 722 infoButton->setIcon(infoMap);
716 infoButton->setFixedSize(QSize(int(fontHeight * 1.2), 726 infoButton->setFixedSize(QSize(int(fontHeight * 1.2),
717 int(fontHeight * 1.2))); 727 int(fontHeight * 1.2)));
718 infoButton->setStyleSheet("QToolButton { border: none; }"); 728 infoButton->setStyleSheet("QToolButton { border: none; }");
719 #endif 729 #endif
720 730
721 selectionLayout->addWidget(infoButton, selectionRow, 3); 731 selectionLayout->addWidget(infoButton, selectionRow, infoColumn);
722 732
723 ++selectionRow; 733 ++selectionRow;
724 734
725 QString moreTitleText = QObject::tr("<b>%1</b><br><i>%2</i>") 735 QString moreTitleText = QObject::tr("<b>%1</b><br><i>%2</i>")
726 .arg(info.title) 736 .arg(info.title)
779 selectionRow, 0); 789 selectionRow, 0);
780 ++selectionRow; 790 ++selectionRow;
781 791
782 selectionLayout->addWidget 792 selectionLayout->addWidget
783 (new QLabel(QObject::tr("Installation will be to: %1").arg(targetDir)), 793 (new QLabel(QObject::tr("Installation will be to: %1").arg(targetDir)),
784 selectionRow, 1, 1, 3); 794 selectionRow, titleColumn, 1, 3);
785 ++selectionRow; 795 ++selectionRow;
786 796
787 QObject::connect(checkAll, &QCheckBox::toggled, 797 QObject::connect(checkAll, &QCheckBox::toggled,
788 [=](bool toCheck) { 798 [=](bool toCheck) {
789 for (auto p: checkBoxMap) { 799 for (auto p: checkBoxMap) {