diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index 8b1b240cf17..03840ac854d 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -62,9 +62,10 @@ int qtGhVersion = QT_VERSION; #endif #if USE_QT_GUI -# include -# include +# include # include +# include +# include #endif #ifdef Q_OS_WIN @@ -1457,7 +1458,9 @@ static void qDumpQHashNode(QDumper &d) static void qDumpQImage(QDumper &d) { const QImage &im = *reinterpret_cast(d.data); - d.putItem("value", "(").put(im.width()).put("x").put(im.height()).put(")"); + d.beginItem("value"); + d.put("(").put(im.width()).put("x").put(im.height()).put(")"); + d.endItem(); d.putItem("type", NS"QImage"); d.putItem("numchild", "1"); if (d.dumpChildren) { @@ -2234,7 +2237,9 @@ static void qDumpQObjectSlotList(QDumper &d) static void qDumpQPixmap(QDumper &d) { const QPixmap &im = *reinterpret_cast(d.data); - d.putItem("value", "(").put(im.width()).put("x").put(im.height()).put(")"); + d.beginItem("value"); + d.put("(").put(im.width()).put("x").put(im.height()).put(")"); + d.endItem(); d.putItem("type", NS"QPixmap"); d.putItem("numchild", "0"); d.disarm(); @@ -2455,7 +2460,7 @@ static void qDumpQVariant(QDumper &d) d.putItem("value", "(invalid)"); } else if (value.isEmpty()) { d.beginItem("value"); - d.put("(").put(v.typeName()).put(") ").put(qPrintable(value)); + d.put("(").put(v.typeName()).put(") "); d.endItem(); } else { QByteArray ba; @@ -2464,7 +2469,7 @@ static void qDumpQVariant(QDumper &d) ba += ") "; ba += qPrintable(value); d.putItem("value", ba); - d.putItem("valueencoded", "4"); + d.putItem("valueencoded", "5"); } d.putItem("type", NS"QVariant"); d.putItem("numchild", (isInvalid ? "0" : "1")); @@ -3023,6 +3028,14 @@ static void handleProtocolVersion2and3(QDumper & d) } // anonymous namespace +#if USE_QT_GUI +extern "C" Q_DECL_EXPORT +void *watchPoint(int x, int y) +{ + return QApplication::widgetAt(x, y); +} +#endif + extern "C" Q_DECL_EXPORT void *qDumpObjectData440( int protocolVersion, @@ -3115,7 +3128,7 @@ void *qDumpObjectData440( .put(""NS"QStringList=\"").put(sizeof(QStringList)).put("\",") .put(""NS"QObject=\"").put(sizeof(QObject)).put("\",") #if USE_QT_GUI - .put(""NS"QWidget=\"").put(sizeof(QWidget)<< "\",") + .put(""NS"QWidget=\"").put(sizeof(QWidget)).put("\",") #endif #ifdef Q_OS_WIN .put("string=\"").put(sizeof(std::string)).put("\",") diff --git a/share/qtcreator/gdbmacros/gdbmacros.pro b/share/qtcreator/gdbmacros/gdbmacros.pro index 67133e732e8..d876af9387f 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.pro +++ b/share/qtcreator/gdbmacros/gdbmacros.pro @@ -1,13 +1,12 @@ TEMPLATE = lib CONFIG += shared -QT = core linux-* { CONFIG -= release CONFIG += debug } SOURCES=gdbmacros.cpp -true { +false { DEFINES += USE_QT_GUI=0 QT = core } else { diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_collection.cpp b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_collection.cpp similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_collection.cpp rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_collection.cpp diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_collection.h b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_collection.h similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_collection.h rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_collection.h diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_plugin.pro b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_plugin.pro similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_plugin.pro rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_plugin.pro diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_resources.qrc b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_resources.qrc similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_resources.qrc rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_resources.qrc diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_single.cpp b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_single.cpp similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_single.cpp rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_single.cpp diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_single.h b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_single.h similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_single.h rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_single.h diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget.cpp b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget.cpp similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget.cpp rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget.cpp diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget.h b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget.h similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget.h rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget.h diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget_include.pri b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget_include.pri similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget_include.pri rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget_include.pri diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget_lib.pro b/share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget_lib.pro similarity index 100% rename from src/plugins/qt4projectmanager/customwidgetwizard/templates/tpl_widget_lib.pro rename to share/qtcreator/templates/qt4project/customwidgetwizard/tpl_widget_lib.pro diff --git a/share/qtcreator/translations/phrasebook_fr.qph b/share/qtcreator/translations/phrasebook_fr.qph new file mode 100644 index 00000000000..8b7636ae70f --- /dev/null +++ b/share/qtcreator/translations/phrasebook_fr.qph @@ -0,0 +1,291 @@ + + + + debugger + débogueur + + + Start Debugger + Lancer le débogueur + + + Executable: + Exécutable: + + + Filter: + Filtre: + + + Clear + Effacer + + + Host and port: + Hôte et port: + + + Architecture: + Architecture: + + + Server start script: + Script de démarrage du serveur: + + + &Undo + Annu&ler + + + Add Bookmark + Ajouter un signet + + + Bookmark: + Signet: + + + Add in Folder: + Ajouter dans le dossier: + + + + + + + + + New Folder + Nouveau Dossier + + + Bookmarks + Signets + + + Rename Folder + Renommer le Dossier + + + Bookmark + Signet + + + Remove + Retirer + + + Delete Folder + Supprimer le Dossier + + + Show Bookmark + Afficher le Signet + + + Show Bookmark in New Tab + Afficher le Signet dans un Nouvel Onglet + + + Delete Bookmark + Supprimer le Signet + + + Rename Bookmark + Renommer le Signet + + + Add + Ajouter + + + Move Up + Vers le Haut + + + Move Down + Vers le Bas + + + Previous Bookmark + Signet Précédent + + + Next Bookmark + Signet Suivant + + + Condition: + Condition: + + + Working Directory: + Répertoire de Travail: + + + Environment + Environnement + + + Arguments + Arguments + + + Build directory: + Répertoire de compilation: + + + Path: + Chemin: + + + CodePaster Error + Erreur dans CodePaster + + + General + Général + + + Username: + Nom d'utilisateur: + + + CodePaster + CodePaster + + + User interface + Interface utilisateur + + + <unlimited> + <illimitée> + + + Open Link + Ouvrir le Lien + + + [read only] + [lecture seule] + + + [directory] + [répertoire] + + + Close + Fermer + + + Close All + Fermer Tout + + + Failed! + Échec! + + + Proceed + Continuer + + + Cancel + Annuler + + + Make writable + Rendre Inscriptible + + + Qt Creator + Qt Creator + + + &File + &Fichier + + + &Edit + &Édition + + + &Redo + Re&faire + + + Activate %1 + Activer %1 + + + Split + Scinder + + + New Project + Nouveau Projet + + + Close %1 + Fermer %1 + + + * + * + + + &Undo + Annu&ler + + + Bookmarks + Signets + + + New Folder + Nouveau dossier + + + Bookmark + Signet + + + Bookmarks + Signets + + + New Folder + Nouveau dossier + + + Add + Ajouter + + + &Change + &Modifier + + + Close + Fermer + + + General + Général + + + Close %1 + Fermer %1 + + + Close Other Editors + Fermer les autres éditeurs + + + Close All Except %1 + Fermer tout sauf %1 + + + C++ + + + diff --git a/share/qtcreator/translations/qtcreator_fr.ts b/share/qtcreator/translations/qtcreator_fr.ts index 6e6a8568edd..a801c67c27a 100644 --- a/share/qtcreator/translations/qtcreator_fr.ts +++ b/share/qtcreator/translations/qtcreator_fr.ts @@ -17,7 +17,7 @@ Couldn't find 'Core.pluginspec' in %1 - 'Core.pluginspec' introuvable dans %1 + 'Core.pluginspec' introuvable dans %1 @@ -43,7 +43,7 @@ Start Debugger - Lancer le débogueur + Lancer le débogueur @@ -72,12 +72,12 @@ Host and port: - Hôte et port: + Hôte et port : Architecture: - Architecture: + Architecture : @@ -95,12 +95,12 @@ &Undo - Annu&ler + Annu&ler &Redo - &Refaire + &Refaire @@ -108,7 +108,7 @@ Add Bookmark - Ajouter un signet + Ajouter un signet @@ -123,12 +123,12 @@ + - + + New Folder - Nouveau Dossier + Nouveau dossier @@ -137,17 +137,17 @@ Bookmarks - Signets + Signets Delete Folder - Supprimer le dossier + Supprimer le dossier Rename Folder - Renommer le Dossier + Renommer le dossier @@ -156,12 +156,12 @@ Bookmark - Signet + Signet Bookmarks - Signets + Signets @@ -177,7 +177,7 @@ New Folder - Nouveau Dossier + Nouveau dossier @@ -220,7 +220,7 @@ Add - Ajouter + Ajouter @@ -233,7 +233,7 @@ Bookmarks - Signets + Signets @@ -351,7 +351,7 @@ Build Environment - Environnement de compilation + Environnement de compilation @@ -359,7 +359,7 @@ &Change - &Changer + &Modifier @@ -367,7 +367,7 @@ CMake Wizard - Assistant CMake + Assistant CMake @@ -385,7 +385,7 @@ Reset to default - Restaurer les paramètres par défaut + Restaurer les paramètres par défaut @@ -395,7 +395,7 @@ Environment - Environnement + Environnement @@ -476,7 +476,7 @@ Please enter the directory in which you want to build your project. - Veuillez spécifier le répertoire où vous voulez compiler votre projet. + Veuillez spécifier le répertoire où vous voulez compiler votre projet. @@ -494,7 +494,7 @@ Qt Creator has found a recent cbp file, which Qt Creator will parse to gather information about the project. You can change the command line arguments used to create this file in the project mode. Click finish to load the project. - Qt Creator a trouvé un fichier cbp récent, Qt Creator va maintenant l'analyser pour rassembler des informations sur le projet. Vous pouvez changer les arguments de ligne de commande utilisés pour la création de ce fichier depuis le mode "projet". Cliquer sur Terminer pour charger le projet. + Qt Creator a trouvé un fichier cbp récent, Qt Creator va maintenant l'analyser pour rassembler des informations sur le projet. Vous pouvez changer les arguments de ligne de commande utilisés pour la création de ce fichier depuis le mode "projet". Cliquer sur Terminer pour charger le projet. @@ -502,12 +502,12 @@ <Select Symbol> - <Selectionner un Symbole> + <Selectionner un symbole> <No Symbols> - <Aucun Symbole>> + <Aucun symbole> @@ -864,53 +864,53 @@ Voulez vous les écraser? Revert to Saved - + Revenir à la version sauvegardée Close - + Fermer Close All - + Fermer Tout Close Others - + Fermer les Autres Éditeurs Next Document in History - + Document Suivant dans l'Historique Previous Document in History - + Document Précédent dans l'Historique Go Back - + Précédent Go Forward - + Suivant Open in External Editor - + Ouvrir dans l'Éditeur Externe Revert File to Saved - + Restaurer le fichier sauvegardé @@ -965,7 +965,7 @@ Voulez vous les écraser? Split - + Scinder @@ -975,7 +975,7 @@ Voulez vous les écraser? Split Side by Side - + Scinder Verticalement @@ -985,7 +985,7 @@ Voulez vous les écraser? Remove Current Split - + Fermer la Vue Courante @@ -995,7 +995,7 @@ Voulez vous les écraser? Remove All Splits - + Fermer toutes les vues @@ -1005,7 +1005,7 @@ Voulez vous les écraser? Goto Other Split - + Changer de vue @@ -1015,7 +1015,7 @@ Voulez vous les écraser? &Advanced - + &Avancé @@ -1026,104 +1026,104 @@ Voulez vous les écraser? Opening File - + Ouverture du Fichier Cannot open file %1! - + Impossible d'ouvrir le fichier %1! Open File - + Ouvrir le Fichier File is Read Only - + Le Fichier est en Lecture Seule The file %1 is read only. - + Le fichier %1 est en lecture seule. Open with VCS (%1) - + Ouvrir avec VCS (%1) Make writable - + Rendre Inscriptible Save as ... - + Enregistrer sous... Failed! - + Échec! Could not open the file for editing with SCC. - + Impossible d'ouvrir le fichier pour écrire avec SCC. Could not set permissions to writable. - + Impossible d'attribuer les droits en écriture. <b>Warning:</b> You are changing a read-only file. - + <b>Attention:</b> Vous apportez des modifications à un fichier en lecture seule. Save %1 As... - + Enregistrer %1 sous... &Save %1 - + Enregi&strer %1 Revert %1 to Saved - + Restaurer %1 Close %1 - + Fermer %1 Close All Except %1 - + Fermer tout sauf %1 You will lose your current changes if you proceed reverting %1. - + Vous perdrez tous les changements en cours si vous restaurez %1. Proceed - + Continuer Cancel - + Annuler @@ -1136,27 +1136,27 @@ Voulez vous les écraser? Can't save file - + Impossible de sauver le fichier Can't save changes to '%1'. Do you want to continue and loose your changes? - + Impossible de sauvegarder les modifications dans '%1'. Voulez vous continuer et perdre vos modifications? Overwrite? - + Écraser? An item named '%1' already exists at this location. Do you want to overwrite it? - + Un élément nommé '%1' existe déjà. Voulez-vous l'écraser? Save File As - + Enregistrer sous @@ -1164,7 +1164,7 @@ Voulez vous les écraser? Activate %1 - + Activer %1 @@ -1172,7 +1172,7 @@ Voulez vous les écraser? Edit - + Modifier @@ -1180,32 +1180,32 @@ Voulez vous les écraser? Split Left/Right - + Scinder Gauche/Droite Split Top/Bottom - + Scinder Haut/Bas Unsplit - + Fermer la vue courante Default Splitter Layout - + Arrangement par Défaut Save Current as Default - + Sauvegarder comme Arrangement par Défaut Restore Default Layout - + Restaurer l'Arrangement par Défaut @@ -1220,7 +1220,7 @@ Voulez vous les écraser? Next Document - + Document Suivant @@ -1230,22 +1230,22 @@ Voulez vous les écraser? Previous Group - + Groupe Précédent Next Group - + Groupe Suivant Move Document to Previous Group - + Déplacer le Document vers le Groupe Précédent Move Document to Next Group - + Déplacer le Document vers le Groupe Suivant @@ -1259,22 +1259,22 @@ Voulez vous les écraser? Close - + Fermer Make writable - + Rendre Inscriptible File is writable - + Le Fichier est Inscriptible Copy full path to clipboard - + Copier le chemin complet vers le presse-papier @@ -1335,7 +1335,7 @@ Voulez vous les écraser? Qt Creator - + Qt Creator @@ -1345,59 +1345,59 @@ Voulez vous les écraser? &File - + &Fichier &Edit - + &Édition &Tools - + O&utils &Window - + F&enêtre &Help - + &Aide &New... - + &Nouveau... &Open... - + &Ouvrir... &Open With... - + Ou&vrir avec... Recent Files - + Fichiers récents &Save - + &Enregistrer Save &As... - + Enregistrer &sous... @@ -1408,17 +1408,17 @@ Voulez vous les écraser? Save A&ll - + &Tout enregistrer &Print... - + Im&primer... E&xit - + &Quitter @@ -1429,38 +1429,38 @@ Voulez vous les écraser? &Undo - + Annu&ler &Redo - + Re&faire Cu&t - + Co&uper &Copy - + Cop&ier &Paste - + C&oller &Select All - + Tout &sélectionner &Go To Line... - + &Aller à la ligne... @@ -1470,7 +1470,7 @@ Voulez vous les écraser? &Options... - + &Options... @@ -1519,7 +1519,7 @@ Voulez vous les écraser? General - + Général @@ -1527,7 +1527,7 @@ Voulez vous les écraser? Activate %1 - + Activer %1 @@ -1535,12 +1535,12 @@ Voulez vous les écraser? Split - + Scinder Close - + Fermer @@ -1548,7 +1548,7 @@ Voulez vous les écraser? Activate %1 Pane - + Activer le Panneau %1 @@ -1556,12 +1556,12 @@ Voulez vous les écraser? New Project - + Nouveau projet 1 - + @@ -1569,32 +1569,33 @@ Voulez vous les écraser? Open Documents - + NB:il ne s'agit pas ici d'une action mais du panneau affichant les documents ouverts + Documents ouverts Close %1 - + Fermer %1 Close Editor - + Fermer l'éditeur Close All Except %1 - + Fermer tout sauf %1 Close Other Editors - + Fermer les autres éditeurs Close All Editors - + Fermer tous les éditeurs @@ -1602,7 +1603,7 @@ Voulez vous les écraser? * - + @@ -1610,7 +1611,7 @@ Voulez vous les écraser? Open file '%1' with: - + Ouvrir le fichier %1 avec : @@ -2501,12 +2502,12 @@ Voulez vous les écraser? C++ - + Creates a C++ header file. - + Créer un fichier header C++. @@ -2549,22 +2550,22 @@ Voulez vous les écraser? File Naming Conventions - + Convention de nommage des fichiers Header suffix: - + Suffixe des header : Source suffix: - + Suffixe des fichiers source Lower case file names - + Nom des fichiers en minuscule @@ -2577,7 +2578,7 @@ Voulez vous les écraser? %1: No such file or directory - + %1 : Aucun fichier ou répertoire de ce type @@ -2585,12 +2586,12 @@ Voulez vous les écraser? File Naming Conventions - + Conventions de nommage des fichiers C++ - + @@ -11261,17 +11262,17 @@ To do this, you type this shortcut and a space in the Locator entry field, and t %1 found - + %1 éléments trouvés List of comma separated wildcard filters - + Liste de filtres séparée par des virgules Use Regular E&xpressions - + Utiliser des e&xpressions régulières @@ -11279,12 +11280,12 @@ To do this, you type this shortcut and a space in the Locator entry field, and t untitled - + document sans titre <em>Binary data</em> - + <em>Données binaire</em> @@ -11292,17 +11293,17 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Print Document - + Imprimer le document <b>Error:</b> Could not decode "%1" with "%2"-encoding. Editing not possible. - + <b>Error :</b> Impossible de décoder "%1" avec l'encodage "%2". L'édition est impossible. Select Encoding - + Choisir l'encodage @@ -11310,12 +11311,12 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Line: %1, Col: %2 - + Ligne : %1, Col : %2 Line: %1, Col: 999 - + Ligne : %1, Col: 999 @@ -11323,52 +11324,52 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Tabs and Indentation - + Tabulation et indentation Insert &spaces instead of tabs - + Insérer des e&spaces au lieu de tabulations Enable automatic &indentation - + Activer l'&indentation automatique Backspace will go back one indentation level instead of one space. - + La touche retour reviendra un niveau d'indentation en arrière au lieux d'un caractère espace. &Backspace follows indentation - + La touche &retour arrière suit l'indentation Ta&b size: - + Taille de &tabulation : &Indent size: - + Taille de l'in&dentation : Tab key performs auto-indent: - + La touche tabulation active l'identation automatique : Never - + Jamais Always - + Toujours @@ -11378,42 +11379,42 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Storage - + Sauvegarde Removes trailing whitespace on saving. - + Supprime les charactères d'espacement à la fin des lignes lors de la sauvegarde. &Clean whitespace - + &Nettoyer les espaces Clean whitespace in entire document instead of only for changed parts. - + Nettoyer les espaces dans tout le document au lieu de limiter le nettoyage aux parties modifiées. In entire &document - + Dans tout le &document Correct leading whitespace according to tab settings. - + Corriger les espaces à l'avant des lignes pour respecter la configuration des tabulations. Clean indentation - + Nettoyer l'indentation &Ensure newline at end of file - + &Forcer un retour de ligne à la fin du fichier @@ -11421,12 +11422,12 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Display - + Affichage Display line &numbers - + Afficher les &numéros de ligne @@ -11436,52 +11437,52 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Show tabs and spaces. - + Afficher les tabulations et espaces. &Visualize whitespace - + &Visualiser les espaces Highlight current &line - + Surligner la &ligne courante Highlight &blocks - + Surligner les &blocs Animate matching parentheses - + Animer les parenthèses correspondantes Text Wrapping - + Retour à la ligne dynamique Enable text &wrapping - + Activer le &retour à la ligne automatique Display right &margin at column: - + Afficher une &marge à la colonne : Navigation - + Navigation Enable &mouse navigation - + Activer la navigation à la &souris @@ -11489,13 +11490,13 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Font & Colors - + Polices et couleurs This is only an example. - + \n\tCeci est seulement un exemple. @@ -11503,28 +11504,28 @@ To do this, you type this shortcut and a space in the Locator entry field, and t Text Encoding - + Encodage du texte The following encodings are likely to fit: - + \nLes encodages suivant pourrait fonctionner: Select encoding for "%1".%2 - + Selectionner l'encodage pour "%1".%2 Reload with Encoding - + Recharger avec l'encodage Save with Encoding - + Sauver avec l'encodage @@ -11532,7 +11533,7 @@ The following encodings are likely to fit: Current File - + Fichier courrant @@ -11540,27 +11541,27 @@ The following encodings are likely to fit: Files on Disk - + Fichiers sur le disque &Directory: - + &Dossier : &Browse - + &Parcourir File &pattern: - + &Motif de fichier : Directory to search - + Dossier sur lequel effectuer la recherche @@ -11568,22 +11569,22 @@ The following encodings are likely to fit: Font - + Police Family: - + Famille : Size: - + Taille : Antialias - + Anticrénelage @@ -11593,37 +11594,37 @@ The following encodings are likely to fit: Bold - + Gras Italic - + Italique Background: - + Arrière plan : Foreground: - + Premier plan : Erase background - + Effacer l'arrière plan x - + Preview: - + Aperçu : @@ -11631,12 +11632,12 @@ The following encodings are likely to fit: Line %1 - + Ligne %1 Line in current document - + Ligne du document courrant @@ -11644,17 +11645,17 @@ The following encodings are likely to fit: Creates a text file (.txt). - + Créer un fichier texte (.txt). Text File - + Fichier texte General - + Général @@ -11664,12 +11665,12 @@ The following encodings are likely to fit: Ctrl+Space - + Ctrl+Espace Meta+Space - + Meta+Espace @@ -11712,12 +11713,12 @@ The following encodings are likely to fit: &Visualize Whitespace - + Ctrl+E, Ctrl+V - + @@ -11915,17 +11916,17 @@ The following encodings are likely to fit: Text - + Texte Link - + Lien Selection - + Sélection diff --git a/src/libs/cplusplus/FastPreprocessor.cpp b/src/libs/cplusplus/FastPreprocessor.cpp index e1e0bd8c509..00b6f8eedab 100644 --- a/src/libs/cplusplus/FastPreprocessor.cpp +++ b/src/libs/cplusplus/FastPreprocessor.cpp @@ -38,10 +38,22 @@ FastPreprocessor::FastPreprocessor(const Snapshot &snapshot) QByteArray FastPreprocessor::run(QString fileName, const QString &source) { +#ifdef QTCREATOR_WITH_MERGED_ENVIRONMENT + if (Document::Ptr doc = _snapshot.value(fileName)) { + _merged.insert(fileName); + + foreach (const Document::Include &i, doc->includes()) + mergeEnvironment(i.fileName()); + } +#endif + const QByteArray preprocessed = _preproc(fileName, source); return preprocessed; } +void FastPreprocessor::sourceNeeded(QString &fileName, IncludeType, unsigned) +{ mergeEnvironment(fileName); } + void FastPreprocessor::mergeEnvironment(const QString &fileName) { if (! _merged.contains(fileName)) { diff --git a/src/libs/cplusplus/FastPreprocessor.h b/src/libs/cplusplus/FastPreprocessor.h index bbdbd535ba0..c7e6e2f8b1c 100644 --- a/src/libs/cplusplus/FastPreprocessor.h +++ b/src/libs/cplusplus/FastPreprocessor.h @@ -54,8 +54,7 @@ public: QByteArray run(QString fileName, const QString &source); // CPlusPlus::Client - virtual void sourceNeeded(QString &fileName, IncludeType, unsigned) - { mergeEnvironment(fileName); } + virtual void sourceNeeded(QString &fileName, IncludeType, unsigned); virtual void macroAdded(const Macro &) {} diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 80832275804..372926f5975 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -771,7 +771,11 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source, } else { if (_dot->whitespace) { - const unsigned endOfPreviousToken = (_dot - 1)->end(); + unsigned endOfPreviousToken = 0; + + if (_dot != _tokens.constBegin()) + endOfPreviousToken = (_dot - 1)->end(); + const unsigned beginOfToken = _dot->begin(); const char *start = _source.constBegin() + endOfPreviousToken; diff --git a/src/plugins/coreplugin/sidebar.cpp b/src/plugins/coreplugin/sidebar.cpp index a72f637e1d4..7e580484b47 100644 --- a/src/plugins/coreplugin/sidebar.cpp +++ b/src/plugins/coreplugin/sidebar.cpp @@ -107,6 +107,14 @@ SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &title) return item; } +void SideBar::removeSideBarWidget(SideBarWidget *widget) +{ + widget->removeCurrentItem(); + m_widgets.removeOne(widget); + widget->hide(); + widget->deleteLater(); +} + void SideBar::split() { SideBarWidget *original = qobject_cast(sender()); @@ -121,10 +129,7 @@ void SideBar::close() SideBarWidget *widget = qobject_cast(sender()); if (!widget) return; - widget->removeCurrentItem(); - m_widgets.removeOne(widget); - widget->hide(); - widget->deleteLater(); + removeSideBarWidget(widget); updateWidgets(); } } @@ -148,6 +153,9 @@ void SideBar::saveSettings(QSettings *settings) void SideBar::readSettings(QSettings *settings) { + foreach (SideBarWidget *widget, m_widgets) + removeSideBarWidget(widget); + if (settings->contains("HelpSideBar/Views")) { QStringList views = settings->value("HelpSideBar/Views").toStringList(); if (views.count()) { diff --git a/src/plugins/coreplugin/sidebar.h b/src/plugins/coreplugin/sidebar.h index 0a023be100f..bd6f1e1c260 100644 --- a/src/plugins/coreplugin/sidebar.h +++ b/src/plugins/coreplugin/sidebar.h @@ -31,6 +31,7 @@ #define SIDEBAR_H #include +#include #include #include @@ -117,6 +118,8 @@ private slots: private: Internal::SideBarWidget *insertSideBarWidget(int position, const QString &title = QString()); + void removeSideBarWidget(Internal::SideBarWidget *widget); + QList m_widgets; QMap m_itemMap; diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 5d4f0a5990d..693dcf4e661 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -165,6 +165,9 @@ DebuggerSettings *DebuggerSettings::instance() item = new SavedAction(instance); instance->insertItem(AssignType, item); + item = new SavedAction(instance); + instance->insertItem(WatchPoint, item); + // // DebuggingHelper // @@ -173,18 +176,21 @@ DebuggerSettings *DebuggerSettings::instance() item->setText(tr("Use debugging helper")); item->setCheckable(true); item->setDefaultValue(true); + item->setValue(true); instance->insertItem(UseDebuggingHelpers, item); item = new SavedAction(instance); item->setSettingsKey(debugModeGroup, QLatin1String("UseCustomDebuggingHelperLocation")); item->setCheckable(true); item->setDefaultValue(false); + item->setValue(false); instance->insertItem(UseCustomDebuggingHelperLocation, item); item = new SavedAction(instance); item->setSettingsKey(debugModeGroup, QLatin1String("CustomDebuggingHelperLocation")); item->setCheckable(true); item->setDefaultValue(QString()); + item->setValue(QString()); instance->insertItem(CustomDebuggingHelperLocation, item); item = new SavedAction(instance); @@ -192,6 +198,7 @@ DebuggerSettings *DebuggerSettings::instance() item->setText(tr("Debug debugging helper")); item->setCheckable(true); item->setDefaultValue(false); + item->setValue(false); instance->insertItem(DebugDebuggingHelpers, item); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index d466a78df3d..5f953b6d10e 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -94,7 +94,7 @@ enum DebuggerActionCode WatchExpression, WatchExpressionInWindow, RemoveWatchExpression, - WatchModelUpdate, + WatchPoint, UseToolTips, AssignValue, AssignType, diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index e9226a7c422..15c586b5bba 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -434,7 +434,8 @@ void DebuggerManager::init() connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), this, SLOT(executeDebuggerCommand())); - + connect(theDebuggerAction(WatchPoint), SIGNAL(triggered()), + this, SLOT(watchPoint())); m_breakDock = createDockForWidget(m_breakWindow); @@ -1089,6 +1090,13 @@ void DebuggerManager::nextIExec() m_engine->nextIExec(); } +void DebuggerManager::watchPoint() +{ + if (QAction *action = qobject_cast(sender())) + if (m_engine) + m_engine->watchPoint(action->data().toPoint()); +} + void DebuggerManager::executeDebuggerCommand() { if (QAction *action = qobject_cast(sender())) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 23624c7d601..bfbfc10e93c 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -318,6 +318,8 @@ public slots: void executeDebuggerCommand(); void executeDebuggerCommand(const QString &command); + void watchPoint(); + void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever private slots: diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index c9f4a27fa39..21d809e9018 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -58,8 +58,8 @@ using ProjectExplorer::ApplicationRunConfiguration; //////////////////////////////////////////////////////////////////////// // A factory to create DebuggerRunControls -DebuggerRunner::DebuggerRunner(DebuggerManager *manager) : - m_manager(manager) +DebuggerRunner::DebuggerRunner(DebuggerManager *manager) + : m_manager(manager) {} bool DebuggerRunner::canRun(RunConfigurationPtr runConfiguration, const QString &mode) @@ -73,7 +73,7 @@ QString DebuggerRunner::displayName() const return tr("Debug"); } -RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, +RunControl *DebuggerRunner::run(RunConfigurationPtr runConfiguration, const QString &mode, const QSharedPointer &sp, DebuggerStartMode startMode) @@ -81,13 +81,13 @@ RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0); ApplicationRunConfigurationPtr rc = runConfiguration.dynamicCast(); - Q_ASSERT(!rc.isNull()); + QTC_ASSERT(!rc.isNull(), return 0); //qDebug() << "***** Debugging" << rc->name() << rc->executable(); DebuggerRunControl *runControl = new DebuggerRunControl(m_manager, startMode, sp, rc); return runControl; } -RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, +RunControl *DebuggerRunner::run(RunConfigurationPtr runConfiguration, const QString &mode) { const QSharedPointer sp(new DebuggerStartParameters); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 9ecdd0fece2..b564a5468a7 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -103,6 +103,42 @@ static int ¤tToken() return token; } +// reads a MI-encoded item frome the consolestream +static bool parseConsoleStream(const GdbResultRecord &record, GdbMi *contents) +{ + GdbMi output = record.data.findChild("consolestreamoutput"); + QByteArray out = output.data(); + + int markerPos = out.indexOf('"') + 1; // position of 'success marker' + if (markerPos == 0 || out.at(markerPos) == 'f') { // 't' or 'f' + // custom dumper produced no output + return false; + } + + out = out.mid(markerPos + 1); + out = out.left(out.lastIndexOf('"')); + // optimization: dumper output never needs real C unquoting + out.replace('\\', ""); + out = "dummy={" + out + "}"; + + contents->fromString(out); + //qDebug() << "CONTENTS" << contents->toString(true); + return contents->isValid(); +} + +static QByteArray parsePlainConsoleStream(const GdbResultRecord &record) +{ + GdbMi output = record.data.findChild("consolestreamoutput"); + QByteArray out = output.data(); + // FIXME: proper decoding needed + if (out.endsWith("\\n")) + out.chop(2); + while (out.endsWith('\n') || out.endsWith(' ')) + out.chop(1); + int pos = out.indexOf(" = "); + return out.mid(pos + 3); +} + /////////////////////////////////////////////////////////////////////// // // GdbEngine @@ -2820,9 +2856,10 @@ static void setWatchDataSAddress(WatchData &data, const GdbMi &mi) void GdbEngine::setUseDebuggingHelpers(const QVariant &on) { - qDebug() << "SWITCHING ON/OFF DUMPER DEBUGGING:" << on; + //qDebug() << "SWITCHING ON/OFF DUMPER DEBUGGING:" << on; // FIXME: a bit too harsh, but otherwise the treeview sometimes look funny //m_expandedINames.clear(); + Q_UNUSED(on); setTokenBarrier(); updateLocals(); } @@ -3111,16 +3148,9 @@ void GdbEngine::handleQueryDebuggingHelper(const GdbResultRecord &record, const { m_dumperHelper.clear(); //qDebug() << "DATA DUMPER TRIAL:" << record.toString(); - GdbMi output = record.data.findChild("consolestreamoutput"); - QByteArray out = output.data(); - out = out.mid(out.indexOf('"') + 2); // + 1 is success marker - out = out.left(out.lastIndexOf('"')); - out.replace('\\', ""); // optimization: dumper output never needs real C unquoting - out = "dummy={" + out + "}"; - //qDebug() << "OUTPUT:" << out; GdbMi contents; - contents.fromString(out); + QTC_ASSERT(parseConsoleStream(record, &contents), /**/); GdbMi simple = contents.findChild("dumpers"); m_dumperHelper.setQtNamespace(_(contents.findChild("namespace").data())); @@ -3281,11 +3311,7 @@ void GdbEngine::handleDebuggingHelperValue1(const GdbResultRecord &record, if (record.resultClass == GdbResultDone) { // ignore this case, data will follow } else if (record.resultClass == GdbResultError) { - // Record an extra result, as the socket result will be lost - // in transmission - //--m_pendingRequests; QString msg = QString::fromLocal8Bit(record.data.findChild("msg").data()); - //qDebug() << "CUSTOM DUMPER ERROR MESSAGE:" << msg; #ifdef QT_DEBUG // Make debugging of dumpers easier if (theDebuggerBoolSetting(DebugDebuggingHelpers) @@ -3296,12 +3322,6 @@ void GdbEngine::handleDebuggingHelperValue1(const GdbResultRecord &record, return; } #endif - //if (msg.startsWith("The program being debugged was sig")) - // msg = strNotInScope; - //if (msg.startsWith("The program being debugged stopped while")) - // msg = strNotInScope; - //data.setError(msg); - //insertData(data); } } @@ -3310,6 +3330,7 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record, { WatchData data = cookie.value(); QTC_ASSERT(data.isValid(), return); + //qDebug() << "CUSTOM VALUE RESULT:" << record.toString(); //qDebug() << "FOR DATA:" << data.toString() << record.resultClass; if (record.resultClass != GdbResultDone) { @@ -3317,26 +3338,8 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record, return; } - GdbMi output = record.data.findChild("consolestreamoutput"); - QByteArray out = output.data(); - - int markerPos = out.indexOf('"') + 1; // position of 'success marker' - if (markerPos == 0 || out.at(markerPos) == 'f') { // 't' or 'f' - // custom dumper produced no output - data.setError(strNotInScope); - insertData(data); - return; - } - - out = out.mid(markerPos + 1); - out = out.left(out.lastIndexOf('"')); - out.replace('\\', ""); // optimization: dumper output never needs real C unquoting - out = "dummy={" + out + "}"; - GdbMi contents; - contents.fromString(out); - //qDebug() << "CONTENTS" << contents.toString(true); - if (!contents.isValid()) { + if (!parseConsoleStream(record, &contents)) { data.setError(strNotInScope); insertData(data); return; @@ -3759,60 +3762,6 @@ void GdbEngine::handleVarListChildren(const GdbResultRecord &record, } } -/* -void GdbEngine::handleToolTip(const GdbResultRecord &record, - const QVariant &cookie) -{ - const QByteArray &what = cookie.toByteArray(); - //qDebug() << "HANDLE TOOLTIP:" << what << m_toolTip.toString(); - // << "record: " << record.toString(); - if (record.resultClass == GdbResultError) { - if (what == "create") { - postCommand(_("ptype ") + m_toolTip.exp, - Discardable, CB(handleToolTip), QByteArray("ptype")); - return; - } - if (what == "evaluate") { - QByteArray msg = record.data.findChild("msg").data(); - if (msg.startsWith("Cannot look up value of a typedef")) { - m_toolTip.value = tr("%1 is a typedef.").arg(m_toolTip.exp); - //return; - } - } - } else if (record.resultClass == GdbResultDone) { - if (what == "create") { - setWatchDataType(m_toolTip, record.data.findChild("type")); - setWatchDataChildCount(m_toolTip, record.data.findChild("numchild")); - if (hasDebuggingHelperForType(m_toolTip.type)) - runDebuggingHelper(m_toolTip, false); - else - q->showStatusMessage(tr("Retrieving data for tooltip..."), 10000); - postCommand(_("-data-evaluate-expression ") + m_toolTip.exp, - Discardable, CB(handleToolTip), QByteArray("evaluate")); - return; - } - if (what == "evaluate") { - m_toolTip.value = m_toolTip.type + _c(' ') + m_toolTip.exp - + _(" = " + record.data.findChild("value").data()); - //return; - } - if (what == "ptype") { - GdbMi mi = record.data.findChild("consolestreamoutput"); - m_toolTip.value = extractTypeFromPTypeOutput(_(mi.data())); - //return; - } - } - - m_toolTip.iname = tooltipIName; - m_toolTip.setChildrenUnneeded(); - m_toolTip.setHasChildrenUnneeded(); - insertData(m_toolTip); - qDebug() << "DATA INSERTED"; - QTimer::singleShot(0, this, SLOT(updateWatchModel2())); - qDebug() << "HANDLE TOOLTIP END"; -} -*/ - #if 0 void GdbEngine::handleChangedItem(QStandardItem *item) { @@ -3933,6 +3882,29 @@ bool GdbEngine::startModeAllowsDumpers() const || q->startMode() == AttachExternal; } +void GdbEngine::watchPoint(const QPoint &pnt) +{ + //qDebug() << "WATCH " << pnt; + postCommand(_("call (void*)watchPoint(%1,%2)").arg(pnt.x()).arg(pnt.y()), + NeedsStop, CB(handleWatchPoint)); +} + +void GdbEngine::handleWatchPoint(const GdbResultRecord &record, const QVariant &) +{ + //qDebug() << "HANDLE WATCH POINT:" << record.toString(); + if (record.resultClass == GdbResultDone) { + GdbMi contents = record.data.findChild("consolestreamoutput"); + // "$5 = (void *) 0xbfa7ebfc\n" + QString str = _(parsePlainConsoleStream(record)); + // "(void *) 0xbfa7ebfc" + QString addr = str.mid(9); + QString ns = m_dumperHelper.qtNamespace(); + QString type = ns.isEmpty() ? _("QWidget*") : _("'%1QWidget'*").arg(ns); + QString exp = _("(*(%1)%2)").arg(type).arg(addr); + theDebuggerAction(WatchExpression)->trigger(exp); + } +} + IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList *opts) { opts->push_back(new GdbOptionsPage); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 47dbd655cfd..84f8ab32f82 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -115,6 +115,7 @@ private: void assignValueInDebugger(const QString &expr, const QString &value); void executeDebuggerCommand(const QString & command); + void watchPoint(const QPoint &); void loadSymbols(const QString &moduleName); void loadAllSymbols(); @@ -220,6 +221,7 @@ private: void handleExit(const GdbResultRecord &, const QVariant &); void handleSetTargetAsync(const GdbResultRecord &, const QVariant &); void handleTargetRemote(const GdbResultRecord &, const QVariant &); + void handleWatchPoint(const GdbResultRecord &, const QVariant &); void debugMessage(const QString &msg); bool showToolTip(); diff --git a/src/plugins/debugger/idebuggerengine.h b/src/plugins/debugger/idebuggerengine.h index 8a7187b77f2..dbbdb143143 100644 --- a/src/plugins/debugger/idebuggerengine.h +++ b/src/plugins/debugger/idebuggerengine.h @@ -93,6 +93,8 @@ public: virtual void reloadSourceFiles() = 0; virtual void reloadFullStack() = 0; + + virtual void watchPoint(const QPoint &) {} }; } // namespace Internal diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index c482a5f668e..abe3b3cb8c0 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -82,16 +82,16 @@ static int generationCounter = 0; class WatchItem : public WatchData { public: - WatchItem() { parent = 0; fetchedTriggered = 0; } + WatchItem() { parent = 0; fetchTriggered = false; } WatchItem(const WatchData &data) : WatchData(data) - { parent = 0; fetchedTriggered = 0; } + { parent = 0; fetchTriggered = false; } void setData(const WatchData &data) { static_cast(*this) = data; } WatchItem *parent; - bool fetchedTriggered; // children fetch has been triggered + bool fetchTriggered; // children fetch has been triggered QList children; // fetched children }; @@ -303,7 +303,7 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type) item->hasChildren = true; item->state = 0; item->parent = m_root; - item->fetchedTriggered = true; + item->fetchTriggered = true; m_root->children.append(item); } @@ -346,9 +346,11 @@ void WatchModel::removeOutdatedHelper(WatchItem *item) { if (item->generation < generationCounter) removeItem(item); - else + else { foreach (WatchItem *child, item->children) removeOutdatedHelper(child); + item->fetchTriggered = false; + } } void WatchModel::removeItem(WatchItem *item) @@ -479,15 +481,15 @@ QString niceType(QString type) bool WatchModel::canFetchMore(const QModelIndex &index) const { - return index.isValid() && !watchItem(index)->fetchedTriggered; + return index.isValid() && !watchItem(index)->fetchTriggered; } void WatchModel::fetchMore(const QModelIndex &index) { QTC_ASSERT(index.isValid(), return); - QTC_ASSERT(!watchItem(index)->fetchedTriggered, return); + QTC_ASSERT(!watchItem(index)->fetchTriggered, return); if (WatchItem *item = watchItem(index)) { - item->fetchedTriggered = true; + item->fetchTriggered = true; WatchData data = *item; data.setChildrenNeeded(); emit m_handler->watchDataUpdateNeeded(data); diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 883d6cba1f7..60b75fdc761 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -376,6 +376,9 @@ QString decodeData(const QByteArray &ba, int encoding) const QByteArray decodedBa = QByteArray::fromBase64(ba); return QString::fromUtf16(reinterpret_cast(decodedBa.data()), decodedBa.size() / 2); } + case 5: { // base64 encoded 8 bit data, without quotes (see 1) + return quoteUnprintableLatin1(QByteArray::fromBase64(ba)); + } } return QCoreApplication::translate("Debugger", ""); } diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 7fedf1520bf..feab5a2989c 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -114,6 +114,8 @@ public: WatchWindow::WatchWindow(Type type, QWidget *parent) : QTreeView(parent), m_alwaysResizeColumnsToContents(true), m_type(type) { + m_grabbing = false; + QAction *act = theDebuggerAction(UseAlternatingRowColors); setWindowTitle(tr("Locals and Watchers")); setAlternatingRowColors(act->isChecked()); @@ -219,6 +221,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) QAction *act3 = new QAction(tr("Insert new watch item"), &menu); menu.addAction(act3); + QAction *act4 = new QAction(tr("Select widget to watch"), &menu); + menu.addAction(act4); menu.addSeparator(); menu.addAction(theDebuggerAction(RecheckDebuggingHelpers)); @@ -233,7 +237,12 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) else if (act == act2) setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); else if (act == act3) - theDebuggerAction(WatchExpression)->trigger(WatchHandler::watcherEditPlaceHolder()); + theDebuggerAction(WatchExpression) + ->trigger(WatchHandler::watcherEditPlaceHolder()); + else if (act == act4) { + grabMouse(Qt::CrossCursor); + m_grabbing = true; + } } void WatchWindow::resizeColumnsToContents() @@ -253,6 +262,17 @@ void WatchWindow::setAlwaysResizeColumnsToContents(bool on) header()->setResizeMode(1, mode); } +bool WatchWindow::event(QEvent *ev) +{ + if (m_grabbing && ev->type() == QEvent::MouseButtonPress) { + QMouseEvent *mev = static_cast(ev); + m_grabbing = false; + releaseMouse(); + theDebuggerAction(WatchPoint)->trigger(mapToGlobal(mev->pos())); + } + return QTreeView::event(ev); +} + void WatchWindow::editItem(const QModelIndex &idx) { Q_UNUSED(idx); // FIXME diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index af8cf163f6a..b32319b6453 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -69,13 +69,14 @@ private: void dragEnterEvent(QDragEnterEvent *ev); void dropEvent(QDropEvent *ev); void dragMoveEvent(QDragMoveEvent *ev); + bool event(QEvent *ev); void editItem(const QModelIndex &idx); - void resetHelper(const QModelIndex &idx); bool m_alwaysResizeColumnsToContents; Type m_type; + bool m_grabbing; }; diff --git a/src/plugins/designer/cpp/cpp.pri b/src/plugins/designer/cpp/cpp.pri index 3827bc836f8..a30a7940228 100644 --- a/src/plugins/designer/cpp/cpp.pri +++ b/src/plugins/designer/cpp/cpp.pri @@ -5,11 +5,14 @@ DEFINES+=CPP_ENABLED HEADERS+=$$PWD/formclasswizardpage.h \ $$PWD/formclasswizarddialog.h \ $$PWD/formclasswizard.h \ - $$PWD/formclasswizardparameters.h + $$PWD/formclasswizardparameters.h \ + $$PWD/cppsettingspage.h SOURCES+=$$PWD/formclasswizardpage.cpp \ $$PWD/formclasswizarddialog.cpp \ $$PWD/formclasswizard.cpp \ - $$PWD/formclasswizardparameters.cpp + $$PWD/formclasswizardparameters.cpp \ + $$PWD/cppsettingspage.cpp -FORMS+=$$PWD/formclasswizardpage.ui +FORMS+=$$PWD/formclasswizardpage.ui \ +$$PWD/cppsettingspagewidget.ui diff --git a/src/plugins/designer/cpp/cppsettingspage.cpp b/src/plugins/designer/cpp/cppsettingspage.cpp new file mode 100644 index 00000000000..1486bd0ad20 --- /dev/null +++ b/src/plugins/designer/cpp/cppsettingspage.cpp @@ -0,0 +1,136 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** +**************************************************************************/ + +#include "cppsettingspage.h" +#include "designerconstants.h" + +#include +#include + +namespace Designer { +namespace Internal { + +// ---------- CppSettingsPageWidget + +CppSettingsPageWidget::CppSettingsPageWidget(QWidget *parent) : + QWidget(parent) +{ + m_ui.setupUi(this); +} + +FormClassWizardGenerationParameters CppSettingsPageWidget::parameters() const +{ + FormClassWizardGenerationParameters rc; + rc.setEmbedding(static_cast(uiEmbedding())); + rc.setRetranslationSupport(m_ui.retranslateCheckBox->isChecked()); + rc.setIncludeQtModule(m_ui.includeQtModuleCheckBox->isChecked()); + return rc; +} + +void CppSettingsPageWidget::setParameters(const FormClassWizardGenerationParameters &p) +{ + m_ui.retranslateCheckBox->setChecked(p.retranslationSupport()); + m_ui.includeQtModuleCheckBox->setChecked(p.includeQtModule()); + setUiEmbedding(p.embedding()); +} + +int CppSettingsPageWidget::uiEmbedding() const +{ + if (m_ui.ptrAggregationRadioButton->isChecked()) + return FormClassWizardGenerationParameters::PointerAggregatedUiClass; + if (m_ui.aggregationButton->isChecked()) + return FormClassWizardGenerationParameters::AggregatedUiClass; + return FormClassWizardGenerationParameters::InheritedUiClass; +} + +void CppSettingsPageWidget::setUiEmbedding(int v) +{ + switch (v) { + case FormClassWizardGenerationParameters::PointerAggregatedUiClass: + m_ui.ptrAggregationRadioButton->setChecked(true); + break; + case FormClassWizardGenerationParameters::AggregatedUiClass: + m_ui.aggregationButton->setChecked(true); + break; + case FormClassWizardGenerationParameters::InheritedUiClass: + m_ui.multipleInheritanceButton->setChecked(true); + break; + } +} + +// ---------- CppSettingsPage +CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent) +{ + m_parameters.fromSettings(Core::ICore::instance()->settings()); +} + +QString CppSettingsPage::id() const +{ + return QLatin1String(Designer::Constants::SETTINGS_CPP_SETTINGS); +} + +QString CppSettingsPage::trName() const +{ + return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CPP_SETTINGS); +} + +QString CppSettingsPage::category() const +{ + return QLatin1String(Designer::Constants::SETTINGS_CATEGORY); +} + +QString CppSettingsPage::trCategory() const +{ + return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CATEGORY); +} + +QWidget *CppSettingsPage::createPage(QWidget *parent) +{ + m_widget = new CppSettingsPageWidget(parent); + m_widget->setParameters(m_parameters); + return m_widget; +} + +void CppSettingsPage::apply() +{ + if (m_widget) { + const FormClassWizardGenerationParameters newParameters = m_widget->parameters(); + if (newParameters != m_parameters) { + m_parameters = newParameters; + m_parameters.toSettings(Core::ICore::instance()->settings()); + } + } +} + +void CppSettingsPage::finish() +{ +} + +} // namespace Internal +} // namespace Designer diff --git a/src/plugins/designer/cpp/cppsettingspage.h b/src/plugins/designer/cpp/cppsettingspage.h new file mode 100644 index 00000000000..bb52a833634 --- /dev/null +++ b/src/plugins/designer/cpp/cppsettingspage.h @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** +**************************************************************************/ + +#ifndef CPPSETTINGSPAGE_H +#define CPPSETTINGSPAGE_H + +#include "formclasswizardparameters.h" +#include "ui_cppsettingspagewidget.h" + +#include + +#include + +namespace Designer { +namespace Internal { + +class CppSettingsPageWidget : public QWidget +{ + Q_OBJECT +public: + explicit CppSettingsPageWidget(QWidget *parent = 0); + + FormClassWizardGenerationParameters parameters() const; + void setParameters(const FormClassWizardGenerationParameters &p); + +private: + int uiEmbedding() const; + void setUiEmbedding(int); + + Ui::CppSettingsPageWidget m_ui; +}; + +class CppSettingsPage : public Core::IOptionsPage +{ +public: + explicit CppSettingsPage(QObject *parent = 0); + + virtual QString id() const; + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + + virtual QWidget *createPage(QWidget *parent); + virtual void apply(); + virtual void finish(); + +private: + QPointer m_widget; + FormClassWizardGenerationParameters m_parameters; +}; + +} // namespace Internal +} // namespace Designer + +#endif // CPPSETTINGSPAGE_H diff --git a/src/plugins/designer/cpp/cppsettingspagewidget.ui b/src/plugins/designer/cpp/cppsettingspagewidget.ui new file mode 100644 index 00000000000..8a34601df91 --- /dev/null +++ b/src/plugins/designer/cpp/cppsettingspagewidget.ui @@ -0,0 +1,110 @@ + + + Designer::Internal::CppSettingsPageWidget + + + + 0 + 0 + 526 + 369 + + + + Form + + + + + + + + Embedding of the UI Class + + + false + + + + + + Aggregation as a pointer member + + + + + + + Aggregation + + + + + + + Multiple Inheritance + + + + + aggregationButton + multipleInheritanceButton + ptrAggregationRadioButton + + + + + + Code Generation + + + + + + Support for changing languages at runtime + + + + + + + Include Qt module name + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 169 + 20 + + + + + + + + + diff --git a/src/plugins/designer/cpp/formclasswizard.cpp b/src/plugins/designer/cpp/formclasswizard.cpp index 28e767ee9bd..3cbb42f5ae1 100644 --- a/src/plugins/designer/cpp/formclasswizard.cpp +++ b/src/plugins/designer/cpp/formclasswizard.cpp @@ -87,17 +87,17 @@ QWizard *FormClassWizard::createWizardDialog(QWidget *parent, Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const { const FormClassWizardDialog *wizardDialog = qobject_cast(w); - const FormClassWizardParameters params = wizardDialog->parameters(); + const Designer::FormClassWizardParameters params = wizardDialog->parameters(); - if (params.uiTemplate.isEmpty()) { + if (params.uiTemplate().isEmpty()) { *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents"); return Core::GeneratedFiles(); } // header - const QString formFileName = buildFileName(params.path, params.uiFile, formSuffix()); - const QString headerFileName = buildFileName(params.path, params.headerFile, headerSuffix()); - const QString sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix()); + const QString formFileName = buildFileName(params.path(), params.uiFile(), formSuffix()); + const QString headerFileName = buildFileName(params.path(), params.headerFile(), headerSuffix()); + const QString sourceFileName = buildFileName(params.path(), params.sourceFile(), sourceSuffix()); Core::GeneratedFile headerFile(headerFileName); headerFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND)); @@ -108,11 +108,13 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e // UI Core::GeneratedFile uiFile(formFileName); - uiFile.setContents(params.uiTemplate); + uiFile.setContents(params.uiTemplate()); uiFile.setEditorKind(QLatin1String(Constants::C_FORMEDITOR)); QString source, header; - params.generateCpp(&header, &source); + Designer::FormClassWizardGenerationParameters generationParameters; + generationParameters.fromSettings(Core::ICore::instance()->settings()); + params.generateCpp(generationParameters, &header, &source); sourceFile.setContents(source); headerFile.setContents(header); diff --git a/src/plugins/designer/cpp/formclasswizarddialog.cpp b/src/plugins/designer/cpp/formclasswizarddialog.cpp index f1b95e17297..191200b9e3f 100644 --- a/src/plugins/designer/cpp/formclasswizarddialog.cpp +++ b/src/plugins/designer/cpp/formclasswizarddialog.cpp @@ -98,7 +98,7 @@ FormClassWizardParameters FormClassWizardDialog::parameters() const FormClassWizardParameters rc; m_classPage->getParameters(&rc); // Name the ui class in the Ui namespace after the class specified - rc.uiTemplate = FormTemplateWizardPage::changeUiClassName(m_rawFormTemplate, rc.className); + rc.setUiTemplate(FormTemplateWizardPage::changeUiClassName(m_rawFormTemplate, rc.className())); return rc; } diff --git a/src/plugins/designer/cpp/formclasswizarddialog.h b/src/plugins/designer/cpp/formclasswizarddialog.h index bcbe8e9885f..c6522de3abb 100644 --- a/src/plugins/designer/cpp/formclasswizarddialog.h +++ b/src/plugins/designer/cpp/formclasswizarddialog.h @@ -37,9 +37,12 @@ namespace Core { } namespace Designer { -namespace Internal { struct FormClassWizardParameters; + +namespace Internal { + + class FormClassWizardPage; class FormTemplateWizardPage; @@ -56,7 +59,7 @@ public: QString path() const; - FormClassWizardParameters parameters() const; + Designer::FormClassWizardParameters parameters() const; bool validateCurrentPage(); diff --git a/src/plugins/designer/cpp/formclasswizardpage.cpp b/src/plugins/designer/cpp/formclasswizardpage.cpp index 9697ed33a0e..86284a6ee86 100644 --- a/src/plugins/designer/cpp/formclasswizardpage.cpp +++ b/src/plugins/designer/cpp/formclasswizardpage.cpp @@ -43,10 +43,6 @@ #include #include -static const char *formClassWizardPageGroupC = "FormClassWizardPage"; -static const char *translationKeyC = "RetranslationSupport"; -static const char *embeddingModeKeyC = "Embedding"; - namespace Designer { namespace Internal { @@ -64,13 +60,7 @@ FormClassWizardPage::FormClassWizardPage(QWidget * parent) : m_ui->newClassWidget->setAllowDirectories(true); connect(m_ui->newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged())); - - m_ui->extensionWidget->setVisible(false); - connect(m_ui->moreButton, SIGNAL(clicked(bool)), m_ui->extensionWidget, SLOT(setVisible(bool))); - connect(m_ui->settingsToolButton, SIGNAL(clicked()), this, SLOT(slotSettings())); - - restoreSettings(); } FormClassWizardPage::~FormClassWizardPage() @@ -79,13 +69,13 @@ FormClassWizardPage::~FormClassWizardPage() } // Retrieve settings of CppTools plugin. -static inline bool lowerCaseFiles(const Core::ICore *core) +static bool inline lowerCaseFiles(const Core::ICore *core) { - QString camelCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP); - camelCaseSettingsKey += QLatin1Char('/'); - camelCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY); + QString lowerCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP); + lowerCaseSettingsKey += QLatin1Char('/'); + lowerCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY); - return core->settings()->value(camelCaseSettingsKey, QVariant(false)).toBool(); + return core->settings()->value(lowerCaseSettingsKey, QVariant(false)).toBool(); } // Set up new class widget from settings @@ -115,40 +105,6 @@ void FormClassWizardPage::setClassName(const QString &suggestedClassName) slotValidChanged(); } -int FormClassWizardPage::uiClassEmbedding() const -{ - if (m_ui->ptrAggregationRadioButton->isChecked()) - return PointerAggregatedUiClass; - if (m_ui->aggregationButton->isChecked()) - return AggregatedUiClass; - return InheritedUiClass; -} - -void FormClassWizardPage::setUiClassEmbedding(int v) -{ - switch (v) { - case PointerAggregatedUiClass: - m_ui->ptrAggregationRadioButton->setChecked(true); - break; - case AggregatedUiClass: - m_ui->aggregationButton->setChecked(true); - break; - case InheritedUiClass: - m_ui->multipleInheritanceButton->setChecked(true); - break; - } -} - -bool FormClassWizardPage::hasRetranslationSupport() const -{ - return m_ui->retranslateCheckBox->isChecked(); -} - -void FormClassWizardPage::setRetranslationSupport(bool v) -{ - m_ui->retranslateCheckBox->setChecked(v); -} - QString FormClassWizardPage::path() const { return m_ui->newClassWidget->path(); @@ -161,13 +117,11 @@ void FormClassWizardPage::setPath(const QString &p) void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const { - p->embedding = static_cast(uiClassEmbedding()); - p->languageChange = m_ui->retranslateCheckBox->isChecked(); - p->className = m_ui->newClassWidget->className(); - p->path = path(); - p->sourceFile = m_ui->newClassWidget->sourceFileName(); - p->headerFile = m_ui->newClassWidget->headerFileName(); - p->uiFile = m_ui->newClassWidget-> formFileName(); + p->setClassName(m_ui->newClassWidget->className()); + p->setPath(path()); + p->setSourceFile(m_ui->newClassWidget->sourceFileName()); + p->setHeaderFile(m_ui->newClassWidget->headerFileName()); + p->setUiFile(m_ui->newClassWidget-> formFileName()); } void FormClassWizardPage::slotValidChanged() @@ -188,47 +142,11 @@ bool FormClassWizardPage::validatePage() { QString errorMessage; const bool rc = m_ui->newClassWidget->isValid(&errorMessage); - if (rc) { - saveSettings(); - } else { + if (!rc) { QMessageBox::critical(this, tr("%1 - Error").arg(title()), errorMessage); } return rc; } -void FormClassWizardPage::saveSettings() -{ - Core::ICore *core = Core::ICore::instance(); - if (QSettings *settings = core->settings()) { - settings->beginGroup(QLatin1String(formClassWizardPageGroupC)); - settings->setValue(QLatin1String(translationKeyC), hasRetranslationSupport()); - settings->setValue(QLatin1String(embeddingModeKeyC), uiClassEmbedding()); - settings->endGroup(); - } -} - -void FormClassWizardPage::restoreSettings() -{ - bool retranslationSupport = true; - int embedding = PointerAggregatedUiClass; - - Core::ICore *core = Core::ICore::instance(); - if (QSettings *settings = core->settings()) { - - QString key = QLatin1String(formClassWizardPageGroupC); - key += QLatin1Char('/'); - const int groupLength = key.size(); - - key += QLatin1String(translationKeyC); - retranslationSupport = settings->value(key, retranslationSupport).toBool(); - - key.truncate(groupLength); - key += QLatin1String(embeddingModeKeyC); - embedding = settings->value(key, embedding).toInt(); - } - setUiClassEmbedding(embedding); - setRetranslationSupport(retranslationSupport); -} - } // namespace Internal } // namespace Designer diff --git a/src/plugins/designer/cpp/formclasswizardpage.h b/src/plugins/designer/cpp/formclasswizardpage.h index 72214604275..d335d953665 100644 --- a/src/plugins/designer/cpp/formclasswizardpage.h +++ b/src/plugins/designer/cpp/formclasswizardpage.h @@ -33,13 +33,16 @@ #include namespace Designer { + +struct FormClassWizardParameters; +struct FormClassWizardGenerationParameters; + namespace Internal { namespace Ui { class FormClassWizardPage; } -struct FormClassWizardParameters; class FormClassWizardPage : public QWizardPage { @@ -52,18 +55,17 @@ public: virtual bool isComplete () const; virtual bool validatePage(); - int uiClassEmbedding() const; - bool hasRetranslationSupport() const; QString path() const; // Fill out applicable parameters - void getParameters(FormClassWizardParameters *) const; + void getParameters(FormClassWizardParameters *) const; + + FormClassWizardGenerationParameters generationParameters() const; + void setGenerationParameters(const FormClassWizardGenerationParameters &gp); public slots: void setClassName(const QString &suggestedClassName); void setPath(const QString &); - void setRetranslationSupport(bool); - void setUiClassEmbedding(int v); void slotSettings(); private slots: @@ -71,8 +73,6 @@ private slots: private: void initParameters(); - void saveSettings(); - void restoreSettings(); Ui::FormClassWizardPage *m_ui; bool m_isValid; diff --git a/src/plugins/designer/cpp/formclasswizardpage.ui b/src/plugins/designer/cpp/formclasswizardpage.ui index 9a2849ad0a0..6381b45fd0b 100644 --- a/src/plugins/designer/cpp/formclasswizardpage.ui +++ b/src/plugins/designer/cpp/formclasswizardpage.ui @@ -6,8 +6,8 @@ 0 0 - 552 - 498 + 542 + 267 @@ -21,7 +21,7 @@ - + @@ -48,114 +48,8 @@ - - - - More - - - true - - - - - - - - 0 - - - - - Embedding of the UI class - - - false - - - - - - Aggregation as a pointer member - - - buttonGroup - - - - - - - Aggregation - - - buttonGroup - - - - - - - Multiple Inheritance - - - buttonGroup - - - - - aggregationButton - multipleInheritanceButton - ptrAggregationRadioButton - - - - - - - - - - - - Support for changing languages at runtime - - - - - - - - - - Qt::Vertical - - - - 20 - 57 - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/src/plugins/designer/cpp/formclasswizardparameters.cpp b/src/plugins/designer/cpp/formclasswizardparameters.cpp index b9a88e4a2c9..4f0881d9481 100644 --- a/src/plugins/designer/cpp/formclasswizardparameters.cpp +++ b/src/plugins/designer/cpp/formclasswizardparameters.cpp @@ -34,32 +34,298 @@ #include #include +#include #include #include +#include static const char *uiMemberC = "m_ui"; static const char *uiNamespaceC = "Ui"; -namespace Designer { -namespace Internal { +static const char *formClassWizardPageGroupC = "FormClassWizardPage"; +static const char *translationKeyC = "RetranslationSupport"; +static const char *embeddingModeKeyC = "Embedding"; -FormClassWizardParameters::FormClassWizardParameters() : - embedding(PointerAggregatedUiClass), - languageChange(true) +// TODO: These 2 are general coding convention settings and +// should go to CppTools... +static const char *includeQtModuleKeyC = "IncludeQtModule"; +static const char *indentNamespaceKeyC = "IndentNamespace"; + +namespace Designer { + +class FormClassWizardGenerationParametersPrivate : public QSharedData +{ +public: + FormClassWizardGenerationParametersPrivate(); + void fromSettings(const QSettings *); + void toSettings(QSettings *) const; + bool equals(const FormClassWizardGenerationParametersPrivate &rhs) const; + + FormClassWizardGenerationParameters::UiClassEmbedding embedding; + bool retranslationSupport; // Add handling for language change events + bool includeQtModule; // Include "" or just "<[Class]>" + bool indentNamespace; +}; + +FormClassWizardGenerationParametersPrivate::FormClassWizardGenerationParametersPrivate() : + embedding(FormClassWizardGenerationParameters::PointerAggregatedUiClass), + retranslationSupport(true), + includeQtModule(false), + indentNamespace(false) { } -bool FormClassWizardParameters::generateCpp(QString *header, QString *source, int indentation) const +void FormClassWizardGenerationParametersPrivate::fromSettings(const QSettings *settings) { - const QString indent = QString(indentation, QLatin1Char(' ')); + QString key = QLatin1String(formClassWizardPageGroupC); + key += QLatin1Char('/'); + const int groupLength = key.size(); + + key += QLatin1String(translationKeyC); + retranslationSupport = settings->value(key, true).toBool(); + + key.truncate(groupLength); + key += QLatin1String(embeddingModeKeyC); + embedding = static_cast(settings->value(key, int(FormClassWizardGenerationParameters::PointerAggregatedUiClass)).toInt()); + + key.truncate(groupLength); + key += QLatin1String(includeQtModuleKeyC); + includeQtModule = settings->value(key, false).toBool(); + + key.truncate(groupLength); + key += QLatin1String(indentNamespaceKeyC); + indentNamespace = settings->value(key, false).toBool(); +} + +void FormClassWizardGenerationParametersPrivate::toSettings(QSettings *settings) const +{ + settings->beginGroup(QLatin1String(formClassWizardPageGroupC)); + settings->setValue(QLatin1String(translationKeyC), retranslationSupport); + settings->setValue(QLatin1String(embeddingModeKeyC), embedding); + settings->setValue(QLatin1String(includeQtModuleKeyC), includeQtModule); + settings->setValue(QLatin1String(indentNamespaceKeyC), indentNamespace); + settings->endGroup(); +} + +bool FormClassWizardGenerationParametersPrivate::equals(const FormClassWizardGenerationParametersPrivate &rhs) const +{ + return embedding == rhs.embedding && retranslationSupport == rhs.retranslationSupport + && includeQtModule == rhs.includeQtModule && indentNamespace == rhs.indentNamespace; +} + +FormClassWizardGenerationParameters::FormClassWizardGenerationParameters() : + m_d(new FormClassWizardGenerationParametersPrivate) +{ +} + +FormClassWizardGenerationParameters::~FormClassWizardGenerationParameters() +{ +} + +FormClassWizardGenerationParameters::FormClassWizardGenerationParameters(const FormClassWizardGenerationParameters &rhs) : + m_d(rhs.m_d) +{ +} + +FormClassWizardGenerationParameters &FormClassWizardGenerationParameters::operator=(const FormClassWizardGenerationParameters &rhs) +{ + if (this != &rhs) + m_d.operator=(rhs.m_d); + return *this; +} + +bool FormClassWizardGenerationParameters::equals(const FormClassWizardGenerationParameters &rhs) const +{ + return m_d->equals(*rhs.m_d.constData()); +} + +FormClassWizardGenerationParameters::UiClassEmbedding FormClassWizardGenerationParameters::embedding() const +{ + return m_d->embedding; +} + +void FormClassWizardGenerationParameters::setEmbedding(UiClassEmbedding e) +{ + m_d->embedding = e; +} + +bool FormClassWizardGenerationParameters::retranslationSupport() const +{ + return m_d->retranslationSupport; +} + +void FormClassWizardGenerationParameters::setRetranslationSupport(bool v) +{ + m_d->retranslationSupport = v; +} + +bool FormClassWizardGenerationParameters::includeQtModule() const +{ + return m_d->includeQtModule; +} + +void FormClassWizardGenerationParameters::setIncludeQtModule(bool v) +{ + m_d->includeQtModule = v; +} + +bool FormClassWizardGenerationParameters::indentNamespace() const +{ + return m_d->indentNamespace; +} + +void FormClassWizardGenerationParameters::setIndentNamespace(bool v) +{ + m_d->indentNamespace = v; +} + +void FormClassWizardGenerationParameters::fromSettings(const QSettings *settings) +{ + m_d->fromSettings(settings); +} + +void FormClassWizardGenerationParameters::toSettings(QSettings *settings) const +{ + m_d->toSettings(settings); +} + +// ----------- + +class FormClassWizardParametersPrivate : public QSharedData { +public: + bool generateCpp(const FormClassWizardGenerationParameters &fgp, + QString *header, QString *source, int indentation) const; + + QString uiTemplate; + QString className; + + QString path; + QString sourceFile; + QString headerFile; + QString uiFile; +}; + +FormClassWizardParameters::FormClassWizardParameters() : + m_d(new FormClassWizardParametersPrivate) +{ +} + +FormClassWizardParameters::~FormClassWizardParameters() +{ +} + +FormClassWizardParameters::FormClassWizardParameters(const FormClassWizardParameters &rhs) : + m_d(rhs.m_d) +{ +} + +FormClassWizardParameters &FormClassWizardParameters::operator=(const FormClassWizardParameters &rhs) +{ + if (this != &rhs) + m_d.operator =(rhs.m_d); + return *this; +} + +QString FormClassWizardParameters::uiTemplate() const +{ + return m_d->uiTemplate; +} + +void FormClassWizardParameters::setUiTemplate(const QString &s) +{ + m_d->uiTemplate = s; +} + +QString FormClassWizardParameters::className() const +{ + return m_d->className; +} + +void FormClassWizardParameters::setClassName(const QString &s) +{ + m_d->className = s; +} + +QString FormClassWizardParameters::path() const +{ + return m_d->path; +} + +void FormClassWizardParameters::setPath(const QString &s) +{ + m_d->path = s; +} + + +QString FormClassWizardParameters::sourceFile() const +{ + return m_d->sourceFile; +} + +void FormClassWizardParameters::setSourceFile(const QString &s) +{ + m_d->sourceFile = s; +} + +QString FormClassWizardParameters::headerFile() const +{ + return m_d->headerFile; +} + +void FormClassWizardParameters::setHeaderFile(const QString &s) +{ + m_d->headerFile = s; +} + + +QString FormClassWizardParameters::uiFile() const +{ + return m_d->uiFile; +} + +void FormClassWizardParameters::setUiFile(const QString &s) +{ + m_d->uiFile = s; +} + +bool FormClassWizardParameters::getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName) +{ + return Designer::Internal::FormTemplateWizardPage::getUIXmlData(uiXml, formBaseClass, uiClassName); +} + +QString FormClassWizardParameters::changeUiClassName(const QString &uiXml, const QString &newUiClassName) +{ + return Designer::Internal::FormTemplateWizardPage::changeUiClassName(uiXml, newUiClassName); +} + +// Write out how to access the Ui class in the source code. +static inline void writeUiMemberAccess(const FormClassWizardGenerationParameters &fp, QTextStream &str) +{ + switch(fp.embedding()) { + case FormClassWizardGenerationParameters::PointerAggregatedUiClass: + str << uiMemberC << "->"; + break; + case FormClassWizardGenerationParameters::AggregatedUiClass: + str << uiMemberC << '.'; + break; + case FormClassWizardGenerationParameters::InheritedUiClass: + break; + } +} + +bool FormClassWizardParametersPrivate::generateCpp(const FormClassWizardGenerationParameters &generationParameters, + QString *header, QString *source, int indentation) const +{ + const QString indent = QString(indentation, QLatin1Char(' ')); QString formBaseClass; QString uiClassName; - if (!FormTemplateWizardPage::getUIXmlData(uiTemplate, &formBaseClass, &uiClassName)) { + if (!FormClassWizardParameters::getUIXmlData(uiTemplate, &formBaseClass, &uiClassName)) { qWarning("Unable to determine the form base class from %s.", uiTemplate.toUtf8().constData()); return false; } // Build the ui class (Ui::Foo) name relative to the namespace (which is the same): + const FormClassWizardGenerationParameters::UiClassEmbedding embedding = generationParameters.embedding(); const QString colonColon = QLatin1String("::"); const int lastSeparator = uiClassName.lastIndexOf(colonColon); if (lastSeparator != -1) @@ -87,88 +353,89 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in << "\n#define " << guard << '\n' << '\n'; // Include 'ui_' - if (embedding != PointerAggregatedUiClass) { + if (embedding != FormClassWizardGenerationParameters::PointerAggregatedUiClass) { Core::Utils::writeIncludeFileDirective(uiInclude, false, headerStr); } else { // Todo: Can we obtain the header from the code model for custom widgets? // Alternatively, from Designer. if (formBaseClass.startsWith(QLatin1Char('Q'))) { - QString baseInclude = QLatin1String("QtGui/"); - baseInclude += formBaseClass; + QString baseInclude = formBaseClass; + if (generationParameters.includeQtModule()) + baseInclude.insert(0, QLatin1String("QtGui/")); Core::Utils::writeIncludeFileDirective(baseInclude, true, headerStr); } } - const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr); + const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, + generationParameters.indentNamespace() ? indent : QString(), + headerStr); // Forward-declare the UI class - if (embedding == PointerAggregatedUiClass) { + if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) { headerStr << '\n' << namespaceIndent << "namespace " << uiNamespaceC << " {\n" - << namespaceIndent << indent << "class " << FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n" + << namespaceIndent << indent << "class " << Internal::FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n" << namespaceIndent << "}\n"; } // Class declaration headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName << " : public " << formBaseClass; - if (embedding == InheritedUiClass) { + if (embedding == FormClassWizardGenerationParameters::InheritedUiClass) { headerStr << ", private " << uiClassName; } headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n" << namespaceIndent << "public:\n" << namespaceIndent << indent << unqualifiedClassName << "(QWidget *parent = 0);\n"; - if (embedding == PointerAggregatedUiClass) + if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) headerStr << namespaceIndent << indent << "~" << unqualifiedClassName << "();\n"; // retranslation - if (languageChange) + if (generationParameters.retranslationSupport()) headerStr << '\n' << namespaceIndent << "protected:\n" << namespaceIndent << indent << "void changeEvent(QEvent *e);\n"; // Member variable - if (embedding != InheritedUiClass) { + if (embedding != FormClassWizardGenerationParameters::InheritedUiClass) { headerStr << '\n' << namespaceIndent << "private:\n" << namespaceIndent << indent << uiClassName << ' '; - if (embedding == PointerAggregatedUiClass) + if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) headerStr << '*'; headerStr << uiMemberC << ";\n"; } headerStr << namespaceIndent << "};\n\n"; - Core::Utils::writeClosingNameSpaces(namespaceList, indent, headerStr); + Core::Utils::writeClosingNameSpaces(namespaceList, generationParameters.indentNamespace() ? indent : QString(), headerStr); headerStr << "#endif // "<< guard << '\n'; // 2) Source file QTextStream sourceStr(source); sourceStr << license; Core::Utils::writeIncludeFileDirective(headerFile, false, sourceStr); - if (embedding == PointerAggregatedUiClass) + if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) Core::Utils::writeIncludeFileDirective(uiInclude, false, sourceStr); // NameSpaces( - Core::Utils::writeOpeningNameSpaces(namespaceList, indent, sourceStr); + Core::Utils::writeOpeningNameSpaces(namespaceList, generationParameters.indentNamespace() ? indent : QString(), sourceStr); // Constructor with setupUi sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n" << namespaceIndent << indent << formBaseClass << "(parent)"; - if (embedding == PointerAggregatedUiClass) + if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")\n"; sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent; - if (embedding != InheritedUiClass) - sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : "."); - sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n"; + writeUiMemberAccess(generationParameters, sourceStr); + sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n"; // Deleting destructor for ptr - if (embedding == PointerAggregatedUiClass) { + if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) { sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::~" << unqualifiedClassName << "()\n" << namespaceIndent << "{\n" << namespaceIndent << indent << "delete " << uiMemberC << ";\n" << namespaceIndent << "}\n"; } // retranslation - if (languageChange) { + if (generationParameters.retranslationSupport()) { sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n" << namespaceIndent << "{\n" << namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n" << namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n" << namespaceIndent << indent << indent; - if (embedding != InheritedUiClass) - sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : "."); + writeUiMemberAccess(generationParameters, sourceStr); sourceStr << "retranslateUi(this);\n" << namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << "default:\n" @@ -176,9 +443,15 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in << namespaceIndent << indent << "}\n" << namespaceIndent << "}\n"; } - Core::Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr); + Core::Utils::writeClosingNameSpaces(namespaceList, generationParameters.indentNamespace() ? indent : QString(), sourceStr); return true; } -} // namespace Internal +bool FormClassWizardParameters::generateCpp(const FormClassWizardGenerationParameters &fgp, + QString *header, QString *source, int indentation) const +{ + return m_d->generateCpp(fgp, header, source, indentation); +} + + } // namespace Designer diff --git a/src/plugins/designer/cpp/formclasswizardparameters.h b/src/plugins/designer/cpp/formclasswizardparameters.h index 15c95253272..6a5c65ac060 100644 --- a/src/plugins/designer/cpp/formclasswizardparameters.h +++ b/src/plugins/designer/cpp/formclasswizardparameters.h @@ -30,35 +30,99 @@ #ifndef FORMCLASSWIZARDPARAMETERS_H #define FORMCLASSWIZARDPARAMETERS_H +#include "../designer_export.h" #include +#include + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE namespace Designer { -namespace Internal { +class FormClassWizardGenerationParametersPrivate; +class FormClassWizardParametersPrivate; -enum UiClassEmbedding { - PointerAggregatedUiClass, - AggregatedUiClass, - InheritedUiClass +// Parameters influencing the code generation. +class DESIGNER_EXPORT FormClassWizardGenerationParameters { +public: + // How to embed the Ui::Form class. + enum UiClassEmbedding { + PointerAggregatedUiClass, // "Ui::Form *m_ui"; + AggregatedUiClass, // "Ui::Form m_ui"; + InheritedUiClass // "...private Ui::Form..." + }; + + FormClassWizardGenerationParameters(); + ~FormClassWizardGenerationParameters(); + FormClassWizardGenerationParameters(const FormClassWizardGenerationParameters&); + FormClassWizardGenerationParameters &operator=(const FormClassWizardGenerationParameters &); + + void fromSettings(const QSettings *); + void toSettings(QSettings *) const; + + UiClassEmbedding embedding() const; + void setEmbedding(UiClassEmbedding e); + + bool retranslationSupport() const; // Add handling for language change events + void setRetranslationSupport(bool v); + + bool includeQtModule() const; // Include "" or just "<[Class]>" + void setIncludeQtModule(bool v); + + bool indentNamespace() const; + void setIndentNamespace(bool v); + + bool equals(const FormClassWizardGenerationParameters &rhs) const; + +private: + QSharedDataPointer m_d; }; -struct FormClassWizardParameters { - explicit FormClassWizardParameters(); +inline bool operator==(const FormClassWizardGenerationParameters &p1, const FormClassWizardGenerationParameters &p2) { return p1.equals(p2); } +inline bool operator!=(const FormClassWizardGenerationParameters &p1, const FormClassWizardGenerationParameters &p2) { return !p1.equals(p2); } - bool generateCpp(QString *header, QString *source, int indentation = 4) const; +// Parameters required to generate the code part of a form class with +// helpers for XML-processing ui templates. +class DESIGNER_EXPORT FormClassWizardParameters { +public: + FormClassWizardParameters(); + ~FormClassWizardParameters(); + FormClassWizardParameters(const FormClassWizardParameters &); + FormClassWizardParameters &operator=(const FormClassWizardParameters &); - UiClassEmbedding embedding; - bool languageChange; // Add handling for language change events - QString uiTemplate; - QString className; + bool generateCpp(const FormClassWizardGenerationParameters &fgp, + QString *header, QString *source, int indentation = 4) const; - QString path; - QString sourceFile; - QString headerFile; - QString uiFile; + // Helper to parse UI XML forms to determine: + // 1) The ui class name from "Designer::Internal::FormClassWizardPage" + // 2) the base class from: widget class="QWizardPage"... + static bool getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName); + // Helper to change the class name in a UI XML form + static QString changeUiClassName(const QString &uiXml, const QString &newUiClassName); + + QString uiTemplate() const; + void setUiTemplate(const QString &); + + QString className() const; + void setClassName(const QString &); + + QString path() const; + void setPath(const QString &); + + QString sourceFile() const; + void setSourceFile(const QString &); + + QString headerFile() const; + void setHeaderFile(const QString &); + + QString uiFile() const; + void setUiFile(const QString &); + +private: + QSharedDataPointer m_d; }; -} // namespace Internal } // namespace Designer #endif // FORMCLASSWIZARDPARAMETERS_H diff --git a/src/plugins/designer/designerconstants.h b/src/plugins/designer/designerconstants.h index a6c53e0a363..6896c67a4e8 100644 --- a/src/plugins/designer/designerconstants.h +++ b/src/plugins/designer/designerconstants.h @@ -30,9 +30,14 @@ #ifndef DESIGNERPLUGIN_CONSTANTS_H #define DESIGNERPLUGIN_CONSTANTS_H +#include + namespace Designer { namespace Constants { +const char * const SETTINGS_CATEGORY = QT_TRANSLATE_NOOP("Designer", "Designer"); +const char * const SETTINGS_CPP_SETTINGS = QT_TRANSLATE_NOOP("Designer", "Class Generation"); + // context const char * const C_FORMEDITOR = "FormEditor"; const char * const T_FORMEDITOR = "FormEditor.Toolbar"; diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index 40a6276133e..3508626fb80 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -35,6 +35,7 @@ #ifdef CPP_ENABLED # include "formclasswizard.h" # include +# include "cppsettingspage.h" #endif #include "designerconstants.h" @@ -60,24 +61,12 @@ using namespace Designer::Internal; using namespace Designer::Constants; -FormEditorPlugin::FormEditorPlugin() : - m_factory(0), - m_formWizard(0), - m_formClassWizard(0) +FormEditorPlugin::FormEditorPlugin() { } FormEditorPlugin::~FormEditorPlugin() { - if (m_factory) - removeObject(m_factory); - if (m_formWizard) - removeObject(m_formWizard); - if (m_formClassWizard) - removeObject(m_formClassWizard); - delete m_factory; - delete m_formWizard; - delete m_formClassWizard; FormEditorW::deleteInstance(); } @@ -95,30 +84,28 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error)) return false; - if (!initializeTemplates(error)) - return false; + initializeTemplates(); const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR)); const QList context = QList() << uid; - m_factory = new FormEditorFactory; - addObject(m_factory); + addAutoReleasedObject(new FormEditorFactory); if (qgetenv("KDE_SESSION_VERSION") == QByteArray("4")) { // KDE 4, possibly dangerous... // KDE 4.2.0 had a nasty bug, which resulted in the File/Open Dialog crashing // so check for that an fully load the plugins QProcess proc; - proc.start("kde4-config", QStringList() << "--version"); + proc.start(QLatin1String("kde4-config"), QStringList(QLatin1String("--version"))); proc.waitForFinished(); - QString output = proc.readAll(); + const QByteArray output = proc.readAll(); if (output.contains("KDE: 4.2.0")) FormEditorW::ensureInitStage(FormEditorW::FullyInitialized); } else { FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins); } - QString locale = qApp->property("qtc_locale").toString(); + const QString locale = qApp->property("qtc_locale").toString(); if (!locale.isEmpty()) { QTranslator *qtr = new QTranslator(this); const QString &creatorTrPath = @@ -143,26 +130,23 @@ void FormEditorPlugin::extensionsInitialized() // //////////////////////////////////////////////////// -bool FormEditorPlugin::initializeTemplates(QString *error) +void FormEditorPlugin::initializeTemplates() { - Q_UNUSED(error); FormWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); wizardParameters.setCategory(QLatin1String("Qt")); wizardParameters.setTrCategory(tr("Qt")); const QString formFileType = QLatin1String(Constants::FORM_FILE_TYPE); wizardParameters.setName(tr("Qt Designer Form")); wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui).")); - m_formWizard = new FormWizard(wizardParameters, this); - addObject(m_formWizard); + addAutoReleasedObject(new FormWizard(wizardParameters, this)); #ifdef CPP_ENABLED wizardParameters.setKind(Core::IWizard::ClassWizard); wizardParameters.setName(tr("Qt Designer Form Class")); wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui) with a matching class.")); - m_formClassWizard = new FormClassWizard(wizardParameters, this); - addObject(m_formClassWizard); + addAutoReleasedObject(new FormClassWizard(wizardParameters, this)); + addAutoReleasedObject(new CppSettingsPage); #endif - return true; } Q_EXPORT_PLUGIN(FormEditorPlugin) diff --git a/src/plugins/designer/formeditorplugin.h b/src/plugins/designer/formeditorplugin.h index 60fdbee7d42..d9d1fe50962 100644 --- a/src/plugins/designer/formeditorplugin.h +++ b/src/plugins/designer/formeditorplugin.h @@ -32,18 +32,9 @@ #include -namespace Core { - class IWizard; - class ICore; -} - namespace Designer { namespace Internal { -class FormEditorFactory; -class FormWizard; -class FormEditorW; - class FormEditorPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -57,12 +48,7 @@ public: void extensionsInitialized(); private: - bool initializeTemplates(QString *error_message); - - FormEditorFactory *m_factory; - - Core::IWizard *m_formWizard; - Core::IWizard *m_formClassWizard; + void initializeTemplates(); }; } // namespace Internal diff --git a/src/plugins/designer/formtemplatewizardpage.h b/src/plugins/designer/formtemplatewizardpage.h index 2c52abd0a61..7ab9c036126 100644 --- a/src/plugins/designer/formtemplatewizardpage.h +++ b/src/plugins/designer/formtemplatewizardpage.h @@ -54,7 +54,11 @@ public: QString templateContents() const { return m_templateContents; } + // Parse UI XML forms to determine: + // 1) The ui class name from "Designer::Internal::FormClassWizardPage" + // 2) the base class from: widget class="QWizardPage"... static bool getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName); + // Change the class name in a UI XML form static QString changeUiClassName(const QString &uiXml, const QString &newUiClassName); static QString stripNamespaces(const QString &className); diff --git a/src/plugins/designer/settingspage.cpp b/src/plugins/designer/settingspage.cpp index 2fdee80d8f2..618c3e20788 100644 --- a/src/plugins/designer/settingspage.cpp +++ b/src/plugins/designer/settingspage.cpp @@ -28,9 +28,11 @@ **************************************************************************/ #include "settingspage.h" +#include "designerconstants.h" #include #include +#include using namespace Designer::Internal; @@ -55,12 +57,12 @@ QString SettingsPage::trName() const QString SettingsPage::category() const { - return QLatin1String("Designer"); + return QLatin1String(Designer::Constants::SETTINGS_CATEGORY); } QString SettingsPage::trCategory() const { - return tr("Designer"); + return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CATEGORY); } QWidget *SettingsPage::createPage(QWidget *parent) diff --git a/src/plugins/projectexplorer/projectwizardpage.cpp b/src/plugins/projectexplorer/projectwizardpage.cpp index bd7c2f12629..ff4d2b6060a 100644 --- a/src/plugins/projectexplorer/projectwizardpage.cpp +++ b/src/plugins/projectexplorer/projectwizardpage.cpp @@ -53,8 +53,11 @@ ProjectWizardPage::~ProjectWizardPage() void ProjectWizardPage::setProjects(const QStringList &l) { + QStringList list = l; + list.removeDuplicates(); + list.sort(); m_ui->projectComboBox->clear(); - m_ui->projectComboBox->addItems(l); + m_ui->projectComboBox->addItems(list); } void ProjectWizardPage::setAddToProjectEnabled(bool b) diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.cpp b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.cpp index 0617d145123..83042b443b5 100644 --- a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.cpp +++ b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.cpp @@ -65,6 +65,8 @@ Core::GeneratedFiles CustomWidgetWizard::generateFiles(const QWizard *w, p.name = cw->name(); p.path = cw->path(); p.license = CppTools::AbstractEditorSupport::licenseTemplate(); + p.templatePath = QtWizard::templateDir(); + p.templatePath += QLatin1String("/customwidgetwizard"); return PluginGenerator::generatePlugin(p, *(cw->pluginOptions()), errorMessage); } diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.pri b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.pri index a52a62848a3..4547080e961 100644 --- a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.pri +++ b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizard.pri @@ -22,4 +22,4 @@ FORMS += \ $$PWD/classdefinition.ui \ $$PWD/customwidgetwidgetswizardpage.ui \ $$PWD/customwidgetpluginwizardpage.ui -RESOURCES += $$PWD/templates/templates.qrc + diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp b/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp index b2b67808921..fdb712892e4 100644 --- a/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp +++ b/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp @@ -97,7 +97,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara sm.clear(); sm.insert(QLatin1String("SINGLE_INCLUDE_GUARD"), headerGuard(wo.pluginHeaderFile)); sm.insert(QLatin1String("PLUGIN_CLASS"), wo.pluginClassName); - const QString pluginHeaderContents = processTemplate(QLatin1String(":/tpl_single.h"), sm, errorMessage); + const QString pluginHeaderContents = processTemplate(p.templatePath + QLatin1String("/tpl_single.h"), sm, errorMessage); if (pluginHeaderContents.isEmpty()) return QList(); Core::GeneratedFile pluginHeader(baseDir + wo.pluginHeaderFile); @@ -128,7 +128,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara wo.pluginClassName + QLatin1Char(')') : QLatin1String("")); - const QString pluginSourceContents = processTemplate(QLatin1String(":/tpl_single.cpp"), sm, errorMessage); + const QString pluginSourceContents = processTemplate(p.templatePath + QLatin1String("/tpl_single.cpp"), sm, errorMessage); if (pluginSourceContents.isEmpty()) return QList(); Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile); @@ -152,9 +152,9 @@ QList PluginGenerator::generatePlugin(const GenerationPara if (pc.headers.isEmpty()) { if (wo.sourceType == PluginOptions::WidgetOptions::LinkLibrary) { pc.library = wo.widgetLibrary; - pc.tmpl = QLatin1String(":/tpl_widget_lib.pro"); + pc.tmpl = p.templatePath + QLatin1String("/tpl_widget_lib.pro"); } else { - pc.tmpl = QLatin1String(":/tpl_widget_include.pri"); + pc.tmpl = p.templatePath + QLatin1String("/tpl_widget_include.pri"); } widgetProjectContents.insert(wo.widgetProjectFile, pc); } else { @@ -171,7 +171,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara sm.insert(QLatin1String("WIDGET_INCLUDE_GUARD"), headerGuard(wo.widgetHeaderFile)); sm.insert(QLatin1String("WIDGET_BASE_CLASS"), wo.widgetBaseClassName); sm.insert(QLatin1String("WIDGET_CLASS"), wo.widgetClassName); - const QString widgetHeaderContents = processTemplate(QLatin1String(":/tpl_widget.h"), sm, errorMessage); + const QString widgetHeaderContents = processTemplate(p.templatePath + QLatin1String("/tpl_widget.h"), sm, errorMessage); if (widgetHeaderContents.isEmpty()) return QList(); Core::GeneratedFile widgetHeader(baseDir + wo.widgetHeaderFile); @@ -180,7 +180,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara sm.remove(QLatin1String("WIDGET_INCLUDE_GUARD")); sm.insert(QLatin1String("WIDGET_HEADER"), wo.widgetHeaderFile); - const QString widgetSourceContents = processTemplate(QLatin1String(":/tpl_widget.cpp"), sm, errorMessage); + const QString widgetSourceContents = processTemplate(p.templatePath + QLatin1String("/tpl_widget.cpp"), sm, errorMessage); if (widgetSourceContents.isEmpty()) return QList(); Core::GeneratedFile widgetSource(baseDir + wo.widgetSourceFile); @@ -213,7 +213,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara sm.clear(); sm.insert(QLatin1String("COLLECTION_INCLUDE_GUARD"), headerGuard(options.collectionHeaderFile)); sm.insert(QLatin1String("COLLECTION_PLUGIN_CLASS"), options.collectionClassName); - const QString collectionHeaderContents = processTemplate(QLatin1String(":/tpl_collection.h"), sm, errorMessage); + const QString collectionHeaderContents = processTemplate(p.templatePath + QLatin1String("/tpl_collection.h"), sm, errorMessage); if (collectionHeaderContents.isEmpty()) return QList(); Core::GeneratedFile collectionHeader(baseDir + options.collectionHeaderFile); @@ -233,7 +233,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara QLatin1String(", ") + options.collectionClassName + QLatin1Char(')')); - const QString collectionSourceFileContents = processTemplate(QLatin1String(":/tpl_collection.cpp"), sm, errorMessage); + const QString collectionSourceFileContents = processTemplate(p.templatePath + QLatin1String("/tpl_collection.cpp"), sm, errorMessage); if (collectionSourceFileContents.isEmpty()) return QList(); Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile); @@ -262,7 +262,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara // Create the resource file with the icons. sm.clear(); sm.insert(QLatin1String("ICON_FILES"), iconFiles); - const QString resourceFileContents = processTemplate(QLatin1String(":/tpl_resources.qrc"), sm, errorMessage); + const QString resourceFileContents = processTemplate(p.templatePath + QLatin1String("/tpl_resources.qrc"), sm, errorMessage); if (resourceFileContents.isEmpty()) return QList(); Core::GeneratedFile resourceFile(baseDir + options.resourceFile); @@ -277,7 +277,7 @@ QList PluginGenerator::generatePlugin(const GenerationPara sm.insert(QLatin1String("PLUGIN_RESOURCES"), options.resourceFile); sm.insert(QLatin1String("WIDGET_LIBS"), QStringList(widgetLibraries.toList()).join(QString(blank))); sm.insert(QLatin1String("INCLUSIONS"), QStringList(widgetProjects.toList()).join(QLatin1String("\n"))); - const QString proFileContents = processTemplate(QLatin1String(":/tpl_plugin.pro"), sm, errorMessage); + const QString proFileContents = processTemplate(p.templatePath + QLatin1String("/tpl_plugin.pro"), sm, errorMessage); if (proFileContents.isEmpty()) return QList(); Core::GeneratedFile proFile(baseDir + p.name + QLatin1String(".pro")); diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.h b/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.h index 5d89ca648b7..6bc653143b0 100644 --- a/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.h +++ b/src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.h @@ -52,6 +52,7 @@ struct GenerationParameters { QString path; QString name; QString license; + QString templatePath; }; class PluginGenerator : public QObject diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/templates/templates.qrc b/src/plugins/qt4projectmanager/customwidgetwizard/templates/templates.qrc deleted file mode 100644 index 804d271dae4..00000000000 --- a/src/plugins/qt4projectmanager/customwidgetwizard/templates/templates.qrc +++ /dev/null @@ -1,14 +0,0 @@ - - - tpl_widget.h - tpl_widget.cpp - tpl_widget_include.pri - tpl_widget_lib.pro - tpl_single.h - tpl_single.cpp - tpl_collection.h - tpl_collection.cpp - tpl_plugin.pro - tpl_resources.qrc - - diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp b/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp index 8dcaeca8839..108fd4cb4c3 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/guiappwizard.cpp @@ -37,9 +37,12 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -89,6 +92,33 @@ QWizard *GuiAppWizard::createWizardDialog(QWidget *parent, return dialog; } +// Use the class generation utils provided by the designer plugin +static inline bool generateFormClass(const GuiAppParameters ¶ms, + const Core::GeneratedFile &uiFile, + Core::GeneratedFile *formSource, + Core::GeneratedFile *formHeader, + QString *errorMessage) +{ + // Retrieve parameters from settings + Designer::FormClassWizardGenerationParameters fgp; + fgp.fromSettings(Core::ICore::instance()->settings()); + Designer::FormClassWizardParameters fp; + fp.setUiTemplate(uiFile.contents()); + fp.setUiFile(uiFile.path()); + fp.setClassName(params.className); + fp.setSourceFile(params.sourceFileName); + fp.setHeaderFile(params.headerFileName); + QString headerContents; + QString sourceContents; + if (!fp.generateCpp(fgp, &headerContents, &sourceContents, 4)) { + *errorMessage = QLatin1String("Internal error: Unable to generate the form classes."); + return false; + } + formHeader->setContents(headerContents); + formSource->setContents(sourceContents); + return true; +} + Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, QString *errorMessage) const { @@ -108,28 +138,32 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage)) return Core::GeneratedFiles(); mainSource.setContents(license + contents); - // Create files: form source - const QString formSourceTemplate = params.designerForm ? QLatin1String("mywidget_form.cpp") : QLatin1String("mywidget.cpp"); + // Create files: form source with or without form const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix()); - Core::GeneratedFile formSource(formSourceFileName); - if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage)) - return Core::GeneratedFiles(); - formSource.setContents(license + contents); - // Create files: form header const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix()); - const QString formHeaderTemplate = params.designerForm ? QLatin1String("mywidget_form.h") : QLatin1String("mywidget.h"); + Core::GeneratedFile formSource(formSourceFileName); Core::GeneratedFile formHeader(formHeaderName); - if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage)) - return Core::GeneratedFiles(); - formHeader.setContents(license + contents); - // Create files: form + QSharedPointer form; if (params.designerForm) { + // Create files: form const QString formName = buildFileName(projectPath, params.formFileName, formSuffix()); form = QSharedPointer(new Core::GeneratedFile(formName)); if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage)) return Core::GeneratedFiles(); - form->setContents(contents); + form->setContents(contents); + if (!generateFormClass(params, *form, &formSource, &formHeader, errorMessage)) + return Core::GeneratedFiles(); + } else { + const QString formSourceTemplate = QLatin1String("mywidget.cpp"); + if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage)) + return Core::GeneratedFiles(); + formSource.setContents(license + contents); + // Create files: form header + const QString formHeaderTemplate = QLatin1String("mywidget.h"); + if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage)) + return Core::GeneratedFiles(); + formHeader.setContents(license + contents); } // Create files: profile const QString profileName = buildFileName(projectPath, projectParams.name, profileSuffix()); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index d4cd03b4bc0..b8b327af50e 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -468,6 +468,7 @@ void testQObject(int &argc, char *argv[]) #endif QString str = QString::fromUtf8("XXXXXXXXXXXXXXyyXXX ö"); QLabel l(str); + l.setObjectName("Some Label"); l.show(); app.exec(); } @@ -915,7 +916,13 @@ void testQVariant1() void testQVariant2() { + QVariant value; + QVariant::Type t = QVariant::String; + value = QVariant(t, (void*)0); + *(QString*)value.data() = QString("XXX"); + int i = 1; +#if 0 QVariant var; var.setValue(1); var.setValue(2); @@ -927,6 +934,7 @@ void testQVariant2() var.setValue(QStringList() << "World" << "Hello"); var.setValue(QStringList() << "Hello" << "Hello"); var.setValue(QStringList() << "World" << "Hello" << "Hello"); +#endif #if 0 QVariant var3; QHostAddress ha("127.0.0.1");