| 663 | }; |
| 664 | |
| 665 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow::Ui) |
| 666 | { |
| 667 | ui->setupUi(this); |
| 668 | |
| 669 | // OSX magic. |
| 670 | setUnifiedTitleAndToolBarOnMac(true); |
| 671 | |
| 672 | // Global shortcuts |
| 673 | { |
| 674 | // FIXME: This is kinda weird. and bad. We need some kind of managed shutdown. |
| 675 | auto q = new QShortcut(QKeySequence::Quit, this); |
| 676 | connect(q, SIGNAL(activated()), qApp, SLOT(quit())); |
| 677 | } |
| 678 | |
| 679 | // Konami Code |
| 680 | { |
| 681 | secretEventFilter = new KonamiCode(this); |
| 682 | connect(secretEventFilter, &KonamiCode::triggered, this, &MainWindow::konamiTriggered); |
| 683 | } |
| 684 | |
| 685 | // Add the news label to the news toolbar. |
| 686 | { |
| 687 | m_newsChecker.reset(new NewsChecker(APPLICATION->network(), BuildConfig.NEWS_RSS_URL)); |
| 688 | newsLabel = new QToolButton(); |
| 689 | newsLabel->setIcon(APPLICATION->getThemedIcon("news")); |
| 690 | newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
| 691 | newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
| 692 | newsLabel->setFocusPolicy(Qt::NoFocus); |
| 693 | ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel); |
| 694 | QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked); |
| 695 | QObject::connect(m_newsChecker.get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel); |
| 696 | updateNewsLabel(); |
| 697 | } |
| 698 | |
| 699 | // Create the instance list widget |
| 700 | { |
| 701 | view = new InstanceView(ui->centralWidget); |
| 702 | |
| 703 | view->setSelectionMode(QAbstractItemView::SingleSelection); |
| 704 | // FIXME: leaks ListViewDelegate |
| 705 | view->setItemDelegate(new ListViewDelegate(this)); |
| 706 | view->setFrameShape(QFrame::NoFrame); |
| 707 | // do not show ugly blue border on the mac |
| 708 | view->setAttribute(Qt::WA_MacShowFocusRect, false); |
| 709 | |
| 710 | view->installEventFilter(this); |
| 711 | view->setContextMenuPolicy(Qt::CustomContextMenu); |
| 712 | connect(view, &QWidget::customContextMenuRequested, this, &MainWindow::showInstanceContextMenu); |
| 713 | connect(view, &InstanceView::droppedURLs, this, &MainWindow::droppedURLs, Qt::QueuedConnection); |
| 714 | |
| 715 | proxymodel = new InstanceProxyModel(this); |
| 716 | proxymodel->setSourceModel(APPLICATION->instances().get()); |
| 717 | proxymodel->sort(0); |
| 718 | connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged); |
| 719 | |
| 720 | view->setModel(proxymodel); |
| 721 | view->setSourceOfGroupCollapseStatus([](const QString & groupName)->bool { |
| 722 | return APPLICATION->instances()->isGroupCollapsed(groupName); |
nothing calls this directly
no test coverage detected