void CMainWindow::editFile()
{
	QString editorPath = CSettings().value(KEY_EDITOR_PATH).toString();
	if (editorPath.isEmpty() || !QFileInfo(editorPath).exists())
	{
		if (QMessageBox::question(this, tr("Editor not configured"), tr("No editor program has been configured (or the specified path doesn't exist). Do you want to specify the editor now?")) == QMessageBox::Yes)
		{
#ifdef _WIN32
			const QString mask(tr("Executable files (*.exe *.cmd *.bat)"));
#else
			const QString mask;
#endif
			editorPath = QFileDialog::getOpenFileName(this, tr("Browse for editor program"), QString(), mask);
			if (editorPath.isEmpty())
				return;

			CSettings().setValue(KEY_EDITOR_PATH, editorPath);
		}
		else
			return;
	}

	const QString currentFile = _currentFileList ? _controller->itemByHash(_currentFileList->panelPosition(), _currentFileList->currentItemHash()).fullAbsolutePath() : QString();
	if (!currentFile.isEmpty())
	{
		const QString editorPath = CSettings().value(KEY_EDITOR_PATH).toString();
		if (!editorPath.isEmpty() && !QProcess::startDetached(CSettings().value(KEY_EDITOR_PATH).toString(), QStringList() << currentFile))
			QMessageBox::information(this, tr("Error"), tr("Cannot launch %1").arg(editorPath));
	}
}
void CFindDialog::hideEvent(QHideEvent * e)
{
	if (!_settingsRootCategory.isEmpty())
		CSettings().setValue(_settingsRootCategory + SETTINGS_GEOMETRY, saveGeometry());

	QDialog::hideEvent(e);
}
void CMainWindow::currentPanelChanged(QStackedWidget *panel)
{
	_currentPanelWidget = panel;
	_currentFileList = dynamic_cast<CPanelWidget*>(panel->widget(0));
	if (panel)
	{
		_otherPanelWidget = panel == ui->leftWidget ? ui->rightWidget : ui->leftWidget;
		_otherFileList = dynamic_cast<CPanelWidget*>(_otherPanelWidget->widget(0));
		assert_r(_otherPanelWidget && _otherFileList);
	}
	else
	{
		_otherPanelWidget = 0;
		_otherFileList = 0;
	}

	if (_currentFileList)
	{
		_controller->activePanelChanged(_currentFileList->panelPosition());
		CSettings().setValue(KEY_LAST_ACTIVE_PANEL, _currentFileList->panelPosition());
		ui->fullPath->setText(_controller->panel(_currentFileList->panelPosition()).currentDirPathNative());
		CPluginEngine::get().currentPanelChanged(_currentFileList->panelPosition());
		_commandLineCompleter.setModel(_currentFileList->sortModel());
	}
	else
		_commandLineCompleter.setModel(0);
}
void CFindDialog::showEvent(QShowEvent * e)
{
	ui->_searchText->lineEdit()->selectAll();
	ui->_searchText->lineEdit()->setFocus();

	if (!_settingsRootCategory.isEmpty())
		restoreGeometry(CSettings().value(_settingsRootCategory + SETTINGS_GEOMETRY).toByteArray());

	QDialog::showEvent(e);
}
Exemple #5
0
LRESULT CAppWindow::OnEndSession(BOOL fClose, LPARAM lParameter)
{
	if (fClose)
	{
		// This is not a crash, but we did not cleanly shut down either.
		CSettings(TRUE).SetApplicationRunning(FALSE);
	}

	return 0;
}
DISABLE_COMPILER_WARNINGS
#include <QDebug>
#include <QFileInfo>
#include <QProcess>
RESTORE_COMPILER_WARNINGS

#include <algorithm>
#include <thread>

#include <cstdlib> // std::system

#ifdef _WIN32
#include <Windows.h>
#endif

QString OsShell::shellExecutable()
{
#ifdef _WIN32
	static const QString defaultShell = QLatin1String("powershell.exe");
	return CSettings().value(KEY_OTHER_SHELL_COMMAND_NAME, defaultShell).toString();
#elif defined __APPLE__
	return CSettings().value(KEY_OTHER_SHELL_COMMAND_NAME, "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal").toString();
#elif defined __linux__
	const QString consoleExecutable = CSettings().value(KEY_OTHER_SHELL_COMMAND_NAME).toString();
	if (QFileInfo(consoleExecutable).exists())
		return consoleExecutable;

	static const std::vector<QString> knownTerminals = {
		"/usr/bin/konsole", // KDE
		"/usr/bin/gnome-terminal", // Gnome
		"/usr/bin/pantheon-terminal" // Pantheon (Elementary OS)
	};

	for (const auto& candidate: knownTerminals)
		if (QFileInfo(candidate).exists())
			return candidate;

	return QString();
#else
	#error unknown platform
#endif
}
bool CMainWindow::executeCommand(QString commandLineText)
{
	if (!_currentFileList || commandLineText.isEmpty())
		return false;

	CShell::executeShellCommand(commandLineText, _currentFileList->currentDir());
	QTimer::singleShot(0, [=](){CSettings().setValue(KEY_LAST_COMMANDS_EXECUTED, ui->commandLine->items());}); // Saving the list AFTER the combobox actually accepts the newly added item
	clearCommandLineAndRestoreFocus();

	return true;
}
void CPromptDialog::showEvent(QShowEvent * e)
{
	restoreGeometry(CSettings().value(KEY_PROMPT_DIALOG_GEOMETRY).toByteArray());

	QDialog::showEvent(e);

	// Leave width intact, but set optimum height
	auto g = geometry();
	g.setHeight(sizeHint().height());
	setGeometry(g);
}
Exemple #9
0
void CAppWindow::CheckApplicationUpdated()
{
	wstring szVersion;

	if (CSettings(FALSE).GetInstalledVersion(szVersion))
	{
		wstring szNewVersion(CVersion::GetAppVersion());

		if (szVersion != szNewVersion)
		{
			CMessagePopup * lpPopup = new CMessagePopup(
				L"Google Wave Notifier has been updated. Click here to read about new features."
			);

			lpPopup->SetUrl(CHANGELOG_LINK);
			lpPopup->SetDuration(8000);

			lpPopup->Show();

			CSettings(TRUE).SetInstalledVersion(szNewVersion);
		}
	}
}
Exemple #10
0
void CAppWindow::SignOut(BOOL fManual)
{
	if (CPopupWindow::Instance() != NULL)
	{
		CPopupWindow::Instance()->CancelAll();
	}

	m_lpSession->SignOut();

	if (fManual)
	{
		CSettings(TRUE).DeleteGooglePassword();
	}
}
void CMainWindow::initActions()
{
	connect(ui->actionRefresh, &QAction::triggered, this, &CMainWindow::refresh);

	connect(ui->actionOpen_Console_Here, &QAction::triggered, this, &CMainWindow::openTerminal);
	connect(ui->actionExit, &QAction::triggered, qApp, &QApplication::quit);

	ui->action_Show_hidden_files->setChecked(CSettings().value(KEY_INTERFACE_SHOW_HIDDEN_FILES, true).toBool());
	connect(ui->action_Show_hidden_files, &QAction::triggered, this, &CMainWindow::showHiddenFiles);
	connect(ui->actionShowAllFiles, &QAction::triggered, this, &CMainWindow::showAllFilesFromCurrentFolderAndBelow);
	connect(ui->action_Settings, &QAction::triggered, this, &CMainWindow::openSettingsDialog);
	connect(ui->actionCalculate_occupied_space, &QAction::triggered, this, &CMainWindow::calculateOccupiedSpace);
	connect(ui->actionQuick_view, &QAction::triggered, this, &CMainWindow::toggleQuickView);

	connect(ui->action_Invert_selection, &QAction::triggered, this, &CMainWindow::invertSelection);
}
Exemple #12
0
void CNotifierApp::DetectStartWithWindowsSetting()
{
	m_szShortcutTargetPath = L"";

	WCHAR szPath[MAX_PATH];
	wstring szModulePath(GetLongPathName(GetModuleFileNameEx()));

	if (!SHGetSpecialFolderPath(NULL, szPath, CSIDL_STARTUP , FALSE))
	{
		return;
	}

	wstring szFindPath(szPath);

	szFindPath += L"\\*.lnk";

	WIN32_FIND_DATA wfd;

	HANDLE hFind = FindFirstFile(szFindPath.c_str(), &wfd);

	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				continue;
			}

			wstring szFilename(szPath);

			szFilename += L"\\";
			szFilename += wfd.cFileName;

			if (DetectShortcut(szModulePath, szFilename))
			{
				m_szShortcutTargetPath = szFilename;
				break;
			}
		}
		while (FindNextFile(hFind, &wfd) != 0);
	}

	FindClose(hFind);

	CSettings(TRUE).SetStartWithWindows(!m_szShortcutTargetPath.empty());
}
DISABLE_COMPILER_WARNINGS
#include "ui_csettingspagetools.h"

#include <QMessageBox>
RESTORE_COMPILER_WARNINGS

CSettingsPageTools::CSettingsPageTools(QWidget *parent) :
	CSettingsPage(parent),
	ui(new Ui::CSettingsPageTools)
{
	ui->setupUi(this);

	connect(ui->_btnWipeSettings, &QPushButton::clicked, this, [this](){
		CSettings().clear();
		QMessageBox::information(this, tr("Settings have been wiped"), tr("Restart the application for the default settings to take effect."));
	});
}
// A current disk has been switched
bool CController::switchToDisk(Panel p, size_t index)
{
	assert_r(index < _diskEnumerator.drives().size());
	const QString drivePath = _diskEnumerator.drives().at(index).storageInfo.rootPath();

	FileOperationResultCode result = rcDirNotAccessible;
	if (drivePath == _diskEnumerator.drives().at(currentDiskIndex(otherPanelPosition(p))).storageInfo.rootPath())
	{
		result = setPath(p, otherPanel(p).currentDirPathNative(), refreshCauseOther);
	}
	else
	{
		const QString lastPathForDrive = CSettings().value(p == LeftPanel ? KEY_LAST_PATH_FOR_DRIVE_L.arg(drivePath.toHtmlEscaped()) : KEY_LAST_PATH_FOR_DRIVE_R.arg(drivePath.toHtmlEscaped()), drivePath).toString();
		result = setPath(p, lastPathForDrive, refreshCauseOther);
	}

	return result == rcOk;
}
bool CMainWindow::moveFiles(const std::vector<CFileSystemObject> & files, const QString & destDir)
{
	if (files.empty() || destDir.isEmpty())
		return false;

	if (CSettings().value(KEY_OPERATIONS_ASK_FOR_COPY_MOVE_CONFIRMATION, true).toBool())
	{
		CFileOperationConfirmationPrompt prompt(tr("Move files"), tr("Move %1 %2 to").arg(files.size()).arg(files.size() > 1 ? "files" : "file"), destDir, this);
		if (prompt.exec() != QDialog::Accepted)
			return false;
	}

	CCopyMoveDialog * dialog = new CCopyMoveDialog(operationMove, files, destDir, this);
	connect(this, &CMainWindow::closed, dialog, &CCopyMoveDialog::deleteLater);
	dialog->connect(dialog, &CCopyMoveDialog::closed, this, &CMainWindow::deleteLater);
	dialog->show();

	return true;
}
bool CMainWindow::copyFiles(const std::vector<CFileSystemObject> & files, const QString & destDir)
{
	if (files.empty() || destDir.isEmpty())
		return false;

	const QString destPath = files.size() == 1 && files.front().isFile() ? cleanPath(destDir % toNativeSeparators("/") % files.front().fullName()) : destDir;
	CFileOperationConfirmationPrompt prompt(tr("Copy files"), tr("Copy %1 %2 to").arg(files.size()).arg(files.size() > 1 ? "files" : "file"), destPath, this);
	if (CSettings().value(KEY_OPERATIONS_ASK_FOR_COPY_MOVE_CONFIRMATION, true).toBool())
	{
		if (prompt.exec() != QDialog::Accepted)
			return false;
	}

	CCopyMoveDialog * dialog = new CCopyMoveDialog(operationCopy, files, prompt.text(), this);
	connect(this, &CMainWindow::closed, dialog, &CCopyMoveDialog::deleteLater);
	dialog->connect(dialog, &CCopyMoveDialog::closed, this, &CMainWindow::deleteLater);
	dialog->show();

	return true;
}
void CMainWindow::updateInterface()
{
	CSettings s;
	restoreGeometry(s.value(KEY_GEOMETRY).toByteArray());
	restoreState(s.value(KEY_STATE).toByteArray());
	ui->splitter->restoreState(s.value(KEY_SPLITTER_SIZES).toByteArray());
	ui->leftPanel->restorePanelGeometry(s.value(KEY_LPANEL_GEOMETRY).toByteArray());
	ui->leftPanel->restorePanelState(s.value(KEY_LPANEL_STATE).toByteArray());
	ui->rightPanel->restorePanelGeometry(s.value(KEY_RPANEL_GEOMETRY).toByteArray());
	ui->rightPanel->restorePanelState(s.value(KEY_RPANEL_STATE).toByteArray());

	ui->commandLine->addItems(s.value(KEY_LAST_COMMANDS_EXECUTED).toStringList());
	ui->commandLine->lineEdit()->clear();

	show();

	Panel lastActivePanel = (Panel)CSettings().value(KEY_LAST_ACTIVE_PANEL, LeftPanel).toInt();
	if (lastActivePanel == LeftPanel)
		ui->leftPanel->setFocusToFileList();
	else
		ui->rightPanel->setFocusToFileList();
}
LPSTR CExceptionHandler::GetVersionInformation()
{
	LPSTR szResult = NULL;
	LPVOID lpData = NULL;

// (( scope ))
{
	stringstream szDetails;

	// Load the version information.

	wstring szFilename(GetModuleFileNameEx());

	DWORD dwHandle = 0;
	DWORD dwSize = GetFileVersionInfoSize(szFilename.c_str(), &dwHandle);

	if (dwSize == 0)
	{
		goto __end;
	}

	lpData = malloc(dwSize);

	if (!GetFileVersionInfo(szFilename.c_str(), dwHandle, dwSize, lpData))
	{
		goto __end;
	}

	// Get the product name.

	UINT uLen;
	LPCWSTR szData;

	if (!VerQueryValue(lpData, L"\\StringFileInfo\\040904b0\\ProductName", (LPVOID*)&szData, &uLen))
	{
		goto __end;
	}

	szDetails << "ProductName=" << ConvertToMultiByte(szData) << "\n";

	// Get the vendor.

	if (!VerQueryValue(lpData, L"\\StringFileInfo\\040904b0\\CompanyName", (LPVOID*)&szData, &uLen))
	{
		goto __end;
	}

	szDetails << "Vendor=" << ConvertToMultiByte(szData) << "\n";

	// Get the application version.

	VS_FIXEDFILEINFO * lpffi;

	if (!VerQueryValue(lpData, L"\\", (LPVOID *)&lpffi, &uLen))
	{
		goto __end;
	}

	ASSERT(lpffi != NULL);

	wstring szVersion(Format(
		L"%d.%d.%d.%d",
		(INT)HIWORD(lpffi->dwProductVersionMS),
		(INT)LOWORD(lpffi->dwProductVersionMS),
		(INT)HIWORD(lpffi->dwProductVersionLS),
		(INT)LOWORD(lpffi->dwProductVersionLS)));

	szDetails << "Version=" << ConvertToMultiByte(szVersion) << "\n";

	// Build the server URL.

	szDetails << "ServerURL=" << ConvertToMultiByte(CRASH_SERVER_URL) << "\n";

	wstring szCookie;

	if (CSettings(FALSE).GetStatisticsCookie(szCookie))
	{
		szDetails << "Cookie=" << ConvertToMultiByte(szCookie) << "\n";
	}

	szResult = _strdup(szDetails.str().c_str());
}

__end:
	if (lpData != NULL)
	{
		free(lpData);
	}

	return szResult;
}
void CPromptDialog::hideEvent(QHideEvent* e)
{
	CSettings().setValue(KEY_PROMPT_DIALOG_GEOMETRY, saveGeometry());
	QDialog::hideEvent(e);
}
void CMainWindow::showHiddenFiles()
{
	CSettings().setValue(KEY_INTERFACE_SHOW_HIDDEN_FILES, ui->action_Show_hidden_files->isChecked());
	_controller->refreshPanelContents(LeftPanel);
	_controller->refreshPanelContents(RightPanel);
}