@ -47,9 +47,9 @@
# include <KMessageWidget>
# include <KMessageWidget>
# if KF5_VERSION_MINOR >= 71
# if KF5_VERSION_MINOR >= 71
# include <KIO/OpenUrlJob>
# include <KIO/OpenUrlJob>
# else
# else
# include <KRun>
# include <KRun>
# endif
# endif
namespace Latte {
namespace Latte {
@ -406,11 +406,7 @@ void Views::onCurrentLayoutChanged()
QObject : : disconnect ( var ) ;
QObject : : disconnect ( var ) ;
}
}
Data : : Layout originlayoutdata = m_handler - > layoutsController ( ) - > originalData ( currentlayoutdata . id ) ;
Latte : : CentralLayout * currentlayout = centralLayout ( currentlayoutdata ) ;
auto activelayout = m_handler - > layoutsController ( ) - > isLayoutOriginal ( currentlayoutdata . id ) ?
m_handler - > corona ( ) - > layoutsManager ( ) - > synchronizer ( ) - > centralLayout ( originlayoutdata . name ) : nullptr ;
Latte : : CentralLayout * currentlayout = activelayout ? activelayout : new Latte : : CentralLayout ( this , currentlayoutdata . id ) ;
if ( currentlayout & & currentlayout - > isActive ( ) ) {
if ( currentlayout & & currentlayout - > isActive ( ) ) {
m_currentLayoutConnections < < connect ( currentlayout , & Layout : : GenericLayout : : viewsCountChanged , this , [ & , currentlayout ] ( ) {
m_currentLayoutConnections < < connect ( currentlayout , & Layout : : GenericLayout : : viewsCountChanged , this , [ & , currentlayout ] ( ) {
@ -421,6 +417,17 @@ void Views::onCurrentLayoutChanged()
messagesForErrorsWarnings ( currentlayout ) ;
messagesForErrorsWarnings ( currentlayout ) ;
}
}
CentralLayout * Views : : centralLayout ( const Data : : Layout & currentLayout )
{
Data : : Layout originlayoutdata = m_handler - > layoutsController ( ) - > originalData ( currentLayout . id ) ;
auto activelayout = m_handler - > layoutsController ( ) - > isLayoutOriginal ( currentLayout . id ) ?
m_handler - > corona ( ) - > layoutsManager ( ) - > synchronizer ( ) - > centralLayout ( originlayoutdata . name ) : nullptr ;
Latte : : CentralLayout * centrallayout = activelayout ? activelayout : new Latte : : CentralLayout ( this , currentLayout . id ) ;
return centrallayout ;
}
void Views : : onSelectionsChanged ( )
void Views : : onSelectionsChanged ( )
{
{
bool hasselectedview = hasSelectedView ( ) ;
bool hasselectedview = hasSelectedView ( ) ;
@ -498,7 +505,7 @@ void Views::updateDoubledMoveDestinationRows() {
}
}
}
}
void Views : : messagesForErrorsWarnings ( const Latte : : CentralLayout * centralLayout )
void Views : : messagesForErrorsWarnings ( const Latte : : CentralLayout * centralLayout , const bool & showNoErrorsMessage )
{
{
if ( ! centralLayout ) {
if ( ! centralLayout ) {
return ;
return ;
@ -580,6 +587,14 @@ void Views::messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout)
}
}
}
}
m_handler - > layoutsController ( ) - > setLayoutCurrentErrorsWarnings ( currentdata . id , currentdata . errors , currentdata . warnings ) ;
if ( showNoErrorsMessage & & currentdata . errors = = 0 & & currentdata . warnings = = 0 ) {
m_handler - > showInlineMessage ( i18n ( " Really nice! You are good to go, your layout does not report any errors or warnings. " ) ,
KMessageWidget : : Positive ,
false ) ;
}
}
}
void Views : : showDefaultPersistentErrorWarningInlineMessage ( const QString & messageText ,
void Views : : showDefaultPersistentErrorWarningInlineMessage ( const QString & messageText ,
@ -610,6 +625,7 @@ void Views::showDefaultPersistentErrorWarningInlineMessage(const QString &messag
# else
# else
KRun : : runUrl ( QUrl : : fromLocalFile ( file ) , QStringLiteral ( " text/plain " ) , m_view ) ;
KRun : : runUrl ( QUrl : : fromLocalFile ( file ) , QStringLiteral ( " text/plain " ) , m_view ) ;
# endif
# endif
showDefaultInlineMessageValidator ( ) ;
}
}
} ) ;
} ) ;
}
}
@ -621,6 +637,32 @@ void Views::showDefaultPersistentErrorWarningInlineMessage(const QString &messag
actions ) ;
actions ) ;
}
}
void Views : : showDefaultInlineMessageValidator ( )
{
Data : : Layout currentlayout = m_handler - > currentData ( ) ;
//! add default action to open layout
QAction * validateaction = new QAction ( i18n ( " Validate " ) , this ) ;
validateaction - > setIcon ( QIcon : : fromTheme ( " view-refresh " ) ) ;
validateaction - > setData ( currentlayout . id ) ;
QList < QAction * > actions ;
actions < < validateaction ;
connect ( validateaction , & QAction : : triggered , this , [ & , currentlayout ] ( ) {
auto centrallayout = centralLayout ( currentlayout ) ;
messagesForErrorsWarnings ( centrallayout , true ) ;
} ) ;
QString messagetext = i18n ( " After you have made your layout file changes, please click <b>Validate</b> to confirm them. " ) ;
//! show message
m_handler - > showInlineMessage ( messagetext ,
KMessageWidget : : Warning ,
true ,
actions ) ;
}
void Views : : messageForErrorAppletsWithSameId ( const Data : : Error & error )
void Views : : messageForErrorAppletsWithSameId ( const Data : : Error & error )
{
{
if ( error . id ! = Data : : Error : : APPLETSWITHSAMEID ) {
if ( error . id ! = Data : : Error : : APPLETSWITHSAMEID ) {
@ -758,6 +800,8 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin
return ;
return ;
}
}
QList < int > orphaned ;
//! construct message
//! construct message
QString message = i18nc ( " warning id and title " , " <b>Warning #%0: %1</b> <br/><br/> " ) . arg ( warning . id ) . arg ( warning . name ) ;
QString message = i18nc ( " warning id and title " , " <b>Warning #%0: %1</b> <br/><br/> " ) . arg ( warning . id ) . arg ( warning . name ) ;
message + = i18n ( " In your layout there are orphaned subcontainments that are not used by any dock or panel. Such situation is not dangerous but it is advised to remove them in order to reduce memory usage.<br/> " ) ;
message + = i18n ( " In your layout there are orphaned subcontainments that are not used by any dock or panel. Such situation is not dangerous but it is advised to remove them in order to reduce memory usage.<br/> " ) ;
@ -774,6 +818,8 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin
QString containmentstorageid = warning . information [ i ] . containment . storageId ;
QString containmentstorageid = warning . information [ i ] . containment . storageId ;
message + = i18nc ( " orphaned subcontainments, containment name, containment id " ,
message + = i18nc ( " orphaned subcontainments, containment name, containment id " ,
" • <b>%0</b> [#%1] <br/> " ) . arg ( containmentname ) . arg ( containmentstorageid ) ;
" • <b>%0</b> [#%1] <br/> " ) . arg ( containmentname ) . arg ( containmentstorageid ) ;
orphaned < < warning . information [ i ] . containment . storageId . toInt ( ) ;
}
}
message + = " <br/> " ;
message + = " <br/> " ;
@ -781,14 +827,28 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin
message + = i18n ( " 1. Click <b>Repair</b> button in order to remove orphaned subcontainments<br/> " ) ;
message + = i18n ( " 1. Click <b>Repair</b> button in order to remove orphaned subcontainments<br/> " ) ;
message + = i18n ( " 2. Remove manually orphaned subcontainments when the layout is <b>not active</b><br/> " ) ;
message + = i18n ( " 2. Remove manually orphaned subcontainments when the layout is <b>not active</b><br/> " ) ;
//! add extra action
//! add extra repair action
QAction * repairlayoutaction = new QAction ( i18n ( " Repair " ) , this ) ;
QAction * repairlayoutaction = new QAction ( i18n ( " Repair " ) , this ) ;
repairlayoutaction - > setIcon ( QIcon : : fromTheme ( " dialog-yes " ) ) ;
repairlayoutaction - > setIcon ( QIcon : : fromTheme ( " dialog-yes " ) ) ;
repairlayoutaction - > setEnabled ( false ) ;
QList < QAction * > extraactions ;
QList < QAction * > extraactions ;
extraactions < < repairlayoutaction ;
extraactions < < repairlayoutaction ;
showDefaultPersistentErrorWarningInlineMessage ( message , KMessageWidget : : Warning , extraactions ) ;
Latte : : Data : : Layout currentlayout = m_handler - > currentData ( ) ;
connect ( repairlayoutaction , & QAction : : triggered , this , [ & , currentlayout , orphaned ] ( ) {
auto centrallayout = centralLayout ( currentlayout ) ;
for ( int i = 0 ; i < orphaned . count ( ) ; + + i ) {
centrallayout - > removeOrphanedSubContainment ( orphaned [ i ] ) ;
}
messagesForErrorsWarnings ( centrallayout , true ) ;
} ) ;
//! show message
showDefaultPersistentErrorWarningInlineMessage ( message ,
KMessageWidget : : Warning ,
extraactions ) ;
}
}
void Views : : save ( )
void Views : : save ( )