void LogWorker::readLog() { QFile logFile(logPath); if(!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "LogWorker: "<< "Esperando a log accesible..."; emit sendLog(tr("Log: ERROR:Cannot open log...")); return; } logFile.seek(logSeek); char line[2048]; int lineLenght; while((lineLenght = logFile.readLine(line, sizeof(line))) > 0) { if((line[lineLenght-1] != '\n') && lineLenght<((int)sizeof(line)-1)) { // qDebug() << "LogWorker: "<< "Leida linea a medias."; return; } emit newLogLineRead(QString(line)); logSeek += lineLenght + 1; emit seekChanged(logSeek); } logFile.close(); }
void MainWindow::mkconnections() { connect(bar,SIGNAL(closeClicked()),SLOT(close())); connect(bar,SIGNAL(maximizeClicked(bool)),SLOT(showWind(bool))); connect(bar,SIGNAL(hideClicked()),SLOT(showMinimized())); connect(playlists,SIGNAL(songAdded(QString,QString)),&library,SLOT(addSongInPlaylist(QString,QString))); connect(bar,SIGNAL(addFilePressed()),SLOT(addFiles())); connect(bar,SIGNAL(addFolderPressed()),SLOT(addFolder())); connect(&player,SIGNAL(inPlaylist(bool)),SLOT(changePlayerConnections(bool))); connect(&library,SIGNAL(newSong(Song)),table,SLOT(addSongInList(Song))); connect(&player,SIGNAL(positionChanged(qint64)),bar,SIGNAL(seekChanged(qint64))); connect(&player,SIGNAL(currentSongChanged(Song)),bar,SIGNAL(songChanged(Song))); connect(bar,SIGNAL(playClicked()),&player,SLOT(playpause())); connect(addFile,SIGNAL(triggered()),SLOT(addFiles())); connect(actionAddFolder,SIGNAL(triggered()),SLOT(addFolder())); connect(actionOuvrir,SIGNAL(triggered()),SLOT(openFile())); connect(bar,SIGNAL(volumeChanged(int)),&player,SLOT(setVolume(int))); connect(bar,SIGNAL(positionChanged(int)),&player,SLOT(setPosition(int))); connect(bar,SIGNAL(seekBarPressed()),&player,SLOT(pause())); connect(bar,SIGNAL(seekBarReleased()),&player,SLOT(play())); connect(&player,SIGNAL(playbackStateChanged(bool)),bar,SLOT(changeButton(bool))); connect(tree,SIGNAL(albumChosen(QString,QString)),table,SLOT(showSongsFrom(QString,QString))); connect(tree,SIGNAL(artistChosen(QString)),table,SLOT(showSongsBy(QString))); connect(&library,SIGNAL(libraryChanged(Library*)),tree,SLOT(updateTree(Library*))); connect(table,SIGNAL(newPlaylist(Song)),this,SLOT(mkPlaylist(Song))); connect(playlists,SIGNAL(playlistChosen(QString)),table,SLOT(showSongsIn(QString))); connect(table,SIGNAL(deleteSong(Song,bool)),&library,SLOT(deleteSong(Song,bool))); connect(bar,SIGNAL(newQuery(QString,int)),table,SLOT(setQuery(QString,int))); connect(bar,SIGNAL(newPlaybackMode(QMediaPlaylist::PlaybackMode)),&player,SLOT(setPlayBackMode(QMediaPlaylist::PlaybackMode))); connect(table,SIGNAL(songChosen(int)),&player,SLOT(play(int))); connect(table,SIGNAL(newSongList(SongList)),&player,SLOT(update(SongList))); connect(&player,SIGNAL(inPlaylist(bool)),bar,SLOT(enableNavigation(bool))); connect(bar,SIGNAL(miniLecteur()),&mLecteur,SLOT(show())); connect(bar,SIGNAL(miniLecteur()),SLOT(hide())); connect(&mLecteur,SIGNAL(windowedMode()),SLOT(show())); connect(&mLecteur,SIGNAL(positionChanged(int)),bar,SIGNAL(positionChanged(int))); connect(&mLecteur,SIGNAL(seekBarPressed()),bar,SIGNAL(seekBarPressed())); connect(&mLecteur,SIGNAL(seekBarReleased()),bar,SIGNAL(seekBarReleased())); connect(&mLecteur,SIGNAL(positionChanged(int)),bar,SIGNAL(positionChanged(int))); connect(&mLecteur,SIGNAL(playClicked()),bar,SIGNAL(playClicked())); connect(&mLecteur,SIGNAL(nextClicked()),bar,SIGNAL(nextClicked())); connect(&mLecteur,SIGNAL(previousClicked()),bar,SIGNAL(previousClicked())); connect(&mLecteur,SIGNAL(volumeChanged(int)),bar,SIGNAL(volumeChanged(int))); connect(&player,SIGNAL(currentSongChanged(Song)),&mLecteur,SLOT(setNewSong(Song))); connect(&player,SIGNAL(positionChanged(qint64)),&mLecteur,SLOT(setPosition(qint64))); connect(&player,SIGNAL(playbackStateChanged(bool)),&mLecteur,SLOT(changeButton(bool))); connect(&player,SIGNAL(indexChanged(int,int)),table,SLOT(setIconTo(int,int))); connect(table,SIGNAL(addFileTriggered()),SLOT(addFiles())); connect(table,SIGNAL(addFolderTriggered()),SLOT(addFolder())); }
VisualNavbar::VisualNavbar(MainWindow *main, QWidget *parent) : QToolBar(main), graphicsView(new QGraphicsView), cursorGraphicsItem(nullptr), main(main) { Q_UNUSED(parent); setObjectName("visualNavbar"); setWindowTitle(tr("Visual navigation bar")); // setMovable(false); setContentsMargins(0, 0, 0, 0); // If line below is used, with the dark theme the paintEvent is not called // and the result is wrong. Something to do with overwriting the style sheet :/ //setStyleSheet("QToolBar { border: 0px; border-bottom: 0px; border-top: 0px; border-width: 0px;}"); /* QComboBox *addsCombo = new QComboBox(); addsCombo->addItem(""); addsCombo->addItem("Entry points"); addsCombo->addItem("Marks"); */ addWidget(this->graphicsView); //addWidget(addsCombo); connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA))); connect(Core(), SIGNAL(refreshAll()), this, SLOT(fetchAndPaintData())); connect(Core(), SIGNAL(functionsChanged()), this, SLOT(updateMetadataAndPaint())); connect(Core(), SIGNAL(flagsChanged()), this, SLOT(updateMetadataAndPaint())); graphicsScene = new QGraphicsScene(this); const QBrush bg = QBrush(QColor(74, 74, 74)); graphicsScene->setBackgroundBrush(bg); this->graphicsView->setAlignment(Qt::AlignLeft); this->graphicsView->setMinimumHeight(20); this->graphicsView->setMaximumHeight(20); this->graphicsView->setFrameShape(QFrame::NoFrame); this->graphicsView->setRenderHints(0); this->graphicsView->setScene(graphicsScene); this->graphicsView->setRenderHints(QPainter::Antialiasing); this->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // So the graphicsView doesn't intercept mouse events. this->graphicsView->setEnabled(false); this->graphicsView->setMouseTracking(true); setMouseTracking(true); }
void LogLoader::init(qint64 &logSize) { readSettings(); logSize = getLogFileSize(); if(logSize >= 0) { emit pDebug("Log found."); emit pLog(tr("Log: Log found.")); if(logSize == 0) { emit pDebug("Log is empty."); emit pLog(tr("Log: Log is empty.")); } this->logSize = logSize; firstRun = true; updateTime = 1000; logWorker = new LogWorker(this, logPath); connect(logWorker, SIGNAL(newLogLineRead(QString, qint64)), this, SLOT(emitNewLogLineRead(QString, qint64))); connect(logWorker, SIGNAL(seekChanged(qint64)), this, SLOT(updateSeek(qint64))); connect(logWorker, SIGNAL(pLog(QString)), this, SIGNAL(pLog(QString))); connect(logWorker, SIGNAL(pDebug(QString,DebugLevel,QString)), this, SIGNAL(pDebug(QString,DebugLevel,QString))); QTimer::singleShot(1000, this, SLOT(sendLogWorker())); //Retraso para dejar que la aplicacion se pinte. } else { QSettings settings("Arena Tracker", "Arena Tracker"); settings.setValue("logPath", ""); emit pDebug("Log not found."); emit pLog(tr("Log: Log not found. Restart Arena Tracker and set the path again.")); QMessageBox::information((QMainWindow*)this->parent(), tr("Log not found"), tr("Log not found. Restart Arena Tracker and set the path again.")); } }
void LogLoader::init(qint64 &logSize) { readSettings(); logSize = getLogFileSize(); if(logSize >= 0) { emit pDebug("Log found."); emit pLog(tr("Log: Log found.")); if(logSize == 0) { emit pDebug("Log is empty."); emit pLog(tr("Log: Log is empty.")); } this->logSize = logSize; firstRun = true; updateTime = 1000; logWorker = new LogWorker(this, logPath); connect(logWorker, SIGNAL(newLogLineRead(QString, qint64)), this, SLOT(emitNewLogLineRead(QString, qint64))); connect(logWorker, SIGNAL(seekChanged(qint64)), this, SLOT(updateSeek(qint64))); connect(logWorker, SIGNAL(pLog(QString)), this, SIGNAL(pLog(QString))); connect(logWorker, SIGNAL(pDebug(QString,DebugLevel,QString)), this, SIGNAL(pDebug(QString,DebugLevel,QString))); QTimer::singleShot(updateTime, this, SLOT(sendLogWorker())); } else { QSettings settings("Arena Tracker", "Arena Tracker"); settings.setValue("logPath", ""); emit pDebug("Log not found."); emit pLog(tr("Log: Log not found. Restart Arena Tracker and set the path again.")); } }
bool LogLoader::isLogReset() { qint64 newSize = getLogFileSize(); if(newSize == 0) return false; if((newSize == -1) || (newSize < logSize)) { //Log se ha reiniciado emit pDebug("Log reset. FileSize: " + QString::number(newSize) + " < " + QString::number(logSize)); emit pLog(tr("Log: Hearthstone started. Log reset.")); emit seekChanged(0); logWorker->resetSeek(); logSize = 0; return true; } else { logSize = newSize; return false; } }
void LogLoader::updateSeek(qint64 logSeek) { if(firstRun) emit seekChanged(logSeek); }