MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { thread = new QThread(); reader = new Reader(); reader->moveToThread(thread); connect(reader, SIGNAL(sendPoint(int,int,double)), this, SLOT(setPointProb(int,int,double))); connect(reader, SIGNAL(workRequested()), thread, SLOT(start())); connect(thread, SIGNAL(started()), reader, SLOT(doWork())); connect(reader, SIGNAL(finished()), thread, SLOT(quit()) , Qt::DirectConnection); connect(reader, SIGNAL(finished()), this, SLOT(fileFinished())); connect(reader, SIGNAL(sendReset()), this, SLOT(resetPositions())); setFixedSize(800,600); p_scene = new QGraphicsScene(this); p_view = new QGraphicsView(p_scene, this); QPixmap background(QCoreApplication::applicationDirPath() + "/img/sol.png"); if (background.isNull()) { std::cout << "Ouverture de sol.png échouée, ouverture de sol.jpg" << std::endl; background = QPixmap(QCoreApplication::applicationDirPath() + "/img/sol.jpg"); } p_scene->setBackgroundBrush(QBrush(background)); p_view->setGeometry(10,10,505,505); p_addPosition = new QPushButton("Ajouter position", this); p_addPosition->setGeometry(590,90, 120, 30); p_deletePos = new QPushButton("Réinitialiser positions", this); p_deletePos->setGeometry(590,130, 120, 30); p_openFile = new QPushButton("Ouvrir fichier", this); p_openFile->setGeometry(590, 170, 120, 30); p_changeTableSize = new QPushButton("Changer taille table", this); p_changeTableSize->setGeometry(50, 560, 120, 30); pauseButton = new QPushButton("", this); QIcon pauseIcon(QCoreApplication::applicationDirPath() + "/img/pause.png"); if (pauseIcon.isNull()) { std::cout << "Ouverture de pause.png échouée, ouverture de pause.jpg" << std::endl; pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/pause.jpg")); } pauseButton->setIcon(pauseIcon); pauseButton->setGeometry(590, 250, 30, 30); pauseButton->setDisabled(true); stopButton = new QPushButton("", this); QIcon stopIcon(QCoreApplication::applicationDirPath() + "/img/stop.png"); if (stopIcon.isNull()) { std::cout << "Ouverture de stop.png échouée, ouverture de stop.jpg" << std::endl; pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/stop.jpg")); } stopButton->setIcon(stopIcon); stopButton->setGeometry(630, 250, 30, 30); stopButton->setDisabled(true); stepButton = new QPushButton("", this); QIcon stepIcon(QCoreApplication::applicationDirPath() + "/img/step.png"); if (stepIcon.isNull()) { std::cout << "Ouverture de step.png échouée, ouverture de step.jpg" << std::endl; stepIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/step.jpg")); } stepButton->setIcon(stepIcon); stepButton->setGeometry(670, 250, 30, 30); stepButton->setDisabled(true); p_quit = new QPushButton("Quitter", this); p_quit->setGeometry(600, 560, 100, 30); p_addPosX = new QLineEdit(this); p_addPosY = new QLineEdit(this); p_addPosP = new QLineEdit(this); p_addPosX->setGeometry(580, 50, 40, 30); p_addPosY->setGeometry(630, 50, 40, 30); p_addPosP->setGeometry(680, 50, 40, 30); p_addPosX->setPlaceholderText("Abscisse"); p_addPosY->setPlaceholderText("Ordonnée"); p_addPosP->setPlaceholderText("Proba"); currentDate = new QLabel("Pas de fichier en cours", this); currentDate->setGeometry(580, 300, 140, 30); QObject::connect(p_addPosition, SIGNAL(clicked()), this, SLOT(sendPointProbValues())); QObject::connect(this, SIGNAL(pointProbValues(int,int,double)), this, SLOT(setPointProb(int,int,double))); QObject::connect(p_deletePos, SIGNAL(clicked()), this, SLOT(resetPositions())); QObject::connect(p_quit, SIGNAL(clicked()), qApp, SLOT(quit())); QObject::connect(p_openFile, SIGNAL(clicked()), this, SLOT(readMatrixFromFile())); QObject::connect(p_changeTableSize, SIGNAL(clicked()), this, SLOT(changeTableSize())); QObject::connect(pauseButton, SIGNAL(clicked()), this, SLOT(pauseRead())); QObject::connect(stopButton, SIGNAL(clicked()), this, SLOT(stopRead())); QObject::connect(reader, SIGNAL(sendDate(QString)), this, SLOT(setDate(QString))); QObject::connect(stepButton, SIGNAL(clicked()), this, SLOT(clickNextDate())); }
AMActionRunnerQueueView3::AMActionRunnerQueueView3(AMActionRunner3* actionRunner, QWidget *parent) : QWidget(parent) { actionRunner_ = actionRunner; isCollapsed_ = false; treeView_ = new QTreeView(); treeView_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); treeView_->setModel(actionRunner_->queueModel()); treeView_->setHeaderHidden(true); treeView_->setAttribute(Qt::WA_MacShowFocusRect, false); treeView_->setSelectionBehavior(QAbstractItemView::SelectRows); treeView_->setSelectionMode(QAbstractItemView::ExtendedSelection); treeView_->setAlternatingRowColors(true); treeView_->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); treeView_->setAutoScroll(true); treeView_->setAutoScrollMargin(20); treeView_->setDragEnabled(true); treeView_->viewport()->setAcceptDrops(true); treeView_->setDropIndicatorShown(true); treeView_->setDragDropMode(QTreeView::DragDrop); treeView_->setItemDelegate(new AMActionRunnerQueueItemDelegate3(this)); QFrame* topFrame = new QFrame(); topFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); topFrame->setObjectName("topFrame"); topFrame->setStyleSheet("QFrame#topFrame {\nbackground-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(89, 89, 89, 255), stop:0.494444 rgba(89, 89, 89, 255), stop:0.5 rgba(58, 58, 58, 255), stop:1 rgba(58, 58, 58, 255));\nborder-bottom: 1px solid black;\n}"); QHBoxLayout* hl = new QHBoxLayout(); hl->setSpacing(0); hl->setContentsMargins(6, 2, 12, 1); hideButton_ = new QToolButton(); hideButton_->setStyleSheet("QToolButton {\nborder: none;\nbackground-color: rgba(255, 255, 255, 0);\ncolor: white;\n image: url(:/22x22/arrow-white-down.png)} \nQToolButton::checked {\n image: url(:/22x22/arrow-white-right.png);\n}\n"); hideButton_->setCheckable(true); hideButton_->setChecked(false); hl->addWidget(hideButton_); hl->addSpacing(10); QVBoxLayout* vl2 = new QVBoxLayout(); vl2->setContentsMargins(0,0,0,0); vl2->setSpacing(0); headerTitle_ = new QLabel("Upcoming Actions"); headerTitle_->setStyleSheet("color: white;\nfont: " AM_FONT_XLARGE_ "pt \"Lucida Grande\""); headerSubTitle_ = new QLabel(QString("%1 actions in the workflow queue.").arg(actionRunner_->queuedActionCount())); headerSubTitle_->setStyleSheet("color: rgb(204, 204, 204);\nfont: " AM_FONT_REGULAR_ "pt \"Lucida Grande\""); vl2->addWidget(headerTitle_); vl2->addWidget(headerSubTitle_); hl->addLayout(vl2); hl->addStretch(1); duplicateButton_ = new QPushButton("Duplicate"); duplicateButton_->setDisabled(true); hl->addWidget(duplicateButton_); deleteButton_ = new QPushButton("Delete"); deleteButton_->setDisabled(true); hl->addWidget(deleteButton_); hl->addSpacing(20); pauseButton_ = new QPushButton; QIcon pauseIcon(":/22x22/media-playback-pause.png"); pauseIcon.addPixmap(QPixmap(":/22x22/media-playback-start.png"), QIcon::Normal, QIcon::On); pauseButton_->setIcon(pauseIcon); pauseButton_->setIconSize(QSize(22, 22)); pauseButton_->setCheckable(true); pauseButton_->setChecked(true); pauseButton_->setStyleSheet("QPushButton { border: 2px solid #8f8f91; border-radius: 6px;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(102,255,102), stop: 1 #dadbde);min-width: 140px; padding: 0px 5px 0 5px;} QPushButton:pressed { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dadbde, stop: 1 #f6f7fa); } QPushButton:flat { border: none; /* no border for a flat push button */ } QPushButton:checked { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(102,102,255), stop: 1 #f6f7fa); } QPushButton:checked:pressed { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dadbde, stop: 1 #f6f7fa); }"); hl->addWidget(pauseButton_); pauseButtonConfiguration(); topFrame->setLayout(hl); QVBoxLayout* vl = new QVBoxLayout(); vl->setContentsMargins(0,0,0,0); vl->setSpacing(0); vl->addWidget(topFrame); vl->addWidget(treeView_); setLayout(vl); connect(hideButton_, SIGNAL(toggled(bool)), this, SLOT(collapse(bool))); connect(pauseButton_, SIGNAL(toggled(bool)), this, SLOT(onPauseButtonClicked(bool))); connect(duplicateButton_, SIGNAL(clicked()), this, SLOT(onDuplicateButtonClicked())); connect(deleteButton_, SIGNAL(clicked()), this, SLOT(onDeleteButtonClicked())); connect(actionRunner_->queueModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(onQueueActionAddedOrRemoved())); connect(actionRunner_->queueModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(onQueueActionAddedOrRemoved())); connect(treeView_->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(onSelectionChanged())); connect(actionRunner_, SIGNAL(queuePausedChanged(bool)), this, SLOT(onQueuePaused(bool))); }