Options dialog: Further polishing.

Task-number: QTCREATOR-26
This commit is contained in:
Friedemann Kleint
2009-11-20 16:55:23 +01:00
parent bc92b63ee1
commit e4a7792d6e
14 changed files with 226 additions and 148 deletions

View File

@@ -40,9 +40,12 @@
#include <QtCore/QtConcurrentRun> #include <QtCore/QtConcurrentRun>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QFormLayout> #include <QtGui/QFormLayout>
#include <QtGui/QBoxLayout>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QGroupBox>
#include <QtGui/QSpacerItem>
using namespace CMakeProjectManager::Internal; using namespace CMakeProjectManager::Internal;
@@ -258,13 +261,17 @@ QString CMakeSettingsPage::trCategory() const
QWidget *CMakeSettingsPage::createPage(QWidget *parent) QWidget *CMakeSettingsPage::createPage(QWidget *parent)
{ {
QWidget *w = new QWidget(parent); QWidget *outerWidget = new QWidget(parent);
QFormLayout *fl = new QFormLayout(w); QVBoxLayout *outerLayout = new QVBoxLayout(outerWidget);
m_pathchooser = new Utils::PathChooser(w); QGroupBox *groupBox = new QGroupBox(trCategory());
outerLayout->addWidget(groupBox);
outerLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
QFormLayout *formLayout = new QFormLayout(groupBox);
m_pathchooser = new Utils::PathChooser;
m_pathchooser->setExpectedKind(Utils::PathChooser::Command); m_pathchooser->setExpectedKind(Utils::PathChooser::Command);
fl->addRow(tr("CMake executable"), m_pathchooser); formLayout->addRow(tr("Executable:"), m_pathchooser);
m_pathchooser->setPath(cmakeExecutable()); m_pathchooser->setPath(cmakeExecutable());
return w; return outerWidget;
} }
void CMakeSettingsPage::updateInfo() void CMakeSettingsPage::updateInfo()

View File

@@ -184,6 +184,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
m_applied(false) m_applied(false)
{ {
setupUi(this); setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
setWindowTitle(tr("Preferences")); setWindowTitle(tr("Preferences"));
#else #else

View File

@@ -34,8 +34,11 @@
#include <utils/consoleprocess.h> #include <utils/consoleprocess.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtCore/QTextStream>
#include "ui_generalsettings.h" #include "ui_generalsettings.h"
using namespace Utils; using namespace Utils;
@@ -94,9 +97,20 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
this, SLOT(resetTerminal())); this, SLOT(resetTerminal()));
#endif #endif
if (m_searchKeywords.isEmpty()) {
QTextStream(&m_searchKeywords) << m_page->colorLabel->text() << ' '
<< m_page->terminalLabel->text() << ' ' << m_page->editorLabel->text()
<< ' '<< m_page->modifiedLabel->text();
m_searchKeywords.remove(QLatin1Char('&'));
}
return w; return w;
} }
bool GeneralSettings::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
void GeneralSettings::apply() void GeneralSettings::apply()
{ {
// Apply the new base color if accepted // Apply the new base color if accepted

View File

@@ -55,6 +55,7 @@ public:
QWidget* createPage(QWidget *parent); QWidget* createPage(QWidget *parent);
void apply(); void apply();
void finish(); void finish();
virtual bool matches(const QString &) const;
private slots: private slots:
void resetInterfaceColor(); void resetInterfaceColor();
@@ -66,6 +67,7 @@ private slots:
private: private:
Ui::GeneralSettings *m_page; Ui::GeneralSettings *m_page;
QString m_searchKeywords;
QPointer<QWidget> m_dialog; QPointer<QWidget> m_dialog;
}; };

View File

@@ -2,24 +2,17 @@
<ui version="4.0"> <ui version="4.0">
<class>Core::Internal::GeneralSettings</class> <class>Core::Internal::GeneralSettings</class>
<widget class="QWidget" name="Core::Internal::GeneralSettings"> <widget class="QWidget" name="Core::Internal::GeneralSettings">
<property name="geometry"> <layout class="QVBoxLayout" name="verticalLayout">
<rect>
<x>0</x>
<y>0</y>
<width>536</width>
<height>233</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>General settings</string> <string>General settings</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QFormLayout" name="formLayout">
<item> <property name="rowWrapPolicy">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <enum>QFormLayout::WrapLongRows</enum>
<item> </property>
<item row="0" column="0">
<widget class="QLabel" name="colorLabel"> <widget class="QLabel" name="colorLabel">
<property name="text"> <property name="text">
<string>User &amp;interface color:</string> <string>User &amp;interface color:</string>
@@ -29,22 +22,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<spacer name="horizontalSpacer_2"> <layout class="QHBoxLayout" name="colorHorizontalLayout">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="Utils::QtColorButton" name="colorButton"> <widget class="Utils::QtColorButton" name="colorButton">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -93,15 +72,15 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="terminalLabel"> <widget class="QLabel" name="terminalLabel">
<property name="text"> <property name="text">
<string>Terminal:</string> <string>Terminal:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="terminalHorizontalLayout">
<item> <item>
<widget class="QLineEdit" name="terminalEdit"/> <widget class="QLineEdit" name="terminalEdit"/>
</item> </item>
@@ -121,15 +100,15 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5"> <widget class="QLabel" name="editorLabel">
<item>
<widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>External editor:</string> <string>External editor:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="editorHorizontalLayout">
<item> <item>
<widget class="QLineEdit" name="externalEditorEdit"/> <widget class="QLineEdit" name="externalEditorEdit"/>
</item> </item>
@@ -156,10 +135,8 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QLabel" name="modifiedLabel">
<item>
<widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>When files are externally modified:</string> <string>When files are externally modified:</string>
</property> </property>
@@ -168,7 +145,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="3" column="1">
<widget class="QComboBox" name="reloadBehavior"> <widget class="QComboBox" name="reloadBehavior">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -197,8 +174,6 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>

View File

@@ -34,6 +34,9 @@
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QGroupBox>
#include <QtGui/QFormLayout>
#include <QtGui/QVBoxLayout>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QVariant> #include <QtCore/QVariant>
@@ -71,21 +74,25 @@ QString CodePasterSettingsPage::trCategory() const
QWidget *CodePasterSettingsPage::createPage(QWidget *parent) QWidget *CodePasterSettingsPage::createPage(QWidget *parent)
{ {
QWidget *w = new QWidget(parent); QGroupBox *groupBox = new QGroupBox(category());
QLabel *label = new QLabel(tr("Server:")); QVBoxLayout *groupBoxLayout = new QVBoxLayout(groupBox);
QLineEdit *lineedit = new QLineEdit; QFormLayout *formLayout = new QFormLayout;
lineedit->setText(m_host); QLineEdit *lineedit = new QLineEdit(m_host);
connect(lineedit, SIGNAL(textChanged(QString)), this, SLOT(serverChanged(QString))); connect(lineedit, SIGNAL(textChanged(QString)), this, SLOT(serverChanged(QString)));
formLayout->addRow(tr("Server:"), lineedit);
groupBoxLayout->addLayout(formLayout);
groupBoxLayout->addSpacerItem(new QSpacerItem(0, 60, QSizePolicy::Ignored, QSizePolicy::Fixed));
QLabel *noteLabel = new QLabel(tr("Note: Specify the host name for the CodePaster service " QLabel *noteLabel = new QLabel(tr("Note: Specify the host name for the CodePaster service "
"without any protocol prepended (e.g. codepaster.mycompany.com).")); "without any protocol prepended (e.g. codepaster.mycompany.com)."));
noteLabel->setWordWrap(true); noteLabel->setWordWrap(true);
QGridLayout* layout = new QGridLayout(); groupBoxLayout->addWidget(noteLabel);
layout->addWidget(label, 0, 0);
layout->addWidget(lineedit, 0, 1); QWidget *outerWidget = new QWidget(parent);
layout->addWidget(noteLabel, 1, 1); QVBoxLayout *outerLayout = new QVBoxLayout(outerWidget);
layout->addItem(new QSpacerItem(1,1, QSizePolicy::Preferred, QSizePolicy::MinimumExpanding), 2, 0); outerLayout->addWidget(groupBox);
w->setLayout(layout); outerLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
return w; return outerWidget;
} }
void CodePasterSettingsPage::apply() void CodePasterSettingsPage::apply()

View File

@@ -6,18 +6,24 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>520</width>
<height>300</height> <height>475</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>PasteBin</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="serverPrefix">
<property name="text"> <property name="text">
<string>Server Prefix:</string> <string>Server Prefix:</string>
</property> </property>
@@ -26,15 +32,30 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="lineEdit"/> <widget class="QLineEdit" name="lineEdit"/>
</item> </item>
<item row="1" column="1"> </layout>
<widget class="QLabel" name="label_2"> </item>
<item>
<spacer name="explanatoryTextSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="explanatoryTextLabel">
<property name="text"> <property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;p&gt;&lt;a href=&quot;http://pastebin.com&quot;&gt;pastebin.com&lt;/a&gt; allows to send posts to custom subdomains (eg. qtcreator.pastebin.com). Fill in the desired prefix.&lt;/p&gt;
p, li { white-space: pre-wrap; } &lt;p&gt;Note that the plugin will use this for posting as well as fetching.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://pastebin.com&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;pastebin.com&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; allows to send posts to custom subdomains (eg. qtcreator.pastebin.com). Fill in the desired prefix.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Note that the plugin will use this for posting as well as fetching.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::RichText</enum> <enum>Qt::RichText</enum>
@@ -45,6 +66,7 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">

View File

@@ -31,11 +31,13 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QtCore/QSettings>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include <QtCore/QSettings>
#include <QtCore/QTextStream>
using namespace CodePaster; using namespace CodePaster;
@@ -86,6 +88,11 @@ QWidget *SettingsPage::createPage(QWidget *parent)
m_ui.userEdit->setText(m_username); m_ui.userEdit->setText(m_username);
m_ui.clipboardBox->setChecked(m_copy); m_ui.clipboardBox->setChecked(m_copy);
m_ui.displayBox->setChecked(m_output); m_ui.displayBox->setChecked(m_output);
if (m_searchKeywords.isEmpty()) {
QTextStream(&m_searchKeywords) << m_ui.protocolLabel->text() << ' '
<< m_ui.userNameLabel->text();
m_searchKeywords.remove(QLatin1Char('&'));
}
return w; return w;
} }
@@ -107,6 +114,11 @@ void SettingsPage::apply()
m_settings->endGroup(); m_settings->endGroup();
} }
bool SettingsPage::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
void SettingsPage::addProtocol(const QString &name) void SettingsPage::addProtocol(const QString &name)
{ {
m_protocols.append(name); m_protocols.append(name);

View File

@@ -59,6 +59,7 @@ public:
QWidget *createPage(QWidget *parent); QWidget *createPage(QWidget *parent);
void apply(); void apply();
void finish() { } void finish() { }
virtual bool matches(const QString &) const;
void addProtocol(const QString& name); void addProtocol(const QString& name);
QString username() const; QString username() const;
@@ -71,6 +72,7 @@ private:
Ui_SettingsPage m_ui; Ui_SettingsPage m_ui;
QSettings *m_settings; QSettings *m_settings;
QString m_searchKeywords;
QStringList m_protocols; QStringList m_protocols;
QString m_username; QString m_username;
QString m_protocol; QString m_protocol;

View File

@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>362</width> <width>453</width>
<height>320</height> <height>320</height>
</rect> </rect>
</property> </property>
@@ -24,7 +24,7 @@
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="protocolLabel">
<property name="text"> <property name="text">
<string>Default Protocol:</string> <string>Default Protocol:</string>
</property> </property>
@@ -50,7 +50,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="userNameLabel">
<property name="text"> <property name="text">
<string>Username:</string> <string>Username:</string>
</property> </property>

View File

@@ -34,6 +34,8 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <QtCore/QTextStream>
using namespace CppTools::Internal; using namespace CppTools::Internal;
CompletionSettingsPage::CompletionSettingsPage(CppCodeCompletion *completion) CompletionSettingsPage::CompletionSettingsPage(CppCodeCompletion *completion)
@@ -75,7 +77,12 @@ QWidget *CompletionSettingsPage::createPage(QWidget *parent)
m_page->caseSensitive->setChecked(m_completion->caseSensitivity() == Qt::CaseSensitive); m_page->caseSensitive->setChecked(m_completion->caseSensitivity() == Qt::CaseSensitive);
m_page->autoInsertBrackets->setChecked(m_completion->autoInsertBrackets()); m_page->autoInsertBrackets->setChecked(m_completion->autoInsertBrackets());
m_page->partiallyComplete->setChecked(m_completion->isPartialCompletionEnabled()); m_page->partiallyComplete->setChecked(m_completion->isPartialCompletionEnabled());
if (m_searchKeywords.isEmpty()) {
QTextStream(&m_searchKeywords) << m_page->caseSensitive->text()
<< ' ' << m_page->autoInsertBrackets->text()
<< ' ' << m_page->partiallyComplete->text();
m_searchKeywords.remove(QLatin1Char('&'));
}
return w; return w;
} }
@@ -86,3 +93,8 @@ void CompletionSettingsPage::apply()
m_completion->setAutoInsertBrackets(m_page->autoInsertBrackets->isChecked()); m_completion->setAutoInsertBrackets(m_page->autoInsertBrackets->isChecked());
m_completion->setPartialCompletionEnabled(m_page->partiallyComplete->isChecked()); m_completion->setPartialCompletionEnabled(m_page->partiallyComplete->isChecked());
} }
bool CompletionSettingsPage::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}

View File

@@ -57,10 +57,12 @@ public:
QWidget *createPage(QWidget *parent); QWidget *createPage(QWidget *parent);
void apply(); void apply();
void finish() { } void finish() { }
virtual bool matches(const QString &) const;
private: private:
CppCodeCompletion *m_completion; CppCodeCompletion *m_completion;
Ui_CompletionSettingsPage *m_page; Ui_CompletionSettingsPage *m_page;
QString m_searchKeywords;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -44,6 +44,7 @@
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QDate> #include <QtCore/QDate>
#include <QtCore/QLocale> #include <QtCore/QLocale>
#include <QtCore/QTextStream>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
@@ -237,6 +238,16 @@ CppFileSettings CppFileSettingsWidget::settings() const
return rc; return rc;
} }
QString CppFileSettingsWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui->headerSuffixLabel->text()
<< ' ' << m_ui->sourceSuffixLabel->text()
<< ' ' << m_ui->lowerCaseFileNamesCheckBox->text();
rc.remove(QLatin1Char('&'));
return rc;
}
static inline void setComboText(QComboBox *cb, const QString &text, int defaultIndex = 0) static inline void setComboText(QComboBox *cb, const QString &text, int defaultIndex = 0)
{ {
const int index = cb->findText(text); const int index = cb->findText(text);
@@ -312,6 +323,8 @@ QWidget *CppFileSettingsPage::createPage(QWidget *parent)
m_widget = new CppFileSettingsWidget(parent); m_widget = new CppFileSettingsWidget(parent);
m_widget->setSettings(*m_settings); m_widget->setSettings(*m_settings);
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
return m_widget; return m_widget;
} }
@@ -327,6 +340,11 @@ void CppFileSettingsPage::apply()
} }
} }
bool CppFileSettingsPage::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
} }
} }

View File

@@ -77,6 +77,8 @@ public:
CppFileSettings settings() const; CppFileSettings settings() const;
void setSettings(const CppFileSettings &s); void setSettings(const CppFileSettings &s);
QString searchKeywords() const;
private slots: private slots:
void slotEdit(); void slotEdit();
@@ -103,10 +105,12 @@ public:
virtual QWidget *createPage(QWidget *parent); virtual QWidget *createPage(QWidget *parent);
virtual void apply(); virtual void apply();
virtual void finish() { } virtual void finish() { }
virtual bool matches(const QString &) const;
private: private:
const QSharedPointer<CppFileSettings> m_settings; const QSharedPointer<CppFileSettings> m_settings;
QPointer<CppFileSettingsWidget> m_widget; QPointer<CppFileSettingsWidget> m_widget;
QString m_searchKeywords;
}; };
} // namespace Internal } // namespace Internal