diff --git a/CMakeLists.txt b/CMakeLists.txt index 0691fcd..ddecef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,126 +1,127 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.65.0") # handled by release scripts set(KF5_DEP_VERSION "5.64.0") # handled by release scripts project(KConfigWidgets VERSION ${KF5_VERSION}) include(FeatureSummary) find_package(ECM 5.64.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(REQUIRED_QT_VERSION 5.11.0) find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED Widgets) if (NOT ANDROID) find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED DBus) endif() include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMGenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) include(ECMQtDeclareLoggingCategory) set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON) add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer") ecm_setup_version(PROJECT VARIABLE_PREFIX KCONFIGWIDGETS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kconfigwidgets_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigWidgetsConfigVersion.cmake" SOVERSION 5) if (NOT ANDROID) find_package(KF5Auth ${KF5_DEP_VERSION} REQUIRED) endif() find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Codecs ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5DocTools ${KF5_DEP_VERSION}) find_package(KF5GuiAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} REQUIRED) remove_definitions(-DQT_NO_CAST_FROM_ASCII) remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) add_definitions(-DQT_NO_FOREACH) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) +add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x053f00) add_definitions(-DTRANSLATION_DOMAIN=\"kconfigwidgets5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) if (KF5DocTools_FOUND) kdoctools_install(po) endif() file(GLOB lang_dirs "po/*") foreach(lang_dir ${lang_dirs}) get_filename_component(lang ${lang_dir} NAME) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/po/${lang}/kf5_entry.desktop") install( FILES po/${lang}/kf5_entry.desktop DESTINATION ${KDE_INSTALL_LOCALEDIR}/${lang} ) endif() endforeach() endif() if (KF5DocTools_FOUND) add_subdirectory(docs) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(tests) add_subdirectory(autotests) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5ConfigWidgets") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5ConfigWidgets_QCH FILE KF5ConfigWidgetsQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5ConfigWidgetsQchTargets.cmake\")") endif() include(CMakePackageConfigHelpers) set(HAVE_KAUTH FALSE) if (TARGET KF5::Auth) set(HAVE_KAUTH TRUE) endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5ConfigWidgetsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigWidgetsConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigWidgetsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigWidgetsConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5ConfigWidgetsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5ConfigWidgetsTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfigwidgets_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) # contains list of debug categories, for kdebugsettings install(FILES kconfigwidgets.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/kstandardaction.cpp b/src/kstandardaction.cpp index 6b15308..e3f49c3 100644 --- a/src/kstandardaction.cpp +++ b/src/kstandardaction.cpp @@ -1,741 +1,746 @@ /* This file is part of the KDE libraries Copyright (C) 1999,2000 Kurt Granroth This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kstandardaction.h" #include "kstandardaction_p.h" #include "moc_kstandardaction_p.cpp" #include "kconfigwidgets_debug.h" #include #include #include #include #include #include #include #include #include "kdualaction.h" #include "kpastetextaction.h" namespace KStandardAction { AutomaticAction::AutomaticAction(const QIcon &icon, const QString &text, const QList &shortcut, const char *slot, QObject *parent) : QAction(parent) { setText(text); setIcon(icon); setShortcuts(shortcut); setProperty("defaultShortcuts", QVariant::fromValue(shortcut)); connect(this, SIGNAL(triggered()), this, slot); } QStringList stdNames() { return internal_stdNames(); } QList actionIds() { QList result; for (uint i = 0; g_rgActionInfo[i].id != ActionNone; i++) { result.append(g_rgActionInfo[i].id); } return result; } KStandardShortcut::StandardShortcut shortcutForActionId(StandardAction id) { const KStandardActionInfo *pInfo = infoPtr(id); return (pInfo) ? pInfo->idAccel : KStandardShortcut::AccelNone; } class ShowMenubarActionFilter : public QObject { public: ShowMenubarActionFilter(QAction *parent) : QObject(parent) , wasNative(false) , wasChecked(false) , wasVisible(false) { } bool eventFilter(QObject * /*watched*/, QEvent *e) override { if (e->type() == QEvent::Show) { updateAction(); } return false; } void updateAction() { bool allMenuBarsNative = true; bool hasAnyMenuBar = false; const auto lstWidget = qApp->topLevelWidgets(); for (QWidget *w : lstWidget) { QMainWindow *mw = qobject_cast(w); if (mw) { mw->installEventFilter(this); // this is just in case a new main window appeared // if we were filtering it already it is almost a noop if (mw->layout() && mw->layout()->menuBar()) { QMenuBar *mb = qobject_cast(mw->layout()->menuBar()); if (mb) { hasAnyMenuBar = true; if (!mb->isNativeMenuBar()) { allMenuBarsNative = false; } } } } } if (!hasAnyMenuBar) return; QAction *showMenubarAction = static_cast(parent()); if (allMenuBarsNative && !wasNative) { wasNative = true; wasChecked = showMenubarAction->isChecked(); wasVisible = showMenubarAction->isVisible(); showMenubarAction->setChecked(true); showMenubarAction->setVisible(false); } else if (!allMenuBarsNative && wasNative) { showMenubarAction->setChecked(wasChecked); showMenubarAction->setVisible(wasVisible); } } bool wasNative; bool wasChecked; bool wasVisible; }; QAction* _k_createInternal(StandardAction id, QObject *parent) { static bool stdNamesInitialized = false; if (!stdNamesInitialized) { KAcceleratorManager::addStandardActionNames(stdNames()); stdNamesInitialized = true; } QAction *pAction = nullptr; const KStandardActionInfo *pInfo = infoPtr(id); // qCDebug(KCONFIG_WIDGETS_LOG) << "KStandardAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << " )"; // ellis if (pInfo) { QString sLabel, iconName = pInfo->psIconName; switch (id) { case Back: sLabel = i18nc("go back", "&Back"); if (QApplication::isRightToLeft()) { iconName = QStringLiteral("go-next"); } break; case Forward: sLabel = i18nc("go forward", "&Forward"); if (QApplication::isRightToLeft()) { iconName = QStringLiteral("go-previous"); } break; case Home: sLabel = i18nc("home page", "&Home"); break; #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 23) case Help: sLabel = i18nc("show help", "&Help"); break; #endif case Preferences: case AboutApp: case HelpContents: { QString appDisplayName = QGuiApplication::applicationDisplayName(); if (appDisplayName.isEmpty()) { appDisplayName = QCoreApplication::applicationName(); } sLabel = i18n(pInfo->psLabel, appDisplayName); } break; default: sLabel = i18n(pInfo->psLabel); } if (QApplication::isRightToLeft()) { switch (id) { case Prior: iconName = QStringLiteral("go-next-view-page"); break; case Next: iconName = QStringLiteral("go-previous-view-page"); break; case FirstPage: iconName = QStringLiteral("go-last-view-page"); break; case LastPage: iconName = QStringLiteral("go-first-view-page"); break; case DocumentBack: iconName = QStringLiteral("go-next"); break; case DocumentForward: iconName = QStringLiteral("go-previous"); break; default: break; } } if (id == Donate) { const QString currencyCode = QLocale().currencySymbol(QLocale::CurrencyIsoCode).toLower(); if (!currencyCode.isEmpty()) { iconName = QStringLiteral("help-donate-%1").arg(currencyCode); } } QIcon icon = iconName.isEmpty() ? QIcon() : QIcon::fromTheme(iconName); switch (id) { case OpenRecent: pAction = new KRecentFilesAction(parent); break; case ShowMenubar: { pAction = new KToggleAction(parent); pAction->setWhatsThis(i18n("Show Menubar

" "Shows the menubar again after it has been hidden

")); pAction->setChecked(true); ShowMenubarActionFilter *mf = new ShowMenubarActionFilter(pAction); const auto lstWidget = qApp->topLevelWidgets(); for (QWidget *w : lstWidget) { if (qobject_cast(w)) { w->installEventFilter(mf); } } mf->updateAction(); break; } case ShowToolbar: pAction = new KToggleAction(parent); pAction->setChecked(true); break; case ShowStatusbar: pAction = new KToggleAction(parent); pAction->setWhatsThis(i18n("Show Statusbar

" "Shows the statusbar, which is the bar at the bottom of the window used for status information.

")); pAction->setChecked(true); break; case FullScreen: pAction = new KToggleFullScreenAction(parent); pAction->setCheckable(true); break; #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 39) && defined(QT_DBUS_LIB) case PasteText: pAction = new KPasteTextAction(parent); break; #endif // Same as default, but with the app icon case AboutApp: { pAction = new QAction(parent); icon = qApp->windowIcon(); + // Using deprecated API for compatibility reasons, remove with KF6 if (icon.isNull()) { const KAboutData data = KAboutData::applicationData(); +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") +QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") if (!data.programIconName().isEmpty()) { icon = QIcon::fromTheme(data.programIconName()); +QT_WARNING_POP } } break; } default: pAction = new QAction(parent); break; } // Set the text before setting the MenuRole, as on OS X setText will do some heuristic role guessing. // This ensures user menu items get the intended role out of the list below. pAction->setText(sLabel); switch (id) { case Quit: pAction->setMenuRole(QAction::QuitRole); break; case Preferences: pAction->setMenuRole(QAction::PreferencesRole); break; case AboutApp: pAction->setMenuRole(QAction::AboutRole); break; default: pAction->setMenuRole(QAction::NoRole); break; } if (pInfo->psToolTip) { pAction->setToolTip(i18n(pInfo->psToolTip)); } pAction->setIcon(icon); QList cut = KStandardShortcut::shortcut(pInfo->idAccel); if (!cut.isEmpty()) { // emulate KActionCollection::setDefaultShortcuts to allow the use of "configure shortcuts" pAction->setShortcuts(cut); pAction->setProperty("defaultShortcuts", QVariant::fromValue(cut)); } pAction->setObjectName(pInfo->psName); } if (pAction && parent && parent->inherits("KActionCollection")) { QMetaObject::invokeMethod(parent, "addAction", Q_ARG(QString, pAction->objectName()), Q_ARG(QAction*, pAction)); } return pAction; } QAction *create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent) { QAction* pAction = _k_createInternal(id, parent); if (recvr && slot) { if (id == OpenRecent) { // FIXME QAction port: probably a good idea to find a cleaner way to do this // Open Recent is a special case - provide the selected URL QObject::connect(pAction, SIGNAL(urlSelected(QUrl)), recvr, slot); } else if (id == ConfigureToolbars) { // #200815 QObject::connect(pAction, SIGNAL(triggered(bool)), recvr, slot, Qt::QueuedConnection); } else { QObject::connect(pAction, SIGNAL(triggered(bool)), recvr, slot); } } return pAction; } const char *name(StandardAction id) { const KStandardActionInfo *pInfo = infoPtr(id); return (pInfo) ? pInfo->psName : nullptr; } QAction *openNew(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(New, recvr, slot, parent); } QAction *open(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Open, recvr, slot, parent); } KRecentFilesAction *openRecent(const QObject *recvr, const char *slot, QObject *parent) { return (KRecentFilesAction *) KStandardAction::create(OpenRecent, recvr, slot, parent); } QAction *save(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Save, recvr, slot, parent); } QAction *saveAs(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(SaveAs, recvr, slot, parent); } QAction *revert(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Revert, recvr, slot, parent); } QAction *print(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Print, recvr, slot, parent); } QAction *printPreview(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(PrintPreview, recvr, slot, parent); } QAction *close(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Close, recvr, slot, parent); } QAction *mail(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Mail, recvr, slot, parent); } QAction *quit(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Quit, recvr, slot, parent); } QAction *undo(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Undo, recvr, slot, parent); } QAction *redo(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Redo, recvr, slot, parent); } QAction *cut(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Cut, recvr, slot, parent); } QAction *copy(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Copy, recvr, slot, parent); } QAction *paste(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Paste, recvr, slot, parent); } #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 39) QAction *pasteText(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(PasteText, recvr, slot, parent); } #endif QAction *clear(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Clear, recvr, slot, parent); } QAction *selectAll(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(SelectAll, recvr, slot, parent); } QAction *deselect(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Deselect, recvr, slot, parent); } QAction *find(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Find, recvr, slot, parent); } QAction *findNext(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(FindNext, recvr, slot, parent); } QAction *findPrev(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(FindPrev, recvr, slot, parent); } QAction *replace(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Replace, recvr, slot, parent); } QAction *actualSize(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(ActualSize, recvr, slot, parent); } QAction *fitToPage(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(FitToPage, recvr, slot, parent); } QAction *fitToWidth(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(FitToWidth, recvr, slot, parent); } QAction *fitToHeight(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(FitToHeight, recvr, slot, parent); } QAction *zoomIn(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(ZoomIn, recvr, slot, parent); } QAction *zoomOut(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(ZoomOut, recvr, slot, parent); } QAction *zoom(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Zoom, recvr, slot, parent); } QAction *redisplay(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Redisplay, recvr, slot, parent); } QAction *up(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Up, recvr, slot, parent); } QAction *back(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Back, recvr, slot, parent); } QAction *forward(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Forward, recvr, slot, parent); } QAction *home(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Home, recvr, slot, parent); } QAction *prior(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Prior, recvr, slot, parent); } QAction *next(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Next, recvr, slot, parent); } QAction *goTo(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Goto, recvr, slot, parent); } QAction *gotoPage(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(GotoPage, recvr, slot, parent); } QAction *gotoLine(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(GotoLine, recvr, slot, parent); } QAction *firstPage(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(FirstPage, recvr, slot, parent); } QAction *lastPage(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(LastPage, recvr, slot, parent); } QAction *documentBack(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(DocumentBack, recvr, slot, parent); } QAction *documentForward(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(DocumentForward, recvr, slot, parent); } QAction *addBookmark(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(AddBookmark, recvr, slot, parent); } QAction *editBookmarks(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(EditBookmarks, recvr, slot, parent); } QAction *spelling(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Spelling, recvr, slot, parent); } static QAction *buildAutomaticAction(QObject *parent, StandardAction id, const char *slot) { const KStandardActionInfo *p = infoPtr(id); if (!p) { return nullptr; } AutomaticAction *action = new AutomaticAction( QIcon::fromTheme(p->psIconName), i18n(p->psLabel), KStandardShortcut::shortcut(p->idAccel), slot, parent); action->setObjectName(p->psName); if (p->psToolTip) { action->setToolTip(i18n(p->psToolTip)); } if (parent && parent->inherits("KActionCollection")) { QMetaObject::invokeMethod(parent, "addAction", Q_ARG(QString, action->objectName()), Q_ARG(QAction*, action)); } return action; } QAction *cut(QObject *parent) { return buildAutomaticAction(parent, Cut, SLOT(cut())); } QAction *copy(QObject *parent) { return buildAutomaticAction(parent, Copy, SLOT(copy())); } QAction *paste(QObject *parent) { return buildAutomaticAction(parent, Paste, SLOT(paste())); } QAction *clear(QObject *parent) { return buildAutomaticAction(parent, Clear, SLOT(clear())); } QAction *selectAll(QObject *parent) { return buildAutomaticAction(parent, SelectAll, SLOT(selectAll())); } KToggleAction *showMenubar(const QObject *recvr, const char *slot, QObject *parent) { QAction* ret = KStandardAction::create(ShowMenubar, recvr, slot, parent); Q_ASSERT(qobject_cast(ret)); return static_cast(ret); } KToggleAction *showStatusbar(const QObject *recvr, const char *slot, QObject *parent) { QAction* ret = KStandardAction::create(ShowStatusbar, recvr, slot, parent); Q_ASSERT(qobject_cast(ret)); return static_cast(ret); } KToggleFullScreenAction *fullScreen(const QObject *recvr, const char *slot, QWidget *window, QObject *parent) { KToggleFullScreenAction *ret; ret = static_cast< KToggleFullScreenAction * >(KStandardAction::create(FullScreen, recvr, slot, parent)); ret->setWindow(window); return ret; } #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 38) QAction *saveOptions(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(SaveOptions, recvr, slot, parent); } #endif QAction *keyBindings(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(KeyBindings, recvr, slot, parent); } QAction *preferences(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Preferences, recvr, slot, parent); } QAction *configureToolbars(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(ConfigureToolbars, recvr, slot, parent); } QAction *configureNotifications(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(ConfigureNotifications, recvr, slot, parent); } #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 38) QAction *help(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Help, recvr, slot, parent); } #endif QAction *helpContents(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(HelpContents, recvr, slot, parent); } QAction *whatsThis(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(WhatsThis, recvr, slot, parent); } QAction *tipOfDay(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(TipofDay, recvr, slot, parent); } QAction *reportBug(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(ReportBug, recvr, slot, parent); } QAction *switchApplicationLanguage(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(SwitchApplicationLanguage, recvr, slot, parent); } QAction *aboutApp(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(AboutApp, recvr, slot, parent); } QAction *aboutKDE(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(AboutKDE, recvr, slot, parent); } QAction *deleteFile(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(DeleteFile, recvr, slot, parent); } QAction *renameFile(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(RenameFile, recvr, slot, parent); } QAction *moveToTrash(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(MoveToTrash, recvr, slot, parent); } QAction *donate(const QObject *recvr, const char *slot, QObject *parent) { return KStandardAction::create(Donate, recvr, slot, parent); } } diff --git a/src/kstandardaction_p.h b/src/kstandardaction_p.h index dca7f13..4513a1c 100644 --- a/src/kstandardaction_p.h +++ b/src/kstandardaction_p.h @@ -1,198 +1,198 @@ /* This file is part of the KDE libraries Copyright (C) 1999,2000 Kurt Granroth This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KSTANDARDACTION_PRIVATE_H #define KSTANDARDACTION_PRIVATE_H #include #include #include #include namespace KStandardAction { struct KStandardActionInfo { StandardAction id; KStandardShortcut::StandardShortcut idAccel; const char *psName; const char *psLabel; const char *psToolTip; const char *psIconName; }; static const KStandardActionInfo g_rgActionInfo[] = { { New, KStandardShortcut::New, "file_new", I18N_NOOP("&New"), I18N_NOOP("Create new document"), "document-new" }, { Open, KStandardShortcut::Open, "file_open", I18N_NOOP("&Open..."), I18N_NOOP("Open an existing document"), "document-open" }, { OpenRecent, KStandardShortcut::AccelNone, "file_open_recent", I18N_NOOP("Open &Recent"), I18N_NOOP("Open a document which was recently opened"), "document-open-recent" }, { Save, KStandardShortcut::Save, "file_save", I18N_NOOP("&Save"), I18N_NOOP("Save document"), "document-save" }, { SaveAs, KStandardShortcut::SaveAs, "file_save_as", I18N_NOOP("Save &As..."), I18N_NOOP("Save document under a new name"), "document-save-as" }, { Revert, KStandardShortcut::Revert, "file_revert", I18N_NOOP("Re&vert"), I18N_NOOP("Revert unsaved changes made to document"), "document-revert" }, { Close, KStandardShortcut::Close, "file_close", I18N_NOOP("&Close"), I18N_NOOP("Close document"), "document-close" }, { Print, KStandardShortcut::Print, "file_print", I18N_NOOP("&Print..."), I18N_NOOP("Print document"), "document-print" }, { PrintPreview, KStandardShortcut::PrintPreview, "file_print_preview", I18N_NOOP("Print Previe&w"), I18N_NOOP("Show a print preview of document"), "document-print-preview" }, { Mail, KStandardShortcut::Mail, "file_mail", I18N_NOOP("&Mail..."), I18N_NOOP("Send document by mail"), "mail-send" }, { Quit, KStandardShortcut::Quit, "file_quit", I18N_NOOP("&Quit"), I18N_NOOP("Quit application"), "application-exit" }, { Undo, KStandardShortcut::Undo, "edit_undo", I18N_NOOP("&Undo"), I18N_NOOP("Undo last action"), "edit-undo" }, { Redo, KStandardShortcut::Redo, "edit_redo", I18N_NOOP("Re&do"), I18N_NOOP("Redo last undone action"), "edit-redo" }, { Cut, KStandardShortcut::Cut, "edit_cut", I18N_NOOP("Cu&t"), I18N_NOOP("Cut selection to clipboard"), "edit-cut" }, { Copy, KStandardShortcut::Copy, "edit_copy", I18N_NOOP("&Copy"), I18N_NOOP("Copy selection to clipboard"), "edit-copy" }, { Paste, KStandardShortcut::Paste, "edit_paste", I18N_NOOP("&Paste"), I18N_NOOP("Paste clipboard content"), "edit-paste" }, #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 39) { PasteText, KStandardShortcut::Paste, "edit_paste", I18N_NOOP("&Paste"), I18N_NOOP("Paste clipboard content"), "edit-paste" }, #endif { Clear, KStandardShortcut::Clear, "edit_clear", I18N_NOOP("C&lear"), nullptr, "edit-clear" }, { SelectAll, KStandardShortcut::SelectAll, "edit_select_all", I18N_NOOP("Select &All"), nullptr, "edit-select-all" }, { Deselect, KStandardShortcut::Deselect, "edit_deselect", I18N_NOOP("Dese&lect"), nullptr, "edit-select-none" }, { Find, KStandardShortcut::Find, "edit_find", I18N_NOOP("&Find..."), nullptr, "edit-find" }, { FindNext, KStandardShortcut::FindNext, "edit_find_next", I18N_NOOP("Find &Next"), nullptr, "go-down-search" }, { FindPrev, KStandardShortcut::FindPrev, "edit_find_prev", I18N_NOOP("Find Pre&vious"), nullptr, "go-up-search" }, { Replace, KStandardShortcut::Replace, "edit_replace", I18N_NOOP("&Replace..."), nullptr, "edit-find-replace" }, { ActualSize, KStandardShortcut::ActualSize, "view_actual_size", I18N_NOOP("&Actual Size"), I18N_NOOP("View document at its actual size"), "zoom-original" }, { FitToPage, KStandardShortcut::FitToPage, "view_fit_to_page", I18N_NOOP("&Fit to Page"), I18N_NOOP("Zoom to fit page in window"), nullptr }, { FitToWidth, KStandardShortcut::FitToWidth, "view_fit_to_width", I18N_NOOP("Fit to Page &Width"), I18N_NOOP("Zoom to fit page width in window"), nullptr }, { FitToHeight, KStandardShortcut::FitToHeight, "view_fit_to_height", I18N_NOOP("Fit to Page &Height"), I18N_NOOP("Zoom to fit page height in window"), nullptr }, { ZoomIn, KStandardShortcut::ZoomIn, "view_zoom_in", I18N_NOOP("Zoom &In"), nullptr, "zoom-in" }, { ZoomOut, KStandardShortcut::ZoomOut, "view_zoom_out", I18N_NOOP("Zoom &Out"), nullptr, "zoom-out" }, { Zoom, KStandardShortcut::Zoom, "view_zoom", I18N_NOOP("&Zoom..."), I18N_NOOP("Select zoom level"), nullptr }, { Redisplay, KStandardShortcut::Reload, "view_redisplay", I18N_NOOP("&Redisplay"), I18N_NOOP("Redisplay document"), "view-refresh" }, { Up, KStandardShortcut::Up, "go_up", I18N_NOOP("&Up"), I18N_NOOP("Go up"), "go-up" }, // The following three have special i18n() needs for sLabel { Back, KStandardShortcut::Back, "go_back", nullptr, nullptr, "go-previous" }, { Forward, KStandardShortcut::Forward, "go_forward", nullptr, nullptr, "go-next" }, { Home, KStandardShortcut::Home, "go_home", nullptr, nullptr, "go-home" }, { Prior, KStandardShortcut::Prior, "go_previous", I18N_NOOP("&Previous Page"), I18N_NOOP("Go to previous page"), "go-previous-view-page" }, { Next, KStandardShortcut::Next, "go_next", I18N_NOOP("&Next Page"), I18N_NOOP("Go to next page"), "go-next-view-page" }, { Goto, KStandardShortcut::Goto, "go_goto", I18N_NOOP("&Go To..."), nullptr, nullptr }, { GotoPage, KStandardShortcut::GotoPage, "go_goto_page", I18N_NOOP("&Go to Page..."), nullptr, "go-jump" }, { GotoLine, KStandardShortcut::GotoLine, "go_goto_line", I18N_NOOP("&Go to Line..."), nullptr, nullptr }, { FirstPage, KStandardShortcut::Begin, "go_first", I18N_NOOP("&First Page"), I18N_NOOP("Go to first page"), "go-first-view-page" }, { LastPage, KStandardShortcut::End, "go_last", I18N_NOOP("&Last Page"), I18N_NOOP("Go to last page"), "go-last-view-page" }, { DocumentBack, KStandardShortcut::DocumentBack, "go_document_back", I18N_NOOP("&Back"), I18N_NOOP("Go back in document"), "go-previous" }, { DocumentForward, KStandardShortcut::DocumentForward, "go_document_forward", I18N_NOOP("&Forward"), I18N_NOOP("Go forward in document"), "go-next" }, { AddBookmark, KStandardShortcut::AddBookmark, "bookmark_add", I18N_NOOP("&Add Bookmark"), nullptr, "bookmark-new" }, { EditBookmarks, KStandardShortcut::EditBookmarks, "bookmark_edit", I18N_NOOP("&Edit Bookmarks..."), nullptr, "bookmarks-organize" }, { Spelling, KStandardShortcut::Spelling, "tools_spelling", I18N_NOOP("&Spelling..."), I18N_NOOP("Check spelling in document"), "tools-check-spelling" }, { ShowMenubar, KStandardShortcut::ShowMenubar, "options_show_menubar", I18N_NOOP("Show &Menubar"), I18N_NOOP("Show or hide menubar"), "show-menu" }, { ShowToolbar, KStandardShortcut::ShowToolbar, "options_show_toolbar", I18N_NOOP("Show &Toolbar"), I18N_NOOP("Show or hide toolbar"), nullptr }, { ShowStatusbar, KStandardShortcut::ShowStatusbar, "options_show_statusbar", I18N_NOOP("Show St&atusbar"), I18N_NOOP("Show or hide statusbar"), nullptr }, { FullScreen, KStandardShortcut::FullScreen, "fullscreen", I18N_NOOP("F&ull Screen Mode"), nullptr, "view-fullscreen" }, #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 38) - { SaveOptions, KStandardShortcut::SaveOptions, "options_save_options", I18N_NOOP("&Save Settings"), nullptr, nullptr }, + { SaveOptions, KStandardShortcut::SaveOptions_DEPRECATED_DO_NOT_USE, "options_save_options", I18N_NOOP("&Save Settings"), nullptr, nullptr }, #endif { KeyBindings, KStandardShortcut::KeyBindings, "options_configure_keybinding", I18N_NOOP("Configure S&hortcuts..."), nullptr, "configure-shortcuts" }, { Preferences, KStandardShortcut::Preferences, "options_configure", I18N_NOOP("&Configure %1..."), nullptr, "configure" }, { ConfigureToolbars, KStandardShortcut::ConfigureToolbars, "options_configure_toolbars", I18N_NOOP("Configure Tool&bars..."), nullptr, "configure-toolbars" }, { ConfigureNotifications, KStandardShortcut::ConfigureNotifications, "options_configure_notifications", I18N_NOOP("Configure &Notifications..."), nullptr, "preferences-desktop-notification" }, // the idea here is that Contents is used in menus, and Help in dialogs, so both share the same // shortcut #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 38) { Help, KStandardShortcut::Help, "help", nullptr, nullptr, "help-contents" }, #endif { HelpContents, KStandardShortcut::Help, "help_contents", I18N_NOOP("%1 &Handbook"), nullptr, "help-contents" }, { WhatsThis, KStandardShortcut::WhatsThis, "help_whats_this", I18N_NOOP("What's &This?"), nullptr, "help-contextual" }, { TipofDay, KStandardShortcut::TipofDay, "help_show_tip", I18N_NOOP("Tip of the &Day"), nullptr, "help-hint" }, { ReportBug, KStandardShortcut::ReportBug, "help_report_bug", I18N_NOOP("&Report Bug..."), nullptr, "tools-report-bug" }, { SwitchApplicationLanguage, KStandardShortcut::SwitchApplicationLanguage, "switch_application_language", I18N_NOOP("Switch Application &Language..."), nullptr, "preferences-desktop-locale" }, { AboutApp, KStandardShortcut::AccelNone, "help_about_app", I18N_NOOP("&About %1"), nullptr, nullptr }, { AboutKDE, KStandardShortcut::AccelNone, "help_about_kde", I18N_NOOP("About &KDE"), nullptr, "kde" }, { DeleteFile, KStandardShortcut::DeleteFile, "deletefile", I18N_NOOP("&Delete"), nullptr, "edit-delete" }, { RenameFile, KStandardShortcut::RenameFile, "renamefile", I18N_NOOP("&Rename..."), nullptr, "edit-rename" }, { MoveToTrash, KStandardShortcut::MoveToTrash, "movetotrash", I18N_NOOP("&Move to Trash"), nullptr, "trash-empty" }, { Donate, KStandardShortcut::Donate, "help_donate", I18N_NOOP("&Donate"), nullptr, "help-donate"}, { ActionNone, KStandardShortcut::AccelNone, nullptr, nullptr, nullptr, nullptr } }; inline const KStandardActionInfo *infoPtr(StandardAction id) { for (uint i = 0; g_rgActionInfo[i].id != ActionNone; i++) { if (g_rgActionInfo[i].id == id) { return &g_rgActionInfo[i]; } } return nullptr; } static inline QStringList internal_stdNames() { QStringList result; for (uint i = 0; g_rgActionInfo[i].id != ActionNone; i++) if (g_rgActionInfo[i].psLabel) { if (QByteArray(g_rgActionInfo[i].psLabel).contains("%1")) // Prevents i18n from complaining about unsubstituted placeholder. { result.append(i18n(g_rgActionInfo[i].psLabel, QString())); } else { result.append(i18n(g_rgActionInfo[i].psLabel)); } } return result; } class AutomaticAction : public QAction { Q_OBJECT public: AutomaticAction(const QIcon &icon, const QString &text, const QList &shortcut, const char *slot, QObject *parent); public Q_SLOTS: inline void cut() { invokeEditSlot("cut"); } inline void copy() { invokeEditSlot("copy"); } inline void paste() { invokeEditSlot("paste"); } inline void clear() { invokeEditSlot("clear"); } inline void selectAll() { invokeEditSlot("selectAll"); } void invokeEditSlot(const char *slot) { if (qApp->focusWidget()) { QMetaObject::invokeMethod(qApp->focusWidget(), slot); } } }; } #endif