Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Make welcome page not show missing shortcuts as X

Carsten Hartenfels3637d58578cc
diff --git a/libs/ui/KisWelcomePageWidget.cpp b/libs/ui/KisWelcomePageWidget.cpp
index 3c44e7a832..6b3008c006 100644
--- a/libs/ui/KisWelcomePageWidget.cpp
+++ b/libs/ui/KisWelcomePageWidget.cpp
@@ -255,14 +255,9 @@ void KisWelcomePageWidget::setMainWindow(KisMainWindow* mainWin)
m_mainWindow = mainWin;
// set the shortcut links from actions (only if a shortcut exists)
- if ( mainWin->viewManager()->actionManager()->actionByName("file_new")->shortcut().toString() != "") {
- newFileLinkShortcut->setText(
- QString("(") + mainWin->viewManager()->actionManager()->actionByName("file_new")->shortcut().toString(QKeySequence::NativeText) + QString(")"));
- }
- if (mainWin->viewManager()->actionManager()->actionByName("file_open")->shortcut().toString() != "") {
- openFileShortcut->setText(
- QString("(") + mainWin->viewManager()->actionManager()->actionByName("file_open")->shortcut().toString(QKeySequence::NativeText) + QString(")"));
- }
+ KisActionManager *actionManager = mainWin->viewManager()->actionManager();
+ updateShortcutLink(newFileLink, newFileLinkShortcut, actionManager->actionByName(QStringLiteral("file_new")));
+ updateShortcutLink(openFileLink, openFileShortcut, actionManager->actionByName(QStringLiteral("file_open")));
connect(recentDocumentsListView, SIGNAL(clicked(QModelIndex)), this, SLOT(recentDocumentClicked(QModelIndex)));
// we need the view manager to actually call actions, so don't create the connections
// until after the view manager is set
@@ -616,6 +611,23 @@ void KisWelcomePageWidget::showDevVersionHighlight()
}
}
+void KisWelcomePageWidget::updateShortcutLink(QToolButton *button, QLabel *label, QAction *action)
+{
+ if (action) {
+ QString shortcutText = action->shortcut().toString(QKeySequence::NativeText);
+ if (shortcutText.isEmpty()) {
+ label->setText(QString());
+ } else {
+ label->setText(QStringLiteral("(%1)").arg(shortcutText));
+ }
+ button->show();
+ label->show();
+ } else {
+ button->hide();
+ label->hide();
+ }
+}
+
void KisWelcomePageWidget::recentDocumentClicked(QModelIndex index)
{
QString fileUrl = index.data(Qt::ToolTipRole).toString();
diff --git a/libs/ui/KisWelcomePageWidget.h b/libs/ui/KisWelcomePageWidget.h
index ca00ce74f3..51d6b2d03c 100644
--- a/libs/ui/KisWelcomePageWidget.h
+++ b/libs/ui/KisWelcomePageWidget.h
@@ -100,6 +100,8 @@ private:
void setupNewsLangSelection(QMenu *newsOptionMenu);
void showDevVersionHighlight();
+ static void updateShortcutLink(QToolButton *button, QLabel *label, QAction *action);
+
#ifdef ENABLE_UPDATERS
void updateVersionUpdaterFrame();
#endif