BookmarksImportDialog::BookmarksImportDialog(QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::BookmarksImportDialog)
    , m_currentPage(0)
    , m_fetcher(0)
    , m_fetcherThread(0)
{
    setAttribute(Qt::WA_DeleteOnClose);
    ui->setupUi(this);

    ui->browserList->setCurrentRow(0);

    connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextPage()));
    connect(ui->chooseFile, SIGNAL(clicked()), this, SLOT(setFile()));
    connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(stopDownloading()));
}
void MapDownloader::addZoomButtons()
{
    // create buttons as controls for zoom
    QPushButton* zoomin = new QPushButton("+");
    QPushButton* zoomout = new QPushButton("-");
    
    zoomin->setMaximumWidth(50);
    zoomout->setMaximumWidth(50);

    sliderZoom = new QSlider();
    sliderZoom->setLayoutDirection(Qt::LeftToRight);
    sliderZoom->setTickInterval(1);
    sliderZoom->setMaximum( mapAdapter->maxZoom() );

    connect(zoomin,  SIGNAL( clicked(bool)), mc, SLOT(zoomIn()));
    connect(zoomout, SIGNAL( clicked(bool)), mc, SLOT(zoomOut()));
    connect(zoomin,  SIGNAL( clicked()),    this, SLOT(debugGPS()));
    connect(zoomout, SIGNAL( clicked()),    this, SLOT(debugGPS()));

    connect(sliderZoom, SIGNAL( valueChanged(int) ),    mc, SLOT(setZoom(int)));
    connect(sliderZoom, SIGNAL( valueChanged(int) ),    this, SLOT(debugGPS()));

    // layout fo the gpc position
    labelLatitude = new QLabel();
    labelLongitude = new QLabel();
    QVBoxLayout* GPSlayout = new QVBoxLayout;
    GPSlayout->addWidget(labelLatitude);
    GPSlayout->addWidget(labelLongitude);

    QPushButton* PushButtonDownload = new QPushButton("Download");
    QPushButton* PushButtonStop = new QPushButton("Stop");
    PushButtonDownload->setMaximumWidth(100);
    PushButtonStop->setMaximumWidth(100);

    comboBoxLayerDepth = new QComboBox();
    comboBoxLayerDepth->setMaximumWidth(50);
    connect(comboBoxLayerDepth,SIGNAL(currentIndexChanged(int)),this,SLOT(labelInfo()) );

    labelTileCount = new QLabel();
    labelTileCount->setMaximumWidth(150);

    QHBoxLayout* layoutButtons = new QHBoxLayout();
    layoutButtons->addWidget(PushButtonDownload);
    layoutButtons->addWidget(PushButtonStop);
    layoutButtons->addStretch();

    QHBoxLayout* layoutOptions = new QHBoxLayout();
    layoutOptions->addWidget(comboBoxLayerDepth);
    layoutOptions->addWidget(labelTileCount);
    layoutOptions->addStretch();

    downloadProgress = new QProgressBar();
    downloadProgress->setMaximumWidth(160);
    QVBoxLayout* layoutmain = new QVBoxLayout();
    layoutmain->addLayout(layoutOptions);
    layoutmain->addWidget(downloadProgress);
    layoutmain->addLayout(layoutButtons);

    connect(PushButtonDownload, SIGNAL(clicked()), this, SLOT(download()));
    connect(PushButtonStop, SIGNAL(clicked()), this, SLOT(stopDownloading()));
    // construct the layout
    QVBoxLayout* innerlayout = new QVBoxLayout;
    innerlayout->addWidget(zoomin);
    innerlayout->addWidget(zoomout);
    innerlayout->addLayout(GPSlayout);
    innerlayout->addWidget(sliderZoom);
    innerlayout->addLayout(layoutmain);
    innerlayout->addWidget(labelLatitude);  //add empty label for not hiding the distancebar
    mc->setLayout(innerlayout);
}
	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();
        }
	}