From c8df10343a2fd145cf7fd690fe177047eace9893 Mon Sep 17 00:00:00 2001 From: John Schember Date: Fri, 26 Jun 2009 21:35:42 -0400 Subject: [PATCH] Implement bug 2720: Title case menu option for QLineEdit and QComboBox where applicable. --- src/calibre/gui2/convert/metadata.ui | 87 ++--- src/calibre/gui2/dialogs/comicconf.ui | 11 +- src/calibre/gui2/dialogs/metadata_bulk.ui | 231 +++++++------- src/calibre/gui2/dialogs/metadata_single.ui | 26 +- src/calibre/gui2/dialogs/tag_editor.ui | 181 ++++++----- src/calibre/gui2/dialogs/user_profiles.ui | 332 ++++++++++---------- src/calibre/gui2/widgets.py | 44 ++- 7 files changed, 507 insertions(+), 405 deletions(-) diff --git a/src/calibre/gui2/convert/metadata.ui b/src/calibre/gui2/convert/metadata.ui index 3721483893..e4533de24c 100644 --- a/src/calibre/gui2/convert/metadata.ui +++ b/src/calibre/gui2/convert/metadata.ui @@ -20,36 +20,6 @@ Book Cover - - - - - - - - - :/images/book.svg - - - true - - - Qt::AlignCenter - - - - - - - - - Use cover from &source file - - - true - - - @@ -92,7 +62,7 @@ ... - + :/images/document_open.svg:/images/document_open.svg @@ -101,6 +71,36 @@ + + + + Use cover from &source file + + + true + + + + + + + + + + + + :/images/book.svg + + + true + + + Qt::AlignCenter + + + + + opt_prefer_metadata_cover @@ -124,7 +124,7 @@ - + Change the title of this book @@ -144,7 +144,7 @@ - + 1 @@ -170,7 +170,7 @@ - + 0 @@ -196,7 +196,7 @@ - + Change the publisher of this book @@ -216,7 +216,7 @@ - + Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. @@ -239,7 +239,7 @@ - + 10 @@ -319,10 +319,21 @@ QLabel
widgets.h
+ + EnLineEdit + QLineEdit +
widgets.h
+
+ + EnComboBox + QComboBox +
widgets.h
+
- + + diff --git a/src/calibre/gui2/dialogs/comicconf.ui b/src/calibre/gui2/dialogs/comicconf.ui index acab125d57..fd50df8e87 100644 --- a/src/calibre/gui2/dialogs/comicconf.ui +++ b/src/calibre/gui2/dialogs/comicconf.ui @@ -29,7 +29,7 @@
- + @@ -42,7 +42,7 @@ - + @@ -155,6 +155,13 @@ + + + EnLineEdit + QLineEdit +
widgets.h
+
+
diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 4597b987f5..beea2cace3 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -1,235 +1,236 @@ - + + MetadataBulkDialog - - + + 0 0 - 461 + 495 387 - + Edit Meta information - - + + :/images/edit_input.svg:/images/edit_input.svg - - - - + + + + Qt::Horizontal - - - + + + 6 - + 0 - - + + Meta information - - - - + + + + &Author(s): - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + authors - - - + + + Change the author(s) of this book. Multiple authors should be separated by an &. If the author name contains an &, use && to represent it. - - - + + + Author S&ort: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + authors - - - + + + Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles. - - - + + + &Rating: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + rating - - - + + + Rating of this book. 0-5 stars - + Rating of this book. 0-5 stars - + QAbstractSpinBox::PlusMinus - + stars - + 5 - - - + + + &Publisher: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + publisher - - - + + + Change the publisher of this book - - - + + + Add Ta&gs: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + tags - - - - Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. + + + + Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. - - - + + + Open Tag Editor - + Open Tag Editor - - + + :/images/chapters.svg:/images/chapters.svg - - - + + + &Remove tags: - + remove_tags - - - + + + Comma separated list of tags to remove from the books. - - - + + + &Series: - + Qt::PlainText - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + series - - - + + + List of known series. You can add new series. - + List of known series. You can add new series. - + true - + QComboBox::InsertAlphabetically - + QComboBox::AdjustToContents - - + + - - - + + + Remove &format: - + remove_format - - - + + + A&utomatically set author sort @@ -241,20 +242,32 @@ - - - + + + Qt::Horizontal - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + EnLineEdit + QLineEdit +
widgets.h
+
+ + EnComboBox + QComboBox +
widgets.h
+
+
- + @@ -263,11 +276,11 @@ MetadataBulkDialog accept() - + 252 382 - + 157 274 @@ -279,11 +292,11 @@ MetadataBulkDialog reject() - + 320 382 - + 286 274 @@ -295,11 +308,11 @@ author_sort setDisabled(bool) - + 240 95 - + 240 113 diff --git a/src/calibre/gui2/dialogs/metadata_single.ui b/src/calibre/gui2/dialogs/metadata_single.ui index 3f44b28d1c..bbf1bb0f7b 100644 --- a/src/calibre/gui2/dialogs/metadata_single.ui +++ b/src/calibre/gui2/dialogs/metadata_single.ui @@ -43,8 +43,8 @@ 0 0 - 879 - 710 + 869 + 696
@@ -87,7 +87,7 @@
- + Change the title of this book @@ -142,7 +142,7 @@ - + Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles. @@ -225,7 +225,7 @@ - + Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. @@ -269,7 +269,7 @@ 5
- + 0 @@ -339,14 +339,14 @@ - + true - + @@ -641,6 +641,16 @@ QLabel
widgets.h
+ + EnLineEdit + QLineEdit +
widgets.h
+
+ + EnComboBox + QComboBox +
widgets.h
+
title diff --git a/src/calibre/gui2/dialogs/tag_editor.ui b/src/calibre/gui2/dialogs/tag_editor.ui index 51014cb4be..713ffc7fdf 100644 --- a/src/calibre/gui2/dialogs/tag_editor.ui +++ b/src/calibre/gui2/dialogs/tag_editor.ui @@ -1,7 +1,8 @@ - + + TagEditor - - + + 0 0 @@ -9,33 +10,34 @@ 335 - + Tag Editor - - :/images/chapters.svg + + + :/images/chapters.svg:/images/chapters.svg - - - + + + - + - - + + A&vailable tags - + available_tags - + Qt::Horizontal - + 40 20 @@ -46,29 +48,30 @@ - + - - + + Delete tag from database. This will unapply the tag from all books and then remove it from the database. - + ... - - :/images/trash.svg + + + :/images/trash.svg:/images/trash.svg - - + + true - + QAbstractItemView::MultiSelection - + QAbstractItemView::SelectRows @@ -77,14 +80,14 @@ - - + + - + Qt::Vertical - + 20 40 @@ -93,24 +96,25 @@ - - + + Apply tag to current book - + ... - - :/images/forward.svg + + + :/images/forward.svg:/images/forward.svg - + Qt::Vertical - + 20 40 @@ -120,26 +124,26 @@ - - + + - + - - + + A&pplied tags - + applied_tags - + Qt::Horizontal - + 40 20 @@ -150,25 +154,25 @@ - - + + true - + QAbstractItemView::MultiSelection - - + + - + Qt::Vertical - + 20 40 @@ -177,24 +181,25 @@ - - + + Unapply (remove) tag from current book - + ... - - :/images/list_remove.svg + + + :/images/list_remove.svg:/images/list_remove.svg - + Qt::Vertical - + 20 40 @@ -204,14 +209,14 @@ - - + + - + Qt::Horizontal - + 40 20 @@ -220,41 +225,42 @@ - - + + &Add tag: - + add_tag_input - - + + If the tag you want is not in the available list, you can add it here. Accepts a comma separated list of tags. - - + + Add tag to available tags and apply it to current book - + ... - - :/images/plus.svg + + + :/images/plus.svg:/images/plus.svg - + Qt::Horizontal - + 40 20 @@ -264,20 +270,27 @@ - - - + + + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + EnLineEdit + QLineEdit +
widgets.h
+
+
- + @@ -286,11 +299,11 @@ TagEditor accept() - + 248 254 - + 157 274 @@ -302,11 +315,11 @@ TagEditor reject() - + 316 260 - + 286 274 diff --git a/src/calibre/gui2/dialogs/user_profiles.ui b/src/calibre/gui2/dialogs/user_profiles.ui index 10e7b9d1df..a913275c61 100644 --- a/src/calibre/gui2/dialogs/user_profiles.ui +++ b/src/calibre/gui2/dialogs/user_profiles.ui @@ -1,7 +1,8 @@ - + + Dialog - - + + 0 0 @@ -9,66 +10,66 @@ 640 - + Add custom news source - - + + :/images/user_profile.svg:/images/user_profile.svg - + - - + + QFrame::NoFrame - + 0 - + true - - + + 0 0 - 730 - 600 + 720 + 586 - - + + 0 - - + + 680 550 - - + + 0 - - - + + + 0 0 - + Available user recipes - + - - - + + + 0 0 @@ -76,56 +77,56 @@ - - + + Add/Update &recipe - - + + :/images/plus.svg:/images/plus.svg - - + + &Remove recipe - - + + :/images/list_remove.svg:/images/list_remove.svg - - + + &Share recipe - - + + :/images/forward.svg:/images/forward.svg - - + + Customize &builtin recipe - - + + :/images/news.svg:/images/news.svg - - + + &Load recipe from file - - + + :/images/chapters.svg:/images/chapters.svg @@ -134,59 +135,59 @@ - - + + QFrame::StyledPanel - + QFrame::Raised - + - - + + Switch to Advanced mode - - + + 0 - - + + - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Create a basic news recipe, by adding RSS feeds to it. <br />For most feeds, you will have to use the "Advanced mode" to further customize the fetch process.</p></body></html> +</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Create a basic news recipe, by adding RSS feeds to it. <br />For most feeds, you will have to use the "Advanced mode" to further customize the fetch process.</p></body></html> - + Qt::RichText - + true - - - - + + + + Recipe &title: - + profile_title - - - + + + 75 true @@ -194,57 +195,57 @@ p, li { white-space: pre-wrap; } - - - + + + &Oldest article: - + oldest_article - - - + + + The oldest article to download - + days - + 1 - + 365 - + 7 - - - + + + &Max. number of articles per feed: - + max_articles - - - + + + Maximum number of articles to download per feed. - + 5 - + 100 - + 10 @@ -252,64 +253,64 @@ p, li { white-space: pre-wrap; } - - - + + + 100 0 - + Feeds in recipe - + - - - + + + 100 0 - + QAbstractItemView::MultiSelection - + - - + + ... - - + + :/images/arrow-up.svg:/images/arrow-up.svg - - + + Remove feed from recipe - + ... - - + + :/images/list_remove.svg:/images/list_remove.svg - - + + ... - - + + :/images/arrow-down.svg:/images/arrow-down.svg @@ -320,47 +321,47 @@ p, li { white-space: pre-wrap; } - - + + Add feed to recipe - - - - + + + + &Feed title: - + feed_title - - + + - - - + + + Feed &URL: - + feed_url - - + + - - - + + + Add feed to recipe - + &Add feed - - + + :/images/plus.svg:/images/plus.svg @@ -370,44 +371,44 @@ p, li { white-space: pre-wrap; } - - + + - - - For help with writing advanced news recipes, please visit <a href="http://__appname__.kovidgoyal.net/user_manual/news.html">User Recipes</a> + + + For help with writing advanced news recipes, please visit <a href="http://__appname__.kovidgoyal.net/user_manual/news.html">User Recipes</a> - + true - + true - - + + Recipe source code (python) - + - - - + + + 100 0 - + DejaVu Sans Mono - + QTextEdit::NoWrap - + false @@ -430,11 +431,11 @@ p, li { white-space: pre-wrap; } - - + + Qt::Horizontal - + QDialogButtonBox::Close @@ -447,9 +448,14 @@ p, li { white-space: pre-wrap; } QListWidget
widgets.h
+ + EnLineEdit + QLineEdit +
widgets.h
+
- + @@ -458,11 +464,11 @@ p, li { white-space: pre-wrap; } Dialog accept() - + 446 649 - + 0 632 @@ -474,11 +480,11 @@ p, li { white-space: pre-wrap; } Dialog reject() - + 175 643 - + 176 636 diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index f692ae24d7..3f7734f8c9 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -10,7 +10,7 @@ from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \ QPixmap, QMovie, QPalette, QTimer, QDialog, \ QAbstractListModel, QVariant, Qt, SIGNAL, \ QRegExp, QSettings, QSize, QModelIndex, \ - QAbstractButton, QPainter + QAbstractButton, QPainter, QLineEdit, QComboBox from calibre.gui2 import human_readable, NONE, TableView, \ qstring_to_unicode, error_dialog @@ -451,6 +451,48 @@ class BasicList(QListWidget): yield self.item(i) +class LineEditECM(object): + + ''' + Extend the contenxt menu of a QLineEdit to include more actions. + ''' + + def contextMenuEvent(self, event): + menu = self.createStandardContextMenu() + menu.addSeparator() + action_title_case = menu.addAction('Title Case') + + self.connect(action_title_case, SIGNAL('triggered()'), self.title_case) + + menu.exec_(event.globalPos()) + + def title_case(self): + self.setText(qstring_to_unicode(self.text()).title()) + + +class EnLineEdit(LineEditECM, QLineEdit): + + ''' + Enhanced QLineEdit. + + Includes an extended content menu. + ''' + + pass + + +class EnComboBox(QComboBox): + + ''' + Enhanced QComboBox. + + Includes an extended content menu. + ''' + + def __init__(self, *args): + QComboBox.__init__(self, *args) + self.setLineEdit(EnLineEdit(self)) + class PythonHighlighter(QSyntaxHighlighter):