Example #1
0
void
MainWindow::addTrackerToList(Backend *newTracker, bool sync)
{
    qDebug() << "Adding tracker to list";
    if (pDetectorProgress != NULL)
    {
        pDetectorProgress->reset();
        pDetectorProgress->hide();
    }

    connect(this, SIGNAL(reloadFromDatabase()),
            newTracker->displayWidget(), SLOT(reloadFromDatabase()));
    connect(this, SIGNAL(setShowOptions(bool,bool,bool,bool)),
            newTracker->displayWidget(), SLOT(setShowOptions(bool,bool,bool,bool)));
    connect(newTracker->displayWidget(), SIGNAL(bugChanged()),
            this, SLOT(toggleButtons()));
    int newIndex = ui->trackerTab->insertTab(0, newTracker->displayWidget(), newTracker->name());
    pSearchTab->addTracker(newTracker);
    filterTable();

    QString iconPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    iconPath.append(QDir::separator()).append("entomologist");
    iconPath.append(QDir::separator()).append(QString("%1.png").arg(newTracker->name()));
    ui->trackerTab->setTabIcon(newIndex, QIcon(iconPath));
    ui->trackerTab->setCurrentIndex(newIndex);
    mBackendMap[newTracker->id()] = newTracker;
    mBackendList.append(newTracker);
    if(!QFile::exists(iconPath))
        fetchIcon(newTracker->url(), iconPath, newTracker->username(), newTracker->password());
    if (sync)
        syncTracker(newTracker);
}
Example #2
0
void
MainWindow::stopAnimation()
{
    pSpinnerMovie->stop();
    refreshButton->setEnabled(true);
    ui->menuShow->setEnabled(true);
    ui->action_Add_Tracker->setEnabled(true);
    ui->action_Preferences->setEnabled(true);
    ui->action_Work_Offline->setEnabled(true);
    ui->spinnerLabel->hide();
    ui->syncingLabel->hide();
    ui->splitter_2->setEnabled(true);

    for(int i = 0; i < ui->trackerTab->count(); i++)
    {
        ui->trackerTab->setTabEnabled(i, true);
    }

    toggleButtons();
}
Example #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    pDetectorProgress = NULL;
    mLogAllXmlRpcOutput = false;
    mDbUpdated = false;
    // mSyncRequests tracks how many sync requests have been made
    // in order to know when to re-enable the widgets
    mSyncRequests = 0;
    // mSyncPosition is used to iterate through the backend list,
    // so we only sync one repository at a time, rather than flinging
    // requests at all of them at once.
    mSyncPosition = 0;
    mUploading = false;
    QSettings settings("Entomologist");

    pManager = new QNetworkAccessManager();
    connect(pManager, SIGNAL(sslErrors(QNetworkReply *, const QList<QSslError> &)),
            this, SLOT(handleSslErrors(QNetworkReply *, const QList<QSslError> &)));

    ui->setupUi(this);

    QToolBar *toolBar = new QToolBar("Main Toolbar");
    toolBar->setObjectName("Main ToolBar");
    toolBar->setIconSize(QSize(32,32));
    refreshButton = toolBar->addAction(style()->standardIcon(QStyle::SP_BrowserReload), "");
    refreshButton->setToolTip("Resync all trackers");
    uploadButton = toolBar->addAction(style()->standardIcon(QStyle::SP_ArrowUp), "");
    uploadButton->setToolTip("Upload changes");
    changelogButton = toolBar->addAction(style()->standardIcon(QStyle::SP_FileDialogInfoView), "");
    changelogButton->setToolTip("Show changelog");
    toolBar->setMovable(false);
    addToolBar(Qt::TopToolBarArea, toolBar);


    setupTrayIcon();
    // Setup the "Show" menu and "Work Offline"
    ui->actionMy_Bugs->setChecked(settings.value("show-my-bugs", true).toBool());
    ui->actionMy_Reports->setChecked(settings.value("show-my-reports", true).toBool());
    ui->actionMy_CCs->setChecked(settings.value("show-my-ccs", true).toBool());
    ui->actionMonitored_Components->setChecked(settings.value("show-my-monitored", true).toBool());
    ui->action_Work_Offline->setChecked(settings.value("work-offline", false).toBool());

    // Set the default network status
    pStatusIcon = new QLabel();
    pStatusIcon->setPixmap(QPixmap(":/online"));
    pStatusMessage = new QLabel("");
    ui->statusBar->addPermanentWidget(pStatusMessage);
    ui->statusBar->addPermanentWidget(pStatusIcon);

    // We use a spinner animation to show that we're doing things
    pSpinnerMovie = new QMovie(this);
    pSpinnerMovie->setFileName(":/spinner");
    pSpinnerMovie->setScaledSize(QSize(48,48));
    ui->spinnerLabel->setMovie(pSpinnerMovie);
    ui->spinnerLabel->hide();
    ui->syncingLabel->hide();

    // Set up the resync timer
    pUpdateTimer = new QTimer(this);
    connect(pUpdateTimer, SIGNAL(timeout()),
            this, SLOT(resync()));
    setTimer();

    // Keyboard shortcuts for search bar focus / upload changes.
    QShortcut* searchFocus;
    QShortcut* uploadChange;
    QShortcut *logXmlRpc;

    searchFocus = new QShortcut(QKeySequence(Qt::META + Qt::Key_Space),this);
    searchFocus->setContext(Qt::ApplicationShortcut);
    connect(searchFocus,SIGNAL(activated()),this,SLOT(searchFocusTriggered()));

    uploadChange = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S),this);
    uploadChange->setContext(Qt::ApplicationShortcut);
    connect(uploadChange,SIGNAL(activated()),this,SLOT(upload()));

    logXmlRpc = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0), this);
    logXmlRpc->setContext(Qt::ApplicationShortcut);
    connect(logXmlRpc, SIGNAL(activated()), this, SLOT(toggleXmlRpcLogging()));

    // Menu actions
    connect(ui->action_Add_Tracker, SIGNAL(triggered()),
            this, SLOT(addTrackerTriggered()));
    connect(ui->action_Refresh_Tracker,SIGNAL(triggered()),
            this, SLOT(resync()));
    connect(ui->actionShow_ToDo_List, SIGNAL(triggered()),
            this, SLOT(showTodoList()));
    connect(ui->action_About, SIGNAL(triggered()),
            this, SLOT(aboutTriggered()));
    connect(ui->action_Web_Site, SIGNAL(triggered()),
            this, SLOT(websiteTriggered()));
    connect(ui->action_Preferences, SIGNAL(triggered()),
            this, SLOT(prefsTriggered()));
    connect(ui->action_Quit, SIGNAL(triggered()),
            this, SLOT(quitEvent()));
    connect(ui->actionMy_Bugs, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionMy_CCs, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionMy_Reports, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionMonitored_Components, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionEdit_Monitored_Components, SIGNAL(triggered()),
            this, SLOT(showEditMonitoredComponents()));
    connect(ui->action_Work_Offline, SIGNAL(triggered()),
            this, SLOT(workOfflineTriggered()));

    // Set up the search button
    connect(changelogButton, SIGNAL(triggered()),
            this, SLOT(changelogTriggered()));

    connect(ui->trackerTab, SIGNAL(showMenu(int)),
            this, SLOT(showMenu(int)));
    ui->trackerTab->removeTab(0);
    ui->trackerTab->removeTab(0);

    // And finally set up the various other widgets
    connect(refreshButton, SIGNAL(triggered()),
            this, SLOT(resync()));
    connect(uploadButton, SIGNAL(triggered()),
            this, SLOT(upload()));
    restoreGeometry(settings.value("window-geometry").toByteArray());
    // Set the network status bar and check for updates if possible
    if (isOnline())
        if (settings.value("update-check", true).toBool() == true)
            checkForUpdates();

    setupDB();
    toggleButtons();

    // Now we need the todo list widget
    pToDoDock = new QDockWidget(tr("ToDo List"), this);
    pToDoDock->setObjectName("ToDoDock");
    pToDoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    pToDoListWidget = new ToDoListWidget(pToDoDock);
    pToDoDock->setWidget(pToDoListWidget);
    addDockWidget(Qt::LeftDockWidgetArea, pToDoDock);
    pToDoDock->hide();
    restoreState(settings.value("entomologist-state").toByteArray());
    connect(pToDoDock, SIGNAL(visibilityChanged(bool)),
            this, SLOT(dockVisibilityChanged(bool)));
    if (pToDoDock->isVisible())
        ui->actionShow_ToDo_List->setText("Hide ToDo List");
    else
        ui->actionShow_ToDo_List->setText("Show ToDo List");

    pSearchTab = new SearchTab(this);
    connect(pSearchTab, SIGNAL(openSearchedBug(QString,QString)),
            this, SLOT(openSearchedBug(QString,QString)));

    loadTrackers();
    ui->trackerTab->addTab(pSearchTab, QIcon(":/search"), "Search");

    if ((settings.value("startup-sync", false).toBool() == true)
       || (mDbUpdated))
        syncNextTracker();
}
Example #4
0
int handleButtonClicked_aiSettingsWindow(SDL_Event e){
	Button *lst = currentPage.btnList;
	int len = currentPage.btnListLen;
	Button curr;
	Button prev;
	int quit = 0;
	int isSuccess = 1;

	for (int i = 0; i < len; i++){
		curr = lst[i];
		char path[100];
		if (isClickInRect(e, curr.buttonsDestRect) == 1){
			if (curr.id >= 1 && curr.id <= 5){
				// a difficulty was chosen
				int isSuccess = 1;
				if (userGuiSettings.difficulty != 0){
					// need to deselect the prevButton
					int difficulty = userGuiSettings.difficulty == BEST ? 5 : userGuiSettings.difficulty;
					Button prevChosenButton = getButtonAccordingToId(lst, len, difficulty);
					sprintf(path, "%s%d%s", SLOT_BTN_URL, difficulty, "_btn.bmp");
					isSuccess = deselectButton(path, prevChosenButton);
				}
				if (isSuccess == 1){
					userGuiSettings.difficulty = curr.id < 5 ? curr.id : BEST;
					sprintf(path,"%s%d%s", SLOT_SELECTED_BTN_URL, curr.id, "_btn.bmp");
					if (userGuiSettings.difficulty == BEST){
						isSuccess = selectButton(BEST_SELECTED_BTN_URL, curr);
					}
					else{
						isSuccess = selectButton(path, curr);
					}
				}
				quit = !isSuccess;
			}
			else{
				switch (curr.id){
				case 6:
					userGuiSettings.isUserColorBlack = 1;
					prev = getButtonAccordingToId(lst, len, 7);
					isSuccess = toggleButtons(prev, curr, WHITE_BTN_URL, BLACK_SELECTED_BTN_URL);
					break;
				case 7:
					userGuiSettings.isUserColorBlack = 0;
					prev = getButtonAccordingToId(lst, len, 6);
					isSuccess = toggleButtons(prev, curr, BLACK_BTN_URL, WHITE_SELECTED_BTN_URL);
					break;
				case 8:
					isSuccess = navigatToPage("mainMenu");
					break;
				case 9:
					saveSettings(0);
					if (userGuiSettings.isSetBoard == 1){
						// navigate to set board window
						quit = 3;
					}
					else{
						// navigate to start game window
						quit = 2;
					}
					break;
				}
			}

			break;
		}
	}

	quit = quit != 0 ? quit : !isSuccess;
	return quit;

}
Example #5
0
int handleButtonClicked_selectionWindow(SDL_Event e){
	Button *lst = currentPage.btnList;
	int len = currentPage.btnListLen;
	Button curr;
	Button prev;
	int quit = 0;
	int isSuccess = 1;

	for (int i = 0; i < len; i++){
		curr = lst[i];
		if (isClickInRect(e, curr.buttonsDestRect) == 1){
			switch (curr.id)
			{
			case 1:
				// user choose player vs. player
				userGuiSettings.gameMode = TWO_PLAYERS;
				prev = getButtonAccordingToId(lst, len, 2);
				isSuccess = toggleButtons(prev, curr, AGAINS_COMPUTER_BTN_URL, TWO_PLAYERS_SELECTED_BTN_URL);

				break;
			case 2:
				// user choose player vs. AI
				userGuiSettings.gameMode = PLAYER_VS_AI;
				prev = getButtonAccordingToId(lst, len, 1);
				isSuccess = toggleButtons(prev, curr, TWO_PLAYERS_BTN_URL, AGAINS_COMPUTER_SELECTED_BTN_URL);
				break;
			case 4:
				// user choose next player black
				userGuiSettings.isNextPlayerBlack = 1;
				prev = getButtonAccordingToId(lst, len, 3);
				isSuccess = toggleButtons(prev, curr, WHITE_BTN_URL, BLACK_SELECTED_BTN_URL);
				break;
			case 3:
				// user choose next player white
				userGuiSettings.isNextPlayerBlack = 0;
				prev = getButtonAccordingToId(lst, len, 4);
				isSuccess = toggleButtons(prev, curr, BLACK_BTN_URL, WHITE_SELECTED_BTN_URL);
				break;
			case 5:
				// user choose to set board
				userGuiSettings.isSetBoard = 0;
				prev = getButtonAccordingToId(lst, len, 6);
				isSuccess = toggleButtons(prev, curr, YES_BTN_URL, NO_SELECTED_BTN_URL);
				break;
			case 6:
				// user choose not to set board
				userGuiSettings.isSetBoard = 1;
				prev = getButtonAccordingToId(lst, len, 5);
				isSuccess = toggleButtons(prev, curr, NO_BTN_URL, YES_SELECTED_BTN_URL);
				break;
			case 7:
				// user choose to cancel and return to the main menu
				isSuccess = navigatToPage("mainMenu");
				break;
			case 8:
				// user choose to aplly settings and continue to next step
				saveSettings(1);
				if (userGuiSettings.gameMode == PLAYER_VS_AI){
					// navigate to AI settings window
					isSuccess = navigatToPage("aiSettingsWindow");
				}
				else if(userGuiSettings.isSetBoard){
					// navigate to set board
					quit = 3;
				}
				else{
					// navigate to start game window
					quit = 2;
				}
				break;
			}

			break;
		}
	}

	quit = quit != 0 ? quit : !isSuccess;
	return quit;

}
void PageFinish::show()
{
	emit toggleButtons(false);
}