diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-03-19 16:33:44 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-03-19 18:08:16 +0100 |
commit | 9c8f4e30a7d4758293afe73392f9cc80f1154e80 (patch) | |
tree | cc47d4f41b2c099d4e8569755179e79b967e800b /src/libs | |
parent | d2f07b967d6b4c5a00bd35cb6ac1d3399698f610 (diff) | |
download | qt-creator-9c8f4e30a7d4758293afe73392f9cc80f1154e80.tar.gz |
Allow specifying the name of a new generic project
The name is used as the base for files like [project].creator,
[project].files, etc. and is displayed in the Projects mode and the
Projects tree.
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/utils/basevalidatinglineedit.h | 11 | ||||
-rw-r--r-- | src/libs/utils/filenamevalidatinglineedit.h | 8 | ||||
-rw-r--r-- | src/libs/utils/filewizardpage.cpp | 14 | ||||
-rw-r--r-- | src/libs/utils/filewizardpage.h | 18 | ||||
-rw-r--r-- | src/libs/utils/filewizardpage.ui | 66 | ||||
-rw-r--r-- | src/libs/utils/pathchooser.h | 12 |
6 files changed, 64 insertions, 65 deletions
diff --git a/src/libs/utils/basevalidatinglineedit.h b/src/libs/utils/basevalidatinglineedit.h index 9dd8f8ec56..a57d04b49a 100644 --- a/src/libs/utils/basevalidatinglineedit.h +++ b/src/libs/utils/basevalidatinglineedit.h @@ -39,7 +39,8 @@ namespace Utils { struct BaseValidatingLineEditPrivate; -/* Base class for validating line edits that performs validation in a virtual +/** + * Base class for validating line edits that performs validation in a virtual * validate() function to be implemented in derived classes. * When invalid, the text color will turn red and a tooltip will * contain the error message. This approach is less intrusive than a @@ -47,9 +48,10 @@ struct BaseValidatingLineEditPrivate; * * The widget has a concept of an "initialText" which can be something like * "<Enter name here>". This results in state 'DisplayingInitialText', which - * is not valid, but is not marked red. */ - -class QWORKBENCH_UTILS_EXPORT BaseValidatingLineEdit : public QLineEdit { + * is not valid, but is not marked red. + */ +class QWORKBENCH_UTILS_EXPORT BaseValidatingLineEdit : public QLineEdit +{ Q_OBJECT Q_DISABLE_COPY(BaseValidatingLineEdit) Q_PROPERTY(QString initialText READ initialText WRITE setInitialText DESIGNABLE true) @@ -97,4 +99,5 @@ private: } // namespace Utils } // namespace Core + #endif // BASEVALIDATINGLINEEDIT_H diff --git a/src/libs/utils/filenamevalidatinglineedit.h b/src/libs/utils/filenamevalidatinglineedit.h index cf37757175..60145bdf4c 100644 --- a/src/libs/utils/filenamevalidatinglineedit.h +++ b/src/libs/utils/filenamevalidatinglineedit.h @@ -35,6 +35,10 @@ namespace Core { namespace Utils { +/** + * A control that let's the user choose a file name, based on a QLineEdit. Has + * some validation logic for embedding into QWizardPage. + */ class QWORKBENCH_UTILS_EXPORT FileNameValidatingLineEdit : public BaseValidatingLineEdit { Q_OBJECT @@ -47,6 +51,10 @@ public: bool allowDirectories = false, QString *errorMessage = 0); + /** + * Sets whether entering directories is allowed. This will enable the user + * to enter slashes in the filename. Default is off. + */ bool allowDirectories() const; void setAllowDirectories(bool v); diff --git a/src/libs/utils/filewizardpage.cpp b/src/libs/utils/filewizardpage.cpp index 59f1bbc56b..3fb0b79b8c 100644 --- a/src/libs/utils/filewizardpage.cpp +++ b/src/libs/utils/filewizardpage.cpp @@ -30,10 +30,6 @@ #include "filewizardpage.h" #include "ui_filewizardpage.h" -#include <QtCore/QDebug> -#include <QtCore/QDir> -#include <QtGui/QMessageBox> - namespace Core { namespace Utils { @@ -103,6 +99,16 @@ bool FileWizardPage::isComplete() const return m_d->m_complete; } +void FileWizardPage::setNameLabel(const QString &label) +{ + m_d->m_ui.nameLabel->setText(label); +} + +void FileWizardPage::setPathLabel(const QString &label) +{ + m_d->m_ui.pathLabel->setText(label); +} + void FileWizardPage::slotValidChanged() { const bool newComplete = m_d->m_ui.pathChooser->isValid() && m_d->m_ui.nameLineEdit->isValid(); diff --git a/src/libs/utils/filewizardpage.h b/src/libs/utils/filewizardpage.h index 657ec4f4ef..b41839e0bf 100644 --- a/src/libs/utils/filewizardpage.h +++ b/src/libs/utils/filewizardpage.h @@ -39,10 +39,15 @@ namespace Utils { struct FileWizardPagePrivate; -/* Standard wizard page for a single file letting the user choose name - * and path. Sets the "FileNames" QWizard field. */ - -class QWORKBENCH_UTILS_EXPORT FileWizardPage : public QWizardPage { +/** + * Standard wizard page for a single file letting the user choose name + * and path. Sets the "FileNames" QWizard field. + * + * The name and path labels can be changed. By default they are simply "Name:" + * and "Path:". + */ +class QWORKBENCH_UTILS_EXPORT FileWizardPage : public QWizardPage +{ Q_OBJECT Q_DISABLE_COPY(FileWizardPage) Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true) @@ -56,7 +61,10 @@ public: virtual bool isComplete() const; - // Validate a base name entry field (potentially containing extension) + void setNameLabel(const QString &label); + void setPathLabel(const QString &label); + + // Validate a base name entry field (potentially containing extension) static bool validateBaseName(const QString &name, QString *errorMessage = 0); signals: diff --git a/src/libs/utils/filewizardpage.ui b/src/libs/utils/filewizardpage.ui index 2e614c6f55..98d0873128 100644 --- a/src/libs/utils/filewizardpage.ui +++ b/src/libs/utils/filewizardpage.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>300</height> + <width>196</width> + <height>68</height> </rect> </property> <property name="windowTitle"> @@ -16,52 +16,26 @@ <property name="title"> <string>Choose the location</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QWidget" name="widget" native="true"> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Core::Utils::FileNameValidatingLineEdit" name="nameLineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="pathLabel"> - <property name="text"> - <string>Path:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="nameLabel"> + <property name="text"> + <string>Name:</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>201</height> - </size> + </widget> + </item> + <item row="0" column="1"> + <widget class="Core::Utils::FileNameValidatingLineEdit" name="nameLineEdit"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="pathLabel"> + <property name="text"> + <string>Path:</string> </property> - </spacer> + </widget> + </item> + <item row="1" column="1"> + <widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/> </item> </layout> </widget> diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h index 99f2330371..04607ef700 100644 --- a/src/libs/utils/pathchooser.h +++ b/src/libs/utils/pathchooser.h @@ -39,10 +39,10 @@ namespace Utils { struct PathChooserPrivate; -/* A Control that let's the user choose a path, consisting of a QLineEdit and - * a "Browse" button. Has some validation logic for embedding into - * QWizardPage. */ - +/** + * A control that let's the user choose a path, consisting of a QLineEdit and + * a "Browse" button. Has some validation logic for embedding into QWizardPage. + */ class QWORKBENCH_UTILS_EXPORT PathChooser : public QWidget { Q_DISABLE_COPY(PathChooser) @@ -74,12 +74,12 @@ public: QString path() const; - // Returns the suggested label title when used in a form layout + /** Returns the suggested label title when used in a form layout. */ static QString label(); virtual bool validatePath(const QString &path, QString *errorMessage = 0); - // Return the home directory, which needs some fixing under Windows. + /** Return the home directory, which needs some fixing under Windows. */ static QString homePath(); private: |