From 5ae43964cc9d44231cd68331f13a887288165c96 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 21 Jan 2014 13:47:12 +0100 Subject: [PATCH] Updated nl translation. Initial implementation of line edit with custom status icon. --- localization/rssguard_nl.ts | 47 ++++++++++++++++++--------------- src/gui/formcategorydetails.cpp | 20 +++++++++++--- src/gui/formcategorydetails.h | 3 +++ src/gui/formcategorydetails.ui | 35 +++++++++++------------- src/gui/lineeditwithstatus.cpp | 44 ++++++++++++++++++++++++++++-- src/gui/lineeditwithstatus.h | 20 ++++++++++++++ src/gui/plaintoolbutton.cpp | 2 +- src/gui/tabbar.cpp | 1 - 8 files changed, 124 insertions(+), 48 deletions(-) diff --git a/localization/rssguard_nl.ts b/localization/rssguard_nl.ts index c4c9f07f4..bce145f0b 100644 --- a/localization/rssguard_nl.ts +++ b/localization/rssguard_nl.ts @@ -16,11 +16,11 @@ Feed update started - + Feed update is gestart Updated feed '%1' - + Update feed '%1' @@ -299,27 +299,27 @@ Open selected messages in internal browser - Open geselecteerde bericht in externe webbrowser + Open geselecteerde berichten met ingebouwde webbrowser Open selected messages in internal browser. - Open geselecteerde bericht in externe webbrowser. + Open geselecteerde berichten met ingebouwde webbrowser. Open selected source articles in external browser - Open geselecteerde bron artikelen in externe webbrowser + Open geselecteerde bron artikelen met externe webbrowser Open selected source articles in external browser. - Open geselecteerde bron artikelen in externe webbrowser. + Open geselecteerde bron artikelen met externe webbrowser. Open selected source articles in internal browser - Open geselecteerde bron artikelen in interne webbrowser + Open geselecteerde bron artikelen met ingebouwde webbrowser Open selected source messages in internal browser. - Open geselecteerde bron artikelen in interne webbrowser. + Open geselecteerde bron artikelen met ingebouwde webbrowser. Add new &category @@ -383,27 +383,27 @@ &Delete selected feed/category - + &Verwijder geselecteerde feed/categorie Delete selected feed/category. - + Verwijder geselecteerde feed/categorie. Mark all messages (without message filters) from selected feeds as read. - + Markeer alle berichten (zonder berichten filters) van geselecteerde feeds als gelezen. Mark all messages (without message filters) from selected feeds as unread. - + Markeer alle berichten (zonder berichten filters) van geselecteerde feeds als ongelezen. Remove all messages from selected feeds. - + Verwijder alle berichten van geselecteerde feeds. Displays all messages from selected feeds/categories in a new "newspaper mode" tab. Note that messages are not set as read automatically. - + Toon alle berichten van geselecteerde feeds/categorieën in een nieuwe "Krantweergave modus" tabblad. Onthoud dat de berichten niet zijn ingesteld als automatisch gelezen. @@ -746,7 +746,7 @@ Use sample arguments for - + Gebruik voorbeeld argumenten voor @@ -878,11 +878,11 @@ Problem with starting external web browser - + Probleem om externe webbrowser te starten External web browser could not be started. - + Externe webbrowser kon niet worden gestart. @@ -946,7 +946,8 @@ Deze categorie bevat geen nested items. %1 (standard category) %2%3 - + %1 (standaard categorie) +%2%3 %1 (%2) @@ -954,7 +955,11 @@ Deze categorie bevat geen nested items. Encoding: %4 Language: %5 - + %1 (%2) +%3 + +Codering: %4 +Taal: %5 @@ -972,11 +977,11 @@ Language: %5 StatusBar Fullscreen mode - + Beeldvullende modus Switch application between fulscreen/normal states right from this status bar icon. - + Wissel Rssguard tussen volledige scherm/normale staat vanaf deze statusbar pictogram. diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp index 5a317b1b8..723c2294c 100644 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -7,6 +7,7 @@ #include "core/feedsmodel.h" #include "gui/iconthemefactory.h" #include "gui/feedsview.h" +#include "gui/baselineedit.h" #include #include @@ -25,6 +26,8 @@ FormCategoryDetails::FormCategoryDetails(FeedsModel *model, QWidget *parent) connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(apply())); + connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), + this, SLOT(onTitleChanged(QString))); } FormCategoryDetails::~FormCategoryDetails() { @@ -36,8 +39,8 @@ void FormCategoryDetails::setEditableCategory(FeedsModelCategory *editable_categ // TODO: Setup the dialog according to the category. // so remove this category from category combobox!! - m_ui->m_txtTitle->setText(editable_category->title()); - m_ui->m_txtDescription->setText(editable_category->description()); + m_ui->m_txtTitle->lineEdit()->setText(editable_category->title()); + m_ui->m_txtDescription->lineEdit()->setText(editable_category->description()); m_ui->m_btnIcon->setIcon(editable_category->icon()); } @@ -65,9 +68,9 @@ void FormCategoryDetails::apply() { FeedsModelRootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); FeedsModelStandardCategory *new_category = new FeedsModelStandardCategory(); - new_category->setTitle(m_ui->m_txtTitle->text()); + new_category->setTitle(m_ui->m_txtTitle->lineEdit()->text()); new_category->setCreationDate(QDateTime::currentDateTime()); - new_category->setDescription(m_ui->m_txtDescription->toPlainText()); + new_category->setDescription(m_ui->m_txtDescription->lineEdit()->text()); new_category->setIcon(m_ui->m_btnIcon->icon()); if (m_feedsModel->addItem(new_category, parent)) { @@ -82,6 +85,15 @@ void FormCategoryDetails::apply() { } } +void FormCategoryDetails::onTitleChanged(const QString &new_title){ + if (m_ui->m_txtTitle->lineEdit()->text().size() >= MIN_CATEGORY_NAME_LENGTH) { + m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("This category name is ok.")); + } + else { + m_ui->m_txtTitle->setStatus(LineEditWithStatus::Error, tr("This category name is too short.")); + } +} + void FormCategoryDetails::initialize() { m_ui = new Ui::FormCategoryDetails(); m_ui->setupUi(this); diff --git a/src/gui/formcategorydetails.h b/src/gui/formcategorydetails.h index 76763dcdb..41c621c25 100644 --- a/src/gui/formcategorydetails.h +++ b/src/gui/formcategorydetails.h @@ -46,6 +46,9 @@ class FormCategoryDetails : public QDialog { protected slots: void apply(); + // Trigerred when title/description changes. + void onTitleChanged(const QString &new_title); + protected: // Sets the category which will be edited. // NOTE: This is used for editing categories. diff --git a/src/gui/formcategorydetails.ui b/src/gui/formcategorydetails.ui index b7f71dbf0..8fbb35374 100644 --- a/src/gui/formcategorydetails.ui +++ b/src/gui/formcategorydetails.ui @@ -7,7 +7,7 @@ 0 0 346 - 199 + 180 @@ -22,6 +22,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + @@ -40,16 +43,6 @@ Title - - m_txtTitle - - - - - - - Title of the category - @@ -82,15 +75,11 @@ + + + - - - - 0 - 0 - - - + @@ -106,6 +95,14 @@ + + + LineEditWithStatus + QWidget +
lineeditwithstatus.h
+ 1 +
+
diff --git a/src/gui/lineeditwithstatus.cpp b/src/gui/lineeditwithstatus.cpp index 1ddc74649..33236e16b 100644 --- a/src/gui/lineeditwithstatus.cpp +++ b/src/gui/lineeditwithstatus.cpp @@ -2,6 +2,7 @@ #include "gui/plaintoolbutton.h" #include "gui/baselineedit.h" +#include "gui/iconthemefactory.h" #include @@ -12,14 +13,53 @@ LineEditWithStatus::LineEditWithStatus(QWidget *parent) m_txtInput = new BaseLineEdit(this); m_btnStatus = new PlainToolButton(this); + // TODO: nastavit korektni ikony + m_iconInformation = IconThemeFactory::instance()->fromTheme("help-about"); + m_iconWarning = IconThemeFactory::instance()->fromTheme("application-exit"); + m_iconError = IconThemeFactory::instance()->fromTheme("application-exit"); + m_iconOk = IconThemeFactory::instance()->fromTheme("application-exit"); + + // Set correct size for the tool button. + int txt_input_height = m_txtInput->sizeHint().height(); + m_btnStatus->setFixedSize(txt_input_height, txt_input_height); + // Compose the layout. m_layout->setMargin(0); - m_layout->setSpacing(0); m_layout->addWidget(m_txtInput); m_layout->addWidget(m_btnStatus); - // TODO: pokracovat tady, podle MarkedLineEditu z qonverteru + setLayout(m_layout); + setStatus(Information, QString()); } LineEditWithStatus::~LineEditWithStatus() { } + +void LineEditWithStatus::setStatus(LineEditWithStatus::StatusType status, + const QString &tooltip_text) { + switch (status) { + case Information: + m_btnStatus->setIcon(m_iconInformation); + break; + + case Warning: + m_btnStatus->setIcon(m_iconWarning); + break; + + case Error: + m_btnStatus->setIcon(m_iconError); + break; + + case Ok: + m_btnStatus->setIcon(m_iconOk); + break; + + default: + break; + } + + // Setup the tooltip text. + m_btnStatus->setToolTip(tooltip_text); +} + + diff --git a/src/gui/lineeditwithstatus.h b/src/gui/lineeditwithstatus.h index 034fb90ff..96bb89aa9 100644 --- a/src/gui/lineeditwithstatus.h +++ b/src/gui/lineeditwithstatus.h @@ -2,6 +2,7 @@ #define LINEEDITWITHSTATUS_H #include +#include class BaseLineEdit; @@ -12,6 +13,13 @@ class LineEditWithStatus : public QWidget { Q_OBJECT public: + enum StatusType { + Information, + Warning, + Error, + Ok + }; + // Constructors and destructors. explicit LineEditWithStatus(QWidget *parent = 0); virtual ~LineEditWithStatus(); @@ -22,11 +30,23 @@ class LineEditWithStatus : public QWidget { // pak bude proste navazani na textEdited() a tam si bude uzivatel // widgetu nastavovat pres to setStatus co chce on + // Sets custom status for this control. + void setStatus(StatusType status, const QString &tooltip_text); + + // Access to line edit. + inline BaseLineEdit *lineEdit() const { + return m_txtInput; + } + private: BaseLineEdit *m_txtInput; PlainToolButton *m_btnStatus; QHBoxLayout *m_layout; + QIcon m_iconInformation; + QIcon m_iconWarning; + QIcon m_iconError; + QIcon m_iconOk; }; #endif // LINEEDITWITHSTATUS_H diff --git a/src/gui/plaintoolbutton.cpp b/src/gui/plaintoolbutton.cpp index 53c4f6d5c..b83cf2205 100644 --- a/src/gui/plaintoolbutton.cpp +++ b/src/gui/plaintoolbutton.cpp @@ -15,7 +15,7 @@ PlainToolButton::~PlainToolButton() { void PlainToolButton::paintEvent(QPaintEvent *e) { QPainter p(this); - icon().paint(&p, QRect(QPoint(0, 0), iconSize())); + icon().paint(&p, QRect(QPoint(0, 0), size())); /* if (underMouse()) { diff --git a/src/gui/tabbar.cpp b/src/gui/tabbar.cpp index eb801e8af..843ae7a18 100644 --- a/src/gui/tabbar.cpp +++ b/src/gui/tabbar.cpp @@ -26,7 +26,6 @@ void TabBar::setTabType(int index, const TabBar::TabType &type) { close_button->setIcon(IconThemeFactory::instance()->fromTheme("application-exit")); close_button->setToolTip(tr("Close this tab.")); close_button->setText(tr("Close tab")); - close_button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); close_button->setFixedSize(iconSize()); // Close underlying tab when button is clicked.