Exemple #1
0
FolderSelection::FolderSelection(QString const &prompt, QWidget *parent)
    : QWidget(parent), d(new Impl(*this, ""))
{
    d->prompt = prompt;
    connect(d->button, SIGNAL(clicked()), this, SLOT(selectFolder()));
    connect(d->edit, SIGNAL(textEdited(QString)), this, SIGNAL(selected()));
}
/// PUBLIC
UImageConvertationForm::UImageConvertationForm(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::UImageConvertationForm)
{
    ui->setupUi(this);

    ui->lWidgetImages->setItemDelegate(new UListWidgetHTMLItem());

    ui->toolBar->addSeparator();
    ui->toolBar->addWidget(ui->label);
    ui->toolBar->addSeparator();
    ui->toolBar->addWidget(ui->lEditUrlPicture);
    ui->toolBar->addWidget(ui->tButtonSelectFile);
    ui->toolBar->addSeparator();

    ui->toolBar_2->addSeparator();
    ui->toolBar_2->addWidget(ui->tButtonDownloadPicture);
    ui->toolBar_2->addWidget(ui->tButtonAbortDownloadPicture);
    ui->toolBar_2->addSeparator();

    ui->toolBar_3->addSeparator();
    ui->toolBar_3->addWidget(ui->tButtonSaveAs);
    ui->toolBar_3->addSeparator();

    ui->toolBar_4->addSeparator();
    ui->toolBar_4->addWidget(ui->tButtonQuit);


    init();

    testingEditUrlPicture(ui->lEditUrlPicture->text());

    networkAccessManager = new QNetworkAccessManager();

    ui->tButtonAbortDownloadPicture->setEnabled(false);
    ui->actionAbortDownloadPicture->setEnabled(false);

    ui->widgetProgressBar->hide();

    ui->tButtonSaveAs->setEnabled(false);
    ui->actionSaveAs->setEnabled(false);

    reply = 0;

    ui->statusBar->addWidget(ui->widgetProgressBar);

    ui->lEditUrlPicture->installEventFilter(this);
    ui->labelImage->installEventFilter(this);

    setContextMenuPolicy(Qt::NoContextMenu);

    selectFolder();
}
void AudioBrowserScreen::init()
{
    connect(buttons[EXIT], SIGNAL(clicked()), this, SLOT(lower()));
    connect(buttons[DOWN], SIGNAL(clicked()), listView, SLOT(scrollDown()));
    connect(buttons[UP], SIGNAL(clicked()), listView, SLOT(scrollUp()));
    connect(buttons[PGDOWN], SIGNAL(clicked()), listView,SLOT(scrollPageDown()));
    connect(buttons[PGUP], SIGNAL(clicked()), listView, SLOT(scrollPageUp()));
    connect(buttons[SELECT], SIGNAL(clicked()), this, SLOT(selectFolder()));
    connect(buttons[PLUS], SIGNAL(clicked()), this, SLOT(selectFolderPlus()));
    connect(buttons[BACK], SIGNAL(clicked()), this, SLOT(backFolder()));
    connect(buttons[BROWSE], SIGNAL(clicked()), this, SLOT(browseFolder()));
    connect(listView,SIGNAL(highlighted(int)),this,SLOT(highlight(int)));
    connect(listView,SIGNAL(selected(int)),this, SLOT(select(int)));

    setDir(rootDir);
}
/// PRIVATE
void UImageConvertationForm::init()
{
    connect(ui->tButtonSelectFile, SIGNAL(clicked()), this, SLOT(selectFilePicture()));
    connect(ui->tButtonDownloadPicture, SIGNAL(clicked()), this, SLOT(downloadUrlImage()));
    connect(ui->tButtonAbortDownloadPicture, SIGNAL(clicked()), this, SLOT(abortDownload()));
    connect(ui->lEditUrlPicture, SIGNAL(textChanged(QString)), this, SLOT(testingEditUrlPicture(QString)));
    connect(ui->tButtonSaveAs, SIGNAL(clicked()), this, SLOT(saveAs()));
    connect(ui->tButtonQuit, SIGNAL(clicked()), qApp, SLOT(quit()));

    connect(ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(ui->actionSelectFile, SIGNAL(triggered()), this, SLOT(selectFilePicture()));
    connect(ui->actionSelectFolder, SIGNAL(triggered()), this, SLOT(selectFolder()));
    connect(ui->actionDownloadPicture, SIGNAL(triggered()), this, SLOT(downloadUrlImage()));
    connect(ui->actionAbortDownloadPicture, SIGNAL(triggered()), this, SLOT(abortDownload()));
    connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));
    connect(ui->actionAboutProgram, SIGNAL(triggered()), this, SLOT(about()));
}
Exemple #5
0
FileSystemWidget::FileSystemWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FileSystemWidget)
{
    ui->setupUi(this);

    m_delegate = new FileSystemItemDelegate(this);
    ui->listView->setItemDelegate(m_delegate);

    initModel();
    ui->listView->setModel(m_sortModel);
    connect(ui->listView, SIGNAL(open(QModelIndex)),m_model, SLOT(cd(QModelIndex)));
    connect(ui->listView, SIGNAL(up()),             m_model, SLOT(cdUp()));
    connect(ui->listView, SIGNAL(play(QStringList,bool,bool)), this, SLOT(play(QStringList,bool,bool)));

    initSearch();

    ui->progressPanel->hide();

    connect(ui->upButton,       SIGNAL(clicked()),      m_model,        SLOT(cdUp()));
    connect(m_model,            SIGNAL(upChanged(bool)),ui->upButton,   SLOT(setEnabled(bool)));
    connect(m_model,            SIGNAL(pathChanged()),  this,           SLOT(onPathChanged()));
    connect(ui->selectButton,   SIGNAL(clicked()),      this,           SLOT(selectFolder()));

    connect(ui->playAllButton,  SIGNAL(clicked()), this,    SLOT(playAll()));
    connect(ui->playRootButton, SIGNAL(clicked()), this,    SLOT(playRoot()));

    connect(ui->addAllButton,   SIGNAL(clicked()), this,    SLOT(addAll()));
    connect(ui->addRootButton,  SIGNAL(clicked()), this,    SLOT(addRoot()));

    m_scanDialog = new ScanProgressDialog(this);
    connect(m_scanDialog,                   SIGNAL(cancelled()),                Player::instance()->folder(), SLOT(cancel()));
    connect(Player::instance()->folder(),   SIGNAL(cancelled()),                m_scanDialog,       SLOT(onScanCancelled()));
    connect(Player::instance()->folder(),   SIGNAL(scanPathChanged(QString)),   m_scanDialog,       SLOT(setScanPath(QString)));
    connect(Player::instance()->folder(),   SIGNAL(finished(int)),              m_scanDialog,       SLOT(onScanFinished(int)));

    m_scanDialogTimer.setSingleShot(true);
    connect(&m_scanDialogTimer,             SIGNAL(timeout()),                  this,               SLOT(showScanDialog()));
    connect(Player::instance()->folder(),   SIGNAL(finished(int)),              &m_scanDialogTimer, SLOT(stop()));
}
Exemple #6
0
FolderSelection::FolderSelection(QString const &prompt, QString const &extraLabel, QWidget *parent)
    : QWidget(parent), d(new Impl(*this, extraLabel))
{
    d->prompt = prompt;
    connect(d->button, SIGNAL(clicked()), this, SLOT(selectFolder()));
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
	int nItemCount;
	int nSelected;
	int *nIndexes;
	BOOL bFlag;
	WCHAR *pszFile;
	WCHAR *handle;
	WCHAR *token;
	Image *imgCurrent;
	Image out;

	switch (iMessage)
	{
		case WM_CREATE:
			HANDLE hToken;

			viewer.changeCaption(L"Preview");

			//Create Controls
			hListLayer = CreateWindow(L"ListBox", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_EXTENDEDSEL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT, 0, 80, 240, 420, hWnd, (HMENU)ID_LAYER_LIST, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
			hButtonStart = CreateWindow(L"Button", L"Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 80, 40, hWnd, (HMENU)ID_START_BUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
			hButtonSave = CreateWindow(L"Button", L"Save Selected in merged file", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 80, 0, 80, 40, hWnd, (HMENU)ID_SAVE_BUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
			hButtonSaveAll = CreateWindow(L"Button", L"Save All in individual file", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 160, 0, 80, 40, hWnd, (HMENU)ID_SAVE_ALL, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
			hButtonResetAll = CreateWindow(L"Button", L"Erase All", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 0, 40, 80, 40, hWnd, (HMENU)ID_RESET_ALL, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
			hButtonResetSelected = CreateWindow(L"Button", L"Erase Selected", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 80, 40, 80, 40, hWnd, (HMENU)ID_RESET_SEL, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
			hButtonResetUnselected = CreateWindow(L"Button", L"Erase Unelected", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 160, 40, 80, 40, hWnd, (HMENU)ID_RESET_UNSEL, ((LPCREATESTRUCT)lParam)->hInstance, NULL);

			hFont = CreateFont(16, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, FF_ROMAN, L"Segoe UI");

			SendMessage(hListLayer, WM_SETFONT, (WPARAM)hFont, TRUE);
			SendMessage(hButtonStart, WM_SETFONT, (WPARAM)hFont, TRUE);
			SendMessage(hButtonSave, WM_SETFONT, (WPARAM)hFont, TRUE);
			SendMessage(hButtonSaveAll, WM_SETFONT, (WPARAM)hFont, TRUE);
			SendMessage(hButtonResetAll, WM_SETFONT, (WPARAM)hFont, TRUE);
			SendMessage(hButtonResetSelected, WM_SETFONT, (WPARAM)hFont, TRUE);
			SendMessage(hButtonResetUnselected, WM_SETFONT, (WPARAM)hFont, TRUE);

			//Create Events
			hAttachSucceeded = CreateEvent(NULL, TRUE, FALSE, NULL);
			hDebugEnd = CreateEvent(NULL, TRUE, FALSE, NULL);
			hDebugInit = CreateEvent(NULL, TRUE, FALSE, NULL);

			//Adjust Privileges
			if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
			{
				if (SetPrivilege(hToken, SE_DEBUG_NAME, TRUE))
					return 0;
				else
					MessageBox(hWnd, L"Fail to get debug privilege!!", L"Error", MB_OK | MB_ICONERROR);
			}
			else
				MessageBox(hWnd, L"Fail to get process token!!", L"Error", MB_OK | MB_ICONERROR);

			SendMessage(hWnd, WM_DESTROY, 0, 0);

			return 0;
		case WM_ACTIVATE:
			if (wParam == WA_CLICKACTIVE)
			{
				viewer.foreground();
				SetForegroundWindow(hWnd);
				SetFocus(hListLayer);
			}
			return 0;
		case WM_COMMAND:
			switch (LOWORD(wParam))
			{
				case ID_START_BUTTON:
					if (!bStarted)
					{
						hAokanaWnd = FindAokana(&dwThreadID, &dwProcessID);

						if (dwThreadID != 0)
						{
							hDebugThread = CreateThread(NULL, 0, DebugThread, NULL, 0, NULL);

							WaitForSingleObject(hDebugInit, INFINITE);
							if (WaitForSingleObject(hAttachSucceeded, 0) != WAIT_OBJECT_0)
							{
								SetEvent(hDebugEnd);
								MessageBox(hWnd, L"Fail to attach process!!", L"Error", MB_OK | MB_ICONERROR);

								break;
							}

							SendMessage(hButtonStart, WM_SETTEXT, 0, (LPARAM)L"Stop");
							bStarted = TRUE;
						}
					}
					else
					{
						SetEvent(hDebugEnd);
						WaitForSingleObject(hDebugThread, INFINITE);

						ResetEvent(hDebugEnd);
						ResetEvent(hDebugInit);
						ResetEvent(hAttachSucceeded);
						CloseHandle(hDebugThread);

						SendMessage(hButtonStart, WM_SETTEXT, 0, (LPARAM)L"Start");
						bStarted = FALSE;
					}
					break;
				case ID_SAVE_BUTTON:
					nItemCount = SendMessage(hListLayer, LB_GETCOUNT, 0, 0);
					nSelected = SendMessage(hListLayer, LB_GETSELCOUNT, 0, 0);

					if (nSelected > 0)
					{
						nIndexes = (int *)calloc(nSelected, sizeof(int));

						SendMessage(hListLayer, LB_GETSELITEMS, nSelected, (LPARAM)nIndexes);

						memset(&out, 0, sizeof(Image));

						for (int i = nSelected - 1; i >= 0; i--)
						{
							imgCurrent = (Image *)SendMessage(hListLayer, LB_GETITEMDATA, nIndexes[i], 0);

							if (imgCurrent == NULL)
								continue;

							if (i == nSelected - 1)
							{
								out.data = (PIXEL *)calloc(imgCurrent->width * imgCurrent->height, sizeof(PIXEL));
								out.width = imgCurrent->width;
								out.height = imgCurrent->height;
							}

							if (imgCurrent->width == out.width && imgCurrent->height == out.height)
								pixeloverlay(out.width, out.height, out.data, imgCurrent->data, out.data);
						}

						saveDialog(hWnd, out);

						free(nIndexes);
						free(out.data);
					}
					break;
				case ID_SAVE_ALL:
					nItemCount = SendMessage(hListLayer, LB_GETCOUNT, 0, 0);

					if (nItemCount > 0)
					{
						if (selectFolder(hWnd, pszFolder))
						{
							pszFile = (WCHAR *)calloc(256, sizeof(WCHAR));

							for (int i = nItemCount - 1; i >= 0; i--)
							{
								imgCurrent = (Image *)SendMessage(hListLayer, LB_GETITEMDATA, i, 0);
								SendMessage(hListLayer, LB_GETTEXT, i, (LPARAM)pszFile);

								token = wcstok_s(pszFile, L" ", &handle);
								token = wcstok_s(NULL, L" ", &handle);

								if (pszFolder[wcslen(pszFolder) - 1] != '\\')
									wcscat_s(pszFolder, L"\\");

								nSelected = wcslen(pszFolder);	//Position of '\' + 1

								wcscat_s(pszFolder, token);
								wcscat_s(pszFolder, L".png");
								saveImage(*imgCurrent, pszFolder);

								pszFolder[nSelected] = 0;
							}

							free(pszFile);
						}
					}
					break;
				case ID_LAYER_LIST:
					if (HIWORD(wParam) == LBN_SELCHANGE)
					{
						nItemCount = SendMessage(hListLayer, LB_GETCOUNT, 0, 0);
						nSelected = SendMessage(hListLayer, LB_GETSELCOUNT, 0, 0);

						if (nSelected > 0)
						{
							nIndexes = (int *)calloc(nSelected, sizeof(int));

							SendMessage(hListLayer, LB_GETSELITEMS, nSelected, (LPARAM)nIndexes);

							for (int i = nSelected - 1; i >= 0; i--)
							{
								imgCurrent = (Image *)SendMessage(hListLayer, LB_GETITEMDATA, nIndexes[i], 0);

								if (imgCurrent == NULL)
									continue;

								if (i == nSelected - 1)
									viewer.create(imgCurrent->width, imgCurrent->height);

								if (imgCurrent->width == viewer.getwidth() && imgCurrent->height == viewer.getheight())
									viewer.overlay(imgCurrent->data);
							}

							viewer.show();

							free(nIndexes);
						}
						else
							viewer.hide();
					}
					break;
				case ID_RESET_ALL:
					nItemCount = SendMessage(hListLayer, LB_GETCOUNT, 0, 0);
					for (int i = 0; i < nItemCount; i++)
					{
						imgCurrent = (Image *)SendMessage(hListLayer, LB_GETITEMDATA, i, 0);
						free(imgCurrent->data);
						free(imgCurrent);
					}
					SendMessage(hListLayer, LB_RESETCONTENT, 0, 0);
					viewer.hide();
					break;
				case ID_RESET_SEL:
					nItemCount = SendMessage(hListLayer, LB_GETCOUNT, 0, 0);
					nSelected = SendMessage(hListLayer, LB_GETSELCOUNT, 0, 0);

					if (nSelected > 0)
					{
						nIndexes = (int *)calloc(nSelected, sizeof(int));

						SendMessage(hListLayer, LB_GETSELITEMS, nSelected, (LPARAM)nIndexes);

						for (int i = nSelected - 1; i >= 0; i--)
						{
							imgCurrent = (Image *)SendMessage(hListLayer, LB_GETITEMDATA, nIndexes[i], 0);
							free(imgCurrent->data);
							free(imgCurrent);
							SendMessage(hListLayer, LB_DELETESTRING, nIndexes[i], 0);
						}

						free(nIndexes);
						viewer.hide();
					}
					break;
				case ID_RESET_UNSEL:
					nItemCount = SendMessage(hListLayer, LB_GETCOUNT, 0, 0);
					nSelected = SendMessage(hListLayer, LB_GETSELCOUNT, 0, 0);

					if (nSelected > 0)
					{
						nIndexes = (int *)calloc(nSelected, sizeof(int));

						SendMessage(hListLayer, LB_GETSELITEMS, nSelected, (LPARAM)nIndexes);

						for (int i = nItemCount - 1; i >= 0; i--)
						{
							bFlag = FALSE;

							for (int j = nSelected - 1; j >= 0; j--)
								if (i == nIndexes[j])
									bFlag = TRUE;

							if (!bFlag)
							{
								imgCurrent = (Image *)SendMessage(hListLayer, LB_GETITEMDATA, i, 0);
								free(imgCurrent->data);
								free(imgCurrent);
								SendMessage(hListLayer, LB_DELETESTRING, i, 0);
							}
						}

						free(nIndexes);
					}
					break;
			}
			return 0;
		case WM_DESTROY:
			if (bStarted)
				SendMessage(hWnd, WM_COMMAND, ID_START_BUTTON, 0);

			SendMessage(hWnd, WM_COMMAND, ID_RESET_ALL, 0);

			CloseHandle(hAttachSucceeded);
			CloseHandle(hDebugEnd);

			DeleteObject(hFont);

			PostQuitMessage(0);
			return 0;
	}

	return DefWindowProc(hWnd, iMessage, wParam, lParam);
}