1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_MAIN_WINDOW_H_ 23 #define _U2_MAIN_WINDOW_H_ 24 25 #include <QEvent> 26 #include <QWidget> 27 28 #include <U2Core/PluginModel.h> 29 #include <U2Core/ServiceTypes.h> 30 #include <U2Core/global.h> 31 32 #include "NotificationsTypes.h" 33 34 class QAction; 35 class QMdiSubWindow; 36 class QDockWidget; 37 class QMenu; 38 class QToolBar; 39 class QMainWindow; 40 41 // menu 42 #define MWMENU "mw_menu_bar" 43 #define MWMENU_FILE "mwmenu_file" 44 #define MWMENU_ACTIONS "mwmenu_actions" 45 #define MWMENU_SETTINGS "mwmenu_settings" 46 #define MWMENU_TOOLS "mwmenu_tools" 47 #define MWMENU_WINDOW "mwmenu_window" 48 #define MWMENU_HELP "mwmenu_help" 49 50 // toolbar 51 #define MWTOOLBAR_MAIN "mwtoolbar_main" 52 #define MWTOOLBAR_ACTIVEMDI "mwtoolbar_activemdi" 53 54 // actions 55 #define ACTION__EXIT "action__exit" 56 #define ACTION__ABOUT "action__about" 57 #define ACTION__LOGVIEW "action__logview" 58 #define ACTION__PLUGINS_VIEW "action__plugins" 59 60 #define ACTION_PROJECTSUPPORT__NEW_PROJECT "action_projectsupport__new_project" 61 #define ACTION_PROJECTSUPPORT__OPEN_PROJECT "action_projectsupport__open_project" 62 #define ACTION_PROJECTSUPPORT__PASTE "action_projectsupport__paste" 63 #define ACTION_PROJECTSUPPORT__OPEN_AS "action_projectsupport__open_as" 64 #define ACTION_PROJECTSUPPORT__SAVE_PROJECT "action_projectsupport__save_project" 65 #define ACTION_PROJECTSUPPORT__SAVE_AS_PROJECT "action_projectsupport__save_as_project" 66 #define ACTION_PROJECTSUPPORT__CLOSE_PROJECT "action_projectsupport__close_project" 67 #define ACTION_PROJECTSUPPORT__RECENT_PROJECTS_MENU "action_projectsupport__recent_projects_menu" 68 #define ACTION_PROJECTSUPPORT__EXPORT_PROJECT "action_projectsupport__export_project" 69 #define ACTION_PROJECTSUPPORT__ACCESS_REMOTE_DB "action_projectsupport__access_remote_db" 70 #define ACTION_PROJECTSUPPORT__ACCESS_SHARED_DB "action_projectsupport__access_shared_db" 71 #define ACTION_PROJECTSUPPORT__SEARCH_GENBANK "action_projectsupport__search_genbank" 72 #define ACTION_PROJECTSUPPORT__NEW_SECTION_SEPARATOR "action_projectsupport__new_section_separator" 73 74 #define ACTION_PROJECT__ADD_MENU "action_project__add_menu" 75 #define ACTION_PROJECT__ADD_OBJECT "action_project__add_object" 76 #define ACTION_PROJECT__REMOVE_MENU "action_project__remove_menu" 77 #define ACTION_PROJECT__REMOVE_SELECTED "action_project__remove_selected_action" 78 #define ACTION_PROJECT__ADD_NEW_DOCUMENT "action_project__add_new_document" 79 #define ACTION_PROJECT__ADD_EXISTING_DOCUMENT "action_project__add_existing_document" 80 #define ACTION_PROJECT__UNLOAD_SELECTED "action_project__unload_selected_action" 81 #define ACTION_PROJECT__IMPORT_TO_DATABASE "action_project__import_to_database" 82 #define ACTION_PROJECT__CREATE_FOLDER "action_project__create_folder" 83 #define ACTION_PROJECT__SAVE_DOCUMENT "action_project__save_document" 84 85 #define PROJECT_MENU_SEPARATOR_1 "project_menu_separator_1" 86 #define ACTION_DOCUMENT__LOCK "action_document_lock" 87 #define ACTION_DOCUMENT__UNLOCK "action_document_unlock" 88 89 #define ACTION_PROJECT__EXPORT_IMPORT_MENU_ACTION "action_project__export_import_menu_action" 90 #define ACTION_PROJECT__EXPORT_AS_SEQUENCES_ACTION "action_project__export_as_sequence_action" 91 #define ACTION_PROJECT__EXPORT_TO_AMINO_ACTION "action_project__export_to_amino_action" 92 93 #define ACTION_BLAST_SUBMENU "BLAST" 94 #define ACTION_BLAST_FORMAT_DB "FormatDB" 95 96 #define ACTION_EXPORT_SEQUENCE "export sequences" 97 #define ACTION_EXPORT_CORRESPONDING_SEQ "export corresponding sequence" 98 #define ACTION_EXPORT_SEQUENCE_AS_ALIGNMENT "export sequences as alignment" 99 #define ACTION_EXPORT_ANNOTATIONS "action_export_annotations" 100 #define ACTION_EXPORT_CHROMATOGRAM "action_export_chromatogram" 101 102 #define ACTION_EXPORT_OBJECT "export object" 103 104 #define ACTION_EDIT_SEQUENCE "edit sequences" 105 #define ACTION_EDIT_SEQUENCE_SETTINGS "action_edit_sequences_settings" 106 #define ACTION_EDIT_INSERT_SUBSEQUENCE "action_edit_insert_sub_sequences" 107 #define ACTION_EDIT_REMOVE_SUBSEQUENCE "action_edit_remove_sub_sequences" 108 #define ACTION_EDIT_REPLACE_SUBSEQUENCE "action_edit_replace_sub_sequences" 109 #define ACTION_EDIT_RESERVE_COMPLEMENT_SEQUENCE "action_edit_reserve_complement_sequences" 110 #define ACTION_EDIT_RESERVE_SEQUENCE "action_edit_reserve_sequences" 111 #define ACTION_EDIT_COMPLEMENT_SEQUENCE "action_edit_complement_sequences" 112 #define ACTION_EDIT_SELECT_SEQUENCE_FROM_VIEW "action_edit_select_sequences_from_view" 113 114 #define ACTION_BOOKMARK_TREE_VIEW "action_bookmark_tree_view" 115 #define ACTION_ACTIVATE_VIEW "action_activate_view" 116 #define ACTION_ADD_BOOKMARK "action_add_bookmark" 117 #define ACTION_RENAME_BOOKMARK "action_rename_bookmark" 118 #define ACTION_REMOVE_BOOKMARK "action_remove_bookmark" 119 120 #define DOCK_PROJECT_VIEW "dock_project_view" 121 #define DOCK_TASK_VIEW "dock_task_view" 122 #define DOCK_LOG_VIEW "dock_log_view" 123 #define DOCK_TASK_TREE_VIEW "taskViewTree" 124 125 namespace U2 { 126 127 class MWMDIManager; 128 class MWDockManager; 129 class NotificationStack; 130 131 class U2GUI_EXPORT MainWindow : public QObject { 132 Q_OBJECT 133 public: 134 virtual QMenu *getTopLevelMenu(const QString &sysName) const = 0; 135 virtual QToolBar *getToolbar(const QString &sysName) const = 0; 136 virtual QMainWindow *getQMainWindow() const = 0; 137 138 virtual MWMDIManager *getMDIManager() const = 0; 139 virtual MWDockManager *getDockManager() const = 0; 140 virtual NotificationStack *getNotificationStack() const = 0; 141 142 virtual void setWindowTitle(const QString &title) = 0; 143 144 virtual void addNotification(const QString &message, NotificationType type) = 0; 145 146 virtual void registerAction(QAction *action) = 0; 147 }; 148 149 ////////////////////////////////////////////////////////////////////////// 150 /// MDI 151 152 class U2GUI_EXPORT MWMDIWindow : public QWidget { 153 Q_OBJECT 154 155 friend class MWMDIManager; 156 157 public: 158 MWMDIWindow(const QString &_windowName); 159 ~MWMDIWindow(); 160 setupMDIToolbar(QToolBar *)161 virtual void setupMDIToolbar(QToolBar *) { 162 } setupViewMenu(QMenu *)163 virtual void setupViewMenu(QMenu *) { 164 } 165 getId()166 int getId() const { 167 return windowId; 168 } 169 170 protected: 171 /* returns true if a window may be closed, false otherwise */ onCloseEvent()172 virtual bool onCloseEvent() { 173 return true; 174 } 175 176 protected: 177 int windowId; 178 }; 179 180 class U2GUI_EXPORT MWMDIManager : public QObject { 181 Q_OBJECT 182 public: MWMDIManager(QObject * p)183 MWMDIManager(QObject *p) 184 : QObject(p) { 185 } 186 187 /** Adds the specified window to MainWindow layout and activates it. */ 188 virtual void addMDIWindow(MWMDIWindow *w) = 0; 189 190 virtual bool closeMDIWindow(MWMDIWindow *w) = 0; 191 192 virtual QList<MWMDIWindow *> getWindows() const = 0; 193 194 virtual MWMDIWindow *getWindowById(int id) const = 0; 195 196 virtual void activateWindow(MWMDIWindow *w) = 0; 197 198 virtual MWMDIWindow *getActiveWindow() const = 0; 199 200 signals: 201 void si_windowAdded(MWMDIWindow *w); 202 void si_windowClosing(MWMDIWindow *w); 203 void si_windowActivated(MWMDIWindow *w); 204 void si_windowDeactivated(MWMDIWindow *w); 205 206 protected: 207 /* returns true if the window agreed to close, false otherwise */ onCloseEvent(MWMDIWindow * w)208 bool onCloseEvent(MWMDIWindow *w) { 209 return w->onCloseEvent(); 210 } 211 }; 212 213 ////////////////////////////////////////////////////////////////////////// 214 /// DOCK 215 216 enum MWDockArea { 217 MWDockArea_Left, 218 MWDockArea_Right, 219 MWDockArea_Bottom, 220 MWDockArea_MaxDocks 221 }; 222 223 class U2GUI_EXPORT MWDockManager : public QObject { 224 Q_OBJECT 225 public: MWDockManager(QObject * p)226 MWDockManager(QObject *p) 227 : QObject(p) { 228 } 229 230 virtual QAction *registerDock(MWDockArea area, QWidget *w, const QKeySequence &ks = QKeySequence()) = 0; 231 232 virtual QWidget *findWidget(const QString &widgetObjName) = 0; 233 234 virtual QWidget *getActiveWidget(MWDockArea a) = 0; 235 236 virtual QWidget *activateDock(const QString &widgetObjName) = 0; 237 238 virtual QWidget *toggleDock(const QString &widgetObjName) = 0; 239 240 virtual void dontActivateNextTime(MWDockArea a) = 0; 241 }; 242 243 } // namespace U2 244 Q_DECLARE_METATYPE(U2::MainWindow *) 245 Q_DECLARE_METATYPE(U2::MWMDIManager *) 246 Q_DECLARE_METATYPE(U2::MWDockManager *) 247 #endif 248