Fix #1349 (Column width in Configuration window)

This commit is contained in:
Kovid Goyal 2008-12-05 14:53:43 -08:00
parent 809b84f539
commit e48113d5a7
4 changed files with 52 additions and 50 deletions

View File

@ -3,7 +3,8 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import os, re, time import os, re, time
from PyQt4.QtGui import QDialog, QMessageBox, QListWidgetItem, QIcon, \ from PyQt4.QtGui import QDialog, QMessageBox, QListWidgetItem, QIcon, \
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \
QStringListModel
from PyQt4.QtCore import SIGNAL, QTimer, Qt, QSize, QVariant, QUrl from PyQt4.QtCore import SIGNAL, QTimer, Qt, QSize, QVariant, QUrl
from calibre.constants import islinux, iswindows from calibre.constants import islinux, iswindows
@ -17,6 +18,22 @@ from calibre.ebooks import BOOK_EXTENSIONS
from calibre.ebooks.epub.iterator import is_supported from calibre.ebooks.epub.iterator import is_supported
from calibre.library import server_config from calibre.library import server_config
class CategoryModel(QStringListModel):
def __init__(self, *args):
QStringListModel.__init__(self, *args)
self.setStringList([_('General'), _('Interface'), _('Advanced'),
_('Content\nServer')])
self.icons = list(map(QVariant, map(QIcon,
[':/images/dialog_information.svg', ':/images/lookfeel.svg',
':/images/view.svg', ':/images/network-server.svg'])))
def data(self, index, role):
if role == Qt.DecorationRole:
return self.icons[index.row()]
return QStringListModel.data(self, index, role)
class ConfigDialog(QDialog, Ui_Dialog): class ConfigDialog(QDialog, Ui_Dialog):
def __init__(self, window, db, server=None): def __init__(self, window, db, server=None):
@ -24,10 +41,10 @@ class ConfigDialog(QDialog, Ui_Dialog):
Ui_Dialog.__init__(self) Ui_Dialog.__init__(self)
self.ICON_SIZES = {0:QSize(48, 48), 1:QSize(32,32), 2:QSize(24,24)} self.ICON_SIZES = {0:QSize(48, 48), 1:QSize(32,32), 2:QSize(24,24)}
self.setupUi(self) self.setupUi(self)
self.item1 = QListWidgetItem(QIcon(':/images/metadata.svg'), _('General'), self.category_list) self._category_model = CategoryModel()
self.item2 = QListWidgetItem(QIcon(':/images/lookfeel.svg'), _('Interface'), self.category_list)
self.item3 = QListWidgetItem(QIcon(':/images/view.svg'), _('Advanced'), self.category_list) self.connect(self.category_view, SIGNAL('activated(QModelIndex)'), lambda i: self.stackedWidget.setCurrentIndex(i.row()))
self.item4 = QListWidgetItem(QIcon(':/images/network-server.svg'), _('Content\nServer'), self.category_list) self.category_view.setModel(self._category_model)
self.db = db self.db = db
self.server = server self.server = server
path = prefs['library_path'] path = prefs['library_path']
@ -120,6 +137,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
self.priority.setCurrentIndex(p) self.priority.setCurrentIndex(p)
self.priority.setVisible(iswindows) self.priority.setVisible(iswindows)
self.priority_label.setVisible(iswindows) self.priority_label.setVisible(iswindows)
self.category_view.setCurrentIndex(self._category_model.index(0))
def up_column(self): def up_column(self):
idx = self.columns.currentRow() idx = self.columns.currentRow()

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>709</width> <width>800</width>
<height>563</height> <height>563</height>
</rect> </rect>
</property> </property>
@ -21,12 +21,12 @@
<item row="0" column="0" > <item row="0" column="0" >
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QListWidget" name="category_list" > <widget class="QListView" name="category_view" >
<property name="maximumSize" > <property name="sizePolicy" >
<size> <sizepolicy vsizetype="Expanding" hsizetype="MinimumExpanding" >
<width>140</width> <horstretch>1</horstretch>
<height>16777215</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="font" > <property name="font" >
<font> <font>
@ -34,43 +34,43 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="mouseTracking" >
<bool>true</bool>
</property>
<property name="verticalScrollBarPolicy" >
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy" >
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="tabKeyNavigation" > <property name="tabKeyNavigation" >
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="showDropIndicator" stdset="0" >
<bool>false</bool>
</property>
<property name="iconSize" > <property name="iconSize" >
<size> <size>
<width>48</width> <width>48</width>
<height>48</height> <height>48</height>
</size> </size>
</property> </property>
<property name="movement" > <property name="verticalScrollMode" >
<enum>QListView::Static</enum> <enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="horizontalScrollMode" >
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
<property name="flow" > <property name="flow" >
<enum>QListView::TopToBottom</enum> <enum>QListView::TopToBottom</enum>
</property> </property>
<property name="isWrapping" stdset="0" >
<bool>false</bool>
</property>
<property name="spacing" > <property name="spacing" >
<number>25</number> <number>20</number>
</property> </property>
<property name="viewMode" > <property name="viewMode" >
<enum>QListView::IconMode</enum> <enum>QListView::ListMode</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QStackedWidget" name="stackedWidget" > <widget class="QStackedWidget" name="stackedWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex" > <property name="currentIndex" >
<number>0</number> <number>0</number>
</property> </property>
@ -801,8 +801,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>235</x> <x>239</x>
<y>671</y> <y>558</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>157</x> <x>157</x>
@ -817,8 +817,8 @@
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>303</x> <x>307</x>
<y>671</y> <y>558</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>286</x> <x>286</x>
@ -826,21 +826,5 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>category_list</sender>
<signal>currentRowChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>142</x>
<y>117</y>
</hint>
<hint type="destinationlabel" >
<x>256</x>
<y>7</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>

View File

@ -332,7 +332,7 @@ class Main(MainWindow, Ui_MainWindow):
self.scheduler = Scheduler(self) self.scheduler = Scheduler(self)
self.action_news.setMenu(self.scheduler.news_menu) self.action_news.setMenu(self.scheduler.news_menu)
self.connect(self.action_news, SIGNAL('triggered(bool)'), self.scheduler.show_dialog) self.connect(self.action_news, SIGNAL('triggered(bool)'), self.scheduler.show_dialog)
self.location_view.setCurrentIndex(self.location_view.model().index(0))
def test_server(self, *args): def test_server(self, *args):
if self.content_server.exception is not None: if self.content_server.exception is not None:

View File

@ -1055,7 +1055,7 @@ class LibraryDatabase2(LibraryDatabase):
(mi.title, mi.authors[0])) (mi.title, mi.authors[0]))
id = obj.lastrowid id = obj.lastrowid
self.data.books_added([id], self.conn) self.data.books_added([id], self.conn)
self.set_path(id, True) self.set_path(id, index_is_id=True)
self.conn.commit() self.conn.commit()
self.set_metadata(id, mi) self.set_metadata(id, mi)