Skip to content

Commit

Permalink
Update version 2.4 - 2022/02/22
Browse files Browse the repository at this point in the history
  • Loading branch information
mxnt10 committed Feb 22, 2022
1 parent b68e269 commit 401b723
Show file tree
Hide file tree
Showing 23 changed files with 489 additions and 86 deletions.
27 changes: 27 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ All notable changes to this project will be documented in this file.
Todas as mudanças notáveis neste projeto serão documentadas neste arquivo.


## [ 2.4 ] - 2022-02-20 #############################################

### Added / Adicionado
- Added notification sound themes.
###


## [ 2.3 ] - 2022-02-20 #############################################

### Added / Adicionado
- Translator Support.
- Options for test notification sound selected.
###

### Changed / Modificado
- Changed install.sh for start webapp using nvidia driver.
- Search for new messages every 800 ms.
- Search for new messages in a new process using multitreading.
###

### Fixed / Corrigido
- Fixed settings for select checkbox to check update.
###

#####################################################################


## [ 2.2 ] - 2022-01-08 #############################################

### Added / Adicionado
Expand Down
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2
2.4
2 changes: 1 addition & 1 deletion common/clean_cache
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

cd ../src || exit

rm -r __pycache__
rm -rf __pycache__
4 changes: 2 additions & 2 deletions common/clean_conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

rm -r ~/.config/Insta
rm -r ~/.local/share/Insta
rm -rf ~/.config/Insta
rm -rf ~/.local/share/Insta
14 changes: 10 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@ install_root=${install_root:-""}

set -e
[ "$install_root" != "" ] && {
mkdir -p "$install_root"/usr/{bin,share/{applications,pixmaps,"$PRGNAM"/{icon_status,sound}},doc/"$PRGNAM"-"$VERSION"}
mkdir -p "$install_root"/usr/{bin,share/{applications,pixmaps,"$PRGNAM"/{icon_status,sound,translate}},doc/"$PRGNAM"-"$VERSION"}
} || {
mkdir -p /usr/{share/"$PRGNAM"/{icon_status,sound},doc/"$PRGNAM"-"$VERSION"}
mkdir -p /usr/{share/"$PRGNAM"/{icon_status,sound,translate},doc/"$PRGNAM"-"$VERSION"}
}

install -Dm 0644 appdata/"$PRGNAM".svg "$install_root"/usr/share/pixmaps
install -Dm 0644 appdata/"$PRGNAM".png "$install_root"/usr/share/pixmaps
install -Dm 0644 appdata/"$PRGNAM".desktop "$install_root"/usr/share/applications
install -Dm 0644 icon_status/* "$install_root"/usr/share/"$PRGNAM"/icon_status
install -Dm 0644 translate/*.qm "$install_root"/usr/share/"$PRGNAM"/translate
install -Dm 0644 sound/* "$install_root"/usr/share/"$PRGNAM"/sound

cp -a ChangeLog LICENSE README.md "$install_root"/usr/doc/"$PRGNAM"-"$VERSION"
cp -Tr src "$install_root"/usr/share/"$PRGNAM"

echo "#!/bin/bash
cd /usr/share/$PRGNAM
python3 main.py" > "$install_root"/usr/bin/"$PRGNAM"
[ \"\$(grep -E \"nouveau|nvidia\" <(lsmod))\" ] && {
LIBGL_ALWAYS_SOFTWARE=1 python3 main.py
} || {
python3 main.py
}" > "$install_root"/usr/bin/"$PRGNAM"

chmod 755 "$install_root"/usr/bin/"$PRGNAM"
exit 0
Binary file added sound/logon7.wav
Binary file not shown.
Binary file added sound/notification.mp3
Binary file not shown.
Binary file added sound/notify7.wav
Binary file not shown.
Binary file added sound/notifyXP.mp3
Binary file not shown.
Binary file added sound/spining.mp3
Binary file not shown.
15 changes: 8 additions & 7 deletions src/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Módulos do PyQt5
from PyQt5.QtCore import Qt, QEvent
from PyQt5.QtGui import QPixmap
from PyQt5.QtGui import QPixmap, QPainter
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel

# Modulos integrados (src)
Expand All @@ -17,7 +17,7 @@
class AboutDialog(QDialog):
def __init__(self):
super(AboutDialog, self).__init__()
self.setWindowTitle('About ' + __appname__)
self.setWindowTitle(self.tr('About') + ' ' + __appname__)
self.setFixedSize(0, 0)

# Título e Logo
Expand All @@ -26,16 +26,17 @@ def __init__(self):
font.setPointSize(20)
title.setFont(font)
logo = QLabel()
logo.setPixmap(QPixmap(setIcon('original')))
pixmap = QPixmap(setIcon('original'))
logo.setPixmap(pixmap.scaled(128, 128))

# Layout com as informações
layout = QVBoxLayout()
layout.addWidget(title)
layout.addWidget(logo)
layout.addWidget(QLabel('Version ' + __version__ + '\n'))
layout.addWidget(QLabel('Maintainer: Mauricio Ferrari'))
layout.addWidget(QLabel('Contact: m10ferrari1200@gmail.com'))
layout.addWidget(QLabel('License: GNU General Public License Version 3 (GLPv3)\n'))
layout.addWidget(QLabel(self.tr('Version') + ' ' + __version__ + '\n'))
layout.addWidget(QLabel(self.tr('Maintainer') + ': Mauricio Ferrari'))
layout.addWidget(QLabel(self.tr('Contact') + ': m10ferrari1200@gmail.com'))
layout.addWidget(QLabel(self.tr('License') + ': GNU General Public License Version 3 (GLPv3)\n'))

for i in range(0, layout.count()): # Definindo os widgets no centro
layout.itemAt(i).setAlignment(Qt.AlignHCenter)
Expand Down
2 changes: 1 addition & 1 deletion src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


# Link para pegar o userAgent: http://httpbin.org/user-agent
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36'
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36'


# A ideia dessa função é prevenir a mensagem de novegador desatualizado mesmo que o agent user seja utilizado.
Expand Down
2 changes: 1 addition & 1 deletion src/jsonTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"DarkMode": False,
"NotifyMessage": False,
"NotifySound": False,
"VerifyNotify": 200,
"VerifyNotify": 800,
"TimeMessage": 5000,
"SoundTheme": "message",
"Opacity": 100,
Expand Down
79 changes: 60 additions & 19 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
from threading import Thread

# Módulos do PyQt5
from PyQt5.QtCore import QUrl, QFileInfo, pyqtSlot, QMargins, Qt, QEvent, QTimer, pyqtSignal
from PyQt5.QtGui import QIcon, QDesktopServices
from PyQt5.QtCore import QUrl, QFileInfo, pyqtSlot, QMargins, Qt, QEvent, QTimer, pyqtSignal, QTranslator
from PyQt5.QtGui import QIcon, QDesktopServices, QKeySequence
from PyQt5.QtMultimedia import QMediaPlayer
from PyQt5.QtWebEngineWidgets import (QWebEngineView, QWebEnginePage, QWebEngineDownloadItem, QWebEngineSettings,
QWebEngineProfile)
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QSystemTrayIcon, QMenu, QAction
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QSystemTrayIcon, QMenu, QAction, QShortcut

# Modulos integrados (src)
from about import AboutDialog
from agent import user_agent, prevent
from jsonTools import checkSettings, set_json, write_json
from notify import verifyNotify
from setting import SettingDialog
from utils import setIcon, checkUpdate
from utils import setIcon, checkUpdate, setTranslate
from version import __appname__, __pagename__, __url__, __desktop__, __err__

# Variáveis globais
Expand All @@ -39,6 +39,7 @@
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.textUpdate1 = self.textUpdate2 = self.textUpdate3 = self.message1 = self.message2 = self.res = None
self.start = self.notify_start = self.reload_start = self.ckUpdate = False
self.notify = self.changeTray = self.soma = 0

Expand Down Expand Up @@ -79,15 +80,29 @@ def __init__(self):
self.changeOpacity()
self.changeFont()

# Teclas de atalho
self.shortcut1 = QShortcut(QKeySequence(Qt.ControlModifier + Qt.Key_R), self)
self.shortcut1.activated.connect(lambda: self.view.load(QUrl(__url__)))
self.shortcut2 = QShortcut(QKeySequence(Qt.ControlModifier + Qt.Key_Q), self)
self.shortcut2.activated.connect(app.quit)
self.shortcut3 = QShortcut(QKeySequence(Qt.AltModifier + Qt.Key_S), self)
self.shortcut3.activated.connect(self.view.showSettings)

# Criando o tray icon
self.tray = QSystemTrayIcon()
self.tray.activated.connect(self.onTrayIconActivated)
self.tray.setIcon(QIcon(setIcon('warning')))

# Itens para o menu do tray icon
self.trayHide = QAction('Hide', self)
self.trayShow = QAction('Show', self)
self.trayExit = QAction('Exit', self)
self.trayHide = QAction(self.tr('Hide'), self)
self.trayShow = QAction(self.tr('Show'), self)
self.trayExit = QAction(self.tr('Exit'), self)

# Ícones para o menu do tray icon
self.trayHide.setIcon(QIcon.fromTheme('go-down'))
self.trayShow.setIcon(QIcon.fromTheme('go-up'))
self.trayExit.setIcon(QIcon.fromTheme('application-exit'))
self.trayExit.setShortcut('Ctrl+Q')

# Funções para as opções do menu do tray icon
self.trayHide.triggered.connect(self.on_hide)
Expand Down Expand Up @@ -143,9 +158,9 @@ def changeStatusBar(self):
self.statusBar().hide()


# Função que manipula o código-fonte do webapp para checar as mensagens não lidas, emitindo sons,
# exibindo mensagens e alterando o ícone de notificação.
def processHtml(self, htm):
# Função que possui o objetivo de ser executada como um thead independentepara resolver problemas
# de lentidão durante o uso do webapp.
def bs(self, htm, num):
try:
res = html.fromstring(htm)
title = res.xpath('//title')
Expand All @@ -167,6 +182,15 @@ def processHtml(self, htm):
warning('\033[33m %s.\033[m', err)


# Função que manipula o código-fonte do webapp para a checagem das mensagens não lidas, emitindo sons,
# exibindo mensagens e alterando o ícone de notificação.
def processHtml(self, htm):
self.message1 = self.tr('Unread messages.') # Textos definidos aqui por conta da tradução
self.message2 = self.tr('Unread message.')
t = Thread(name='scratch', target=self.bs, args=(htm, 1))
t.start()


# Mostra os links ao passar o mouse sobre eles no statusBar e captura o link numa variável.
def link_hovered(self, link):
if set_json('StatusBar'):
Expand Down Expand Up @@ -194,6 +218,9 @@ def loaded(self):
self.notify_loop.start()
self.notify_start = True # Não precisa ficar reativando o som cada vez que o webapp é recarregado
if set_json('CheckUpdate') and not self.ckUpdate:
self.textUpdate1 = self.tr('Update available') # Textos definidos aqui por conta da tradução
self.textUpdate2 = self.tr('A new version is available')
self.textUpdate3 = self.tr('New version')
t = Thread(name='update', target=checkUpdate, args=(self, 1))
t.start()
self.ckUpdate = True
Expand Down Expand Up @@ -267,18 +294,29 @@ def __init__(self):
self.settings().setAttribute(QWebEngineSettings.AutoLoadImages, True)
self.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)

# Necessary to map mouse event
# Necessário para maear os eventos de mouse
QApplication.instance().installEventFilter(self)
self.setMouseTracking(True)

# Define items for create custom menu
self.menuExternal = QAction('Open link in the browser')
self.menuLinkClip = QAction('Copy link to clipboard')
self.menuReload = QAction('Reload')
self.menuConfig = QAction('Preferencies')
self.menuAbout = QAction('About')

# Add functions for options menu
# Definindo itens para a criação do menu
self.menuExternal = QAction(self.tr('Open link in the browser'))
self.menuLinkClip = QAction(self.tr('Copy link to clipboard'))
self.menuReload = QAction(self.tr('Reload'))
self.menuConfig = QAction(self.tr('Preferencies'))
self.menuAbout = QAction(self.tr('About'))

# Ícones para o menu
self.menuExternal.setIcon(QIcon.fromTheme('globe'))
self.menuLinkClip.setIcon(QIcon.fromTheme('edit-copy'))
self.menuReload.setIcon(QIcon.fromTheme('view-refresh'))
self.menuConfig.setIcon(QIcon.fromTheme('configure'))
self.menuAbout.setIcon(QIcon.fromTheme('help-about'))

# Teclas de atalho
self.menuReload.setShortcut('Ctrl+R')
self.menuConfig.setShortcut('Alt+S')

# Adicionar funções para as opções de menu
self.menuExternal.triggered.connect(self.externalBrowser)
self.menuLinkClip.triggered.connect(lambda: clipboard.setText(self.save_url, mode=clipboard.Clipboard))
self.menuReload.triggered.connect(lambda: self.setUrl(QUrl(__url__))) # Método melhor
Expand Down Expand Up @@ -396,6 +434,9 @@ def permission(self, frame, feature):
lang = getdefaultlocale()[0]
QWebEngineProfile.defaultProfile().setHttpAcceptLanguage(lang.split('_')[0])
clipboard = app.clipboard()
translate = QTranslator()
translate.load(setTranslate() + '/insta_' + lang.split('_')[0] + '.qm')
app.installTranslator(translate)
main = MainWindow()

# Definindo como o programa será aberto
Expand Down
4 changes: 2 additions & 2 deletions src/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# Função para exibição de notificação.
def notifyMessage(self):
if self.soma > 1:
ms = 'notifications not seen.'
ms = self.message1
else:
ms = 'notification not seen.'
ms = self.message2
com = 'notify-send --app-name="' + __pagename__ + '" --expire-time=' + str(set_json('TimeMessage')) + \
' --icon="' + realpath(setIcon('notify')) + '" "' + str(self.soma) + ' ' + ms + '"'
run(com, shell=True)
Expand Down
Loading

0 comments on commit 401b723

Please sign in to comment.