File indexing completed on 2024-05-19 04:55:51
0001 /** 0002 * \file kdemainwindow.h 0003 * KDE Kid3 main window. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 9 Jan 2003 0008 * 0009 * Copyright (C) 2003-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QtGlobal> 0030 #include <KXmlGuiWindow> 0031 #include "basemainwindow.h" 0032 0033 class QAction; 0034 class KRecentFilesAction; 0035 class KToggleAction; 0036 class KUrl; 0037 class IPlatformTools; 0038 0039 /** 0040 * KDE Kid3 main window. 0041 */ 0042 class KdeMainWindow : public KXmlGuiWindow, public BaseMainWindow { 0043 Q_OBJECT 0044 public: 0045 /** 0046 * Constructor. 0047 * 0048 * @param platformTools platform specific tools 0049 * @param app application context 0050 * @param parent parent widget 0051 */ 0052 explicit KdeMainWindow(IPlatformTools* platformTools, 0053 Kid3Application* app, QWidget* parent = nullptr); 0054 0055 /** 0056 * Destructor. 0057 */ 0058 ~KdeMainWindow() override = default; 0059 0060 /** 0061 * Init menu and toolbar actions. 0062 */ 0063 void initActions() override; 0064 0065 /** 0066 * Get keyboard shortcuts. 0067 * @return mapping of action names to key sequences. 0068 */ 0069 QMap<QString, QKeySequence> shortcutsMap() const override; 0070 0071 /** 0072 * Add directory to recent files list. 0073 * 0074 * @param dirName path to directory 0075 */ 0076 void addDirectoryToRecentFiles(const QString& dirName) override; 0077 0078 /** 0079 * Read settings from the configuration. 0080 */ 0081 void readConfig() override; 0082 0083 /** 0084 * Store geometry and recent files in settings. 0085 */ 0086 void saveConfig() override; 0087 0088 /** 0089 * Get action for Settings/Auto Hide Tags. 0090 * @return action. 0091 */ 0092 QAction* autoHideTagsAction() override; 0093 0094 /** 0095 * Get action for Settings/Hide Picture. 0096 * @return action. 0097 */ 0098 QAction* showHidePictureAction() override; 0099 0100 /** 0101 * Set main window caption. 0102 * 0103 * @param caption caption without application name 0104 * @param modified true if any file is modified 0105 */ 0106 void setWindowCaption(const QString& caption, bool modified) override; 0107 0108 protected: 0109 /** 0110 * Update modification state before closing. 0111 * Called on closeEvent() of window. 0112 * If anything was modified, save after asking user. 0113 * 0114 * @return FALSE if user canceled. 0115 */ 0116 bool queryClose() override; 0117 0118 /** 0119 * Saves the window properties for each open window during session end 0120 * to the session config file. 0121 * 0122 * @param cfg application configuration 0123 */ 0124 void saveProperties(KConfigGroup& cfg) override; 0125 0126 /** 0127 * Reads the session config file and restores the application's state. 0128 * 0129 * @param cfg application configuration 0130 */ 0131 void readProperties(const KConfigGroup& cfg) override; 0132 0133 private slots: 0134 /** 0135 * Open recent directory. 0136 * 0137 * @param url URL of directory to open 0138 */ 0139 void slotFileOpenRecentUrl(const QUrl& url); 0140 0141 /** 0142 * Shortcuts configuration. 0143 */ 0144 void slotSettingsShortcuts(); 0145 0146 /** 0147 * Toolbars configuration. 0148 */ 0149 void slotSettingsToolbars(); 0150 0151 /** 0152 * Statusbar configuration. 0153 */ 0154 void slotSettingsShowStatusbar(); 0155 0156 /** 0157 * Preferences. 0158 */ 0159 void slotSettingsConfigure(); 0160 0161 /** 0162 * Add user action to collection. 0163 * @param name name of action 0164 * @param action action to add 0165 */ 0166 void onUserActionAdded(const QString& name, QAction* action); 0167 0168 /** 0169 * Remove user action from collection. 0170 * @param name name of action 0171 * @param action action to remove 0172 */ 0173 void onUserActionRemoved(const QString& name, QAction* action); 0174 0175 private: 0176 IPlatformTools* m_platformTools; 0177 /** Actions */ 0178 KRecentFilesAction* m_fileOpenRecent; 0179 KToggleAction* m_settingsShowStatusbar; 0180 KToggleAction* m_settingsAutoHideTags; 0181 KToggleAction* m_settingsShowHidePicture; 0182 };