Skip to content

Commit

Permalink
add a button in the notification window to open default email
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Nov 4, 2022
1 parent 8f4ac74 commit 824ad2a
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 204 deletions.
96 changes: 62 additions & 34 deletions src/qcheckgmail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,30 @@ qCheckGMail::qCheckGMail( const qCheckGMail::args& args ) :
m_dbusInterface( a,b,c,m_dbusConnection )
{
m_networkRequest.setRawHeader( "Content-Type","application/x-www-form-urlencoded" ) ;

m_dbusConnection.connect( a,b,c,"NotificationClosed",
this,SLOT( handleSignal( quint32,quint32 ) ) ) ;
this,SLOT( notificationClosed( quint32,quint32 ) ) ) ;

m_dbusConnection.connect( a,b,c,"ActionInvoked",
this,SLOT( actionInvoked( quint32,QString ) ) ) ;

auto m = m_dbusInterface.call( "GetCapabilities" ).arguments() ;

if( m.size() > 0 ){

auto s = m.first().toStringList() ;

if( s.size() > 0 ){

auto e = "Pop Notification Has Following Capabilities:\n" ;

m_logWindow.update( logWindow::TYPE::INFO,e + s.join( ", " ),true ) ;
}else{
auto e = "Pop Notification Has No Capabilities" ;

m_logWindow.update( logWindow::TYPE::INFO,e,true ) ;
}
}
}

qCheckGMail::~qCheckGMail()
Expand Down Expand Up @@ -192,39 +214,31 @@ void qCheckGMail::start()
this->getAccountsInfo() ;
}

static void _start_detached( logWindow& logger,QString& exe,const QString& url )
void qCheckGMail::openMail()
{
if( exe.isEmpty() ){
if( !m_defaultApplication.isEmpty() ){

return ;
}
auto url = "https://mail.google.com/" ;

if( exe == "browser" ){
if( m_defaultApplication == "browser" ){

QDesktopServices::openUrl( QUrl( url ) ) ;
}else{
exe.replace( "%{url}",url ) ;
QDesktopServices::openUrl( QUrl( url ) ) ;
}else{
auto e = m_defaultApplication ;

auto s = util::splitPreserveQuotes( exe ) ;
e.replace( "%{url}",url ) ;

auto m = s.takeAt( 0 ) ;
auto s = util::splitPreserveQuotes( e ) ;

auto e = "Running Command\n" + exe + " " + s.join( " " ) ;
auto m = s.takeAt( 0 ) ;

logger.update( logWindow::TYPE::INFO,e ) ;
e = "Running Command\n" + e + " " + s.join( " " ) ;

QProcess::startDetached( m,s ) ;
}
}
m_logWindow.update( logWindow::TYPE::INFO,e ) ;

void qCheckGMail::openMail( const accounts& )
{
_start_detached( m_logWindow,m_defaultApplication,"https://mail.google.com/" ) ;
}

void qCheckGMail::openMail()
{
_start_detached( m_logWindow,m_defaultApplication,"https://mail.google.com/" ) ;
QProcess::startDetached( m,s ) ;
}
}
}

void qCheckGMail::addActionsToMenu()
Expand Down Expand Up @@ -606,6 +620,9 @@ void qCheckGMail::visualNotify()
auto a = static_cast< qint32 >( m_notificationTimeOut ) ;
auto aa = "qCheckGMail" ;

l.append( "defaultInbox" ) ;
l.append( tr( "Open Default Inbox" ) ) ;

auto result = m_dbusInterface.call( "Notify",aa,m_dbusId,"",m,e,l,mm,a ) ;

auto s = result.arguments() ;
Expand All @@ -618,6 +635,27 @@ void qCheckGMail::visualNotify()
}
}

void qCheckGMail::actionInvoked( quint32 u,QString s )
{
if( u == m_dbusId ){

if( s == "defaultInbox" ){

this->openMail() ;
}
}
}

void qCheckGMail::notificationClosed( quint32 id,quint32 reason )
{
Q_UNUSED( reason )

if( id == m_dbusId ){

m_dbusId = 0 ;
}
}

void qCheckGMail::doneCheckingMail()
{
if( m_errorOccured ){
Expand Down Expand Up @@ -1298,16 +1336,6 @@ QString qCheckGMail::defaultApplication()
return m_defaultApplication ;
}

void qCheckGMail::handleSignal( quint32 id,quint32 reason )
{
Q_UNUSED( reason )

if( id == m_dbusId ){

m_dbusId = 0 ;
}
}

void qCheckGMail::configureAccounts()
{
class meaw : public addaccount::gMailInfo
Expand Down
4 changes: 2 additions & 2 deletions src/qcheckgmail.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class qCheckGMail : public QObject
QWidget * widget() ;
QString defaultApplication() ;
private slots:
void handleSignal( quint32,quint32 ) ;
void notificationClosed( quint32,quint32 ) ;
void actionInvoked( quint32,QString ) ;
private:
void start() ;
void configurationWindowClosed( int ) ;
Expand Down Expand Up @@ -127,7 +128,6 @@ private slots:
void checkMail( int,const accounts& acc ) ;
void checkMail() ;
void checkMail( bool ) ;
void openMail( const accounts& acc ) ;
void openMail() ;
void changeIcon( const QString& icon ) ;
void changeIcon( const QString& icon,int ) ;
Expand Down
61 changes: 33 additions & 28 deletions translations.ts/dutch_NL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../src/qcheckgmail.cpp" line="1009"/>
<location filename="../src/qcheckgmail.cpp" line="1056"/>
<source>Unknown GMail Error</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -142,117 +142,122 @@ FOUT: minimum tijdinterval is 1 minuut</translation>
<context>
<name>qCheckGMail</name>
<message>
<location filename="../src/qcheckgmail.cpp" line="191"/>
<location filename="../src/qcheckgmail.cpp" line="1267"/>
<location filename="../src/qcheckgmail.cpp" line="213"/>
<location filename="../src/qcheckgmail.cpp" line="1314"/>
<source>Status</source>
<translation>Status</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="191"/>
<location filename="../src/qcheckgmail.cpp" line="213"/>
<source>Opening Wallet</source>
<translation>Portefeuille openen</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="274"/>
<location filename="../src/qcheckgmail.cpp" line="288"/>
<source>Show Log Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="236"/>
<location filename="../src/qcheckgmail.cpp" line="250"/>
<source>Check Mail Now</source>
<translation>Mail nu controleren</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="241"/>
<location filename="../src/qcheckgmail.cpp" line="255"/>
<source>Pause Checking Mail</source>
<translation>Mailcontrole onderbreken</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="254"/>
<location filename="../src/qcheckgmail.cpp" line="268"/>
<source>Configure Accounts</source>
<translation>Accounts instellen</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="259"/>
<location filename="../src/qcheckgmail.cpp" line="273"/>
<source>Configure Password</source>
<translation>Wachtwoord instellen</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="269"/>
<location filename="../src/qcheckgmail.cpp" line="283"/>
<source>Configure Options</source>
<translation>Opties instellen</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="298"/>
<location filename="../src/qcheckgmail.cpp" line="312"/>
<source>Operation Cancelled</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="302"/>
<location filename="../src/qcheckgmail.cpp" line="316"/>
<source>Host Not Found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="306"/>
<location filename="../src/qcheckgmail.cpp" line="320"/>
<source>Network TimeOut</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="852"/>
<location filename="../src/qcheckgmail.cpp" line="624"/>
<source>Open Default Inbox</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="899"/>
<source>Unexpected Data Received</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="1350"/>
<location filename="../src/qcheckgmail.cpp" line="1387"/>
<source>Account Related Error Was Detected</source>
<translation>Probleem met het account gedetecteerd</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="538"/>
<location filename="../src/qcheckgmail.cpp" line="552"/>
<source>Found 1 New Email</source>
<translation>1 email gevonden</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="542"/>
<location filename="../src/qcheckgmail.cpp" line="587"/>
<location filename="../src/qcheckgmail.cpp" line="556"/>
<location filename="../src/qcheckgmail.cpp" line="610"/>
<source>Found %1 New Emails</source>
<translation>%1 nieuwe emails gevonden</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="561"/>
<location filename="../src/qcheckgmail.cpp" line="575"/>
<source>No New Email Found</source>
<translation>Geen nieuwe emails gevonden</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="737"/>
<location filename="../src/qcheckgmail.cpp" line="743"/>
<location filename="../src/qcheckgmail.cpp" line="784"/>
<location filename="../src/qcheckgmail.cpp" line="790"/>
<source>Checking For Email Updates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="1216"/>
<location filename="../src/qcheckgmail.cpp" line="1263"/>
<source>Missing Refresh Token</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="1281"/>
<location filename="../src/qcheckgmail.cpp" line="1328"/>
<source>%1 Seconds Network TimeOut</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="1351"/>
<location filename="../src/qcheckgmail.cpp" line="1388"/>
<source>No Account Appear To Be Configured In The Wallet</source>
<translation>Er is blijkbaar geen account in de portefeuille ingesteld</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="1457"/>
<location filename="../src/qcheckgmail.cpp" line="1473"/>
<location filename="../src/qcheckgmail.cpp" line="1494"/>
<location filename="../src/qcheckgmail.cpp" line="1510"/>
<source>another instance is already running,exiting this one</source>
<translation>Een ander exemplaar is reeds actief, deze wordt afgesloten</translation>
</message>
<message>
<location filename="../src/qcheckgmail.cpp" line="1492"/>
<location filename="../src/qcheckgmail.cpp" line="1508"/>
<location filename="../src/qcheckgmail.cpp" line="1529"/>
<location filename="../src/qcheckgmail.cpp" line="1545"/>
<source>Autostart Disabled,Exiting This One</source>
<translation>Automatisch starten is uitgeschakeld, deze wordt afgesloten</translation>
</message>
Expand Down
Loading

0 comments on commit 824ad2a

Please sign in to comment.