From dcddedd425e1fbb07507e8468857c75e09188cfd Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Mon, 13 Jan 2014 15:55:25 +0000 Subject: Testing vertical dialog layout. Change-Id: If6ab16c96b94dd26b0c9b3169ae3199ad3cad328 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 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 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 + +#include +#include + +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 +#include + +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 @@ + + + QtHighlightRuleWidget + + + + 0 + 0 + 403 + 779 + + + + Form + + + + + 20 + 200 + 376 + 364 + + + + Rule conditions + + + + QFormLayout::ExpandingFieldsGrow + + + + + Choose when this rule should be applied. +If you want to provide more than one sender or keyword, input them in separate lines. + + + true + + + + + + + Qt::Horizontal + + + + + + + &Apply to: + + + applyTo + + + + + + + + + + Sender: + + + + + + + &Keywords: + + + keywords + + + + + + + + + + Treat &nick as a keyword (in MUC) + + + + + + + Match whole &words + + + + + + + Match &case + + + + + + + + + + + + 20 + 570 + 376 + 142 + + + + Actions + + + + + + &Highlight text + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 28 + 20 + + + + + + + + false + + + Custom c&olors: + + + + + + + false + + + &Foreground + + + Qt::ToolButtonTextBesideIcon + + + + + + + false + + + &Background + + + Qt::ToolButtonTextBesideIcon + + + + + + + + + &Play sound + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 28 + 20 + + + + + + + + false + + + Custom soun&d: + + + + + + + false + + + true + + + + + + + false + + + ... + + + + + + + + + + + 120 + 740 + 271 + 27 + + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 710 + 381 + 31 + + + + Qt::Horizontal + + + + + + 10 + 10 + 381 + 181 + + + + + + + Incoming messages are checked against the following rules. First rule that matches will be executed. + + + true + + + + + + + + + false + + + false + + + + + + + + + New + + + + + + + Delete + + + + + + + Move up + + + + + + + Move down + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Swift::QtColorToolButton + QToolButton +
QtColorToolButton.h
+
+
+ + +
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); - virtual HighlightEditorWidget* createHighlightEditorWidget(); + virtual HighlightEditorWindow* createHighlightEditorWindow(); virtual BlockListEditorWidget* createBlockListEditorWidget(); virtual void createAdHocCommandWindow(boost::shared_ptr 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") -- cgit v0.10.2-6-g49f6