示例#1
0
void GraphicsView::setupContextMenu() {

	// Get the last modification date
	qint64 secs = QFileInfo(QDir::homePath() + "/.photoqt/contextmenu").lastModified().toMSecsSinceEpoch();

	// If the menu has been modified since last time or hasn't been setup yet, we set it up
	if(secs != menuLastChange || !menuSetup) {

		menuSetup = true;
		menuLastChange = secs;

		// Make sure it's empty (after a change, we would re-setup the menu and not calling clear() would lead to double entries)
		menu->clear();


		// Move in directory
		QWidgetAction *moveImg = new QWidgetAction(menu);
		CustomLabel *move = new CustomLabel(tr("Move:"));
		move->setStyleSheet("QLabel {color: rgba(180,180,180,255); background: transparent; }");
		CustomLabel *moveFirst = new CustomLabel;
		moveFirst->setPixmap(QPixmap(":/img/firstSmall.png"));
		moveFirst->setObjectName("__CTX__movefirst");
		moveFirst->setCursor(Qt::PointingHandCursor);
		CustomLabel *moveLeft = new CustomLabel(tr("Previous"));
		moveLeft->setObjectName("__CTX__moveprev");
		moveLeft->setCursor(Qt::PointingHandCursor);
		CustomLabel *moveRight = new CustomLabel(tr("Next"));
		moveRight->setObjectName("__CTX__movenext");
		moveRight->setCursor(Qt::PointingHandCursor);
		CustomLabel *moveLast = new CustomLabel;
		moveLast->setPixmap(QPixmap(":/img/lastSmall.png"));
		moveLast->setObjectName("__CTX__movelast");
		moveLast->setCursor(Qt::PointingHandCursor);
		QWidget *moveWid = new QWidget;
		QHBoxLayout *moveLay = new QHBoxLayout;
		moveLay->addWidget(move);
		moveLay->addSpacing(5);
		moveLay->addWidget(moveFirst);
		moveLay->addSpacing(5);
		moveLay->addWidget(moveLeft);
		moveLay->addWidget(moveRight);
		moveLay->addSpacing(5);
		moveLay->addWidget(moveLast);
		moveLay->addStretch();
		moveWid->setLayout(moveLay);
		moveImg->setDefaultWidget(moveWid);
		menu->addAction(moveImg);
		connect(moveFirst, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(moveLeft, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(moveRight, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(moveLast, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));

		// Rotate Image
		QWidgetAction *rotateImg = new QWidgetAction(menu);
		CustomLabel *rot = new CustomLabel(tr("Rotate:"));
		rot->setStyleSheet("QLabel {color: rgba(180,180,180,255); background: transparent; }");
		CustomLabel *rotLeft = new CustomLabel("<img src=\":/img/rotateLeftSmall.png\"> " + tr("Left"));
		rotLeft->setObjectName("__CTX__rotateleft");
		rotLeft->setCursor(Qt::PointingHandCursor);
		CustomLabel *rotRight = new CustomLabel(tr("Right") + " <img src=\":/img/rotateRightSmall.png\">");
		rotRight->setObjectName("__CTX__rotateright");
		rotRight->setCursor(Qt::PointingHandCursor);
		QWidget *rotWid = new QWidget;
		QHBoxLayout *rotLay = new QHBoxLayout;
		rotLay->addWidget(rot);
		rotLay->addSpacing(5);
		rotLay->addWidget(rotLeft);
		rotLay->addSpacing(10);
		rotLay->addWidget(rotRight);
		rotLay->addStretch();
		rotWid->setLayout(rotLay);
		rotateImg->setDefaultWidget(rotWid);
		menu->addAction(rotateImg);
		connect(rotLeft, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(rotRight, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));

		// Flip Image
		QWidgetAction *flipImg = new QWidgetAction(menu);
		CustomLabel *flip = new CustomLabel(tr("Flip:"));
		flip->setStyleSheet("QLabel {color: rgba(180,180,180,255); background: transparent; }");
		CustomLabel *flipHor = new CustomLabel("<img src=\":/img/flipHSmall.png\"> " + tr("Horizontal"));
		flipHor->setObjectName("__CTX__fliph");
		flipHor->setCursor(Qt::PointingHandCursor);
		CustomLabel *flipVer = new CustomLabel("<img src=\":/img/flipVSmall.png\">" + tr("Vertical"));
		flipVer->setObjectName("__CTX__flipv");
		flipVer->setCursor(Qt::PointingHandCursor);
		QWidget *flipWid = new QWidget;
		QHBoxLayout *flipLay = new QHBoxLayout;
		flipLay->addWidget(flip);
		flipLay->addSpacing(5);
		flipLay->addWidget(flipHor);
		flipLay->addSpacing(5);
		flipLay->addWidget(flipVer);
		flipLay->addStretch();
		flipWid->setLayout(flipLay);
		flipImg->setDefaultWidget(flipWid);
		menu->addAction(flipImg);
		connect(flipHor, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(flipVer, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));

		// Zoom Image
		QWidgetAction *zoomImg = new QWidgetAction(menu);
		CustomLabel *zoom = new CustomLabel(tr("Zoom:"));
		zoom->setStyleSheet("QLabel {color: rgba(180,180,180,255); background: transparent; }");
		CustomLabel *zoomIn = new CustomLabel("(+) " + tr("In"));
		zoomIn->setObjectName("__CTX__zoomin");
		zoomIn->setCursor(Qt::PointingHandCursor);
		CustomLabel *zoomOut = new CustomLabel("(-) " + tr("Out"));
		zoomOut->setObjectName("__CTX__zoomout");
		zoomOut->setCursor(Qt::PointingHandCursor);
		CustomLabel *zoomActual = new CustomLabel("(1:1) " + tr("Actual"));
		zoomActual->setObjectName("__CTX__zoomactual");
		zoomActual->setCursor(Qt::PointingHandCursor);
		CustomLabel *zoomReset = new CustomLabel("(0) " + tr("Reset"));
		zoomReset->setObjectName("__CTX__zoomreset");
		zoomReset->setCursor(Qt::PointingHandCursor);
		QWidget *zoomWid = new QWidget;
		QHBoxLayout *zoomLay = new QHBoxLayout;
		zoomLay->addWidget(zoom);
		zoomLay->addSpacing(5);
		zoomLay->addWidget(zoomIn);
		zoomLay->addSpacing(5);
		zoomLay->addWidget(zoomOut);
		zoomLay->addSpacing(5);
		zoomLay->addWidget(zoomActual);
		zoomLay->addSpacing(5);
		zoomLay->addWidget(zoomReset);
		zoomLay->addStretch();
		zoomWid->setLayout(zoomLay);
		zoomImg->setDefaultWidget(zoomWid);
		menu->addAction(zoomImg);
		connect(zoomIn, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(zoomOut, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(zoomActual, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));
		connect(zoomReset, SIGNAL(clicked()), this, SLOT(contextMenuClickedWidgetAction()));

		menu->addSeparator();

		QAction *scale = new QAction(tr("Scale Image"), menu);
		scale->setData("__CTX__scaleimage");
		scale->setIcon(QIcon(":/img/scale.png"));
		menu->addAction(scale);
		connect(scale, SIGNAL(triggered()), this, SLOT(contextMenuClicked()));

		menu->addSeparator();

		QAction *openInFm = new QAction(tr("Open in default File Manager"), menu);
		openInFm->setData("__CTX__openinfm");
		openInFm->setIcon(QIcon(":/img/open.png"));
		menu->addAction(openInFm);
		connect(openInFm, SIGNAL(triggered()), this, SLOT(contextMenuClicked()));

		QAction *deleteFile = new QAction(tr("Delete File"), menu);
		deleteFile->setData("__CTX__delete");
		deleteFile->setIcon(QIcon(":/img/delete.png"));
		menu->addAction(deleteFile);
		connect(deleteFile, SIGNAL(triggered()), this, SLOT(contextMenuClicked()));

		QAction *renameFile = new QAction(tr("Rename File"), menu);
		renameFile->setData("__CTX__rename");
		renameFile->setIcon(QIcon(":/img/rename.png"));
		menu->addAction(renameFile);
		connect(renameFile, SIGNAL(triggered()), this, SLOT(contextMenuClicked()));

		menu->addSeparator();

		// Now read in the additional entries from file
		QFile file(QDir::homePath() + "/.photoqt/contextmenu");

		if(file.open(QIODevice::ReadOnly)) {

			QTextStream in(&file);

			QStringList all = in.readAll().split("\n\n",QString::SkipEmptyParts);

			// And set up the rest of the menu
			for(int i = 0; i < all.length(); ++i) {

				QString cmd = all.at(i).split("\n").at(0);
				QString desc = all.at(i).split("\n").at(1);

				QString binary = cmd;
				binary = binary.remove("%f").remove("%d");

				binary = binary.trimmed();

				QAction *action = new QAction(desc, menu);
				action->setIcon(QIcon::fromTheme(binary));
				action->setData(cmd);
				menu->addAction(action);

				connect(action, SIGNAL(triggered()), this, SLOT(contextMenuClicked()));

			}

		}

	}

}
示例#2
0
StartUpWidget::StartUpWidget(QWidget *parent) : MyWidget(parent) {

	this->setFullscreen(true);

	// A close button to close widget
	CustomPushButton *close = new CustomPushButton(tr("Okay, I got enough now. Lets start!"));
	close->setFontSize("12pt");
	QHBoxLayout *butLay = new QHBoxLayout;
	butLay->setMargin(8);
	butLay->addStretch();
	butLay->addWidget(close);
	butLay->addStretch();
	connect(close, SIGNAL(clicked()), this, SLOT(animate()));

	// Line above buttons
	CustomLine *line = new CustomLine;

	// Create and set the main layout
	QVBoxLayout *lay = new QVBoxLayout;
	this->setWidgetLayout(lay);
	this->addWidgetAtBottom(line);
	this->addButtonLayout(butLay);

	// The title is set depending on update or fresh install
	title = new CustomLabel;
	title->setFontSize(20);
	title->setBold(true);
	title->setAlignment(Qt::AlignCenter);
	title->setTextInteractionFlags(Qt::TextSelectableByMouse);

	// The logo
	CustomLabel *logo = new CustomLabel;
	QPixmap splash(":/img/logo.png");
	logo->setPixmap(splash);
	logo->setAlignment(Qt::AlignCenter);

	// The introduction is set depending on update or fresh install
	customIntro = new CustomLabel;
	customIntro->setFontSize(12);
	customIntro->setWordWrap(true);
	customIntro->setTextInteractionFlags(Qt::TextSelectableByMouse);

	// the description is the same in both cases
	CustomLabel *desc = new CustomLabel;
	desc->setFontSize(12);
	desc->setWordWrap(true);
	desc->setTextInteractionFlags(Qt::TextSelectableByMouse);

	QString descTxt = "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/fileformats.png\">";
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Many File Formats") + "</span><br>" + tr("PhotoQt can make use of GraphicsMagick, an image library, to display many different image formats. Currently, there are up to 72 different file formats supported (exact number depends on your system)! You can find a list of it in the settings (Tab 'Other'). There you can en-/disable different ones and also add custom file endings.");
	descTxt += "</td></tr>";

	descTxt += "</table>";
	descTxt += "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Make PhotoQt your own") + "</span><br>" + tr("PhotoQt has an extensive settings area. By default you can call it with the shortcut 'e' or through the dropdown menu at the top edge towards the top right corner. You can adjust almost everything in PhotoQt, and it's certainly worth having a look there. Each setting usually comes with a little explanation text.");
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/settings.png\">";
	descTxt += "</td></tr>";

	descTxt += "</table>";
	descTxt += "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/thumbnails.png\">";
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Thumbnails") + "</span><br>" + tr("What would be an image viewer without thumbnails support? It would only be half as good. Whenever you load an image, PhotoQt loads the other images in the directory in the background (by default, it tries to be smart about it and only loads the ones that are needed). It lines them up in a row at the bottom edge (move your mouse there to see them). There are many settings just for the thumbnails, like, e.g., size, liftup, en-/disabled, type, filename, permanently shown/hidden, etc. PhotoQt's quite flexible with that.");
	descTxt += "</td></tr>";

	descTxt += "</table>";
	descTxt += "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Shortcuts") + "</span><br>" + tr("One of the many strengths of PhotoQt is the ability to easily set a shortcut for almost anything. Even mouse shortcuts are possible! You can choose from a huge number of internal functions, or you can run any custom script or command.");
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/shortcuts.png\">";
	descTxt += "</td></tr>";

	descTxt += "</table>";
	descTxt += "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/exif.png\">";
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Image Information (Exif)") + "</span><br>" + tr("Most images store some information about the image in the file. PhotoQt can read and display a good bit of that (currently, only Exif is supported). You can find this information in the slide-in window hidden behind the left edge of PhotoQt.");
	descTxt += "</td></tr>";

	descTxt += "</table>";
	descTxt += "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Slideshow") + "</span><br>" + tr("PhotoQt also brings a slideshow feature. When you start a slideshow, it starts at the currently displayed image. There are a couple settings like transition, speed, loop, and shuffle. Plus, you can set a music file that is played in the background. When the slideshow takes longer than the music file, then PhotoQt starts the music file all over from the beginning. At anytime during the slideshow, you can move the mouse cursor to the top edge of the screen to get a little bar, where you can pause/exit the slideshow and adjust the music volume.");
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/slideshow.png\">";
	descTxt += "</td></tr>";

	descTxt += "</table>";
	descTxt += "<table>";

	descTxt += "<tr><td style=\"vertical-align: middle\">";
		descTxt += "<img src=\":/img/startupwidget/localisation.png\">";
	descTxt += "</td><td style=\"vertical-align: middle\">";
		descTxt += "<span style=\"font-size: 15pt; font-weight: bold\">" + tr("Localisation") + "</span><br>" + tr("PhotoQt comes with a number of translations. Many have taken some of their time to create/update one of them (Thank you!). Not all of them are complete... do you want to help?");
	descTxt += "</td></tr>";

	descTxt += "</table><br><br><br>";

	descTxt += tr("There are many many more features. Best is, you just give it a go. Don't forget to check out the settings to make PhotoQt YOUR image viewer.") + "<br><br><br>" + tr("Enjoy :-)") + "<br><br>";

	desc->setText(descTxt);

	lay->addSpacing(40);
	lay->addWidget(logo);
	lay->addSpacing(30);
	lay->addWidget(title);
	lay->addSpacing(20);
	lay->addWidget(customIntro);
	lay->addSpacing(10);
	lay->addWidget(desc);
	lay->addStretch();

}