seafile-applet.cpp (seafile-client-9.0.1) | : | seafile-applet.cpp (seafile-client-9.0.2) | ||
---|---|---|---|---|
skipping to change at line 52 | skipping to change at line 52 | |||
#include "account-info-service.h" | #include "account-info-service.h" | |||
#include "customization-service.h" | #include "customization-service.h" | |||
#if defined(Q_OS_WIN32) | #if defined(Q_OS_WIN32) | |||
#include "ext-handler.h" | #include "ext-handler.h" | |||
#include "utils/registry.h" | #include "utils/registry.h" | |||
#elif defined(HAVE_FINDER_SYNC_SUPPORT) | #elif defined(HAVE_FINDER_SYNC_SUPPORT) | |||
#include "finder-sync/finder-sync-listener.h" | #include "finder-sync/finder-sync-listener.h" | |||
#endif | #endif | |||
#ifdef HAVE_SPARKLE_SUPPORT | ||||
#include "auto-update-service.h" | ||||
#endif | ||||
#if defined(Q_OS_MAC) | #if defined(Q_OS_MAC) | |||
#include "utils/utils-mac.h" | #include "utils/utils-mac.h" | |||
#endif | #endif | |||
#include "seafile-applet.h" | #include "seafile-applet.h" | |||
namespace { | namespace { | |||
enum DEBUG_LEVEL { | enum DEBUG_LEVEL { | |||
DEBUG = 0, | DEBUG = 0, | |||
WARNING | WARNING | |||
skipping to change at line 230 | skipping to change at line 226 | |||
// seafile-applet exit will inform seaf-daemon to clean sync token, | // seafile-applet exit will inform seaf-daemon to clean sync token, | |||
// so the class object deamon_mgr daemon_mgr_ dealloc after account_mgr_. | // so the class object deamon_mgr daemon_mgr_ dealloc after account_mgr_. | |||
delete daemon_mgr_; | delete daemon_mgr_; | |||
delete configurator_; | delete configurator_; | |||
delete data_mgr_; | delete data_mgr_; | |||
if (main_win_) | if (main_win_) | |||
delete main_win_; | delete main_win_; | |||
#if defined(Q_OS_WIN32) | #if defined(Q_OS_WIN32) | |||
SeafileExtensionHandler::instance()->stop(); | SeafileExtensionHandler::instance()->stop(); | |||
#ifdef HAVE_SPARKLE_SUPPORT | ||||
AutoUpdateService::instance()->stop(); | ||||
#endif | ||||
#endif | #endif | |||
} | } | |||
void SeafileApplet::start() | void SeafileApplet::start() | |||
{ | { | |||
refreshQss(); | refreshQss(); | |||
configurator_->checkInit(); | configurator_->checkInit(); | |||
initLog(); | initLog(); | |||
skipping to change at line 403 | skipping to change at line 394 | |||
this, SLOT(updateReposPropertyForHttpSync())); | this, SLOT(updateReposPropertyForHttpSync())); | |||
// | // | |||
// start finder/explorer extension handler | // start finder/explorer extension handler | |||
// | // | |||
#if defined(Q_OS_WIN32) | #if defined(Q_OS_WIN32) | |||
SeafileExtensionHandler::instance()->start(); | SeafileExtensionHandler::instance()->start(); | |||
#elif defined(HAVE_FINDER_SYNC_SUPPORT) | #elif defined(HAVE_FINDER_SYNC_SUPPORT) | |||
finderSyncListenerStart(); | finderSyncListenerStart(); | |||
#endif | #endif | |||
#ifdef HAVE_SPARKLE_SUPPORT | ||||
if (AutoUpdateService::instance()->shouldSupportAutoUpdate()) { | ||||
AutoUpdateService::instance()->start(); | ||||
} | ||||
#endif | ||||
} | } | |||
void SeafileApplet::checkInitVDrive() | void SeafileApplet::checkInitVDrive() | |||
{ | { | |||
if (configurator_->firstUse() && account_mgr_->hasAccount()) { | if (configurator_->firstUse() && account_mgr_->hasAccount()) { | |||
const Account account = account_mgr_->currentAccount(); | const Account account = account_mgr_->currentAccount(); | |||
InitVirtualDriveDialog *dialog = new InitVirtualDriveDialog(account); | InitVirtualDriveDialog *dialog = new InitVirtualDriveDialog(account); | |||
// Move the dialog to the left of the main window | // Move the dialog to the left of the main window | |||
int x = main_win_->pos().x() - dialog->rect().width() - 30; | int x = main_win_->pos().x() - dialog->rect().width() - 30; | |||
int y = (getScreenSize(0).center() - dialog->rect().center()).y(); | int y = (getScreenSize(0).center() - dialog->rect().center()).y(); | |||
skipping to change at line 534 | skipping to change at line 519 | |||
#endif | #endif | |||
} | } | |||
void SeafileApplet::warningBox(const QString& msg, QWidget *parent) | void SeafileApplet::warningBox(const QString& msg, QWidget *parent) | |||
{ | { | |||
QMessageBox box(parent ? parent : main_win_); | QMessageBox box(parent ? parent : main_win_); | |||
box.setText(msg); | box.setText(msg); | |||
box.setWindowTitle(getBrand()); | box.setWindowTitle(getBrand()); | |||
box.setIcon(QMessageBox::Warning); | box.setIcon(QMessageBox::Warning); | |||
box.addButton(tr("OK"), QMessageBox::YesRole); | box.addButton(tr("OK"), QMessageBox::YesRole); | |||
box.setFocusPolicy(Qt::ClickFocus); | ||||
box.exec(); | box.exec(); | |||
if (!parent && main_win_) { | if (!parent && main_win_) { | |||
main_win_->showWindow(); | main_win_->showWindow(); | |||
} | } | |||
qWarning("%s", msg.toUtf8().data()); | qWarning("%s", msg.toUtf8().data()); | |||
} | } | |||
void SeafileApplet::messageBox(const QString& msg, QWidget *parent) | void SeafileApplet::messageBox(const QString& msg, QWidget *parent) | |||
{ | { | |||
QMessageBox box(parent ? parent : main_win_); | QMessageBox box(parent ? parent : main_win_); | |||
box.setText(msg); | box.setText(msg); | |||
box.setWindowTitle(getBrand()); | box.setWindowTitle(getBrand()); | |||
box.setIcon(QMessageBox::Information); | box.setIcon(QMessageBox::Information); | |||
box.addButton(tr("OK"), QMessageBox::YesRole); | box.addButton(tr("OK"), QMessageBox::YesRole); | |||
if (!parent) { | if (!parent) { | |||
main_win_->showWindow(); | main_win_->showWindow(); | |||
} | } | |||
box.setFocusPolicy(Qt::ClickFocus); | ||||
box.exec(); | box.exec(); | |||
qDebug("%s", msg.toUtf8().data()); | qDebug("%s", msg.toUtf8().data()); | |||
} | } | |||
bool SeafileApplet::yesOrNoBox(const QString& msg, QWidget *parent, bool default _val) | bool SeafileApplet::yesOrNoBox(const QString& msg, QWidget *parent, bool default _val) | |||
{ | { | |||
QMessageBox box(parent ? parent : main_win_); | QMessageBox box(parent ? parent : main_win_); | |||
box.setText(msg); | box.setText(msg); | |||
box.setWindowTitle(getBrand()); | box.setWindowTitle(getBrand()); | |||
box.setIcon(QMessageBox::Question); | box.setIcon(QMessageBox::Question); | |||
QPushButton *yes_btn = box.addButton(tr("Yes"), QMessageBox::YesRole); | QPushButton *yes_btn = box.addButton(tr("Yes"), QMessageBox::YesRole); | |||
QPushButton *no_btn = box.addButton(tr("No"), QMessageBox::NoRole); | QPushButton *no_btn = box.addButton(tr("No"), QMessageBox::NoRole); | |||
box.setDefaultButton(default_val ? yes_btn: no_btn); | box.setDefaultButton(default_val ? yes_btn: no_btn); | |||
box.setFocusPolicy(Qt::ClickFocus); | ||||
box.exec(); | box.exec(); | |||
return box.clickedButton() == yes_btn; | return box.clickedButton() == yes_btn; | |||
} | } | |||
bool SeafileApplet::yesOrCancelBox(const QString& msg, QWidget *parent, bool def ault_yes) | bool SeafileApplet::yesOrCancelBox(const QString& msg, QWidget *parent, bool def ault_yes) | |||
{ | { | |||
QMessageBox box(parent ? parent : main_win_); | QMessageBox box(parent ? parent : main_win_); | |||
box.setText(msg); | box.setText(msg); | |||
box.setWindowTitle(getBrand()); | box.setWindowTitle(getBrand()); | |||
box.setIcon(QMessageBox::Question); | box.setIcon(QMessageBox::Question); | |||
QPushButton *yes_btn = box.addButton(tr("Yes"), QMessageBox::YesRole); | QPushButton *yes_btn = box.addButton(tr("Yes"), QMessageBox::YesRole); | |||
QPushButton *cancel_btn = box.addButton(tr("Cancel"), QMessageBox::RejectRol e); | QPushButton *cancel_btn = box.addButton(tr("Cancel"), QMessageBox::RejectRol e); | |||
box.setDefaultButton(default_yes ? yes_btn: cancel_btn); | box.setDefaultButton(default_yes ? yes_btn: cancel_btn); | |||
box.setFocusPolicy(Qt::ClickFocus); | ||||
box.exec(); | box.exec(); | |||
return box.clickedButton() == yes_btn; | return box.clickedButton() == yes_btn; | |||
} | } | |||
QMessageBox::StandardButton | QMessageBox::StandardButton | |||
SeafileApplet::yesNoCancelBox(const QString& msg, QWidget *parent, QMessageBox:: StandardButton default_btn) | SeafileApplet::yesNoCancelBox(const QString& msg, QWidget *parent, QMessageBox:: StandardButton default_btn) | |||
{ | { | |||
QMessageBox box(parent ? parent : main_win_); | QMessageBox box(parent ? parent : main_win_); | |||
box.setText(msg); | box.setText(msg); | |||
box.setWindowTitle(getBrand()); | box.setWindowTitle(getBrand()); | |||
box.setIcon(QMessageBox::Question); | box.setIcon(QMessageBox::Question); | |||
QPushButton *yes_btn = box.addButton(tr("Yes"), QMessageBox::YesRole); | QPushButton *yes_btn = box.addButton(tr("Yes"), QMessageBox::YesRole); | |||
QPushButton *no_btn = box.addButton(tr("No"), QMessageBox::NoRole); | QPushButton *no_btn = box.addButton(tr("No"), QMessageBox::NoRole); | |||
box.addButton(tr("Cancel"), QMessageBox::RejectRole); | box.addButton(tr("Cancel"), QMessageBox::RejectRole); | |||
box.setDefaultButton(default_btn); | box.setDefaultButton(default_btn); | |||
box.setFocusPolicy(Qt::ClickFocus); | ||||
box.exec(); | box.exec(); | |||
QAbstractButton *btn = box.clickedButton(); | QAbstractButton *btn = box.clickedButton(); | |||
if (btn == yes_btn) { | if (btn == yes_btn) { | |||
return QMessageBox::Yes; | return QMessageBox::Yes; | |||
} else if (btn == no_btn) { | } else if (btn == no_btn) { | |||
return QMessageBox::No; | return QMessageBox::No; | |||
} | } | |||
return QMessageBox::Cancel; | return QMessageBox::Cancel; | |||
skipping to change at line 623 | skipping to change at line 613 | |||
parent != 0 ? parent : main_win_); | parent != 0 ? parent : main_win_); | |||
msgBox.setDetailedText(detailed_text); | msgBox.setDetailedText(detailed_text); | |||
msgBox.setButtonText(QMessageBox::Yes, tr("Yes")); | msgBox.setButtonText(QMessageBox::Yes, tr("Yes")); | |||
msgBox.setButtonText(QMessageBox::No, tr("No")); | msgBox.setButtonText(QMessageBox::No, tr("No")); | |||
// Turns out the layout box in the QMessageBox is a grid | // Turns out the layout box in the QMessageBox is a grid | |||
// You can force the resize using a spacer this way: | // You can force the resize using a spacer this way: | |||
QSpacerItem* horizontalSpacer = new QSpacerItem(400, 0, QSizePolicy::Minimum , QSizePolicy::Expanding); | QSpacerItem* horizontalSpacer = new QSpacerItem(400, 0, QSizePolicy::Minimum , QSizePolicy::Expanding); | |||
QGridLayout* layout = (QGridLayout*)msgBox.layout(); | QGridLayout* layout = (QGridLayout*)msgBox.layout(); | |||
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCo unt()); | layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCo unt()); | |||
msgBox.setDefaultButton(default_val ? QMessageBox::Yes : QMessageBox::No); | msgBox.setDefaultButton(default_val ? QMessageBox::Yes : QMessageBox::No); | |||
msgBox.setFocusPolicy(Qt::ClickFocus); | ||||
return msgBox.exec() == QMessageBox::Yes; | return msgBox.exec() == QMessageBox::Yes; | |||
} | } | |||
bool SeafileApplet::bulkDeletingMessageBox(const QString& text, const QString& i nfo) | bool SeafileApplet::deletingConfirmationBox(const QString& text, const QString& info) | |||
{ | { | |||
QMessageBox box(main_win_); | QMessageBox box(main_win_); | |||
box.setText(text); | box.setText(text); | |||
box.setInformativeText(info); | box.setInformativeText(info); | |||
box.setIcon(QMessageBox::Question); | box.setIcon(QMessageBox::Question); | |||
// Disable the close button | // Disable the close button | |||
box.setWindowFlags((box.windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::Cu stomizeWindowHint); | box.setWindowFlags((box.windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::Cu stomizeWindowHint); | |||
auto yesButton = box.addButton(tr("Yes"), QMessageBox::YesRole); | auto yesButton = box.addButton(tr("Yes"), QMessageBox::YesRole); | |||
auto noButton = box.addButton(tr("No"), QMessageBox::NoRole); | auto noButton = box.addButton(tr("No"), QMessageBox::NoRole); | |||
auto settingsButton = box.addButton(tr("Settings"), QMessageBox::NoRole); | auto settingsButton = box.addButton(tr("Settings"), QMessageBox::NoRole); | |||
box.setDefaultButton(noButton); | box.setDefaultButton(noButton); | |||
box.setFocusPolicy(Qt::ClickFocus); | ||||
box.exec(); | box.exec(); | |||
if (box.clickedButton() == yesButton) { | if (box.clickedButton() == yesButton) { | |||
return true; | return true; | |||
} else if (box.clickedButton() == noButton) { | } else if (box.clickedButton() == noButton) { | |||
return false; | return false; | |||
} else if (box.clickedButton() == settingsButton) { | } else if (box.clickedButton() == settingsButton) { | |||
settings_dialog_->setCurrentTab(1); | settings_dialog_->setCurrentTab(1); | |||
settings_dialog_->show(); | settings_dialog_->show(); | |||
End of changes. 11 change blocks. | ||||
16 lines changed or deleted | 8 lines changed or added |