forked from qt-creator/qt-creator
QmlDesigner: Remove Update QmlProject File action
- removes the action from the file menu - adds tr::tr to the menu string - fixes an if condition - adds some comments on how we can improve it Change-Id: I5f816a8dc9245bec5aa0db13318b702414ad6bcd Reviewed-by: Aleksei German <aleksei.german@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Burak Hancerli <burak.hancerli@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -81,7 +81,7 @@ QmlBuildSystem::QmlBuildSystem(Target *target)
|
||||
refresh(RefreshOptions::Project);
|
||||
|
||||
updateDeploymentData();
|
||||
registerMenuButtons();
|
||||
// registerMenuButtons(); //is wip
|
||||
|
||||
connect(target->project(), &Project::activeTargetChanged, this, [this](Target *target) {
|
||||
refresh(RefreshOptions::NoFileRefresh);
|
||||
@@ -117,24 +117,29 @@ void QmlBuildSystem::updateDeploymentData()
|
||||
setDeploymentData(deploymentData);
|
||||
}
|
||||
|
||||
//probably this method needs to be moved into QmlProjectPlugin::initialize to be called only once
|
||||
void QmlBuildSystem::registerMenuButtons()
|
||||
{
|
||||
Core::ActionContainer *menu = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||
|
||||
// QML Project file update button
|
||||
// This button saves the current configuration into the .qmlproject file
|
||||
auto action = new QAction("Update QmlProject File", this);
|
||||
auto action = new QAction(Tr::tr("Update QmlProject File"), this);
|
||||
//this registerAction registers a new action for each opened project,
|
||||
//causes the "action is already registered" warning if you have multiple opened projects,
|
||||
//is not a big thing for qds, but is annoying for qtc and should be fixed.
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.ProjectManager");
|
||||
menu->addAction(cmd, Core::Constants::G_FILE_SAVE);
|
||||
QObject::connect(action, &QAction::triggered, this, &QmlBuildSystem::updateProjectFile);
|
||||
}
|
||||
|
||||
//wip:
|
||||
bool QmlBuildSystem::updateProjectFile()
|
||||
{
|
||||
qDebug() << "debug#1-mainfilepath" << mainFilePath();
|
||||
|
||||
QFile file(mainFilePath().fileName().append("project-test"));
|
||||
if (file.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
|
||||
qCritical() << "Cannot open Qml Project file for editing!";
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user