| 915 | }; |
| 916 | |
| 917 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow::Ui) |
| 918 | { |
| 919 | ui->setupUi(this); |
| 920 | |
| 921 | // OSX magic. |
| 922 | setUnifiedTitleAndToolBarOnMac(true); |
| 923 | |
| 924 | // Global shortcuts |
| 925 | { |
| 926 | // FIXME: This is kinda weird. and bad. We need some kind of managed shutdown. |
| 927 | auto q = new QShortcut(QKeySequence::Quit, this); |
| 928 | connect(q, SIGNAL(activated()), qApp, SLOT(quit())); |
| 929 | } |
| 930 | |
| 931 | // Konami Code |
| 932 | { |
| 933 | secretEventFilter = new KonamiCode(this); |
| 934 | connect(secretEventFilter, &KonamiCode::triggered, this, &MainWindow::konamiTriggered); |
| 935 | } |
| 936 | |
| 937 | // Add the news label to the news toolbar. |
| 938 | { |
| 939 | m_newsChecker.reset(new NewsChecker(APPLICATION->network(), BuildConfig.NEWS_RSS_URL)); |
| 940 | newsLabel = new QToolButton(); |
| 941 | newsLabel->setIcon(APPLICATION->getThemedIcon("news")); |
| 942 | newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
| 943 | newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
| 944 | newsLabel->setFocusPolicy(Qt::NoFocus); |
| 945 | ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel); |
| 946 | QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked); |
| 947 | QObject::connect(m_newsChecker.get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel); |
| 948 | updateNewsLabel(); |
| 949 | } |
| 950 | |
| 951 | // Create the instance list widget |
| 952 | { |
| 953 | view = new InstanceView(ui->centralWidget); |
| 954 | |
| 955 | view->setSelectionMode(QAbstractItemView::SingleSelection); |
| 956 | // FIXME: leaks ListViewDelegate |
| 957 | view->setItemDelegate(new ListViewDelegate(this)); |
| 958 | view->setFrameShape(QFrame::NoFrame); |
| 959 | // do not show ugly blue border on the mac |
| 960 | view->setAttribute(Qt::WA_MacShowFocusRect, false); |
| 961 | |
| 962 | view->installEventFilter(this); |
| 963 | view->setContextMenuPolicy(Qt::CustomContextMenu); |
| 964 | connect(view, &QWidget::customContextMenuRequested, this, &MainWindow::showInstanceContextMenu); |
| 965 | connect(view, &InstanceView::droppedURLs, this, &MainWindow::droppedURLs, Qt::QueuedConnection); |
| 966 | |
| 967 | proxymodel = new InstanceProxyModel(this); |
| 968 | proxymodel->setSourceModel(APPLICATION->instances().get()); |
| 969 | proxymodel->sort(0); |
| 970 | connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged); |
| 971 | |
| 972 | view->setModel(proxymodel); |
| 973 | view->setSourceOfGroupCollapseStatus([](const QString & groupName)->bool { |
| 974 | return APPLICATION->instances()->isGroupCollapsed(groupName); |
nothing calls this directly
no test coverage detected