Esempio n. 1
0
def main(argv=None):
    '''Entry point if executing as standalone'''
    if argv is None:
        argv = sys.argv

    app = QApplication(argv)
    app.processEvents()
    pixmap = QPixmap(os.path.abspath(os.path.join("res", "CLEED_logo.png")))
    splash = QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(pixmap.mask())  # this is useful if splash isn't a rectangle
    splash.showMessage((u'Starting %s...' % __APP_NAME__),
                       QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom,
                       QtCore.Qt.yellow)
    splash.show()

    # make sure Qt really display the splash screen
    app.processEvents()

    app.setQuitOnLastWindowClosed(False)

    window = MainWindow()

    if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():
        window.logger.warning("Unable to create a Systray on this system")

    # now kill the splash screen
    splash.finish(window)
    splash.close()

    window.show()
    sys.exit(app.exec_())
Esempio n. 2
0
def start():
    app = QApplication(sys.argv)

    # Create and display the splash screen
    splash_pix = QPixmap(resources.images['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    loader.load_syntax()

    ide = IDE()
    #Settings
    settings = QSettings('NINJA-IDE', 'Kunai')
    if (settings.value('Preferences/General/activate_plugins', 2) == 2):
        set_plugin_access(ide)
        core.load_plugins(ide)

    ide.show()
    for projectFolder in settings.value('Open_Files/projects',
                                        []).toStringList():
        ide.main.open_project_folder(str(projectFolder))

    for openFile in settings.value('Open_Files/tab1', []).toStringList():
        ide.main.open_document(str(openFile))

    for openFile2 in settings.value('Open_Files/tab2', []).toStringList():
        ide.main.split_tab(True)
        ide.main.open_document(str(openFile2))

    splash.finish(ide)
    sys.exit(app.exec_())
Esempio n. 3
0
    def __init__(self, parent=None):
        from radiance import __version__
        self.__version = __version__
        self.parent = parent
        
        pixmap = QPixmap(QString(':/Radiance/splashscreen.png'))
        flags = Qt.WindowStaysOnTopHint
        QSplashScreen.__init__(self, pixmap, flags)
        self.setMask(pixmap.mask())
        
        # Custom progress bar stylesheet
        progressbar_stylesheet = """
        QProgressBar:horizontal {
            border: 1px solid black;
            background: white;
            padding: 1px;
        }
        QProgressBar::chunk:horizontal {
            background-color: qlineargradient(spread: pad, x1: 1, y1: 0.5, x2: 0, y2: 0.5, stop: 0 black, stop: 1 white);
        }
        """
        
        # Place progress bar to bottom of splash screen.
        progressbar = QProgressBar(self)
        progressbar.setRange(0, 0)
        progressbar.setGeometry(10, self.height() - 20, self.width() - 20, 10)
        progressbar.setTextVisible(False)
        progressbar.setStyleSheet(progressbar_stylesheet)
        self.progressbar = progressbar

        self.show()
Esempio n. 4
0
def start():
    app = QApplication(sys.argv)

    # Create and display the splash screen
    splash_pix = QPixmap(resources.images['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    loader.load_syntax()

    ide = IDE()
    #Settings
    settings = QSettings('NINJA-IDE','Kunai')
    if (settings.value('Preferences/General/activate_plugins', 2)==2):
        set_plugin_access(ide)
        core.load_plugins(ide)

    ide.show()
    for projectFolder in settings.value('Open_Files/projects',[]).toStringList():
        ide.main.open_project_folder(str(projectFolder))

    for openFile in settings.value('Open_Files/tab1', []).toStringList():
        ide.main.open_document(str(openFile))

    for openFile2 in settings.value('Open_Files/tab2', []).toStringList():
        ide.main.split_tab(True)
        ide.main.open_document(str(openFile2))

    splash.finish(ide)
    sys.exit(app.exec_())
Esempio n. 5
0
 def __init__(self):
     """Launch GUI"""
     #translator = DFF_Translator()
     self.app = QApplication(sys.argv)
     #app.installTranslator(translator)
     pixmap = QPixmap(":splash.png")
     self.splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
     self.splash.setMask(pixmap.mask())
Esempio n. 6
0
 def setupUi(self):
     self.setObjectName(u'splash_screen')
     self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
     self.setContextMenuPolicy(Qt.PreventContextMenu)
     splash_image = QPixmap(u':/icons/128/luma')
     self.setPixmap(splash_image)
     self.setMask(splash_image.mask())
     self.resize(128, 128)
     QMetaObject.connectSlotsByName(self)
Esempio n. 7
0
 def setupUi(self):
     self.setObjectName(u'splash_screen')
     self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
     self.setContextMenuPolicy(Qt.PreventContextMenu)
     splash_image = QPixmap(u':/icons/128/luma')
     self.setPixmap(splash_image)
     self.setMask(splash_image.mask())
     self.resize(128, 128)
     QMetaObject.connectSlotsByName(self)
Esempio n. 8
0
 def __init__(self, image_resource=":/images/splash_wait.png", text=None):
     pixmap = QPixmap(image_resource)
     self.splash = QSplashScreen(pixmap)
     self.splash.setMask(QRegion(pixmap.mask()));
     self.splash.setPixmap(pixmap);
     flags = self.splash.windowFlags()
     flags |= Qt.WindowStaysOnTopHint
     self.splash.setWindowFlags(flags)
     self._text = None
     if text is not None:
         self.setText(text)
Esempio n. 9
0
File: gui.py Progetto: halbbob/dff
    def __init__(self, debug = False):
        """Launch GUI"""
        self.debug = debug
        self.app = QApplication(sys.argv)

        self.translator = Translator()
        
        self.app.installTranslator(self.translator.getGeneric())
        self.app.installTranslator(self.translator.getDFF())
        self.app.setApplicationName("Digital Forensics Framework")
	self.app.setApplicationVersion("1.2.0")
        pixmap = QPixmap(":splash.png")
        self.splash = SplashScreen(pixmap, Qt.WindowStaysOnTopHint, self.app.applicationVersion())
        self.splash.setMask(pixmap.mask()) 
Esempio n. 10
0
File: gui.py Progetto: arxsys/dff-ui
    def __init__(self, debug = False, verbosity = 0):
        """Launch GUI"""
	QApplication.__init__(self, sys.argv)
        UI.__init__(self, debug, verbosity)
        self.translator = Translator()
        self.installTranslator(self.translator.getGeneric())
        self.installTranslator(self.translator.getDFF())
        self.setApplicationName("Digital Forensics Framework")
        # Below are macros replaced by CMake using configure_file please don't
        # commit this file with macros replaced, view those macros definition
        # in the top level CMakeLists.txt
        self.setApplicationVersion("1.3.0")
        pixmap = QPixmap(":splash.png")
        self.splash = SplashScreen(pixmap, Qt.WindowStaysOnTopHint, self.applicationVersion())
        self.splash.setMask(pixmap.mask()) 
Esempio n. 11
0
def main():
    app = QtGui.QApplication(sys.argv)

    splash_pix = QPixmap(':/splash/3dlp_slicer_splash.png')
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    window = Main()
    window.show()
    splash.finish(window)

    # It's exec_ because exec is a reserved word in Python
    sys.exit(app.exec_())
Esempio n. 12
0
File: gui.py Progetto: kzwkt/dff
 def __init__(self, debug=False, verbosity=0):
     """Launch GUI"""
     QApplication.__init__(self, sys.argv)
     UI.__init__(self, debug, verbosity)
     self.translator = Translator()
     self.installTranslator(self.translator.getGeneric())
     self.installTranslator(self.translator.getDFF())
     self.setApplicationName("Digital Forensics Framework")
     # Below are macros replaced by CMake using configure_file please don't
     # commit this file with macros replaced, view those macros definition
     # in the top level CMakeLists.txt
     self.setApplicationVersion("1.3.0")
     pixmap = QPixmap(":splash.png")
     self.splash = SplashScreen(pixmap, Qt.WindowStaysOnTopHint,
                                self.applicationVersion())
     self.splash.setMask(pixmap.mask())
Esempio n. 13
0
File: gui.py Progetto: vertrex/DFF
 def __init__(self, arguments):
     """Launch GUI"""
     self.arguments = arguments
     QApplication.__init__(self, sys.argv)
     UI.__init__(self, arguments)
     self.translator = Translator()
     self.translator.addTranslationPath("dff/ui/gui/i18n/Dff_pro_")
     self.translator.addTranslationPath("dff/modules/i18n/Dff_pro_modules_")
     self.translator.loadLanguage()
     self.setApplicationName("Digital Forensics Framework")
     # Below are macros replaced by CMake using configure_file please don't
     # commit this file with macros replaced, view those macros definition
     # in the top level CMakeLists.txt
     self.setApplicationVersion(dff.VERSION)
     pixmap = QPixmap(":splash.png")
     self.splash = SplashScreen(pixmap, Qt.WindowStaysOnTopHint,
                                self.applicationVersion())
     self.splash.setMask(pixmap.mask())
Esempio n. 14
0
def start_eas(host, client, app):
    multisite_client = MultisiteClient(host, client)

    # Add splash screen
    pixmap = QPixmap(":/images/splash_start.png")
    splash = QSplashScreen(pixmap)
    splash.setMask(QRegion(pixmap.mask()))
    splash.setPixmap(pixmap)
    splash.show()
    app.splash = splash
    splash.showMessage(tr("Loading application"), Qt.AlignBottom | Qt.AlignRight)
    app.processEvents()

    # Load the main window
    from console_edenwall import MainWindow

    window = MainWindow(app, multisite_client)
    window.show()
    splash.finish(window)
Esempio n. 15
0
def showSplash(app):

    # splash pixmap
    logo = QPixmap(RES + ICONS + SPLASH)
    splash = QSplashScreen(logo, Qt.WindowStaysOnTopHint)
    splash.setWindowFlags(Qt.WindowStaysOnTopHint)

    # alpha mask
    splash.show()
    splash.setMask(logo.mask())

    # status message
    labelAlignment = Qt.Alignment(Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute)
    newline = '<br/>'
    family = FONTS_DICT['splash'][0]
    size = str(FONTS_DICT['splash'][2])
    font = "<font style='font-family: " + family + "; font-size: " + size + "pt; color: white;'>"
    info = newline * 10 + font + 'Loading...<br/>' + __name__ + ' ' + __version__ + '</font'
    splash.showMessage(info, labelAlignment)        #NB: html tags completely break alignment and color settings

    # checking for mouse click
    app.processEvents()

    return splash
Esempio n. 16
0
class Piece(QWidget):
    def __init__(self, type, parent=None):
        super().__init__(parent)
        self.__type = type
        self.setFixedSize(100 * variables.SCALE, 91 * variables.SCALE)
        self.__section = 7
        self.main_label = QLabel(self)
        self._pixmap = None
        self._selected_pixmap = None
        self.__timer = None
        self.__selected = False
        self.setMouseTracking(True)
        self.__init_main_label()

    def __init_main_label(self):
        if "star_" in self.__type:
            self._pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "{}.png".format(self.__type[5:]))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
            self._selected_pixmap = QPixmap(PATH + os.sep + "assets" + os.sep +
                                            "{}_selected.png".format(self.__type[5:]))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
            self.__star_label = QLabel(self)
            self.__star_pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "tiny_star.png")\
                .scaled(variables.STAR_SIZE*variables.SCALE, variables.STAR_SIZE*variables.SCALE, Qt.KeepAspectRatio)
            self.__star_label.setPixmap(self.__star_pixmap)
            self.__star_label.move(
                (50 - variables.STAR_SIZE * variables.SCALE / 2) *
                variables.SCALE,
                (46 - variables.STAR_SIZE * variables.SCALE / 2) *
                variables.SCALE)
            self.__star_label.setMouseTracking(True)
        else:
            self._pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "{}.png".format(self.__type))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
            self._selected_pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "{}_selected.png".format(self.__type))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
        self.main_label.setPixmap(self._pixmap)
        self.main_label.setMask(self._pixmap.mask())
        self.setMask(self.main_label.mask())
        self.main_label.setFixedSize(100 * variables.SCALE,
                                     91 * variables.SCALE)
        self.main_label.show()
        self.main_label.setMouseTracking(True)

    @property
    def selected(self):
        return self.__selected

    @selected.setter
    def selected(self, value):
        self.__set_selected(value)

    def __set_selected(self, selected):
        self.__selected = selected
        if selected:
            self.main_label.setPixmap(self._selected_pixmap)
        else:
            self.main_label.setPixmap(self._pixmap)

    def leaveEvent(self, event):
        self.__section = 7

    def mousePressEvent(self, QMouseEvent):
        self.parent().pieceClickedSignal.emit(
            PieceClickedEvent(self.column, self.row, self.__section, self))
        QMouseEvent.accept()

    def mouseMoveEvent(self, event):
        v1 = event.y() - 45 * variables.SCALE
        v2 = event.x() - 46.3 * variables.SCALE
        u1 = 45 * variables.SCALE
        u2 = 75 * variables.SCALE

        numerator = abs(u1 * v1 + u2 * v2)
        denominator = math.sqrt(u1**2 + u2**2) * math.sqrt(v1**2 + v2**2)
        if denominator != 0:
            angle = math.degrees(math.acos(numerator / denominator))

            if (45 / 75) * event.x() + 15 * variables.SCALE >= event.y():
                if (-75 / 45) * event.x() + 128.33 * variables.SCALE < event.y(
                ):
                    angle = 180 - angle
            else:
                if (-75 / 45
                    ) * event.x() + 128.33 * variables.SCALE >= event.y():
                    angle = 360 - angle
                else:
                    angle += 180

            if 0 <= angle <= 60:
                self.section_entered(1)
            elif 60 < angle <= 120:
                self.section_entered(2)
            elif 120 < angle <= 180:
                self.section_entered(3)
            elif 180 < angle <= 240:
                self.section_entered(4)
            elif 240 < angle <= 300:
                self.section_entered(5)
            else:
                self.section_entered(6)
        else:
            # Mouse en el centro
            pass

    def section_entered(self, section):
        if self.__section != section:
            self.__section = section
            variables.GAME_INTERFACE.piece_section_entered(section, self)

    def animated_move(self, final_pos, on_move_end=None):
        if variables.ANIMATIONS:
            if self.__timer is None:
                self.__timer = MovePieceTimer(self, final_pos, self.parent(),
                                              on_move_end)
                self.__timer.start()
            else:
                if not sip.isdeleted(self.__timer):
                    self.__timer.deleteLater()
                self.__timer = MovePieceTimer(self, final_pos, self.parent(),
                                              on_move_end)
                self.__timer.start()
        else:
            self.move(*final_pos)
Esempio n. 17
0
def start(filenames=None, projects_path=None,
          extra_plugins=None, linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    global cursor_flash_time
    cursor_flash_time = app.cursorFlashTime()
    app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = QSettings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language', language) + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(
      resources.LANGS_DOWNLOAD, lang)):
        settings.LANGUAGE = file_manager.create_path(
            resources.LANGS_DOWNLOAD, lang)
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA__THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default")
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    #Showing GUI
    ide.show()

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    main_files = qsettings.value('openFiles/mainTab', [])
    if main_files is not None:
        mainFiles = list(main_files)
    else:
        mainFiles = list()
    tempFiles = []
    for file_ in mainFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    mainFiles = tempFiles
    #Files in Secondary Tab
    sec_files = qsettings.value('openFiles/secondaryTab', [])
    if sec_files is not None:
        secondaryFiles = list(sec_files)
    else:
        secondaryFiles = list()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    secondaryFiles = tempFiles
    # Recent Files
    recent = qsettings.value('openFiles/recentFiles', [])
    if recent is not None:
        recent_files = list(recent)
    else:
        recent_files = list()
    recent_files = [file_ for file_ in recent_files]
    #Current File
    current_file = qsettings.value('openFiles/currentFile', '')
    #Projects
    projects_list = qsettings.value('openFiles/projects', [])
    if projects_list is not None:
        projects = list(projects_list)
    else:
        projects = list()
    projects = [project for project in projects]
    #Include files received from console args
    file_with_nro = list(map(lambda f: (f[0], f[1] - 1),
        zip(filenames, linenos)))
    file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):]))
    mainFiles += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects,
        current_file, recent_files)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Esempio n. 18
0
from PyQt4.QtCore import Qt
import sys
import os.path
"""
This script imports the minimum modules necessary to display a splash
screen before importing and displaying the downloader application.
"""


def resource_path(relative):
    local = getattr(sys, '_MEIPASS', '.')
    return os.path.join(local, relative)


# Create and display the splash screen
app = QApplication([])
splash_pix = QPixmap(resource_path('icons\splash_loading.png'))
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
splash.setMask(splash_pix.mask())
splash.show()
app.processEvents()

# Import and display the application
from mileage_gui import mileageGui
myapp = mileageGui()
myapp.show()

# Close the splash screen
splash.finish(myapp)
app.exec_()
Esempio n. 19
0
class Piece(QWidget):

    def __init__(self, type, parent=None):
        super().__init__(parent)
        self.__type = type
        self.setFixedSize(100*variables.SCALE, 91*variables.SCALE)
        self.__section = 7
        self.main_label = QLabel(self)
        self._pixmap = None
        self._selected_pixmap = None
        self.__timer = None
        self.__selected = False
        self.setMouseTracking(True)
        self.__init_main_label()

    def __init_main_label(self):
        if "star_" in self.__type:
            self._pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "{}.png".format(self.__type[5:]))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
            self._selected_pixmap = QPixmap(PATH + os.sep + "assets" + os.sep +
                                            "{}_selected.png".format(self.__type[5:]))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
            self.__star_label = QLabel(self)
            self.__star_pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "tiny_star.png")\
                .scaled(variables.STAR_SIZE*variables.SCALE, variables.STAR_SIZE*variables.SCALE, Qt.KeepAspectRatio)
            self.__star_label.setPixmap(self.__star_pixmap)
            self.__star_label.move((50 - variables.STAR_SIZE*variables.SCALE/2)*variables.SCALE,
                                   (46 - variables.STAR_SIZE*variables.SCALE/2)*variables.SCALE)
            self.__star_label.setMouseTracking(True)
        else:
            self._pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "{}.png".format(self.__type))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
            self._selected_pixmap = QPixmap(PATH + os.sep + "assets" + os.sep + "{}_selected.png".format(self.__type))\
                .scaled(100*variables.SCALE, 91*variables.SCALE, Qt.KeepAspectRatio)
        self.main_label.setPixmap(self._pixmap)
        self.main_label.setMask(self._pixmap.mask())
        self.setMask(self.main_label.mask())
        self.main_label.setFixedSize(100*variables.SCALE, 91*variables.SCALE)
        self.main_label.show()
        self.main_label.setMouseTracking(True)

    @property
    def selected(self):
        return self.__selected

    @selected.setter
    def selected(self, value):
        self.__set_selected(value)

    def __set_selected(self, selected):
        self.__selected = selected
        if selected:
            self.main_label.setPixmap(self._selected_pixmap)
        else:
            self.main_label.setPixmap(self._pixmap)

    def leaveEvent(self, event):
        self.__section = 7

    def mousePressEvent(self, QMouseEvent):
        self.parent().pieceClickedSignal.emit(PieceClickedEvent(self.column, self.row, self.__section, self))
        QMouseEvent.accept()

    def mouseMoveEvent(self, event):
        v1 = event.y() - 45*variables.SCALE
        v2 = event.x() - 46.3*variables.SCALE
        u1 = 45*variables.SCALE
        u2 = 75*variables.SCALE

        numerator = abs(u1*v1 + u2*v2)
        denominator = math.sqrt(u1**2 + u2**2) * math.sqrt(v1**2 + v2**2)
        if denominator != 0:
            angle = math.degrees(math.acos(numerator/denominator))

            if (45/75)*event.x() + 15*variables.SCALE >= event.y():
                if (-75/45)*event.x() + 128.33*variables.SCALE < event.y():
                    angle = 180 - angle
            else:
                if (-75/45)*event.x() + 128.33*variables.SCALE >= event.y():
                    angle = 360 - angle
                else:
                    angle += 180

            if 0 <= angle <= 60:
                self.section_entered(1)
            elif 60 < angle <= 120:
                self.section_entered(2)
            elif 120 < angle <= 180:
                self.section_entered(3)
            elif 180 < angle <= 240:
                self.section_entered(4)
            elif 240 < angle <= 300:
                self.section_entered(5)
            else:
                self.section_entered(6)
        else:
            # Mouse en el centro
            pass

    def section_entered(self, section):
        if self.__section != section:
                self.__section = section
                variables.GAME_INTERFACE.piece_section_entered(section, self)

    def animated_move(self, final_pos, on_move_end=None):
        if variables.ANIMATIONS:
            if self.__timer is None:
                self.__timer = MovePieceTimer(self, final_pos, self.parent(), on_move_end)
                self.__timer.start()
            else:
                if not sip.isdeleted(self.__timer):
                    self.__timer.deleteLater()
                self.__timer = MovePieceTimer(self, final_pos, self.parent(), on_move_end)
                self.__timer.start()
        else:
            self.move(*final_pos)
Esempio n. 20
0
    def setupUi( self ):
        super( dlgUserLogin, self ).setupUi()

        #No mostrar el marco de la ventana
        self.setWindowFlags( Qt.FramelessWindowHint )

        self.resize( 519, 311 )
        self.setMinimumSize( QSize( 519, 311 ) )
        self.setMaximumSize( QSize( 519, 311 ) )

        horizontal_layout = QHBoxLayout( self )
        horizontal_layout.setMargin( 0 )

        frame = QFrame( self )
        frame.setFrameShape( QFrame.NoFrame )
        frame.setFrameShadow( QFrame.Plain )

        grid_layout = QGridLayout( frame )
        grid_layout.setMargin( 0 )

        spacerItem = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding )
        grid_layout.addItem( spacerItem, 0, 0, 1, 6 )



        sizePolicy = QSizePolicy( QSizePolicy.Preferred,
                                  QSizePolicy.Maximum )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth( self.txtApplication.sizePolicy().hasHeightForWidth() )
        self.txtApplication.setSizePolicy( sizePolicy )

        font = QFont()
        font.setPointSize( 16 )
        font.setWeight( 75 )
        font.setBold( True )
        self.txtApplication.setFont( font )
        self.txtApplication.setAutoFillBackground( False )
        self.txtApplication.setAlignment( Qt.AlignCenter )

        grid_layout.addWidget( self.txtApplication, 1, 0, 1, 5 )
        spacer_item_1 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_1, 2, 0, 1, 6 )
        spacer_item_2 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_2, 3, 0, 1, 6 )
        spacer_item_3 = QSpacerItem( 60, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_3, 5, 0, 1, 1 )
        spacer_item_4 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_4, 5, 1, 1, 1 )
        spacer_item_6 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_6, 5, 2, 1, 1 )


        self.label = QLabel()

        self.txtBd = QLineEdit()

        self.formLayout.addRow( u"Base de datos", self.txtBd )
        self.formLayout.setFieldGrowthPolicy( QFormLayout.ExpandingFieldsGrow )

        grid_layout.addLayout( self.formLayout, 5, 3, 1, 1 )
        spacer_item_6 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_6, 5, 4, 1, 1 )
        spacer_item_7 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_7, 5, 5, 1, 1 )
        self.lblError = QLabel( frame )
        self.lblError.setProperty( "error", True )
        grid_layout.addWidget( self.lblError, 6, 3, 1, 2 )
        spacer_item_8 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_8, 7, 0, 1, 6 )
        self.buttonbox = QDialogButtonBox( frame )
        self.buttonbox.setOrientation( Qt.Horizontal )
        self.buttonbox.setStandardButtons( QDialogButtonBox.Cancel |
                                           QDialogButtonBox.Ok )
        grid_layout.addWidget( self.buttonbox, 8, 0, 1, 5 )
        spacer_item_9 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_9, 9, 0, 1, 6 )
        horizontal_layout.addWidget( frame )


        self.txtApplication.setText( "%s : %s" % ( qApp.organizationName(),
                                                qApp.applicationName() ) )
        self.lblError.setVisible( False )

        #Centrar el dialogo en la pantalla
        desktop_widget = QDesktopWidget()
        geometry = desktop_widget.screenGeometry()
        self.setGeometry( ( geometry.width() - 519 ) / 2,
                           ( geometry.height() - 311 ) / 2  ,
                            519, 311 )

        #mostrar redondeado el dialogo
        pixmap = QPixmap( ":/images/res/passwd-bg.png" )
        self.setMask( pixmap.mask() )
Esempio n. 21
0
def label_img(widget, name):
    img = get_file_path('images', name)
    pixmap = QPixmap(img)
    widget.setPixmap(pixmap)
    widget.setMask(pixmap.mask())
    widget.show()
Esempio n. 22
0
 def __init__(self):
     splash_pix = QPixmap(':/splash.png')
     self.splash = QSplashScreen(splash_pix,
                                 Qt.WindowStaysOnTopHint)
     self.splash.setMask(splash_pix.mask())
Esempio n. 23
0
def start():
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('ninja-ide.org.ar')
    QCoreApplication.setApplicationName('Kunai')

    # Create and display the splash screen
    splash_pix = QPixmap(resources.images['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    loader.load_syntax()

    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignBottom, Qt.white)
    settings = QSettings()
    if not settings.value('preferences/skins/default', True).toBool():
        selectedSkin = settings.value('preferences/skins/selectedSkin', '').toString()
        skins = loader.load_gui_skins()
        css = skins.get(str(selectedSkin), '')
        app.setStyleSheet(css)
    schemeColor = str(settings.value('preferences/editor/scheme', 'default').toString())
    if schemeColor != 'default':
        resources.custom_scheme = loader.load_editor_skins().get(schemeColor, {})
    #Editor Configuration
    EditorGeneric.codeCompletion = settings.value('preferences/editor/codeCompletion', True).toBool()
    EditorGeneric.indent = settings.value('preferences/editor/indent', 4).toInt()[0]
    EditorGeneric.findErrors = settings.value('preferences/editor/errors', False).toBool()
    EditorGeneric.checkStyle = settings.value('preferences/editor/checkStyle', True).toBool()
    EditorGeneric.highlightVariables = settings.value('preferences/editor/highlightWord', True).toBool()
    if not settings.value('preferences/editor/parentheses', True).toBool():
        del EditorGeneric.braces_strings['(']
    if not settings.value('preferences/editor/brackets', True).toBool():
        del EditorGeneric.braces_strings['[']
    if not settings.value('preferences/editor/keys', True).toBool():
        del EditorGeneric.braces_strings['{']
    if not settings.value('preferences/editor/simpleQuotes', True).toBool():
        del EditorGeneric.braces_strings["'"]
    if not settings.value('preferences/editor/doubleQuotes', True).toBool():
        del EditorGeneric.braces_strings['"']

    ide = IDE()
    if settings.value('preferences/interface/centralRotate', False).toBool():
        ide.main._splitter_central_rotate()
    if settings.value('preferences/interface/panelsRotate', False).toBool():
        ide.main._splitter_main_rotate()
    if settings.value('preferences/interface/centralOrientation', False).toBool():
        ide.main._splitter_central_orientation()

    #Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignBottom, Qt.white)
    resources.python_path = str(settings.value('preferences/general/pythonPath', 'python').toString())
    if (settings.value('preferences/general/activatePlugins', Qt.Checked) == Qt.Checked):
        set_plugin_access(ide)
        ninja_ide.core.load_plugins(ide)
    resources.workspace = str(settings.value('preferences/general/workspace', '').toString())
    supportedExtensions = settings.value('preferences/general/extensions', []).toList()
    if supportedExtensions:
        tempExtensions = []
        for se in supportedExtensions:
            tempExtensions.append(str(se.toString()))
        manage_files.supported_extensions = tuple(tempExtensions)

    #Load Font preference
    font = str(settings.value('preferences/editor/font', "Monospace, 11").toString())
    EditorGeneric.font_family = font.split(', ')[0]
    EditorGeneric.font_size = int(font.split(', ')[1])

    ide.show()
    splash.showMessage("Loading Projects", Qt.AlignRight | Qt.AlignBottom, Qt.white)
    for projectFolder in settings.value('openFiles/projects', []).toStringList():
        if os.path.isdir(projectFolder):
            ide.main.open_project_folder(str(projectFolder), False)

    if (settings.value('preferences/general/loadFiles', Qt.Checked) == Qt.Checked):
        for openFile in settings.value('openFiles/tab1', []).toList():
            if len(openFile.toList()) > 0:
                fileList = openFile.toList()
                fileName = str(fileList[0].toString())
                projectPath = str(fileList[1].toString())
                if len(projectPath) == 0:
                    projectPath = None
                cursorPosition = fileList[2].toInt()[0]
                if os.path.isfile(fileName):
                    ide.main.open_document(fileName, projectPath)
                    ide.main._central.obtain_editor().set_cursor_position(cursorPosition)

        for openFile2 in settings.value('openFiles/tab2', []).toList():
            #ide.main.split_tab(True)
            if len(openFile2.toList()) > 0:
                ide.main._central._tabs2.show()
                ide.main._central._mainTabSelected = False
                fileList = openFile2.toList()
                fileName = fileList[0].toString()
                projectPath = fileList[1].toString()
                cursorPosition = fileList[2].toInt()[0]
                if os.path.isfile(fileName):
                    ide.main.open_document(str(fileName), str(projectPath))
                    ide.main._central.obtain_editor().set_cursor_position(cursorPosition)
                ide.main._central._mainTabSelected = True

    filenames, projects_path = ninja_ide.core.cliparser.parse()

    for filename in filenames:
        ide.main.open_document(filename)

    for project_path in projects_path:
        ide.main.open_project_folder(project_path)

    splash.finish(ide)
    sys.exit(app.exec_())
Esempio n. 24
0
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName("NINJA-IDE")
    QCoreApplication.setOrganizationDomain("NINJA-IDE")
    QCoreApplication.setApplicationName("NINJA-IDE")
    app.setWindowIcon(QIcon(resources.IMAGES["icon"]))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES["splash"])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    global cursor_flash_time
    cursor_flash_time = app.cursorFlashTime()
    app.setCursorFlashTime(0)

    # Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8"))

    # Translator
    qsettings = QSettings()
    language = QLocale.system().language()
    lang = unicode(qsettings.value("preferences/interface/language", language).toString()) + ".qm"
    lang_path = file_manager.create_path(resources.LANGS, unicode(lang))
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))):
        settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    # Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    # Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black)
    settings.load_settings()

    # Set Stylesheet
    if settings.USE_STYLESHEET:
        with open(resources.NINJA_THEME) as f:
            qss = f.read()
            app.setStyleSheet(qss)

    # Loading Themes
    splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = unicode(qsettings.value("preferences/editor/scheme", "default").toString())
    if scheme != "default":
        scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color")
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    # Loading Shortcuts
    resources.load_shortcuts()
    # Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    # Showing GUI
    ide.show()

    # Loading Session Files
    splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black)
    # Files in Main Tab
    mainFiles = qsettings.value("openFiles/mainTab", []).toList()
    tempFiles = []
    for file_ in mainFiles:
        fileData = file_.toList()
        tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0]))
    mainFiles = tempFiles
    # Files in Secondary Tab
    secondaryFiles = qsettings.value("openFiles/secondaryTab", []).toList()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = file_.toList()
        tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0]))
    secondaryFiles = tempFiles
    # Current File
    current_file = unicode(qsettings.value("openFiles/currentFile", "").toString())
    # Projects
    projects = qsettings.value("openFiles/projects", []).toList()
    projects = [unicode(project.toString()) for project in projects]
    # Include files received from console args
    file_with_nro = map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))
    file_without_nro = map(lambda f: (f, 0), filenames[len(linenos) :])
    mainFiles += file_with_nro + file_without_nro
    # Include projects received from console args
    if projects_path:
        projects += projects_path
    mainFiles.reverse()
    secondaryFiles.reverse()
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file)
    # Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Esempio n. 25
0
 def __init__(self):
     splash_pix = QPixmap(':/imgs/logo.png')
     super(AppSplashScreen, self).__init__(splash_pix,
                                           Qt.WindowStaysOnTopHint)
     self.setMask(splash_pix.mask())
Esempio n. 26
0
def run_edis(app):
    """ Se carga la interfáz """

    DEBUG("Running Edis...")
    qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat)
    # Ícono
    app.setWindowIcon(QIcon(":image/edis"))
    # Lenguaje
    local = QLocale.system().name()
    DEBUG("Loading language...")
    language = settings.get_setting('general/language')
    if language:
        edis_translator = QTranslator()
        edis_translator.load(
            os.path.join(paths.PATH, "extras", "i18n", language))
        app.installTranslator(edis_translator)
        # Qt translator
        qtranslator = QTranslator()
        qtranslator.load("qt_" + local,
                         QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtranslator)
    pixmap = QPixmap(":image/splash")
    # Splash screen
    show_splash = False
    if settings.get_setting('general/show-splash'):
        DEBUG("Showing splash...")
        splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
        splash.setMask(pixmap.mask())
        splash.show()
        app.processEvents()
        show_splash = True

    # Style Sheet
    style = settings.get_setting('window/style-sheet')
    path_style = None
    style_sheet = None
    if style == 'Edark':
        path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss')
    elif style != 'Default':
        path_style = os.path.join(paths.EDIS, style + '.qss')
    if path_style is not None:
        with open(path_style, mode='r') as f:
            style_sheet = f.read()
    app.setStyleSheet(style_sheet)

    # Fuente en Tooltips
    QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9))

    # GUI
    if show_splash:
        alignment = Qt.AlignBottom | Qt.AlignLeft
        splash.showMessage("Loading UI...", alignment, Qt.white)
    DEBUG("Loading GUI...")
    edis = Edis()
    edis.show()
    # Archivos de última sesión
    files, recents_files, projects = [], [], []
    projects = qsettings.value('general/projects')
    #FIXME:
    if projects is None:
        projects = []
    if settings.get_setting('general/load-files'):
        DEBUG("Loading files and projects...")
        if show_splash:
            splash.showMessage("Loading files...", alignment, Qt.white)
        files = qsettings.value('general/files')
        if files is None:
            files = []
        # Archivos recientes
        recents_files = qsettings.value('general/recents-files')
        if recents_files is None:
            recents_files = []
    # Archivos desde línea de comandos
    files += cmd_parser.parse()
    edis.load_files_and_projects(files, recents_files, projects)
    if show_splash:
        splash.finish(edis)
    DEBUG("Edis is Ready!")
    sys.exit(app.exec_())
Esempio n. 27
0
def start(listener, filenames=None, projects_path=None, extra_plugins=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = QSettings()
    language = QLocale.system().language()
    lang = unicode(
        qsettings.value('preferences/interface/language',
                        language).toString()) + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, unicode(lang))
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(
            file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))):
        settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD,
                                                     unicode(lang))
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    settings.load_settings()

    #Loading Themes
    splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = unicode(
        qsettings.value('preferences/editor/scheme', "default").toString())
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE()

    #Showing GUI
    ide.show()
    #Connect listener signals
    ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file)
    ide.connect(listener, SIGNAL("projectOpenRequested(QString)"),
                ide.open_project)

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    mainFiles = qsettings.value('openFiles/mainTab', []).toList()
    tempFiles = []
    for file_ in mainFiles:
        fileData = file_.toList()
        tempFiles.append(
            (unicode(fileData[0].toString()), fileData[1].toInt()[0]))
    mainFiles = tempFiles
    #Files in Secondary Tab
    secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = file_.toList()
        tempFiles.append(
            (unicode(fileData[0].toString()), fileData[1].toInt()[0]))
    secondaryFiles = tempFiles
    #Projects
    projects = qsettings.value('openFiles/projects', []).toList()
    projects = [unicode(project.toString()) for project in projects]
    #Include files received from console args
    if filenames:
        mainFiles += [(f, 0) for f in filenames]
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Esempio n. 28
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    #if not settings.IS_WINDOWS:
    #app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
                           defaultValue=language,
                           type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
                          QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)

    #Set Stylesheet
    style_applied = False
    print(settings.NINJA_SKIN)
    if settings.NINJA_SKIN not in ('Default'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as fileaccess:
                qss = fileaccess.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as fileaccess:
                qss = fileaccess.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    scheme = qsettings.value('preferences/editor/scheme',
                             "default",
                             type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value('lastSession/currentFile',
                                            '',
                                            type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], (f[1] - 1, 0), 0)
                          for f in zip(filenames, linenos)])
    file_without_nro = list([(f, (0, 0), 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects, current_file,
                                         recent_files)
    #Load external plugins
    #if extra_plugins:
    #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Esempio n. 29
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if not settings.IS_WINDOWS:
        app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
        defaultValue=language, type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
            QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA_THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default",
        type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value(
                        'lastSession/currentFile', '', type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects,
                                         current_file, recent_files)
    #Load external plugins
    #if extra_plugins:
        #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Esempio n. 30
0
def run_edis(app):
    """ Se carga la interfáz """

    DEBUG("Running Edis...")
    qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat)
    # Ícono
    app.setWindowIcon(QIcon(":image/edis"))
    # Lenguaje
    local = QLocale.system().name()
    DEBUG("Loading language...")
    language = settings.get_setting('general/language')
    if language:
        edis_translator = QTranslator()
        edis_translator.load(os.path.join(paths.PATH,
                             "extras", "i18n", language))
        app.installTranslator(edis_translator)
        # Qt translator
        qtranslator = QTranslator()
        qtranslator.load("qt_" + local, QLibraryInfo.location(
                         QLibraryInfo.TranslationsPath))
        app.installTranslator(qtranslator)
    pixmap = QPixmap(":image/splash")
    # Splash screen
    show_splash = False
    if settings.get_setting('general/show-splash'):
        DEBUG("Showing splash...")
        splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
        splash.setMask(pixmap.mask())
        splash.show()
        app.processEvents()
        show_splash = True

    # Style Sheet
    style = settings.get_setting('window/style-sheet')
    path_style = None
    style_sheet = None
    if style == 'Edark':
        path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss')
    elif style != 'Default':
        path_style = os.path.join(paths.EDIS, style + '.qss')
    if path_style is not None:
        with open(path_style, mode='r') as f:
            style_sheet = f.read()
    app.setStyleSheet(style_sheet)

    # Fuente en Tooltips
    QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9))

    # GUI
    if show_splash:
        alignment = Qt.AlignBottom | Qt.AlignLeft
        splash.showMessage("Loading UI...", alignment, Qt.white)
    DEBUG("Loading GUI...")
    edis = Edis()
    edis.show()
    # Archivos de última sesión
    files, recents_files, projects = [], [], []
    projects = qsettings.value('general/projects')
    #FIXME:
    if projects is None:
        projects = []
    if settings.get_setting('general/load-files'):
        DEBUG("Loading files and projects...")
        if show_splash:
            splash.showMessage("Loading files...", alignment, Qt.white)
        files = qsettings.value('general/files')
        if files is None:
            files = []
        # Archivos recientes
        recents_files = qsettings.value('general/recents-files')
        if recents_files is None:
            recents_files = []
    # Archivos desde línea de comandos
    files += cmd_parser.parse()
    edis.load_files_and_projects(files, recents_files, projects)
    if show_splash:
        splash.finish(edis)
    DEBUG("Edis is Ready!")
    sys.exit(app.exec_())
Esempio n. 31
0
 def __init__(self):
     splash_pix = QPixmap(':/imgs/logo.png')
     super(AppSplashScreen, self).__init__(splash_pix, Qt.WindowStaysOnTopHint)
     self.setMask(splash_pix.mask())
Esempio n. 32
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName("NINJA-IDE")
    QCoreApplication.setOrganizationDomain("NINJA-IDE")
    QCoreApplication.setApplicationName("NINJA-IDE")
    app.setWindowIcon(QIcon(resources.IMAGES["icon"]))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES["splash"])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if not settings.IS_WINDOWS:
        app.setCursorFlashTime(0)

    # Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8"))

    # Translator
    qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat)
    language = QLocale.system().name()
    lang = qsettings.value("preferences/interface/language", defaultValue=language, type="QString") + ".qm"
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    # Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    # Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black)
    settings.load_settings()

    # Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ("Default", "Classic Theme"):
        file_name = "%s.qss" % settings.NINJA_SKIN
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == "Default":
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA_THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    # Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value("preferences/editor/scheme", "default", type="QString")
    if scheme != "default":
        scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color")
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    # Loading Shortcuts
    resources.load_shortcuts()
    # Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    # Showing GUI
    ninjaide.show()

    # Loading Session Files
    splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black)

    # First check if we need to load last session files
    if qsettings.value("preferences/general/loadFiles", True, type=bool):
        # Files in Main Tab
        main_files = qsettings.value("openFiles/mainTab", [])
        tempFiles = []
        if main_files:
            for file_ in main_files:
                fileData = list(file_)
                if fileData:
                    lineno = fileData[1]
                    tempFiles.append((fileData[0], lineno))
        main_files = tempFiles
        # Files in Secondary Tab
        sec_files = qsettings.value("openFiles/secondaryTab", [])
        tempFiles = []
        if sec_files:
            for file_ in sec_files:
                fileData = list(file_)
                if fileData:
                    lineno = fileData[1]
                    tempFiles.append((fileData[0], lineno))
        sec_files = tempFiles

        # Recent Files
        recent_files = qsettings.value("openFiles/recentFiles", [])
        # Current File
        current_file = qsettings.value("openFiles/currentFile", "", type="QString")
        # Projects
        projects = qsettings.value("openFiles/projects", [])
    else:
        main_files = []
        sec_files = []
        recent_files = []
        current_file = ""
        projects = []

    # Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos) :]])
    main_files += file_with_nro + file_without_nro
    # Include projects received from console args
    if projects_path:
        projects += projects_path
    # FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    # ninjaide.load_session_files_projects(main_files, sec_files,
    # projects, current_file, recent_files)
    # Load external plugins
    # if extra_plugins:
    # ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Esempio n. 33
0
    if getattr(sys, 'frozen', None):

        basedir = sys._MEIPASS

    else:

        import os

        basedir = os.path.dirname(__file__)

    # Create and display the splash screen
    directory_to_image = str(basedir) + '\Data\splash_loading.png'
    splashme = QApplication(sys.argv)
    splash_pix = QPixmap(directory_to_image)
    splash = QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    splashme.processEvents()

    import time
    time.sleep(3)

    app = QApplication(sys.argv)

    # Give GUI a theme
    # Some look better than others on different operating systems
    # That is why I choose not to use a single style
    if sys.platform == 'win32':

        app.setStyle('cleanlooks')
Esempio n. 34
0
def start(listener, filenames=None, projects_path=None, extra_plugins=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = QSettings()
    language = QLocale.system().language()
    lang = unicode(qsettings.value(
        'preferences/interface/language', language).toString()) + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, unicode(lang))
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(
      resources.LANGS_DOWNLOAD, unicode(lang))):
        settings.LANGUAGE = file_manager.create_path(
            resources.LANGS_DOWNLOAD, unicode(lang))
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Loading Themes
    splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = unicode(qsettings.value('preferences/editor/scheme',
        "default").toString())
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE()

    #Showing GUI
    ide.show()
    #Connect listener signals
    ide.connect(listener, SIGNAL("fileOpenRequested(QString)"),
        ide.open_file)
    ide.connect(listener, SIGNAL("projectOpenRequested(QString)"),
        ide.open_project)

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    mainFiles = qsettings.value('openFiles/mainTab', []).toList()
    tempFiles = []
    for file_ in mainFiles:
        fileData = file_.toList()
        tempFiles.append((unicode(fileData[0].toString()),
            fileData[1].toInt()[0]))
    mainFiles = tempFiles
    #Files in Secondary Tab
    secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = file_.toList()
        tempFiles.append((unicode(fileData[0].toString()),
            fileData[1].toInt()[0]))
    secondaryFiles = tempFiles
    #Projects
    projects = qsettings.value('openFiles/projects', []).toList()
    projects = [unicode(project.toString()) for project in projects]
    #Include files received from console args
    if filenames:
        mainFiles += [(f, 0) for f in filenames]
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Esempio n. 35
0
def start(filenames=None,
          projects_path=None,
          extra_plugins=None,
          linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    global cursor_flash_time
    cursor_flash_time = app.cursorFlashTime()
    app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = QSettings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language', language) + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(
            file_manager.create_path(resources.LANGS_DOWNLOAD, lang)):
        settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD,
                                                     lang)
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA__THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default")
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    #Showing GUI
    ide.show()

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    main_files = qsettings.value('openFiles/mainTab', [])
    if main_files is not None:
        mainFiles = list(main_files)
    else:
        mainFiles = list()
    tempFiles = []
    for file_ in mainFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    mainFiles = tempFiles
    #Files in Secondary Tab
    sec_files = qsettings.value('openFiles/secondaryTab', [])
    if sec_files is not None:
        secondaryFiles = list(sec_files)
    else:
        secondaryFiles = list()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = list(file_)
        tempFiles.append((fileData[0], int(fileData[1])))
    secondaryFiles = tempFiles
    # Recent Files
    recent = qsettings.value('openFiles/recentFiles', [])
    if recent is not None:
        recent_files = list(recent)
    else:
        recent_files = list()
    recent_files = [file_ for file_ in recent_files]
    #Current File
    current_file = qsettings.value('openFiles/currentFile', '')
    #Projects
    projects_list = qsettings.value('openFiles/projects', [])
    if projects_list is not None:
        projects = list(projects_list)
    else:
        projects = list()
    projects = [project for project in projects]
    #Include files received from console args
    file_with_nro = list(
        map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos)))
    file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):]))
    mainFiles += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects,
                                    current_file, recent_files)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    sys.exit(app.exec_())
Esempio n. 36
0
    def __init__(self, parent=None):
        super().__init__(parent)

        # Load saved application settings
        self.recentNotes = []

        self.numberOfTabs = 0  # keep track of the total number of tabs in the window
        self.currentPage = None
        self.__mediator = MITM.Mediator.Mediator(
        )  # the mediator object. intermediary btwn view and model

        # create a timer
        timer = QTimer(self)
        # dialogs: saved to avoid eating memory by constant cre- and re- creation
        self.findDialog = None
        self.renameDialog = None
        self.helpAboutDialog = HelpAboutDialog(self)
        self.helpHelpDialog = HelpHelpDialog(self)
        self.recentFilesListWidget = QListWidget

        # create menus first
        self.fileMenu = self.menuBar().addMenu("File")
        self.recentNotesMenu = self.fileMenu.addMenu("Open Recent")
        self.editMenu = self.menuBar().addMenu("Edit")
        self.syncMenu = self.menuBar().addMenu("Sync")
        self.helpMenu = self.menuBar().addMenu("Help")

        # region Actions
        # create the menu actions
        # first the file menu actions
        fileNewAct = self.createAction(self,
                                       "&New",
                                       shortcut=QKeySequence.New,
                                       tooltip="Create a new note",
                                       enabled=True,
                                       slot=self.onNewClick)
        fileOpenRecentNotesAct = self.createAction(self,
                                                   "&Open Recent Note",
                                                   tooltip="open recent notes",
                                                   enabled=True,
                                                   slot=self.onOpenRecentNotes)
        fileQuitAct = self.createAction(self,
                                        "&Exit",
                                        shortcut=QKeySequence.Quit,
                                        tooltip="Exit the application",
                                        enabled=True,
                                        slot=self.close)

        # recent files menu actions
        self.recentFilesMenuAct = self.createAction(self.recentNotesMenu,
                                                    "File 1")

        # edit menu actions
        editInsertAct = self.createAction(self,
                                          "Ins&ert...",
                                          shortcut="Ctrl+I",
                                          tooltip="Insert a media file",
                                          enabled=True)
        editPreferencesAct = self.createAction(
            self,
            "&Preferences",
            shortcut="Ctrl+Shift+P",
            tooltip="Set application preferences",
            enabled=True)
        editFindAct = self.createAction(self,
                                        "&Find",
                                        shortcut=QKeySequence.Find,
                                        tooltip="Find a text string",
                                        slot=self.onFind)
        editUndoAct = self.createAction(
            self,
            "&Undo",
            shortcut=QKeySequence.Undo,
            tooltip="Roll back changes to document",
            slot=self.onUndo)
        editRedoAct = self.createAction(self,
                                        "&Redo",
                                        shortcut=QKeySequence.Redo,
                                        tooltip="Repeat the last action",
                                        slot=self.onRedo)
        editRenameAct = self.createAction(self,
                                          "&Rename...",
                                          shortcut="Ctrl+Shift+R",
                                          tooltip="Rename current note",
                                          slot=self.onRenameNote)

        # sync menu actions
        synCloudAcctAct = self.createAction(self,
                                            "Cloud &Account",
                                            shortcut="Alt+A",
                                            tooltip="Sync with cloud accounts",
                                            enabled=True)

        # help menu actions
        helpHelpAct = self.createAction(self,
                                        "Help",
                                        shortcut=QKeySequence.HelpContents,
                                        tooltip="Display help",
                                        enabled=True,
                                        slot=self.onHelpHelp)
        helpAboutAct = self.createAction(self,
                                         "A&bout",
                                         shortcut="Ctrl+Shift+B",
                                         tooltip="About application",
                                         enabled=True,
                                         slot=self.onHelpAbout)

        boldTextAction = self.createAction(self,
                                           "B",
                                           shortcut="Ctrl+B",
                                           tooltip="Bold text")
        italicsTextAction = self.createAction(self,
                                              "<i>I</i>",
                                              shortcut="Ctrl+I",
                                              tooltip="Italics text")
        # endregion

        # add actions to corresponding menu
        self.addActions_(
            self.fileMenu,
            (fileNewAct, fileOpenRecentNotesAct, fileQuitAct))  # to file menu
        self.addActions_(self.editMenu,
                         (editRenameAct, editUndoAct, editRedoAct, editFindAct,
                          editInsertAct, editPreferencesAct))  # to edit menu
        self.addActions_(self.helpMenu,
                         (helpHelpAct, helpAboutAct))  # to help menu
        self.addActions_(self.recentNotesMenu, (self.recentFilesMenuAct, ))
        # create tool bar and add relevant actions
        allToolBar = self.addToolBar(
            "All Tools"
        )  # tool bar that contains all tool;not separated into file/edit/*
        self.addActions_(allToolBar,
                         (fileNewAct, synCloudAcctAct, editInsertAct,
                          editFindAct, editUndoAct, editRedoAct))

        fontDetailsToolBar = self.addToolBar("Font Details")
        self.fontTypeComboBox = QFontComboBox(
            fontDetailsToolBar)  # get font list present on the user system
        self.fontSizeSpinBox = QSpinBox(fontDetailsToolBar)  # size of the font
        self.fontSizeSpinBox.setMinimum(7)
        self.fontSizeSpinBox.setValue(12)
        self.textBoldButton = QPushButton("B")
        self.addNewNoteButton = QPushButton("+")
        self.textItalicsButton = QPushButton("I")
        maskLabel = QLabel(
            fontDetailsToolBar)  # TODO: experimental, to be removed
        pixmap = QPixmap("Asset/guit.png")  # TODO: experimental, remove
        maskLabel.setPixmap(pixmap.mask())  # TODO: experimental, remove
        self.addWidgetToToolBar(fontDetailsToolBar,
                                (self.fontTypeComboBox, self.fontSizeSpinBox,
                                 self.textBoldButton, self.textItalicsButton))
        # self.addActions_(fontDetailsToolBar, (boldTextAction, italicsTextAction))

        # create a QTabWidget
        self.tabWidget = QTabWidget(self)
        self.tabWidget.setMovable(True)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.setTabPosition(QTabWidget.South)
        # self.setTabPosition(Qt.BottomDockWidgetArea, QTabWidget.South)  # TODO: not working yet. Handled
        self.tabWidgetTabBar = self.tabWidget.tabBar()
        self.tabWidget.setCornerWidget(self.addNewNoteButton,
                                       Qt.TopRightCorner)

        # create pages  # TODO:     let an event handler handle this job: HANDLED
        self.onWindowStartOpenNote()
        # self.page1 = View.TabbedPage.TabbedPage(self, Note("First", "/path"))
        # # add the pages to the tab Widget
        # self.tabWidget.addTab(self.page1, "Note 1 ")
        # self.currentPage = self.tabWidget.currentWidget()
        self.setCurrentPage()
        #        print("count() returned: ", self.tabWidget.count())

        # create "+" bar:  TODO: find a better way to create a plus tab: DONE
        # self.plusTabIndex = self.tabWidgetTabBar.insertTab(self.tabWidget.count() + 1,
        #                                         "+")  # this tab bears the "+" sign that indicates 'create new tab'
        # self.plusTabWidget = self.tabWidget.widget(self.plusTabIndex)  # get a reference to the plus tab widget

        # create Dock widget that holds find dialog
        # self.dockWidget = QDockWidget(self)
        # self.dockWidget.setAllowedAreas(Qt.TopDockWidgetArea)
        # self.dockWidget.setFeatures(QDockWidget.DockWidgetClosable|QDockWidget.DockWidgetMovable)
        # self.dockWidget.setWidget(FindDialog.FindDialog(self.currentPage, self))
        # self.dockWidget.hide()

        # do window namings and other stuffs
        self.statusbar = QStatusBar(self)
        self.statusbar.setSizeGripEnabled(False)
        self.setStatusBar(self.statusbar)
        self.setCentralWidget(self.tabWidget)
        self.setWindowTitle("Notes")

        # region Signal And Slot Bindings
        self.tabWidget.currentChanged.connect(self.setCurrentPage)
        # self.currentPage.firstTime.connect(self.openPageOnFirstNavigation)
        self.tabWidget.currentChanged.connect(
            self.notifyMediatorOfCurrentPageChange)
        # fileNewAct.triggered.connect(self.onNewClick)
        # fileQuitAct.triggered.connect(self.close)
        self.tabWidget.tabCloseRequested.connect(
            self.confirmTabCloseAndCloseTab)
        # self.tabWidget.tabCloseRequested.connect(self.holla)
        self.fontTypeComboBox.currentFontChanged.connect(self.changeFont)
        self.fontSizeSpinBox.valueChanged.connect(self.changeFontSize)
        self.textBoldButton.clicked.connect(self.toggleTextBold)
        self.textItalicsButton.clicked.connect(self.toggleTextItalics)
        timer.timeout.connect(self.onSaveClick)
        timer.timeout.connect(self.timed)
        self.addNewNoteButton.clicked.connect(self.onNewClick)
        self.currentPage.cursorPositionChanged.connect(
            self.reportCurrentCursor)
        self.recentNotesMenu.aboutToShow.connect(self.updateRecentNotesMenu)
        # editUndoAct.triggered.connect(self.currentPage.undo)
        # editRedoAct.triggered.connect(self.currentPage.redo)
        # endregion

        self.readSettings()
        # QTimer.singleShot(5000, self.onSaveClick)
        # Start the timer
        timer.start(1500000)