2012-02-16 13:42:44 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2012-05-21 18:48:49 +04:00
|
|
|
#include "owncloudtheme.h"
|
|
|
|
|
2012-02-16 13:42:44 +04:00
|
|
|
#include <QString>
|
|
|
|
#include <QDebug>
|
2012-02-23 14:44:44 +04:00
|
|
|
#include <QPixmap>
|
2012-05-02 17:50:01 +04:00
|
|
|
#include <QIcon>
|
2012-12-20 19:31:24 +04:00
|
|
|
#include <QStyle>
|
2012-08-02 13:09:37 +04:00
|
|
|
#include <QApplication>
|
2012-02-16 13:42:44 +04:00
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
ownCloudTheme::ownCloudTheme()
|
|
|
|
{
|
2012-02-28 18:13:59 +04:00
|
|
|
// qDebug() << " ** running ownCloud theme!";
|
2012-02-16 13:42:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ownCloudTheme::appName() const
|
|
|
|
{
|
2012-08-03 16:03:57 +04:00
|
|
|
/* If this is changed, existing configs are not found any more
|
|
|
|
* because the value is used by QDesktopServices to find the config
|
|
|
|
* file. Be aware.
|
|
|
|
*/
|
2012-09-27 14:22:27 +04:00
|
|
|
return QLatin1String("ownCloud");
|
2012-02-16 13:42:44 +04:00
|
|
|
}
|
|
|
|
|
2012-02-17 14:11:18 +04:00
|
|
|
QString ownCloudTheme::configFileName() const
|
|
|
|
{
|
2012-08-02 13:17:24 +04:00
|
|
|
return QLatin1String("owncloud.cfg");
|
2012-02-17 14:11:18 +04:00
|
|
|
}
|
2012-02-23 14:44:44 +04:00
|
|
|
|
|
|
|
QPixmap ownCloudTheme::splashScreen() const
|
|
|
|
{
|
2012-08-02 13:17:24 +04:00
|
|
|
return QPixmap(QLatin1String(":/mirall/resources/owncloud_splash.png"));
|
2012-02-23 14:44:44 +04:00
|
|
|
}
|
|
|
|
|
2012-05-02 17:50:01 +04:00
|
|
|
QIcon ownCloudTheme::folderIcon( const QString& backend ) const
|
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
|
2012-08-02 13:17:24 +04:00
|
|
|
if( backend == QLatin1String("owncloud")) {
|
2012-09-25 19:14:21 +04:00
|
|
|
name = QLatin1String( "owncloud-framed" );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
2012-08-02 13:17:24 +04:00
|
|
|
if( backend == QLatin1String("unison" )) {
|
|
|
|
name = QLatin1String( "folder-sync" );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
2012-08-02 13:17:24 +04:00
|
|
|
if( backend == QLatin1String("csync" )) {
|
|
|
|
name = QLatin1String( "folder-remote" );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
2012-08-02 13:17:24 +04:00
|
|
|
if( backend.isEmpty() || backend == QLatin1String("none") ) {
|
|
|
|
name = QLatin1String("folder-grey");
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "==> load folder icon " << name;
|
2012-07-18 19:29:06 +04:00
|
|
|
return themeIcon( name );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
QIcon ownCloudTheme::trayFolderIcon( const QString& ) const
|
|
|
|
{
|
2012-12-20 19:31:24 +04:00
|
|
|
QPixmap fallback = qApp->style()->standardPixmap(QStyle::SP_FileDialogNewFolder);
|
|
|
|
return QIcon::fromTheme("folder", fallback);
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
2012-12-20 19:31:24 +04:00
|
|
|
QIcon ownCloudTheme::syncStateIcon( SyncResult::Status status, bool sysTray ) const
|
2012-05-02 17:50:01 +04:00
|
|
|
{
|
|
|
|
// FIXME: Mind the size!
|
|
|
|
QString statusIcon;
|
|
|
|
|
|
|
|
switch( status ) {
|
|
|
|
case SyncResult::Undefined:
|
|
|
|
case SyncResult::NotYetStarted:
|
2013-01-16 17:39:43 +04:00
|
|
|
case SyncResult::Unavailable:
|
2013-01-09 19:29:50 +04:00
|
|
|
statusIcon = QLatin1String("state-offline");
|
2012-05-02 17:50:01 +04:00
|
|
|
break;
|
|
|
|
case SyncResult::SyncRunning:
|
2013-01-09 19:29:50 +04:00
|
|
|
statusIcon = QLatin1String("state-sync");
|
2012-05-02 17:50:01 +04:00
|
|
|
break;
|
|
|
|
case SyncResult::Success:
|
2013-01-09 19:29:50 +04:00
|
|
|
statusIcon = QLatin1String("state-ok");
|
2012-05-02 17:50:01 +04:00
|
|
|
break;
|
|
|
|
case SyncResult::Error:
|
|
|
|
case SyncResult::SetupError:
|
|
|
|
default:
|
2013-01-09 19:29:50 +04:00
|
|
|
statusIcon = QLatin1String("state-error");
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
2012-12-20 19:31:24 +04:00
|
|
|
return themeIcon( statusIcon, sysTray );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
2012-07-18 19:29:06 +04:00
|
|
|
QIcon ownCloudTheme::folderDisabledIcon( ) const
|
2012-05-02 17:50:01 +04:00
|
|
|
{
|
|
|
|
// Fixme: Do we really want the dialog-canel from theme here?
|
2013-01-16 17:40:06 +04:00
|
|
|
return themeIcon( QLatin1String("state-pause") );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
QIcon ownCloudTheme::applicationIcon( ) const
|
|
|
|
{
|
2013-01-09 19:29:50 +04:00
|
|
|
return themeIcon( QLatin1String("owncloud") );
|
2012-05-02 17:50:01 +04:00
|
|
|
}
|
|
|
|
|
2012-02-16 13:42:44 +04:00
|
|
|
}
|
|
|
|
|