Esempio n. 1
0
void FileBrowser::setFilter(const QStringList &filter)
{
	_filter = filter;
	if (!_files.isEmpty())
		reloadDirectory(_files.last().canonicalPath());
}
Esempio n. 2
0
MainWindow::MainWindow(bool verbose, QWindow *parent) : QQuickView(parent) {

	connect(this, SIGNAL(statusChanged(QQuickView::Status)), this, SLOT(loadStatus(QQuickView::Status)));

#ifdef Q_OS_WIN
	QtWin::enableBlurBehindWindow(this);
#endif

	// Settings and variables
	settingsPerSession = new SettingsSession;
	settingsPermanent = new Settings;
	fileformats = new FileFormats(verbose);
	variables = new Variables;
	shortcuts = new Shortcuts;
	touch = new TouchHandler;

	variables->verbose = verbose;

	overrideCursorHowOftenSet = 0;

	this->setMinimumSize(QSize(800,600));

	// Add image providers
	this->engine()->addImageProvider("thumb",new ImageProviderThumbnail);
	this->engine()->addImageProvider("full",new ImageProviderFull);
	this->engine()->addImageProvider("icon",new ImageProviderIcon);

	// Add settings access to QML
	qmlRegisterType<Settings>("Settings", 1, 0, "Settings");
	qmlRegisterType<FileFormats>("FileFormats", 1, 0, "FileFormats");
	qmlRegisterType<SettingsSession>("SettingsSession", 1, 0, "SettingsSession");
	qmlRegisterType<GetMetaData>("GetMetaData", 1, 0, "GetMetaData");
	qmlRegisterType<GetAndDoStuff>("GetAndDoStuff", 1, 0, "GetAndDoStuff");
	qmlRegisterType<ThumbnailManagement>("ThumbnailManagement", 1, 0, "ThumbnailManagement");
	qmlRegisterType<ToolTip>("ToolTip", 1, 0, "ToolTip");
	qmlRegisterType<ShortcutsNotifier>("ShortcutsNotifier", 1, 0, "ShortcutsNotifier");
	qmlRegisterType<Colour>("Colour", 1, 0, "Colour");

	// Load QML
	this->setSource(QUrl("qrc:/qml/mainwindow.qml"));
	this->setColor(QColor(Qt::transparent));

	// Get object (for signals and stuff)
	object = this->rootObject();

	// Class to load a new directory
	loadDir = new LoadDir(verbose);

	// Scrolled view
	connect(object, SIGNAL(thumbScrolled(int)), this, SLOT(handleThumbnails(int)));


	connect(object, SIGNAL(reloadDirectory(QString,QString)), this, SLOT(handleOpenFileEvent(QString,QString)));
	connect(object, SIGNAL(loadMoreThumbnails()), this, SLOT(loadMoreThumbnails()));
	connect(object, SIGNAL(didntLoadThisThumbnail(int)), this, SLOT(didntLoadThisThumbnail(int)));
	connect(object, SIGNAL(setOverrideCursor()), this, SLOT(setOverrideCursor()));
	connect(object, SIGNAL(restoreOverrideCursor()), this, SLOT(restoreOverrideCursor()));
	connect(object, SIGNAL(stopThumbnails()), this, SLOT(stopThumbnails()));
	connect(object, SIGNAL(reloadThumbnails()), this, SLOT(reloadThumbnails()));

	connect(object, SIGNAL(verboseMessage(QString,QString)), this, SLOT(qmlVerboseMessage(QString,QString)));

	// Hide/Quit window
	connect(object, SIGNAL(hideToSystemTray()), this, SLOT(hideToSystemTray()));
	connect(object, SIGNAL(quitPhotoQt()), this, SLOT(quitPhotoQt()));

	// React to some settings...
	connect(settingsPermanent, SIGNAL(trayiconChanged(int)), this, SLOT(showTrayIcon()));
	connect(settingsPermanent, SIGNAL(trayiconChanged(int)), this, SLOT(hideTrayIcon()));
	connect(settingsPermanent, SIGNAL(windowmodeChanged(bool)), this, SLOT(updateWindowGeometry()));
	connect(settingsPermanent, SIGNAL(windowDecorationChanged(bool)), this, SLOT(updateWindowGeometry()));

	connect(this, SIGNAL(xChanged(int)), this, SLOT(updateWindowXandY()));
	connect(this, SIGNAL(yChanged(int)), this, SLOT(updateWindowXandY()));

	// Pass on touchevent
	connect(touch, SIGNAL(receivedTouchEvent(QPointF,QPointF,qint64,int,QStringList)), this, SLOT(passOnTouchEvent(QPointF,QPointF,qint64,int,QStringList)));
	connect(touch, SIGNAL(setImageInteractiveMode(bool)), this, SLOT(setImageInteractiveMode(bool)));

	showTrayIcon();

	// We need to call this with a little delay, as the automatic restoration of the window geometry at startup when window mode
	// is enabled doesn't update the actualy window x/y (and thus PhotoQt might be detected on the wrong screen which messes up
	// calculations involving local cursor coordinates (e.g., for 'close on click on grey'))
	QTimer::singleShot(100,this, SLOT(updateWindowXandY()));

}