mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Cleanup
This commit is contained in:
parent
6c19b02888
commit
fa82a4aff3
3 changed files with 36 additions and 40 deletions
|
@ -201,7 +201,6 @@ Application::Application(int &argc, char **argv)
|
||||||
|
|
||||||
setApplicationName(_theme->appName());
|
setApplicationName(_theme->appName());
|
||||||
setWindowIcon(_theme->applicationIcon());
|
setWindowIcon(_theme->applicationIcon());
|
||||||
setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
|
|
||||||
if (!ConfigFile().exists()) {
|
if (!ConfigFile().exists()) {
|
||||||
// Migrate from version <= 2.4
|
// Migrate from version <= 2.4
|
||||||
|
|
|
@ -41,20 +41,45 @@
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char TOOLBAR_CSS[] =
|
const QString TOOLBAR_CSS()
|
||||||
"QToolBar { background: %1; margin: 0; padding: 0; border: none; border-bottom: 0 solid %2; spacing: 0; } "
|
{
|
||||||
"QToolBar QToolButton { background: %1; border: none; border-bottom: 0 solid %2; margin: 0; padding: 5px; } "
|
return QStringLiteral("QToolBar { background: %1; margin: 0; padding: 0; border: none; border-bottom: 1px solid %2; spacing: 0; } "
|
||||||
"QToolBar QToolBarExtension { padding:0; } "
|
"QToolBar QToolButton { background: %1; border: none; border-bottom: 1px solid %2; margin: 0; padding: 5px; } "
|
||||||
"QToolBar QToolButton:checked { background: %3; color: %4; }";
|
"QToolBar QToolBarExtension { padding:0; } "
|
||||||
|
"QToolBar QToolButton:checked { background: %3; color: %4; }");
|
||||||
|
}
|
||||||
|
|
||||||
static const float buttonSizeRatio = 1.618f; // golden ratio
|
const float buttonSizeRatio = 1.618f; // golden ratio
|
||||||
|
|
||||||
|
|
||||||
|
/** display name with two lines that is displayed in the settings
|
||||||
|
* If width is bigger than 0, the string will be ellided so it does not exceed that width
|
||||||
|
*/
|
||||||
|
QString shortDisplayNameForSettings(OCC::Account *account, int width)
|
||||||
|
{
|
||||||
|
QString user = account->davDisplayName();
|
||||||
|
if (user.isEmpty()) {
|
||||||
|
user = account->credentials()->user();
|
||||||
|
}
|
||||||
|
QString host = account->url().host();
|
||||||
|
int port = account->url().port();
|
||||||
|
if (port > 0 && port != 80 && port != 443) {
|
||||||
|
host.append(QLatin1Char(':'));
|
||||||
|
host.append(QString::number(port));
|
||||||
|
}
|
||||||
|
if (width > 0) {
|
||||||
|
QFont f;
|
||||||
|
QFontMetrics fm(f);
|
||||||
|
host = fm.elidedText(host, Qt::ElideMiddle, width);
|
||||||
|
user = fm.elidedText(user, Qt::ElideRight, width);
|
||||||
|
}
|
||||||
|
return QStringLiteral("%1\n%2").arg(user, host);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
|
|
||||||
#include "settingsdialogcommon.cpp"
|
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
|
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, _ui(new Ui::SettingsDialog)
|
, _ui(new Ui::SettingsDialog)
|
||||||
|
@ -224,7 +249,7 @@ void SettingsDialog::accountAdded(AccountState *s)
|
||||||
|
|
||||||
if (!brandingSingleAccount) {
|
if (!brandingSingleAccount) {
|
||||||
accountAction->setToolTip(s->account()->displayName());
|
accountAction->setToolTip(s->account()->displayName());
|
||||||
accountAction->setIconText(SettingsDialogCommon::shortDisplayNameForSettings(s->account().data(), qRound(height * buttonSizeRatio)));
|
accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), height * buttonSizeRatio));
|
||||||
}
|
}
|
||||||
|
|
||||||
_toolBar->insertAction(_actionBefore, accountAction);
|
_toolBar->insertAction(_actionBefore, accountAction);
|
||||||
|
@ -273,7 +298,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
|
||||||
QString displayName = account->displayName();
|
QString displayName = account->displayName();
|
||||||
action->setText(displayName);
|
action->setText(displayName);
|
||||||
auto height = _toolBar->sizeHint().height();
|
auto height = _toolBar->sizeHint().height();
|
||||||
action->setIconText(SettingsDialogCommon::shortDisplayNameForSettings(account, qRound(height * buttonSizeRatio)));
|
action->setIconText(shortDisplayNameForSettings(account, height * buttonSizeRatio));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +342,7 @@ void SettingsDialog::customizeStyle()
|
||||||
QString highlightTextColor(palette().highlightedText().color().name());
|
QString highlightTextColor(palette().highlightedText().color().name());
|
||||||
QString dark(palette().dark().color().name());
|
QString dark(palette().dark().color().name());
|
||||||
QString background(palette().base().color().name());
|
QString background(palette().base().color().name());
|
||||||
_toolBar->setStyleSheet(QString::fromLatin1(TOOLBAR_CSS).arg(background, dark, highlightColor, highlightTextColor));
|
_toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));
|
||||||
|
|
||||||
Q_FOREACH (QAction *a, _actionGroup->actions()) {
|
Q_FOREACH (QAction *a, _actionGroup->actions()) {
|
||||||
QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
|
QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
namespace SettingsDialogCommon
|
|
||||||
{
|
|
||||||
|
|
||||||
/** display name with two lines that is displayed in the settings
|
|
||||||
* If width is bigger than 0, the string will be elided so it does not exceed that width
|
|
||||||
*/
|
|
||||||
QString shortDisplayNameForSettings(Account* account, int width)
|
|
||||||
{
|
|
||||||
QString user = account->davDisplayName();
|
|
||||||
if (user.isEmpty()) {
|
|
||||||
user = account->credentials()->user();
|
|
||||||
}
|
|
||||||
QString host = account->url().host();
|
|
||||||
int port = account->url().port();
|
|
||||||
if (port > 0 && port != 80 && port != 443) {
|
|
||||||
host.append(QLatin1Char(':'));
|
|
||||||
host.append(QString::number(port));
|
|
||||||
}
|
|
||||||
if (width > 0) {
|
|
||||||
QFont f;
|
|
||||||
QFontMetrics fm(f);
|
|
||||||
host = fm.elidedText(host, Qt::ElideMiddle, width);
|
|
||||||
user = fm.elidedText(user, Qt::ElideRight, width);
|
|
||||||
}
|
|
||||||
return user + QLatin1String("\n") + host;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue