def setup_actions(self):
        """Set up the relevant actions, tooltips, and load the RC file."""

        self.create_actions()
        self.setup_tooltips()
        self.setup_action_collection()

        # Connect signals
        self.connect_action.triggered.connect(self.connect)
        self.fetch_action.triggered.connect(self.get_posts)
        self.clean_action.triggered.connect(self.clean_cache)
        self.batch_download_action.triggered.connect(self.batch_download)
        self.pool_toggle_action.toggled.connect(self.pool_toggle)
        self.tag_display_action.activeChanged.connect(self.tag_display)

        window_options = self.StandardWindowOption(self.ToolBar | self.Keys
                                                   | self.Create | self.Save
                                                   | self.StatusBar)

        setupGUI_args = [
            QSize(500, 400),
            self.StandardWindowOption(window_options)
        ]

        #Check first in standard locations for danbooruui.rc

        rc_file = KStandardDirs.locate("appdata", "danbooruui.rc")

        if rc_file.isEmpty():
            setupGUI_args.append(os.path.join(sys.path[0], "danbooruui.rc"))
        else:
            setupGUI_args.append(rc_file)

        self.setupGUI(*setupGUI_args)
Beispiel #2
0
 def loadSetup(self):
     indihostfile = QtCore.QFile(
         KStandardDirs.locate("data", "kstars/indihosts.xml"))
     #print(indihostfile.fileName())
     if ((indihostfile.size() == 0)
             or not (indihostfile.open(QtCore.QIODevice.ReadOnly))):
         return
     handler = XmlIndiHostHandler(self)
     xmlreader = QtXml.QXmlSimpleReader()
     xmlreader.setContentHandler(handler)
     xmlreader.setErrorHandler(handler)
     source = QtXml.QXmlInputSource(indihostfile)
     ok = xmlreader.parse(source, True)
     #while (source.data() != ""):
     #source.reset()
     #ok=xmlreader.parseContinue()
     #xmlreader=QtCore.QXmlStreamReader(indihostfile)
     #ok=True
     #while not(xmlreader.atEnd()):
     #  xmlreader.readNext()
     #  if xmlreader.isStartElement():
     #    print("xml token name " + xmlreader.name().toString())
     #if xmlreader.hasError():
     #  ok=False
     if not (ok):
         print("Failed to load indihosts setup")
    def setup_welcome_widget(self):
        """Load the welcome widget at startup."""

        widget = QWidget()
        layout = QVBoxLayout()

        welcome = QLabel(parent=self)
        pix = QPixmap(KStandardDirs.locate("appdata", "logo.png"))

        welcome.setPixmap(pix)
        welcome.setAlignment(Qt.AlignCenter)

        self.first_fetch_widget = connectwidget.ConnectWidget(
            self.preferences.boards_list, self)

        self.statusbar.addPermanentWidget(self.first_fetch_widget, 300)

        self.first_fetch_widget.connectionEstablished.connect(
            self.handle_connection)
        self.first_fetch_widget.rejected.connect(self.first_fetch_widget.hide)

        self.first_fetch_widget.hide()

        self.first_fetch_widget.setSizePolicy(QSizePolicy.Preferred,
                                              QSizePolicy.Fixed)

        layout.addWidget(self.first_fetch_widget)
        layout.addWidget(welcome)
        widget.setLayout(layout)

        self.setCentralWidget(widget)
    def setup_actions(self):

        """Set up the relevant actions, tooltips, and load the RC file."""

        self.create_actions()
        self.setup_tooltips()
        self.setup_action_collection()

        # Connect signals
        self.connect_action.triggered.connect(self.connect)
        self.fetch_action.triggered.connect(self.get_posts)
        self.clean_action.triggered.connect(self.clean_cache)
        self.batch_download_action.triggered.connect(self.batch_download)
        self.pool_toggle_action.toggled.connect(self.pool_toggle)
        self.tag_display_action.activeChanged.connect(self.tag_display)

        window_options = self.StandardWindowOption(self.ToolBar| self.Keys |
                                                   self.Create | self.Save |
                                                   self.StatusBar)

        setupGUI_args = [
            QSize(500, 400), self.StandardWindowOption(window_options)
        ]

        #Check first in standard locations for danbooruui.rc

        rc_file = KStandardDirs.locate("appdata", "danbooruui.rc")

        if rc_file.isEmpty():
            setupGUI_args.append(os.path.join(sys.path [0],
                                              "danbooruui.rc"))
        else:
            setupGUI_args.append(rc_file)

        self.setupGUI(*setupGUI_args)
    def setup_welcome_widget(self):

        """Load the welcome widget at startup."""

        widget = QWidget()
        layout = QVBoxLayout()

        welcome = QLabel(parent=self)
        pix = QPixmap(KStandardDirs.locate("appdata","logo.png"))

        welcome.setPixmap(pix)
        welcome.setAlignment(Qt.AlignCenter)

        self.first_fetch_widget = connectwidget.ConnectWidget(
        self.preferences.boards_list, self)

        self.statusbar.addPermanentWidget(self.first_fetch_widget, 300)

        self.first_fetch_widget.connectionEstablished.connect(
            self.handle_connection)
        self.first_fetch_widget.rejected.connect(
            self.first_fetch_widget.hide)

        self.first_fetch_widget.hide()

        self.first_fetch_widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)

        layout.addWidget(self.first_fetch_widget)
        layout.addWidget(welcome)
        widget.setLayout(layout)

        self.setCentralWidget(widget)
Beispiel #6
0
def getData(fileName):
    global localDataDir

    absPath = unicode(KStandardDirs.locate('data',
        os.path.join('eclectus', fileName)))
    if absPath:
        return absPath
    elif localDataDir:
        return os.path.join(localDataDir, fileName)
Beispiel #7
0
 def loadSetup(self):
   indihostfile=QtCore.QFile(KStandardDirs.locate("data", "kstars/indihosts.xml"))
   #print(indihostfile.fileName())
   if ((indihostfile.size() == 0) or not(indihostfile.open(QtCore.QIODevice.ReadOnly))):
     return
   handler=XmlIndiHostHandler(self)
   xmlreader=QtXml.QXmlSimpleReader()
   xmlreader.setContentHandler(handler)
   xmlreader.setErrorHandler(handler)
   source=QtXml.QXmlInputSource(indihostfile)
   ok=xmlreader.parse(source, True)
   #while (source.data() != ""):
     #source.reset()
     #ok=xmlreader.parseContinue()
   #xmlreader=QtCore.QXmlStreamReader(indihostfile)
   #ok=True
   #while not(xmlreader.atEnd()):
   #  xmlreader.readNext()
   #  if xmlreader.isStartElement():
   #    print("xml token name " + xmlreader.name().toString())
   #if xmlreader.hasError():
   #  ok=False
   if not(ok):
     print("Failed to load indihosts setup")
Beispiel #8
0
    def __initUI(self):
        """Initialize the interface"""

        # Locate the ui for the main window and load it.
        if os.path.exists(self.__mainWindow_ui):
            appdir = QDir.currentPath()
        else:
            file =  KStandardDirs.locate("appdata", self.__mainWindow_ui)
            appdir = file.left(file.lastIndexOf("/"))
        uic.loadUi(appdir + "/" + self.__mainWindow_ui, self.__mainWindow)

        #set default persist size
        self.__mainWindow.ui_persist_label.setText(format_mb_size(128))

        #set persistent ui elements state
        if self.__persistent:
            self.__mainWindow.ui_persist_enabled.setChecked(True)
            self.__mainWindow.ui_persist_text.setEnabled(True)
            self.__mainWindow.ui_persist_slider.setEnabled(True)
            self.__mainWindow.ui_persist_label.setEnabled(True)
        else:
            self.__mainWindow.ui_persist_disabled.setChecked(True)
            self.__mainWindow.ui_persist_text.setDisabled(True)
            self.__mainWindow.ui_persist_slider.setDisabled(True)
            self.__mainWindow.ui_persist_label.setDisabled(True)

        #disable the start button and persist frame by default
        self.__mainWindow.ui_persist_frame.setEnabled(False)
        self.__mainWindow.ui_start_button.setEnabled(False)


        #add some buttons
        self.__mainWindow.ui_quit_button.setIcon(KIcon("application-exit"))
        self.__mainWindow.ui_start_button.setIcon(KIcon("dialog-ok-apply"))
        self.__mainWindow.ui_add_source.setIcon(KIcon("media-optical"))
        self.__mainWindow.ui_format_dest.setIcon(KIcon("drive-removable-media-usb-pendrive"))

        #set up signals
        self.connect(self.__mainWindow.ui_add_source,SIGNAL('clicked()'),
            self.add_file_source_dialog)
        self.connect(self.__mainWindow.ui_persist_slider,SIGNAL('valueChanged(int)'),
            lambda value: self.__mainWindow.ui_persist_label.setText(format_mb_size(value)))
        self.connect(self.__mainWindow.ui_quit_button,SIGNAL('clicked()'),
            self.quit)
        self.connect(self.__mainWindow.ui_start_button,SIGNAL('clicked()'),
            self.install)
        self.connect(self.__mainWindow.ui_dest_list,SIGNAL(
            'currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)'),
            self.dest_selection_changed)
        self.connect(self.__mainWindow.ui_source_list,SIGNAL(
            'currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)'),
            self.source_selection_changed)
        self.connect(self.__mainWindow.ui_format_dest,SIGNAL('clicked()'),
            self.format_dest_clicked)

        self.progress_bar = QProgressDialog("","Cancel",0,100,self.__mainWindow)
        #prevent progress bar from emitting reset on reaching max value (and auto closing)
        self.progress_bar.setAutoReset(False)
        #force immediate showing, rather than waiting...
        self.progress_bar.setMinimumDuration(0)
        #must disconnect the canceled() SIGNAL, otherwise the progress bar is actually destroyed
        self.disconnect(self.progress_bar,SIGNAL('canceled()'),self.progress_bar.cancel)
        #now we connect our own signal to display a warning dialog instead
        self.connect(self.progress_bar,SIGNAL('canceled()'),self.warning_dialog)

        #show the window
        self.__mainWindow.show()
    def __initUI(self):
        """Initialize the interface"""

        # Locate the ui for the main window and load it.
        if 'USBCREATOR_LOCAL' in os.environ:
            appdir = os.path.join(os.getcwd(), 'gui')
        else:
            file = KStandardDirs.locate("appdata", self.__mainWindow_ui)
            appdir = file[:file.rfind("/")]
        uic.loadUi(misc.text_type(appdir + "/" + self.__mainWindow_ui), self.__mainWindow)

        #set default persist size
        self.__mainWindow.ui_persist_label.setText(misc.format_mb_size(128))

        #set persistent ui elements state
        if self.__persistent:
            self.__mainWindow.ui_persist_enabled.setChecked(True)
            self.__mainWindow.ui_persist_text.setEnabled(True)
            self.__mainWindow.ui_persist_slider.setEnabled(True)
            self.__mainWindow.ui_persist_label.setEnabled(True)
        else:
            self.__mainWindow.ui_persist_disabled.setChecked(True)
            self.__mainWindow.ui_persist_frame.hide()

        #hide sources if an argument was provided
        if self.__img is not None:
            self.__mainWindow.ui_source_list.hide()
            self.__mainWindow.ui_add_source.hide()
            self.__mainWindow.insert_label.hide()
            self.__mainWindow.source_label.hide()

        #disable the start button and persist frame by default
        self.__mainWindow.ui_persist_frame.setEnabled(False)
        self.__mainWindow.ui_start_button.setEnabled(False)

        #add some buttons
        self.__mainWindow.ui_quit_button.setIcon(KIcon("application-exit"))
        self.__mainWindow.ui_start_button.setIcon(KIcon("dialog-ok-apply"))
        self.__mainWindow.ui_add_source.setIcon(KIcon("media-optical"))
        self.__mainWindow.ui_format_dest.setIcon(KIcon("drive-removable-media-usb-pendrive"))

        #set up signals
        self.connect(self.__mainWindow.ui_add_source,SIGNAL('clicked()'),
            self.add_file_source_dialog)
        self.connect(self.__mainWindow.ui_persist_slider,SIGNAL('valueChanged(int)'),
            lambda value: self.__mainWindow.ui_persist_label.setText(misc.format_mb_size(value)))
        self.connect(self.__mainWindow.ui_quit_button,SIGNAL('clicked()'),
            self.quit)
        self.connect(self.__mainWindow.ui_start_button,SIGNAL('clicked()'),
            self.install)
        self.connect(self.__mainWindow.ui_dest_list,SIGNAL(
            'currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)'),
            self.dest_selection_changed)
        self.connect(self.__mainWindow.ui_source_list,SIGNAL(
            'currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)'),
            self.source_selection_changed)
        self.connect(self.__mainWindow.ui_format_dest,SIGNAL('clicked()'),
            self.format_dest_clicked)

        self.__mainWindow.ui_source_list.setSortingEnabled(True)
        self.__mainWindow.ui_source_list.sortByColumn(0, Qt.AscendingOrder)
        self.__mainWindow.ui_dest_list.setSortingEnabled(True)
        self.__mainWindow.ui_dest_list.sortByColumn(0, Qt.AscendingOrder)
        self.progress_bar = QProgressDialog("",i18n('Cancel'),0,100,self.__mainWindow)
        #set title of progress window (same as gtk frontend)
        self.progress_bar.setWindowTitle(_('Installing'))
        #prevent progress bar from emitting reset on reaching max value (and auto closing)
        self.progress_bar.setAutoReset(False)
        #force immediate showing, rather than waiting...
        self.progress_bar.setMinimumDuration(0)
        #must disconnect the canceled() SIGNAL, otherwise the progress bar is actually destroyed
        self.disconnect(self.progress_bar,SIGNAL('canceled()'),self.progress_bar.cancel)
        #now we connect our own signal to display a warning dialog instead
        self.connect(self.progress_bar,SIGNAL('canceled()'),self.warning_dialog)

        #show the window
        self.__mainWindow.show()