| 111 | |
| 112 | |
| 113 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { |
| 114 | ui->setupUi(this); |
| 115 | |
| 116 | // Register custom types. |
| 117 | qRegisterMetaType<NymphPlaybackStatus>("NymphPlaybackStatus"); |
| 118 | qRegisterMetaType<NymphPlaybackStatus>("NCRemoteInstance"); |
| 119 | qRegisterMetaType<NymphPlaybackStatus>("NCRemoteGroup"); |
| 120 | qRegisterMetaType<uint32_t>("uint32_t"); |
| 121 | |
| 122 | // Set application options. |
| 123 | QCoreApplication::setOrganizationName("Nyanko"); |
| 124 | QCoreApplication::setApplicationName("NymphCastPlayer"); |
| 125 | //QCoreApplication::setApplicationVersion("v0.1"); |
| 126 | QCoreApplication::setApplicationVersion(STR(__NCVERSION)); |
| 127 | |
| 128 | // Set location for user data. |
| 129 | appDataLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); |
| 130 | |
| 131 | // Set configured or default stylesheet. Read out current value. |
| 132 | // Skip stylesheet if file isn't found. |
| 133 | QSettings settings; |
| 134 | if (!settings.contains("stylesheet")) { |
| 135 | settings.setValue("stylesheet", "default.css"); |
| 136 | } |
| 137 | |
| 138 | QString sFile = settings.value("stylesheet", "default.css").toString(); |
| 139 | |
| 140 | if (!QFile::exists(sFile)) { |
| 141 | // Use stylesheet from resource bundle. |
| 142 | std::cout << "Using stylesheet from resources." << std::endl; |
| 143 | sFile = ":/css/default.css"; |
| 144 | } |
| 145 | |
| 146 | QFile file(sFile); |
| 147 | if (file.exists()) { |
| 148 | file.open(QIODevice::ReadOnly); |
| 149 | QString ssheet = QString::fromLocal8Bit(file.readAll()); |
| 150 | setStyleSheet(ssheet); |
| 151 | } |
| 152 | else { |
| 153 | std::cerr << "Stylesheet file " << sFile.toStdString() << " not found." << std::endl; |
| 154 | } |
| 155 | |
| 156 | // Set up UI connections. |
| 157 | // Menu |
| 158 | connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit())); |
| 159 | connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); |
| 160 | connect(ui->actionFile, SIGNAL(triggered()), this, SLOT(castFile())); |
| 161 | connect(ui->actionURL, SIGNAL(triggered()), this, SLOT(castUrl())); |
| 162 | connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(savePlaylist())); |
| 163 | connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(loadPlaylist())); |
| 164 | connect(ui->actionClear, SIGNAL(triggered()), this, SLOT(clearPlaylist())); |
| 165 | connect(ui->actionManageGroups, SIGNAL(triggered()), this, SLOT(openRemotesDialog())); |
| 166 | connect(ui->actionManageCustom, SIGNAL(triggered()), this, SLOT(openCustomRemotesDialog())); |
| 167 | |
| 168 | // UI |
| 169 | connect(ui->editRemotesButton, SIGNAL(clicked()), this, SLOT(openRemotesDialog())); |
| 170 | connect(ui->refreshRemotesButton, SIGNAL(clicked()), this, SLOT(remoteListRefresh())); |
nothing calls this directly
no test coverage detected