Commit 4367d06b authored by Felix Ernst's avatar Felix Ernst 🇺🇦 Committed by Nate Graham
Browse files

Add tooltips for "Fit" and "Show Thumbnails" actions

"Fit" is a bit non-descriptive so a tooltip is added: "Fit image into the
viewing area".

Its text is changed from "Zoom to fit" to "Zoom to Fit" (capital "F") to
conform with the HIG.

An expanded tooltip is also added so users who might not understand why
smaller images aren't enlarged are aware of the setting "Enlarge smaller
images". A hyperlink is added to the help text that will open the
relevant settings page.

"Show Thumbnails" also gets an expanded tooltip mostly to make
users aware of the cool functionalities and settings it has.

Some other useful information is also added to the help texts.
parent 4e43fa72
Pipeline #141509 passed with stage
in 3 minutes and 50 seconds
......@@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Local
#include <lib/gwenviewconfig.h>
#include <lib/invisiblebuttongroup.h>
namespace Gwenview
{
......@@ -46,8 +47,6 @@ ConfigDialog::ConfigDialog(QWidget *parent)
{
setFaceType(KPageDialog::List);
KPageWidgetItem *pageItem;
// General
QWidget *widget = setupPage(mGeneralConfigPage);
......@@ -68,8 +67,8 @@ ConfigDialog::ConfigDialog(QWidget *parent)
mThumbnailActionsGroup->addButton(mGeneralConfigPage.selectionOnlyThumbnailActionsRadioButton, int(ThumbnailActions::ShowSelectionButtonOnly));
mThumbnailActionsGroup->addButton(mGeneralConfigPage.noneThumbnailActionsRadioButton, int(ThumbnailActions::None));
pageItem = addPage(widget, i18n("General"));
pageItem->setIcon(QIcon::fromTheme(QStringLiteral("gwenview")));
mGeneralConfigPageItem = addPage(widget, i18n("General"));
mGeneralConfigPageItem->setIcon(QIcon::fromTheme(QStringLiteral("gwenview")));
connect(mGeneralConfigPage.kcfg_JPEGQuality, &QAbstractSlider::valueChanged, this, [=](int value) {
mGeneralConfigPage.jpegQualitySpinner->setValue(value);
});
......@@ -121,8 +120,8 @@ ConfigDialog::ConfigDialog(QWidget *parent)
mThumbnailBarOrientationGroup->addButton(mImageViewConfigPage.horizontalRadioButton, int(Qt::Horizontal));
mThumbnailBarOrientationGroup->addButton(mImageViewConfigPage.verticalRadioButton, int(Qt::Vertical));
pageItem = addPage(widget, i18n("Image View"));
pageItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-display-color")));
mImageViewConfigPageItem = addPage(widget, i18n("Image View"));
mImageViewConfigPageItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-display-color")));
// Advanced
widget = setupPage(mAdvancedConfigPage);
......@@ -132,12 +131,24 @@ ConfigDialog::ConfigDialog(QWidget *parent)
mRenderingIntentGroup->addButton(mAdvancedConfigPage.relativeRenderingIntentRadioButton, int(RenderingIntent::Relative));
mRenderingIntentGroup->addButton(mAdvancedConfigPage.perceptualRenderingIntentRadioButton, int(RenderingIntent::Perceptual));
pageItem = addPage(widget, i18n("Advanced"));
pageItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-other")));
mAdvancedConfigPageItem = addPage(widget, i18n("Advanced"));
mAdvancedConfigPageItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-other")));
mAdvancedConfigPage.cacheHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
mAdvancedConfigPage.perceptualHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
mAdvancedConfigPage.relativeHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
mAdvancedConfigPage.colorProfileHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
}
void ConfigDialog::setCurrentPage(int page)
{
switch (page) {
case 1:
return KPageDialog::setCurrentPage(mImageViewConfigPageItem);
case 2:
return KPageDialog::setCurrentPage(mAdvancedConfigPageItem);
default:
return KPageDialog::setCurrentPage(mGeneralConfigPageItem);
}
}
} // namespace
......@@ -30,16 +30,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ui_advancedconfigpage.h"
#include "ui_generalconfigpage.h"
#include "ui_imageviewconfigpage.h"
#include <lib/invisiblebuttongroup.h>
namespace Gwenview
{
class InvisibleButtonGroup;
class ConfigDialog : public KConfigDialog
{
Q_OBJECT
public:
ConfigDialog(QWidget *parent);
/**
* Changes the page being displayed.
* @param page The page to be shown counted from the top.
*/
void setCurrentPage(int page);
private:
InvisibleButtonGroup *mWrapNavigationBehaviorGroup = nullptr;
InvisibleButtonGroup *mAlphaBackgroundModeGroup = nullptr;
......@@ -53,6 +60,9 @@ private:
Ui_GeneralConfigPage mGeneralConfigPage;
Ui_ImageViewConfigPage mImageViewConfigPage;
Ui_AdvancedConfigPage mAdvancedConfigPage;
KPageWidgetItem *mGeneralConfigPageItem;
KPageWidgetItem *mImageViewConfigPageItem;
KPageWidgetItem *mAdvancedConfigPageItem;
};
} // namespace
......
......@@ -918,6 +918,48 @@ struct MainWindow::Private {
printHelper.print(doc);
}
}
/// Handles the clicking of links in help texts if the clicked url uses the "gwenview:" scheme.
class InternalUrlClickedHandler : public QObject
{
public:
InternalUrlClickedHandler(MainWindow *parent)
: QObject(parent)
{
Q_CHECK_PTR(parent);
}
inline bool eventFilter(QObject * /* watched */, QEvent *event) override
{
if (event->type() != QEvent::WhatsThisClicked) {
return false;
}
const QString linkAddress = static_cast<QWhatsThisClickedEvent *>(event)->href();
if (!linkAddress.startsWith(QStringLiteral("gwenview:"))) {
// This eventFilter only handles our internal "gwenview" scheme. Everything else is handled by KXmlGui::KToolTipHelper.
return false;
}
event->accept();
auto linkPathList = linkAddress.split(QLatin1Char('/'));
linkPathList.removeFirst(); // remove "gwenview:/"
Q_ASSERT(!linkPathList.isEmpty());
Q_ASSERT_X(linkPathList.constFirst() == QStringLiteral("config"), "link resolver", "Handling of this URL is not yet implemented");
linkPathList.removeFirst(); // remove "config/"
auto mainWindow = static_cast<MainWindow *>(parent());
if (linkPathList.isEmpty()) {
mainWindow->showConfigDialog();
} else if (linkPathList.constFirst() == QStringLiteral("general")) {
mainWindow->showConfigDialog(0); // "0" should open General.
} else if (linkPathList.constFirst() == QStringLiteral("imageview")) {
mainWindow->showConfigDialog(1); // "1" should open Image View.
} else if (linkPathList.constFirst() == QStringLiteral("advanced")) {
mainWindow->showConfigDialog(2); // "2" should open Advanced.
} else {
Q_ASSERT_X(false, "config link resolver", "Handling of this config URL is not yet implemented");
}
return true;
}
};
};
MainWindow::MainWindow()
......@@ -966,6 +1008,7 @@ MainWindow::MainWindow()
#ifdef Q_OS_OSX
qApp->installEventFilter(this);
#endif
qApp->installEventFilter(new Private::InternalUrlClickedHandler(this));
}
MainWindow::~MainWindow()
......@@ -1678,7 +1721,7 @@ bool MainWindow::queryClose()
}
}
void MainWindow::showConfigDialog()
void MainWindow::showConfigDialog(int page)
{
// Save first so changes like thumbnail zoom level are not lost when reloading config
saveConfig();
......@@ -1687,6 +1730,7 @@ void MainWindow::showConfigDialog()
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setModal(true);
connect(dialog, &KConfigDialog::settingsChanged, this, &MainWindow::loadConfig);
dialog->setCurrentPage(page);
dialog->show();
}
......
......@@ -121,7 +121,11 @@ private Q_SLOTS:
void showDocumentInFullScreen(const QUrl &);
void showConfigDialog();
/**
* Shows Gwenview's settings dialog.
* @param page defines which page should be shown initially.
*/
void showConfigDialog(int page = 0);
void loadConfig();
void print();
void printPreview();
......
......@@ -427,6 +427,13 @@ ViewMainPage::ViewMainPage(QWidget *parent, SlideShow *slideShow, KActionCollect
d->mToggleThumbnailBarAction = view->add<KToggleAction>(QStringLiteral("toggle_thumbnailbar"));
d->mToggleThumbnailBarAction->setText(i18n("Show Thumbnails"));
d->mToggleThumbnailBarAction->setIcon(QIcon::fromTheme(QStringLiteral("folder-image")));
// clang-format off
// i18n: For languages that are read right to left, "right side" refers to the left side in this context.
d->mToggleThumbnailBarAction->setWhatsThis(xi18nc("@info:whatsthis", "<para>This toggles a small bar showing all the other images in the current folder. "
"Selecting one of them changes the currently viewed image.</para><para>Select multiple images at the same time to see them side by side.</para>"
"<para>The bar can optionally be moved to the right side of the screen and contain multiple rows of images; <link url='%1'>configure these options in the settings</link>.</para>", QStringLiteral("gwenview:/config/imageview")));
// Keep the previous link address in sync with MainWindow::Private::SettingsOpenerHelper::eventFilter().
// clang-format on
actionCollection->setDefaultShortcut(d->mToggleThumbnailBarAction, Qt::CTRL | Qt::Key_B);
connect(d->mToggleThumbnailBarAction, &KToggleAction::triggered, this, &ViewMainPage::setThumbnailBarVisibility);
d->mToggleThumbnailBarButton->setDefaultAction(d->mToggleThumbnailBarAction);
......
......@@ -60,9 +60,24 @@ struct DocumentViewControllerPrivate {
view->collection()->setDefaultShortcut(mZoomToFitAction, Qt::Key_F);
mZoomToFitAction->setCheckable(true);
mZoomToFitAction->setChecked(true);
mZoomToFitAction->setText(i18n("Zoom to fit"));
mZoomToFitAction->setText(i18n("Zoom to Fit"));
mZoomToFitAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-fit-best")));
mZoomToFitAction->setIconText(i18nc("@action:button Zoom to fit, shown in status bar, keep it short please", "Fit"));
mZoomToFitAction->setToolTip(i18nc("@info:tooltip", "Fit image into the viewing area"));
// clang-format off
// i18n: "a previous zoom value" is worded in such an unclear way because it can either be the zoom value for the image viewed previously or the
// zoom value that was used the last time this same image was viewed. Being more clear about this isn't really necessary here so I kept it short
// but a more elaborate translation would also be fine.
// The text "in the settings" is supposed to sound like clicking it opens the settings.
mZoomToFitAction->setWhatsThis(xi18nc("@info:whatsthis, %1 the action's text", "<para>This fits the image into the available viewing area:<list>"
"<item>Images that are bigger than the viewing area are displayed at a smaller size so they fit.</item>"
"<item>Images that are smaller than the viewing area are displayed at their normal size. If smaller images should instead use all of "
"the available viewing area, turn on <emphasis>Enlarge smaller images</emphasis> <link url='%2'>in the settings</link>.</item></list></para>"
"<para>If \"%1\" is already enabled, pressing it again will switch it off and the image will be displayed at its normal size instead.</para>"
"<para>\"%1\" is the default zoom mode for images. This can be changed so images are displayed at a previous zoom value instead "
"<link url='%2'>in the settings</link>.</para>", mZoomToFitAction->iconText(), QStringLiteral("gwenview:/config/imageview")));
// Keep the previous link address in sync with MainWindow::Private::SettingsOpenerHelper::eventFilter().
// clang-format on
mZoomToFillAction = view->addAction(QStringLiteral("view_zoom_to_fill"));
view->collection()->setDefaultShortcut(mZoomToFillAction, Qt::SHIFT | Qt::Key_F);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment