MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setListFile(); model = new TableModel(this); model->setSettings(&settings); model->readFromFile(listfile); ui->tableView->setModel(model); readSettings(); if (settings.trayicon) { trayicon = new QSystemTrayIcon(this->windowIcon(), this); connect(trayicon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); traymenu = new QMenu(this); traymenu->addAction(ui->actionStart); traymenu->addAction(ui->actionStop); traymenu->addAction(ui->actionExit); trayicon->setContextMenu(traymenu); trayicon->setToolTip(tr("Upcoder")); trayicon->show(); } else { trayicon = 0; traymenu = 0; } time = new QTime(); settingsdialog = 0; resdialog = 0; connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settingsPressed())); connect(ui->actionAdd, SIGNAL(triggered()), this, SLOT(addPressed())); connect(ui->actionDelete, SIGNAL(triggered()), this, SLOT(deletePressed())); connect(ui->actionClear, SIGNAL(triggered()), model, SLOT(clear())); connect(ui->actionStart, SIGNAL(triggered()), model, SLOT(startUploading())); connect(ui->actionStop, SIGNAL(triggered()), model, SLOT(stopUploading())); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(exitApplication())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(ui->actionShow_links_to_files, SIGNAL(triggered()), this, SLOT(showLinks())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPressed())); connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(showLinks())); connect(model, SIGNAL(statusChanged(QString)), ui->statusBar, SLOT(showMessage(QString))); connect(model, SIGNAL(progress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64))); connect(model, SIGNAL(uploadingStarted()), this, SLOT(uploadingStarted())); connect(model, SIGNAL(allUploadsStarted()), this, SLOT(allUploadsStarted())); connect(model, SIGNAL(allUploadsFinished()), this, SLOT(allUploadsFinished())); }
void FileSharingWidget::mouseReleaseEvent(QMouseEvent *event) { event->ignore(); Ui::HistoryControlPage* page = Utils::InterConnector::instance().getHistoryPage(ContactUin_); if (page && page->touchScrollInProgress()) { return; } const auto isLeftClick = (event->button() == Qt::LeftButton); if (!isLeftClick) { return; } const auto mousePos = event->pos(); const auto clickedOnButton = (isControlButtonVisible() && isOverControlButton(mousePos)); const auto isDownloadButtonClicked = (clickedOnButton && isState(State::PlainFile_MetainfoLoaded)); if (isDownloadButtonClicked) { startDownloadingPlainFile(); return; } const auto isDownloading = (isState(State::PlainFile_Downloading) || isState(State::ImageFile_Downloading)); const auto isStopDownloadButtonClicked = (clickedOnButton && isDownloading); if (isStopDownloadButtonClicked) { stopDownloading(); return; } const auto isUploading = (isState(State::PlainFile_Uploading) || isState(State::ImageFile_Uploading)); const auto isStopUploadButtonClicked = (clickedOnButton && isUploading); if (isStopUploadButtonClicked) { stopUploading(); return; } const auto isOpenDownloadsDirButtonClicked = (isOpenDownloadsDirButtonVisible() && isOverOpenDownloadsDirButton(mousePos)); if (isOpenDownloadsDirButtonClicked) { openDownloadsDir(); return; } const auto fullImageReady = ( isState(State::ImageFile_Downloaded) || isState(State::ImageFile_Uploaded) ); if (fullImageReady && isOverPreview(mousePos)) { if (platform::is_apple()) { openPreviewMac(event->globalX(), event->globalY()); } else { openPreview(); } return; } if (canStartImageDownloading(mousePos)) { setState(State::ImageFile_Downloading); startDownloadingFullImage(); } }