summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-01-13 15:55:25 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-01-13 15:55:25 (GMT)
commitdcddedd425e1fbb07507e8468857c75e09188cfd (patch)
treea6a874921529e551c1649661cc7d1ed2b855fe8e
parentc47011d1098b94c53f733b633598883a9e66ab3a (diff)
downloadswift-dcddedd425e1fbb07507e8468857c75e09188cfd.zip
swift-dcddedd425e1fbb07507e8468857c75e09188cfd.tar.bz2
Testing vertical dialog layout.
Change-Id: If6ab16c96b94dd26b0c9b3169ae3199ad3cad328
-rw-r--r--Swift/Controllers/HighlightEditorController.cpp4
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp150
-rw-r--r--Swift/QtUI/QtHighlightEditor.h41
-rw-r--r--Swift/QtUI/QtHighlightEditor.ui361
-rw-r--r--Swift/QtUI/QtUIFactory.h2
-rw-r--r--Swift/QtUI/SConscript6
6 files changed, 557 insertions, 7 deletions
diff --git a/Swift/Controllers/HighlightEditorController.cpp b/Swift/Controllers/HighlightEditorController.cpp
index 2b57dbf..66a9f25 100644
--- a/Swift/Controllers/HighlightEditorController.cpp
+++ b/Swift/Controllers/HighlightEditorController.cpp
@@ -34,7 +34,7 @@ void HighlightEditorController::handleUIEvent(boost::shared_ptr<UIEvent> rawEven
if (!highlightEditorWindow_) {
highlightEditorWindow_ = highlightEditorWindowFactory_->createHighlightEditorWindow();
highlightEditorWindow_->setHighlightManager(highlightManager_);
- highlightEditorWindow_->onContactSuggestionsRequested.connect(boost::bind(&HighlightEditorController::handleContactSuggestionsRequested, this, _1));
+ //highlightEditorWindow_->onContactSuggestionsRequested.connect(boost::bind(&HighlightEditorController::handleContactSuggestionsRequested, this, _1));
}
highlightEditorWindow_->show();
}
@@ -42,7 +42,7 @@ void HighlightEditorController::handleUIEvent(boost::shared_ptr<UIEvent> rawEven
void HighlightEditorController::handleContactSuggestionsRequested(const std::string& text)
{
- highlightEditorWindow_->setContactSuggestions(contactSuggester_->getSuggestions(text));
+ //highlightEditorWindow_->setContactSuggestions(contactSuggester_->getSuggestions(text));
}
}
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp
new file mode 100644
index 0000000..191b239
--- /dev/null
+++ b/Swift/QtUI/QtHighlightEditor.cpp
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2012 Maciej Niedzielski
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <cassert>
+
+#include <Swift/QtUI/QtHighlightEditorWidget.h>
+#include <Swift/QtUI/QtHighlightRulesItemModel.h>
+
+namespace Swift {
+
+QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* parent)
+ : QWidget(parent), settings_(settings)
+{
+ ui_.setupUi(this);
+
+ //itemModel_ = new QtHighlightRulesItemModel(this);
+ //ui_.treeView->setModel(itemModel_);
+ //ui_.ruleWidget->setModel(itemModel_);
+//
+ //for (int i = 0; i < QtHighlightRulesItemModel::NumberOfColumns; ++i) {
+ //switch (i) {
+ //case QtHighlightRulesItemModel::ApplyTo:
+ //case QtHighlightRulesItemModel::Sender:
+ //case QtHighlightRulesItemModel::Keyword:
+ //case QtHighlightRulesItemModel::Action:
+ //ui_.treeView->showColumn(i);
+ //break;
+ //default:
+ //ui_.treeView->hideColumn(i);
+ //break;
+ //}
+ //}
+//
+ //setHighlightManager(NULL); // setup buttons for empty rules list
+//
+ //connect(ui_.treeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentRowChanged(QModelIndex)));
+//
+ //connect(ui_.newButton, SIGNAL(clicked()), SLOT(onNewButtonClicked()));
+ //connect(ui_.deleteButton, SIGNAL(clicked()), SLOT(onDeleteButtonClicked()));
+//
+ //connect(ui_.moveUpButton, SIGNAL(clicked()), SLOT(onMoveUpButtonClicked()));
+ //connect(ui_.moveDownButton, SIGNAL(clicked()), SLOT(onMoveDownButtonClicked()));
+//
+ //connect(ui_.closeButton, SIGNAL(clicked()), SLOT(close()));
+
+ setWindowTitle(tr("Highlight Rules"));
+}
+
+QtHighlightEditor::~QtHighlightEditor()
+{
+}
+
+void QtHighlightEditor::show()
+{
+ //if (itemModel_->rowCount(QModelIndex())) {
+ //selectRow(0);
+ //}
+ QWidget::show();
+ QWidget::activateWindow();
+}
+
+void QtHighlightEditor::setHighlightManager(HighlightManager* highlightManager)
+{
+ //itemModel_->setHighlightManager(highlightManager);
+ //ui_.newButton->setEnabled(highlightManager != NULL);
+//
+ //ui_.ruleWidget->setEnabled(false);
+ //ui_.deleteButton->setEnabled(false);
+ //ui_.moveUpButton->setEnabled(false);
+ //ui_.moveDownButton->setEnabled(false);
+}
+
+void QtHighlightEditor::closeEvent(QCloseEvent* event) {
+ //ui_.ruleWidget->save();
+ //event->accept();
+}
+
+void QtHighlightEditor::onNewButtonClicked()
+{
+ //int row = getSelectedRow() + 1;
+ //itemModel_->insertRow(row, QModelIndex());
+ //selectRow(row);
+}
+
+void QtHighlightEditor::onDeleteButtonClicked()
+{
+ //int row = getSelectedRow();
+ //assert(row >= 0);
+//
+ //itemModel_->removeRow(row, QModelIndex());
+ //if (row == itemModel_->rowCount(QModelIndex())) {
+ //--row;
+ //}
+ //selectRow(row);
+}
+
+void QtHighlightEditor::onMoveUpButtonClicked()
+{
+ //int row = getSelectedRow();
+ //assert(row > 0);
+//
+ //ui_.ruleWidget->save();
+ //ui_.ruleWidget->setActiveIndex(QModelIndex());
+ //itemModel_->swapRows(row, row - 1);
+ //selectRow(row - 1);
+}
+
+void QtHighlightEditor::onMoveDownButtonClicked()
+{
+ //int row = getSelectedRow();
+ //assert(row < itemModel_->rowCount(QModelIndex()) - 1);
+//
+ //ui_.ruleWidget->save();
+ //ui_.ruleWidget->setActiveIndex(QModelIndex());
+ //if (itemModel_->swapRows(row, row + 1)) {
+ //selectRow(row + 1);
+ //}
+}
+
+void QtHighlightEditor::onCurrentRowChanged(const QModelIndex& index)
+{
+ //ui_.ruleWidget->save();
+ //ui_.ruleWidget->setActiveIndex(index);
+//
+ //ui_.ruleWidget->setEnabled(index.isValid());
+//
+ //ui_.deleteButton->setEnabled(index.isValid());
+//
+ //ui_.moveUpButton->setEnabled(index.isValid() && index.row() != 0);
+ //ui_.moveDownButton->setEnabled(index.isValid() && index.row() != itemModel_->rowCount(QModelIndex()) - 1);
+}
+
+void QtHighlightEditor::selectRow(int row)
+{
+ //QModelIndex index = itemModel_->index(row, 0, QModelIndex());
+ //ui_.treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+}
+
+/** Return index of selected row or -1 if none is selected */
+int QtHighlightEditor::getSelectedRow() const
+{
+ //QModelIndexList rows = ui_.treeView->selectionModel()->selectedRows();
+ //return rows.isEmpty() ? -1 : rows[0].row();
+ return 0;
+}
+
+}
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
new file mode 100644
index 0000000..b063ff0
--- /dev/null
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012 Maciej Niedzielski
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swift/Controllers/UIInterfaces/HighlightEditorWindow.h>
+#include <Swift/QtUI/ui_QtHighlightEditor.h>
+
+namespace Swift {
+
+ class QtHighlightEditor : public QWidget, public HighlightEditorWindow {
+ Q_OBJECT
+
+ public:
+ QtHighlightEditor(QtSettingsProvider* settings, QWidget* parent = NULL);
+ virtual ~QtHighlightEditor();
+
+ virtual void show();
+ virtual void setHighlightManager(HighlightManager* highlightManager);
+
+ private slots:
+ void onNewButtonClicked();
+ void onDeleteButtonClicked();
+ void onMoveUpButtonClicked();
+ void onMoveDownButtonClicked();
+ void onCurrentRowChanged(const QModelIndex&);
+
+ private:
+ virtual void closeEvent(QCloseEvent* event);
+
+ void selectRow(int row);
+ int getSelectedRow() const;
+
+ Ui::QtHighlightEditor ui_;
+ QtSettingsProvider *settings_;
+ };
+
+}
diff --git a/Swift/QtUI/QtHighlightEditor.ui b/Swift/QtUI/QtHighlightEditor.ui
new file mode 100644
index 0000000..933c61f
--- /dev/null
+++ b/Swift/QtUI/QtHighlightEditor.ui
@@ -0,0 +1,361 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtHighlightRuleWidget</class>
+ <widget class="QWidget" name="QtHighlightRuleWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>403</width>
+ <height>779</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>200</y>
+ <width>376</width>
+ <height>364</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Rule conditions</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Choose when this rule should be applied.
+If you want to provide more than one sender or keyword, input them in separate lines.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>&amp;Apply to:</string>
+ </property>
+ <property name="buddy">
+ <cstring>applyTo</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="applyTo"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Sender:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>&amp;Keywords:</string>
+ </property>
+ <property name="buddy">
+ <cstring>keywords</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QPlainTextEdit" name="keywords"/>
+ </item>
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="nickIsKeyword">
+ <property name="text">
+ <string>Treat &amp;nick as a keyword (in MUC)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QCheckBox" name="matchWholeWords">
+ <property name="text">
+ <string>Match whole &amp;words</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="QCheckBox" name="matchCase">
+ <property name="text">
+ <string>Match &amp;case</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>570</y>
+ <width>376</width>
+ <height>142</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Actions</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="highlightText">
+ <property name="text">
+ <string>&amp;Highlight text</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>28</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="customColors">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Custom c&amp;olors:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Swift::QtColorToolButton" name="foreground">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Foreground</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Swift::QtColorToolButton" name="background">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Background</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="playSound">
+ <property name="text">
+ <string>&amp;Play sound</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>28</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="customSound">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Custom soun&amp;d:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="soundFile">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="soundFileButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>740</y>
+ <width>271</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ <widget class="Line" name="line_2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>710</y>
+ <width>381</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QWidget" name="">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>381</width>
+ <height>181</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Incoming messages are checked against the following rules. First rule that matches will be executed.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QTreeView" name="treeView">
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ <property name="itemsExpandable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QPushButton" name="newButton">
+ <property name="text">
+ <string>New</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deleteButton">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="moveUpButton">
+ <property name="text">
+ <string>Move up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="moveDownButton">
+ <property name="text">
+ <string>Move down</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>Swift::QtColorToolButton</class>
+ <extends>QToolButton</extends>
+ <header>QtColorToolButton.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
index 662c78e..3830774 100644
--- a/Swift/QtUI/QtUIFactory.h
+++ b/Swift/QtUI/QtUIFactory.h
@@ -48,7 +48,7 @@ namespace Swift {
virtual ContactEditWindow* createContactEditWindow();
virtual FileTransferListWidget* createFileTransferListWidget();
virtual WhiteboardWindow* createWhiteboardWindow(boost::shared_ptr<WhiteboardSession> whiteboardSession);
- virtual HighlightEditorWidget* createHighlightEditorWidget();
+ virtual HighlightEditorWindow* createHighlightEditorWindow();
virtual BlockListEditorWidget* createBlockListEditorWidget();
virtual void createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command);
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 24fb371..20dc6e6 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -126,9 +126,7 @@ sources = [
"QtContactEditWindow.cpp",
"QtContactEditWidget.cpp",
"QtSingleWindow.cpp",
- "QtHighlightEditorWidget.cpp",
- "QtHighlightRulesItemModel.cpp",
- "QtHighlightRuleWidget.cpp",
+ "QtHighlightEditor.cpp",
"QtColorToolButton.cpp",
"ChatSnippet.cpp",
"MessageSnippet.cpp",
@@ -283,7 +281,7 @@ myenv.Uic4("QtAffiliationEditor.ui")
myenv.Uic4("QtJoinMUCWindow.ui")
myenv.Uic4("QtHistoryWindow.ui")
myenv.Uic4("QtConnectionSettings.ui")
-myenv.Uic4("QtHighlightRuleWidget.ui")
+myenv.Uic4("QtHighlightEditor.ui")
myenv.Uic4("QtHighlightEditorWidget.ui")
myenv.Uic4("QtBlockListEditorWindow.ui")
myenv.Uic4("QtSpellCheckerWindow.ui")