def __init__(self, key, parent=None): super(LatestCollectionAction, self).__init__(parent) settings = QtCore.QSettings() self.fileName = settings.value(key) self.setText(Collection.fileNameToCollectionName(self.fileName)) self.triggered.connect(self.trigger)
def actions(self): actions = [] for i in range(LatestCollections.LatestCount): key = self.__key(i) fileName = self.settings.value(key) if fileName: title = Collection.fileNameToCollectionName(fileName) act = QAction(title, self) act.setData(fileName) actions.append(act) return actions
sys.path.append('..') from OpenNumismat.Collection.Collection import Collection from OpenNumismat.Collection.CollectionFields import CollectionFieldsBase app = QApplication(sys.argv) HOME_PATH = '' __docDirs = QStandardPaths.standardLocations(QStandardPaths.DocumentsLocation) if __docDirs: HOME_PATH = os.path.join(__docDirs[0], "OpenNumismat") file_name, _selectedFilter = QFileDialog.getOpenFileName( None, "Open collection", HOME_PATH, "Collections (*.db)") if file_name: collection = Collection(None) collection.open(file_name) json_file_name = file_name.replace('.db', '.json') json_file = codecs.open(json_file_name, "w", "utf-8") image_path = file_name.replace('.db', '_images') os.makedirs(image_path, exist_ok=True) desc = collection.getDescription() data = { 'title': desc.title, 'description': desc.description, 'author': desc.author, 'type': "OpenNumismat" }
def __init__(self): QMainWindow.__init__(self) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowIcon(createIcon('main.ico')) self.createStatusBar() menubar = self.menuBar() self.collectionActs = [] if statisticsAvailable: self.statisticsAct = QAction(self) self.updateStatisticsAct(False) self.statisticsAct.triggered.connect(self.statisticsEvent) self.collectionActs.append(self.statisticsAct) summaryAct = QAction(self.tr("Summary"), self) summaryAct.triggered.connect(self.summaryEvent) self.collectionActs.append(summaryAct) settingsAct = QAction(createIcon('cog.png'), self.tr("Settings..."), self) settingsAct.triggered.connect(self.settingsEvent) self.collectionActs.append(settingsAct) cancelFilteringAct = QAction(createIcon('funnel.png'), self.tr("Clear all filters"), self) cancelFilteringAct.triggered.connect(self.cancelFilteringEvent) self.collectionActs.append(cancelFilteringAct) self.exitAct = QAction(createIcon('door_in.png'), self.tr("E&xit"), self) self.exitAct.setShortcut(QKeySequence.Quit) self.exitAct.triggered.connect(self.close) newCollectionAct = QAction(self.tr("&New..."), self) newCollectionAct.triggered.connect(self.newCollectionEvent) style = QApplication.style() icon = style.standardIcon(QStyle.SP_DialogOpenButton) openCollectionAct = QAction(icon, self.tr("&Open..."), self) openCollectionAct.setShortcut(QKeySequence.Open) openCollectionAct.triggered.connect(self.openCollectionEvent) backupCollectionAct = QAction(createIcon('database_backup.png'), self.tr("Backup"), self) backupCollectionAct.triggered.connect(self.backupCollectionEvent) self.collectionActs.append(backupCollectionAct) vacuumCollectionAct = QAction(createIcon('compress.png'), self.tr("Vacuum"), self) vacuumCollectionAct.triggered.connect(self.vacuumCollectionEvent) self.collectionActs.append(vacuumCollectionAct) descriptionCollectionAct = QAction(self.tr("Description"), self) descriptionCollectionAct.triggered.connect( self.descriptionCollectionEvent) self.collectionActs.append(descriptionCollectionAct) passwordCollectionAct = QAction(createIcon('key.png'), self.tr("Set password..."), self) passwordCollectionAct.triggered.connect(self.passwordCollectionEvent) self.collectionActs.append(passwordCollectionAct) importMenu = QMenu(self.tr("Import"), self) self.collectionActs.append(importMenu) if ImportExcel.isAvailable(): importExcelAct = QAction(createIcon('excel.png'), self.tr("Excel"), self) importExcelAct.triggered.connect(self.importExcel) self.collectionActs.append(importExcelAct) importMenu.addAction(importExcelAct) if ImportNumizmat.isAvailable(): importNumizmatAct = QAction(createIcon('numizmat.png'), self.tr("Numizmat 2.1"), self) importNumizmatAct.triggered.connect(self.importNumizmat) self.collectionActs.append(importNumizmatAct) importMenu.addAction(importNumizmatAct) if ImportCabinet.isAvailable(): importCabinetAct = QAction(createIcon('cabinet.png'), self.tr("Cabinet 2.2.2.1, 2013"), self) importCabinetAct.triggered.connect(self.importCabinet) self.collectionActs.append(importCabinetAct) importMenu.addAction(importCabinetAct) if ImportCoinsCollector.isAvailable(): importCoinsCollectorAct = QAction(createIcon('CoinsCollector.png'), self.tr("CoinsCollector 2.6"), self) importCoinsCollectorAct.triggered.connect( self.importCoinsCollector) self.collectionActs.append(importCoinsCollectorAct) importMenu.addAction(importCoinsCollectorAct) if ImportCoinManage.isAvailable(): importCoinManageAct = QAction(createIcon('CoinManage.png'), self.tr("CoinManage 2011"), self) importCoinManageAct.triggered.connect(self.importCoinManage) self.collectionActs.append(importCoinManageAct) importMenu.addAction(importCoinManageAct) if ImportCollectionStudio.isAvailable(): importCollectionStudioAct = QAction( createIcon('CollectionStudio.png'), self.tr("Collection Studio 3.65"), self) importCollectionStudioAct.triggered.connect( self.importCollectionStudio) self.collectionActs.append(importCollectionStudioAct) importMenu.addAction(importCollectionStudioAct) if ImportNumizmatik_Ru.isAvailable(): importNumizmaticRuAct = QAction(createIcon('Numizmatik_Ru.png'), self.tr("Numizmatik_Ru 1.0.0.82"), self) importNumizmaticRuAct.triggered.connect(self.importNumizmatik_Ru) self.collectionActs.append(importNumizmaticRuAct) importMenu.addAction(importNumizmaticRuAct) if ImportUcoin2.isAvailable(): importUcoinAct = QAction(createIcon('ucoin.png'), self.tr("uCoin.net"), self) importUcoinAct.triggered.connect(self.importUcoin2) self.collectionActs.append(importUcoinAct) importMenu.addAction(importUcoinAct) elif ImportUcoin.isAvailable(): importUcoinAct = QAction(createIcon('ucoin.png'), self.tr("uCoin.net"), self) importUcoinAct.triggered.connect(self.importUcoin) self.collectionActs.append(importUcoinAct) importMenu.addAction(importUcoinAct) if ImportTellico.isAvailable(): importTellicoAct = QAction(createIcon('tellico.png'), self.tr("Tellico"), self) importTellicoAct.triggered.connect(self.importTellico) self.collectionActs.append(importTellicoAct) importMenu.addAction(importTellicoAct) mergeCollectionAct = QAction(createIcon('refresh.png'), self.tr("Synchronize..."), self) mergeCollectionAct.triggered.connect(self.mergeCollectionEvent) self.collectionActs.append(mergeCollectionAct) exportMenu = QMenu(self.tr("Export"), self) self.collectionActs.append(exportMenu) exportMobileAct = QAction(self.tr("For Android version"), self) exportMobileAct.triggered.connect(self.exportMobile) self.collectionActs.append(exportMobileAct) exportMenu.addAction(exportMobileAct) file = menubar.addMenu(self.tr("&File")) file.addAction(newCollectionAct) file.addAction(openCollectionAct) file.addSeparator() file.addAction(backupCollectionAct) file.addAction(vacuumCollectionAct) file.addAction(passwordCollectionAct) file.addAction(descriptionCollectionAct) file.addSeparator() file.addMenu(importMenu) file.addAction(mergeCollectionAct) file.addSeparator() file.addMenu(exportMenu) file.addSeparator() self.latestActions = [] self.__updateLatest(file) file.addAction(settingsAct) file.addSeparator() file.addAction(self.exitAct) addCoinAct = QAction(createIcon('add.png'), self.tr("Add"), self) addCoinAct.setShortcut('Insert') addCoinAct.triggered.connect(self.addCoin) self.collectionActs.append(addCoinAct) editCoinAct = QAction(createIcon('pencil.png'), self.tr("Edit..."), self) editCoinAct.triggered.connect(self.editCoin) self.collectionActs.append(editCoinAct) style = QApplication.style() icon = style.standardIcon(QStyle.SP_TrashIcon) deleteCoinAct = QAction(icon, self.tr("Delete"), self) deleteCoinAct.setShortcut(QKeySequence.Delete) deleteCoinAct.triggered.connect(self.deleteCoin) self.collectionActs.append(deleteCoinAct) copyCoinAct = QAction(createIcon('page_copy.png'), self.tr("Copy"), self) copyCoinAct.setShortcut(QKeySequence.Copy) copyCoinAct.triggered.connect(self.copyCoin) self.collectionActs.append(copyCoinAct) pasteCoinAct = QAction(createIcon('page_paste.png'), self.tr("Paste"), self) pasteCoinAct.setShortcut(QKeySequence.Paste) pasteCoinAct.triggered.connect(self.pasteCoin) self.collectionActs.append(pasteCoinAct) coin = menubar.addMenu(self.tr("Coin")) self.collectionActs.append(coin) coin.addAction(addCoinAct) coin.addAction(editCoinAct) coin.addSeparator() coin.addAction(copyCoinAct) coin.addAction(pasteCoinAct) coin.addSeparator() coin.addAction(deleteCoinAct) viewBrowserAct = QAction(createIcon('page_white_world.png'), self.tr("View in browser"), self) viewBrowserAct.triggered.connect(self.viewBrowser) self.collectionActs.append(viewBrowserAct) self.viewTab = TabView(self) actions = self.viewTab.actions() listMenu = menubar.addMenu(self.tr("List")) self.collectionActs.append(listMenu) listMenu.addAction(actions['new']) listMenu.addMenu(actions['open']) listMenu.aboutToShow.connect(self.viewTab.updateOpenPageMenu) listMenu.addAction(actions['rename']) listMenu.addSeparator() listMenu.addAction(actions['select']) listMenu.addSeparator() listMenu.addAction(actions['close']) listMenu.addAction(actions['remove']) self.referenceMenu = menubar.addMenu(self.tr("Reference")) self.collectionActs.append(self.referenceMenu) reportAct = QAction(self.tr("Report..."), self) reportAct.setShortcut(Qt.CTRL + Qt.Key_P) reportAct.triggered.connect(self.report) self.collectionActs.append(reportAct) saveTableAct = QAction(createIcon('table.png'), self.tr("Save current list..."), self) saveTableAct.triggered.connect(self.saveTable) self.collectionActs.append(saveTableAct) report = menubar.addMenu(self.tr("Report")) self.collectionActs.append(report) report.addAction(reportAct) report.addAction(saveTableAct) report.addAction(viewBrowserAct) if statisticsAvailable: report.addSeparator() report.addAction(self.statisticsAct) report.addAction(summaryAct) helpAct = QAction(createIcon('help.png'), self.tr("User manual"), self) helpAct.setShortcut(QKeySequence.HelpContents) helpAct.triggered.connect(self.onlineHelp) webAct = QAction(self.tr("Visit web-site"), self) webAct.triggered.connect(self.visitWeb) checkUpdatesAct = QAction(self.tr("Check for updates"), self) checkUpdatesAct.triggered.connect(self.manualUpdate) aboutAct = QAction(self.tr("About %s") % version.AppName, self) aboutAct.triggered.connect(self.about) help_ = menubar.addMenu(self.tr("&Help")) help_.addAction(helpAct) help_.addAction(webAct) help_.addSeparator() help_.addAction(checkUpdatesAct) help_.addSeparator() help_.addAction(aboutAct) toolBar = QToolBar(self.tr("Toolbar"), self) toolBar.setObjectName("Toolbar") toolBar.setMovable(False) toolBar.addAction(openCollectionAct) toolBar.addSeparator() toolBar.addAction(addCoinAct) toolBar.addAction(editCoinAct) toolBar.addAction(viewBrowserAct) toolBar.addSeparator() toolBar.addAction(cancelFilteringAct) toolBar.addSeparator() toolBar.addAction(settingsAct) if statisticsAvailable: toolBar.addSeparator() toolBar.addAction(self.statisticsAct) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) toolBar.addWidget(spacer) self.quickSearch = QLineEdit() self.quickSearch.setMaximumWidth(250) self.quickSearch.setClearButtonEnabled(True) self.quickSearch.setPlaceholderText(self.tr("Quick search")) self.quickSearch.textEdited.connect(self.quickSearchEdited) self.collectionActs.append(self.quickSearch) self.quickSearchTimer = QTimer(self) self.quickSearchTimer.setSingleShot(True) self.quickSearchTimer.timeout.connect(self.quickSearchClicked) toolBar.addWidget(self.quickSearch) self.addToolBar(toolBar) self.setWindowTitle(version.AppName) if len(sys.argv) > 1: fileName = sys.argv[1] else: latest = LatestCollections(self) fileName = latest.latest() self.collection = Collection(self) self.openCollection(fileName) self.setCentralWidget(self.viewTab) settings = QSettings() pageIndex = settings.value('tabwindow/page', 0) if pageIndex is not None: self.viewTab.setCurrentIndex(int(pageIndex)) geometry = settings.value('mainwindow/geometry') if geometry: self.restoreGeometry(geometry) winState = settings.value('mainwindow/winState') if winState: self.restoreState(winState) self.autoUpdate()
def __init__(self): QMainWindow.__init__(self) self.setWindowIcon(createIcon('main.ico')) self.createStatusBar() menubar = self.menuBar() self.collectionActs = [] settingsAct = QAction(createIcon('cog.png'), self.tr("Settings..."), self) settingsAct.triggered.connect(self.settingsEvent) cancelFilteringAct = QAction(createIcon('funnel.png'), self.tr("Clear all filters"), self) cancelFilteringAct.triggered.connect(self.cancelFilteringEvent) self.collectionActs.append(cancelFilteringAct) self.exitAct = QAction(createIcon('door_in.png'), self.tr("E&xit"), self) self.exitAct.setShortcut(QKeySequence.Quit) self.exitAct.triggered.connect(self.close) newCollectionAct = QAction(self.tr("&New..."), self) newCollectionAct.triggered.connect(self.newCollectionEvent) style = QApplication.style() icon = style.standardIcon(QStyle.SP_DialogOpenButton) openCollectionAct = QAction(icon, self.tr("&Open..."), self) openCollectionAct.setShortcut(QKeySequence.Open) openCollectionAct.triggered.connect(self.openCollectionEvent) backupCollectionAct = QAction(createIcon('database_backup.png'), self.tr("Backup"), self) backupCollectionAct.triggered.connect(self.backupCollectionEvent) self.collectionActs.append(backupCollectionAct) vacuumCollectionAct = QAction(createIcon('compress.png'), self.tr("Vacuum"), self) vacuumCollectionAct.triggered.connect(self.vacuumCollectionEvent) self.collectionActs.append(vacuumCollectionAct) descriptionCollectionAct = QAction(self.tr("Description"), self) descriptionCollectionAct.triggered.connect( self.descriptionCollectionEvent) self.collectionActs.append(descriptionCollectionAct) passwordCollectionAct = QAction(createIcon('key.png'), self.tr("Set password..."), self) passwordCollectionAct.triggered.connect(self.passwordCollectionEvent) self.collectionActs.append(passwordCollectionAct) importMenu = QMenu(self.tr("Import"), self) self.collectionActs.append(importMenu) if ImportNumizmat.isAvailable(): importNumizmatAct = QAction(createIcon('numizmat.ico'), self.tr("Numizmat 2.1"), self) importNumizmatAct.triggered.connect(self.importNumizmat) self.collectionActs.append(importNumizmatAct) importMenu.addAction(importNumizmatAct) if ImportCabinet.isAvailable(): importCabinetAct = QAction(createIcon('cabinet.ico'), self.tr("Cabinet 2.2.2.1, 2013"), self) importCabinetAct.triggered.connect(self.importCabinet) self.collectionActs.append(importCabinetAct) importMenu.addAction(importCabinetAct) if ImportCoinsCollector.isAvailable(): importCoinsCollectorAct = QAction(createIcon('CoinsCollector.ico'), self.tr("CoinsCollector 2.6"), self) importCoinsCollectorAct.triggered.connect( self.importCoinsCollector) self.collectionActs.append(importCoinsCollectorAct) importMenu.addAction(importCoinsCollectorAct) if ImportCoinManage.isAvailable(): importCoinManageAct = QAction(createIcon('CoinManage.ico'), self.tr("CoinManage 2011"), self) importCoinManageAct.triggered.connect(self.importCoinManage) self.collectionActs.append(importCoinManageAct) importMenu.addAction(importCoinManageAct) if ImportCollectionStudio.isAvailable(): importCollectionStudioAct = QAction( createIcon('CollectionStudio.ico'), self.tr("Collection Studio 3.65"), self) importCollectionStudioAct.triggered.connect( self.importCollectionStudio) self.collectionActs.append(importCollectionStudioAct) importMenu.addAction(importCollectionStudioAct) if ImportNumizmatik_Ru.isAvailable(): importNumizmaticRuAct = QAction(createIcon('Numizmatik_Ru.ico'), self.tr("Numizmatik_Ru 1.0.0.82"), self) importNumizmaticRuAct.triggered.connect(self.importNumizmatik_Ru) self.collectionActs.append(importNumizmaticRuAct) importMenu.addAction(importNumizmaticRuAct) if ImportUcoin.isAvailable(): importUcoinAct = QAction(createIcon('ucoin.png'), self.tr("uCoin.net"), self) importUcoinAct.triggered.connect(self.importUcoin) self.collectionActs.append(importUcoinAct) importMenu.addAction(importUcoinAct) mergeCollectionAct = QAction(self.tr("Add from another..."), self) mergeCollectionAct.triggered.connect(self.mergeCollectionEvent) self.collectionActs.append(mergeCollectionAct) exportMenu = QMenu(self.tr("Export"), self) self.collectionActs.append(exportMenu) exportMobileAct = QAction(self.tr("For Android version"), self) exportMobileAct.triggered.connect(self.exportMobile) self.collectionActs.append(exportMobileAct) exportMenu.addAction(exportMobileAct) file = menubar.addMenu(self.tr("&File")) file.addAction(newCollectionAct) file.addAction(openCollectionAct) file.addSeparator() file.addAction(backupCollectionAct) file.addAction(vacuumCollectionAct) file.addAction(passwordCollectionAct) file.addAction(descriptionCollectionAct) file.addSeparator() file.addMenu(importMenu) file.addAction(mergeCollectionAct) file.addSeparator() file.addMenu(exportMenu) file.addSeparator() self.latestActions = [] self.__updateLatest(file) file.addAction(settingsAct) file.addSeparator() file.addAction(self.exitAct) addCoinAct = QAction(createIcon('add.png'), self.tr("Add"), self) addCoinAct.setShortcut('Insert') addCoinAct.triggered.connect(self.addCoin) self.collectionActs.append(addCoinAct) editCoinAct = QAction(createIcon('pencil.png'), self.tr("Edit..."), self) editCoinAct.triggered.connect(self.editCoin) self.collectionActs.append(editCoinAct) style = QApplication.style() icon = style.standardIcon(QStyle.SP_TrashIcon) deleteCoinAct = QAction(icon, self.tr("Delete"), self) deleteCoinAct.setShortcut(QKeySequence.Delete) deleteCoinAct.triggered.connect(self.deleteCoin) self.collectionActs.append(deleteCoinAct) copyCoinAct = QAction(createIcon('page_copy.png'), self.tr("Copy"), self) copyCoinAct.setShortcut(QKeySequence.Copy) copyCoinAct.triggered.connect(self.copyCoin) self.collectionActs.append(copyCoinAct) pasteCoinAct = QAction(createIcon('page_paste.png'), self.tr("Paste"), self) pasteCoinAct.setShortcut(QKeySequence.Paste) pasteCoinAct.triggered.connect(self.pasteCoin) self.collectionActs.append(pasteCoinAct) coin = menubar.addMenu(self.tr("Coin")) self.collectionActs.append(coin) coin.addAction(addCoinAct) coin.addAction(editCoinAct) coin.addSeparator() coin.addAction(copyCoinAct) coin.addAction(pasteCoinAct) coin.addSeparator() coin.addAction(deleteCoinAct) viewBrowserAct = QAction(createIcon('page_white_world.png'), self.tr("View in browser"), self) viewBrowserAct.triggered.connect(self.viewBrowser) self.collectionActs.append(viewBrowserAct) self.viewTab = TabView(self) actions = self.viewTab.actions() listMenu = menubar.addMenu(self.tr("List")) self.collectionActs.append(listMenu) listMenu.addAction(actions['new']) listMenu.addMenu(actions['open']) listMenu.aboutToShow.connect(self.viewTab.updateOpenPageMenu) listMenu.addAction(actions['rename']) listMenu.addSeparator() listMenu.addAction(actions['select']) listMenu.addSeparator() listMenu.addAction(actions['close']) listMenu.addAction(actions['remove']) self.referenceMenu = menubar.addMenu(self.tr("Reference")) reportAct = QAction(self.tr("Report..."), self) reportAct.setShortcut(Qt.CTRL + Qt.Key_P) reportAct.triggered.connect(self.report) self.collectionActs.append(reportAct) saveTableAct = QAction(createIcon('table.png'), self.tr("Save current list..."), self) saveTableAct.triggered.connect(self.saveTable) self.collectionActs.append(saveTableAct) report = menubar.addMenu(self.tr("Report")) self.collectionActs.append(report) report.addAction(reportAct) report.addAction(saveTableAct) report.addAction(viewBrowserAct) helpAct = QAction(createIcon('help.png'), self.tr("Online help"), self) helpAct.setShortcut(QKeySequence.HelpContents) helpAct.triggered.connect(self.onlineHelp) checkUpdatesAct = QAction(self.tr("Check for updates"), self) checkUpdatesAct.triggered.connect(self.manualUpdate) aboutAct = QAction(self.tr("About %s") % version.AppName, self) aboutAct.triggered.connect(self.about) help_ = menubar.addMenu(self.tr("&Help")) help_.addAction(helpAct) help_.addSeparator() help_.addAction(checkUpdatesAct) help_.addSeparator() help_.addAction(aboutAct) toolBar = QToolBar(self.tr("Toolbar"), self) toolBar.setMovable(False) toolBar.addAction(openCollectionAct) toolBar.addSeparator() toolBar.addAction(addCoinAct) toolBar.addAction(editCoinAct) toolBar.addAction(viewBrowserAct) toolBar.addSeparator() toolBar.addAction(cancelFilteringAct) toolBar.addSeparator() toolBar.addAction(settingsAct) self.addToolBar(toolBar) self.setWindowTitle(version.AppName) self.reference = Reference(self) self.reference.open(Settings()['reference']) if len(sys.argv) > 1: fileName = sys.argv[1] else: latest = LatestCollections(self) fileName = latest.latest() self.collection = Collection(self.reference, self) self.openCollection(fileName) self.setCentralWidget(self.viewTab) settings = QSettings() pageIndex = settings.value('tabwindow/page') if pageIndex != None: self.viewTab.setCurrentIndex(int(pageIndex)) if settings.value('mainwindow/maximized') == 'true': self.showMaximized() size = settings.value('mainwindow/maximizedsize') else: size = settings.value('mainwindow/size') if size: self.resize(size) self.autoUpdate()
def __init__(self): QMainWindow.__init__(self) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowIcon(QIcon(':/main.ico')) self.createStatusBar() menubar = self.menuBar() self.collectionActs = [] self.tableViewAct = QAction(QIcon(':/application_view_list.png'), self.tr("Table view"), self) self.tableViewAct.setData(CollectionPageTypes.List) self.tableViewAct.triggered.connect(self.changeViewEvent) self.collectionActs.append(self.tableViewAct) self.iconViewAct = QAction(QIcon(':/application_view_icons.png'), self.tr("Icon view"), self) self.iconViewAct.setData(CollectionPageTypes.Icon) self.iconViewAct.triggered.connect(self.changeViewEvent) self.collectionActs.append(self.iconViewAct) self.cardViewAct = QAction(QIcon(':/application_view_tile.png'), self.tr("Card view"), self) self.cardViewAct.setData(CollectionPageTypes.Card) self.cardViewAct.triggered.connect(self.changeViewEvent) self.collectionActs.append(self.cardViewAct) viewMenu = QMenu(self.tr("Change view"), self) viewMenu.addAction(self.tableViewAct) viewMenu.addAction(self.iconViewAct) viewMenu.addAction(self.cardViewAct) self.viewButton = QToolButton() self.viewButton.setPopupMode(QToolButton.InstantPopup) self.viewButton.setMenu(viewMenu) self.viewButton.setDefaultAction(self.tableViewAct) colnectAct = QAction(QIcon(':/colnect.png'), "Colnect...", self) colnectAct.triggered.connect(self.colnectEvent) self.collectionActs.append(colnectAct) self.detailsAct = QAction(QIcon(':/application-form.png'), self.tr("Info panel"), self) self.detailsAct.setCheckable(True) self.detailsAct.triggered.connect(self.detailsEvent) self.collectionActs.append(self.detailsAct) if statisticsAvailable: self.statisticsAct = QAction(QIcon(':/chart-bar.png'), self.tr("Statistics"), self) self.statisticsAct.setCheckable(True) self.statisticsAct.triggered.connect(self.statisticsEvent) self.collectionActs.append(self.statisticsAct) if importedQtWebKit: self.mapAct = QAction(QIcon(':/world.png'), self.tr("Map"), self) self.mapAct.setCheckable(True) self.mapAct.triggered.connect(self.mapEvent) self.collectionActs.append(self.mapAct) summaryAct = QAction(self.tr("Summary"), self) summaryAct.triggered.connect(self.summaryEvent) self.collectionActs.append(summaryAct) settingsAct = QAction(QIcon(':/cog.png'), self.tr("Settings..."), self) settingsAct.triggered.connect(self.settingsEvent) self.collectionActs.append(settingsAct) cancelFilteringAct = QAction(QIcon(':/funnel_clear.png'), self.tr("Clear all filters"), self) cancelFilteringAct.triggered.connect(self.cancelFilteringEvent) self.collectionActs.append(cancelFilteringAct) cancelSortingAct = QAction(QIcon(':/sort_clear.png'), self.tr("Clear sort order"), self) cancelSortingAct.triggered.connect(self.cancelSortingEvent) self.collectionActs.append(cancelSortingAct) self.enableDragAct = QAction(QIcon(':/arrow_switch.png'), self.tr("Sort by drag-n-drop mode"), self) self.enableDragAct.setCheckable(True) self.enableDragAct.triggered.connect(self.enableDragEvent) self.collectionActs.append(self.enableDragAct) self.exitAct = QAction(QIcon(':/door_in.png'), self.tr("E&xit"), self) self.exitAct.setShortcut(QKeySequence.Quit) self.exitAct.triggered.connect(self.close) newCollectionAct = QAction(self.tr("&New..."), self) newCollectionAct.triggered.connect(self.newCollectionEvent) style = QApplication.style() icon = style.standardIcon(QStyle.SP_DialogOpenButton) openCollectionAct = QAction(icon, self.tr("&Open..."), self) openCollectionAct.setShortcut(QKeySequence.Open) openCollectionAct.triggered.connect(self.openCollectionEvent) backupCollectionAct = QAction( QIcon(':/database_backup.png'), self.tr("Backup"), self) backupCollectionAct.triggered.connect(self.backupCollectionEvent) self.collectionActs.append(backupCollectionAct) vacuumCollectionAct = QAction( QIcon(':/compress.png'), self.tr("Vacuum"), self) vacuumCollectionAct.triggered.connect(self.vacuumCollectionEvent) self.collectionActs.append(vacuumCollectionAct) descriptionCollectionAct = QAction(self.tr("Description"), self) descriptionCollectionAct.triggered.connect( self.descriptionCollectionEvent) self.collectionActs.append(descriptionCollectionAct) passwordCollectionAct = QAction(QIcon(':/key.png'), self.tr("Set password..."), self) passwordCollectionAct.triggered.connect(self.passwordCollectionEvent) self.collectionActs.append(passwordCollectionAct) importMenu = QMenu(self.tr("Import"), self) self.collectionActs.append(importMenu) if ImportExcel.isAvailable(): importExcelAct = QAction( QIcon(':/excel.png'), "Excel", self) importExcelAct.triggered.connect(self.importExcel) self.collectionActs.append(importExcelAct) importMenu.addAction(importExcelAct) if ImportColnect.isAvailable(): importColnectAct = QAction( QIcon(':/colnect.png'), "Colnect", self) importColnectAct.triggered.connect(self.importColnect) self.collectionActs.append(importColnectAct) importMenu.addAction(importColnectAct) if ImportNumista.isAvailable(): importNumistaAct = QAction( QIcon(':/numista.png'), "Numista", self) importNumistaAct.triggered.connect(self.importNumista) self.collectionActs.append(importNumistaAct) importMenu.addAction(importNumistaAct) if ImportCabinet.isAvailable(): importCabinetAct = QAction( QIcon(':/cabinet.png'), "Cabinet 2.2.2.1, 2013", self) importCabinetAct.triggered.connect(self.importCabinet) self.collectionActs.append(importCabinetAct) importMenu.addAction(importCabinetAct) if ImportCoinManage.isAvailable(): importCoinManageAct = QAction( QIcon(':/CoinManage.png'), "CoinManage 2011", self) importCoinManageAct.triggered.connect(self.importCoinManage) self.collectionActs.append(importCoinManageAct) importMenu.addAction(importCoinManageAct) if ImportCollectionStudio.isAvailable(): importCollectionStudioAct = QAction( QIcon(':/CollectionStudio.png'), "Collection Studio 3.65", self) importCollectionStudioAct.triggered.connect( self.importCollectionStudio) self.collectionActs.append(importCollectionStudioAct) importMenu.addAction(importCollectionStudioAct) if ImportUcoin2.isAvailable(): importUcoinAct = QAction( QIcon(':/ucoin.png'), "uCoin.net", self) importUcoinAct.triggered.connect(self.importUcoin2) self.collectionActs.append(importUcoinAct) importMenu.addAction(importUcoinAct) elif ImportUcoin.isAvailable(): importUcoinAct = QAction( QIcon(':/ucoin.png'), "uCoin.net", self) importUcoinAct.triggered.connect(self.importUcoin) self.collectionActs.append(importUcoinAct) importMenu.addAction(importUcoinAct) if ImportTellico.isAvailable(): importTellicoAct = QAction( QIcon(':/tellico.png'), "Tellico", self) importTellicoAct.triggered.connect(self.importTellico) self.collectionActs.append(importTellicoAct) importMenu.addAction(importTellicoAct) mergeCollectionAct = QAction( QIcon(':/refresh.png'), self.tr("Synchronize..."), self) mergeCollectionAct.triggered.connect(self.mergeCollectionEvent) self.collectionActs.append(mergeCollectionAct) exportMenu = QMenu(self.tr("Export"), self) self.collectionActs.append(exportMenu) exportMobileAct = QAction(self.tr("For Android version"), self) exportMobileAct.triggered.connect(self.exportMobile) self.collectionActs.append(exportMobileAct) exportMenu.addAction(exportMobileAct) file = menubar.addMenu(self.tr("&File")) file.addAction(newCollectionAct) file.addAction(openCollectionAct) file.addSeparator() file.addAction(backupCollectionAct) file.addAction(vacuumCollectionAct) file.addAction(passwordCollectionAct) file.addAction(descriptionCollectionAct) file.addSeparator() file.addMenu(importMenu) file.addAction(mergeCollectionAct) file.addSeparator() file.addMenu(exportMenu) file.addSeparator() self.latestActions = [] self.__updateLatest(file) file.addAction(settingsAct) file.addSeparator() file.addAction(self.exitAct) addCoinAct = QAction(QIcon(':/add.png'), self.tr("Add"), self) addCoinAct.setShortcut('Insert') addCoinAct.triggered.connect(self.addCoin) self.collectionActs.append(addCoinAct) editCoinAct = QAction(QIcon(':/pencil.png'), self.tr("Edit..."), self) editCoinAct.triggered.connect(self.editCoin) self.collectionActs.append(editCoinAct) style = QApplication.style() icon = style.standardIcon(QStyle.SP_TrashIcon) deleteCoinAct = QAction(icon, self.tr("Delete"), self) deleteCoinAct.setShortcut(QKeySequence.Delete) deleteCoinAct.triggered.connect(self.deleteCoin) self.collectionActs.append(deleteCoinAct) copyCoinAct = QAction(QIcon(':/page_copy.png'), self.tr("Copy"), self) copyCoinAct.setShortcut(QKeySequence.Copy) copyCoinAct.triggered.connect(self.copyCoin) self.collectionActs.append(copyCoinAct) pasteCoinAct = QAction(QIcon(':/page_paste.png'), self.tr("Paste"), self) pasteCoinAct.setShortcut(QKeySequence.Paste) pasteCoinAct.triggered.connect(self.pasteCoin) self.collectionActs.append(pasteCoinAct) coin = menubar.addMenu(self.tr("Coin")) self.collectionActs.append(coin) coin.addAction(addCoinAct) coin.addAction(editCoinAct) coin.addSeparator() if Settings()['colnect_enabled'] and colnectAvailable: coin.addAction(colnectAct) coin.addSeparator() coin.addAction(copyCoinAct) coin.addAction(pasteCoinAct) coin.addSeparator() coin.addAction(deleteCoinAct) viewBrowserAct = QAction(QIcon(':/page_white_world.png'), self.tr("View in browser"), self) viewBrowserAct.triggered.connect(self.viewBrowserEvent) self.collectionActs.append(viewBrowserAct) self.viewTab = TabView(self) actions = self.viewTab.actions() listMenu = menubar.addMenu(self.tr("List")) listMenu.addAction(actions['new']) listMenu.addMenu(actions['open']) listMenu.aboutToShow.connect(self.viewTab.updateOpenPageMenu) listMenu.addAction(actions['rename']) listMenu.addSeparator() listMenu.addAction(actions['select']) listMenu.addMenu(viewMenu) listMenu.addSeparator() listMenu.addAction(actions['close']) listMenu.addAction(actions['remove']) self.collectionActs.append(listMenu) self.referenceMenu = menubar.addMenu(self.tr("Reference")) self.collectionActs.append(self.referenceMenu) reportAct = QAction(self.tr("Report..."), self) reportAct.setShortcut(Qt.CTRL + Qt.Key_P) reportAct.triggered.connect(self.report) self.collectionActs.append(reportAct) saveTableAct = QAction(QIcon(':/table.png'), self.tr("Save current list..."), self) saveTableAct.triggered.connect(self.saveTable) self.collectionActs.append(saveTableAct) report = menubar.addMenu(self.tr("Report")) self.collectionActs.append(report) report.addAction(reportAct) report.addAction(saveTableAct) default_template = Settings()['template'] viewBrowserMenu = report.addMenu(QIcon(':/page_white_world.png'), self.tr("View in browser")) for template in Report.scanTemplates(): act = QAction(template[0], self) act.setData(template[1]) act.triggered.connect(self.viewBrowserEvent) viewBrowserMenu.addAction(act) if default_template == template[1]: viewBrowserMenu.setDefaultAction(act) self.collectionActs.append(exportMenu) if statisticsAvailable: report.addSeparator() report.addAction(self.statisticsAct) report.addAction(summaryAct) helpAct = QAction(QIcon(':/help.png'), self.tr("User manual"), self) helpAct.setShortcut(QKeySequence.HelpContents) helpAct.triggered.connect(self.onlineHelp) webAct = QAction(self.tr("Visit web-site"), self) webAct.triggered.connect(self.visitWeb) checkUpdatesAct = QAction(self.tr("Check for updates"), self) checkUpdatesAct.triggered.connect(self.manualUpdate) aboutAct = QAction(self.tr("About %s") % version.AppName, self) aboutAct.triggered.connect(self.about) help_ = menubar.addMenu(self.tr("&Help")) help_.addAction(helpAct) help_.addAction(webAct) help_.addSeparator() help_.addAction(checkUpdatesAct) help_.addSeparator() help_.addAction(aboutAct) toolBar = QToolBar(self.tr("Toolbar"), self) toolBar.setObjectName("Toolbar") toolBar.setMovable(False) toolBar.addAction(openCollectionAct) toolBar.addSeparator() toolBar.addAction(addCoinAct) toolBar.addAction(editCoinAct) toolBar.addAction(viewBrowserAct) toolBar.addSeparator() toolBar.addAction(cancelFilteringAct) toolBar.addAction(cancelSortingAct) toolBar.addAction(self.enableDragAct) toolBar.addSeparator() toolBar.addAction(settingsAct) if statisticsAvailable or importedQtWebKit: toolBar.addSeparator() toolBar.addAction(self.detailsAct) if statisticsAvailable: toolBar.addAction(self.statisticsAct) if importedQtWebKit: toolBar.addAction(self.mapAct) if Settings()['colnect_enabled'] and colnectAvailable: toolBar.addSeparator() toolBar.addAction(colnectAct) toolBar.addSeparator() toolBar.addWidget(self.viewButton) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) toolBar.addWidget(spacer) self.quickSearch = QLineEdit() self.quickSearch.setMaximumWidth(250) self.quickSearch.setClearButtonEnabled(True) self.quickSearch.setPlaceholderText(self.tr("Quick search")) self.quickSearch.textEdited.connect(self.quickSearchEdited) self.collectionActs.append(self.quickSearch) self.quickSearchTimer = QTimer(self) self.quickSearchTimer.setSingleShot(True) self.quickSearchTimer.timeout.connect(self.quickSearchClicked) toolBar.addWidget(self.quickSearch) self.addToolBar(toolBar) self.setWindowTitle(version.AppName) if len(sys.argv) > 1: fileName = sys.argv[1] else: latest = LatestCollections(self) fileName = latest.latest() self.collection = Collection(self) self.openCollection(fileName) self.setCentralWidget(self.viewTab) settings = QSettings() pageIndex = settings.value('tabwindow/page', 0) if pageIndex is not None: self.viewTab.setCurrentIndex(int(pageIndex)) geometry = settings.value('mainwindow/geometry') if geometry: self.restoreGeometry(geometry) winState = settings.value('mainwindow/winState') if winState: self.restoreState(winState) self.autoUpdate()