| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /**
- * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved.
- *
- * This file is part of the QCAD project.
- *
- * QCAD is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * QCAD 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with QCAD.
- */
- /**
- * \defgroup ecma_window Window Tools
- * \ingroup ecma_scripts
- *
- * \brief This module contains ECMAScript implementations of various
- * window tools.
- */
- include("scripts/EAction.js");
- function MenuData(d) {
- this.data = d;
- }
- MenuData.prototype.triggered = function() {
- var mdiArea = EAction.getMdiArea();
- this.data.show();
- mdiArea.setActiveSubWindow(this.data);
- };
- /**
- * \class Window
- * \brief Base class for all window tools.
- * \ingroup ecma_window
- */
- function Window(guiAction) {
- EAction.call(this, guiAction);
- }
- Window.prototype = new EAction();
- Window.includeBasePath = includeBasePath;
- Window.getMenu = function() {
- var i, action;
- var menu = EAction.getMenu(Window.getTitle(), "WindowMenu", function(menu) {
- menu.aboutToShow.connect(function() {
- var mdiArea = EAction.getMdiArea();
- var windows = mdiArea.subWindowList();
- var actions = menu.actions();
- for (i = 0; i < actions.length; ++i) {
- action = actions[i];
- if (action.objectName === "MdiChild") {
- menu.removeAction(action);
- }
- }
- var separator = new RGuiAction("", menu);
- separator.setSeparator(true);
- separator.objectName = "MdiChild";
- separator.addToMenu(menu);
- // for (i = 0; i < windows.length; ++i) {
- // var window = windows[i];
- // var file = window.getDocument().getFileName();
- // var modified = window.getDocument().isModified();
- // var text = new QFileInfo(file).fileName();
- // if (text === "") {
- // text = stripDirtyFlag(window.windowTitle);
- // }
- // if (modified) {
- // text += " *";
- // }
- // text = text.replace(/&/g, "&&");
- // action = menu.addAction(text);
- // action.checkable = true;
- // var winId;
- // var activeWinId;
- // if (RSettings.getQtVersion() >= 0x060000) {
- // winId = window.getAddress();
- // activeWinId = mdiArea.activeSubWindow().getAddress();
- // }
- // else {
- // winId = window.getObjectId();
- // activeWinId = mdiArea.activeSubWindow().getObjectId();
- // }
- // if (!isNull(mdiArea.activeSubWindow()) && winId === activeWinId) {
- // action.checked = true;
- // } else {
- // action.checked = false;
- // }
- // action.objectName = "MdiChild";
- // var menuData = new MenuData(windows[i]);
- // action.triggered.connect(menuData, menuData.triggered);
- // }
- });
- });
- menu.setProperty("scriptFile", Window.includeBasePath + "/Window.js");
- return menu;
- };
- Window.getToolBar = function() {
- var tb = EAction.getToolBar(Window.getTitle(), "WindowToolBar");
- tb.visible = false;
- return tb;
- };
- Window.getTitle = function() {
- return qsTr("窗口");
- // return qsTr("&Window");
- };
- Window.prototype.getTitle = function() {
- return Window.getTitle();
- };
- Window.init = function() {
- Window.getMenu();
- Window.getToolBar();
- // make sure there's an action:
- // var appWin = EAction.getMainWindow();
- // var action = new RGuiAction(qsTr("Window Tools"), appWin);
- // action.setScriptFile(Window.includeBasePath + "/Window.js");
- // action.setWidgetNames([]);
- };
|