allow user to choose whether to remove configs when uninstall

This commit is contained in:
lins05 2013-12-29 11:07:51 +08:00
parent 1ace5ffc6b
commit 392b36acb5
13 changed files with 431 additions and 57 deletions

View file

@ -78,6 +78,7 @@ SET(moc_headers
src/ui/clone-tasks-table-view.h
src/ui/server-status-dialog.h
src/ui/init-vdrive-dialog.h
src/ui/uninstall-helper-dialog.h
third_party/QtAwesome/QtAwesome.h
${platform_specific_moc_headers}
)
@ -98,6 +99,7 @@ SET(ui_files
ui/clone-tasks-dialog.ui
ui/server-status-dialog.ui
ui/init-vdrive-dialog.ui
ui/uninstall-helper-dialog.ui
${platform_specific_ui_files}
)
@ -187,6 +189,7 @@ SET(seafile_client_sources
src/ui/clone-tasks-table-view.cpp
src/ui/server-status-dialog.cpp
src/ui/init-vdrive-dialog.cpp
src/ui/uninstall-helper-dialog.cpp
third_party/QtAwesome/QtAwesome.cpp
${platform_specific_sources}
)

View file

@ -797,7 +797,7 @@ Do you like to download your default library and create a virtual disk?</source>
<context>
<name>MainWindow</name>
<message>
<location filename="../src/ui/main-window.cpp" line="106"/>
<location filename="../src/ui/main-window.cpp" line="108"/>
<source>Refresh</source>
<translation type="unfinished"></translation>
</message>
@ -1079,7 +1079,7 @@ The library owner&apos;s storage space is used up.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/main.cpp" line="82"/>
<location filename="../src/main.cpp" line="117"/>
<source>%1 is already running</source>
<translation type="unfinished"></translation>
</message>
@ -1411,7 +1411,7 @@ The library owner&apos;s storage space is used up.</source>
</message>
<message>
<location filename="../src/seafile-applet.cpp" line="296"/>
<source>A new vesrion of %1 client (%2) is available.
<source>A new version of %1 client (%2) is available.
Do you want to visit the download page?</source>
<translation type="unfinished"></translation>
</message>
@ -1505,17 +1505,17 @@ Do you want to visit the download page?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/tray-icon.cpp" line="297"/>
<location filename="../src/ui/tray-icon.cpp" line="295"/>
<source>About %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/tray-icon.cpp" line="298"/>
<location filename="../src/ui/tray-icon.cpp" line="296"/>
<source>&lt;h2&gt;%1 Client %2&lt;/h2&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/tray-icon.cpp" line="358"/>
<location filename="../src/ui/tray-icon.cpp" line="356"/>
<source>some servers not connected</source>
<translation type="unfinished"></translation>
</message>
@ -1612,4 +1612,42 @@ Do you want to visit the download page?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UninstallHelperDialog</name>
<message>
<location filename="../src/ui/uninstall-helper-dialog.cpp" line="12"/>
<source>Uninstall %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/uninstall-helper-dialog.cpp" line="14"/>
<source>Do you want to remove the %1 account information?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/uninstall-helper-dialog.cpp" line="37"/>
<source>Removing account information...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="107"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="108"/>
<source>text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="109"/>
<source>Yes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="110"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -800,7 +800,7 @@ Do you like to download your default library and create a virtual disk?</source>
<context>
<name>MainWindow</name>
<message>
<location filename="../src/ui/main-window.cpp" line="106"/>
<location filename="../src/ui/main-window.cpp" line="108"/>
<source>Refresh</source>
<translation></translation>
</message>
@ -1085,7 +1085,7 @@ The library owner&apos;s storage space is used up.</source>
<translation>%1 </translation>
</message>
<message>
<location filename="../src/main.cpp" line="82"/>
<location filename="../src/main.cpp" line="117"/>
<source>%1 is already running</source>
<translation>%1 </translation>
</message>
@ -1179,6 +1179,10 @@ The library owner&apos;s storage space is used up.</source>
<source>and %1 more</source>
<translation> %1 </translation>
</message>
<message>
<source>Do you want to remove the %1 account information?</source>
<translation type="obsolete"> %1 </translation>
</message>
</context>
<context>
<name>RepoDetailDialog</name>
@ -1417,9 +1421,15 @@ The library owner&apos;s storage space is used up.</source>
</message>
<message>
<location filename="../src/seafile-applet.cpp" line="296"/>
<source>A new vesrion of %1 client (%2) is available.
<source>A new version of %1 client (%2) is available.
Do you want to visit the download page?</source>
<translation>%1 (%2)
</translation>
</message>
<message>
<source>A new vesrion of %1 client (%2) is available.
Do you want to visit the download page?</source>
<translation type="obsolete">%1 (%2)
</translation>
</message>
</context>
@ -1512,17 +1522,17 @@ Do you want to visit the download page?</source>
<translation></translation>
</message>
<message>
<location filename="../src/ui/tray-icon.cpp" line="297"/>
<location filename="../src/ui/tray-icon.cpp" line="295"/>
<source>About %1</source>
<translation> %1</translation>
</message>
<message>
<location filename="../src/ui/tray-icon.cpp" line="298"/>
<location filename="../src/ui/tray-icon.cpp" line="296"/>
<source>&lt;h2&gt;%1 Client %2&lt;/h2&gt;</source>
<translation>&lt;h2&gt;%1 %2 &lt;/h2&gt;</translation>
</message>
<message>
<location filename="../src/ui/tray-icon.cpp" line="358"/>
<location filename="../src/ui/tray-icon.cpp" line="356"/>
<source>some servers not connected</source>
<translation></translation>
</message>
@ -1618,4 +1628,72 @@ Do you want to visit the download page?</source>
<translation></translation>
</message>
</context>
<context>
<name>UninstallHelperDialog</name>
<message>
<location filename="../src/ui/uninstall-helper-dialog.cpp" line="12"/>
<source>Uninstall %1</source>
<translation> %1</translation>
</message>
<message>
<location filename="../src/ui/uninstall-helper-dialog.cpp" line="14"/>
<source>Do you want to remove the %1 account information?</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../src/ui/uninstall-helper-dialog.cpp" line="37"/>
<source>Removing account information...</source>
<translation>...</translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="107"/>
<source>Dialog</source>
<translation></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="108"/>
<source>text</source>
<translation></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="109"/>
<source>Yes</source>
<translation></translation>
</message>
<message>
<location filename="../ui_uninstall-helper-dialog.h" line="110"/>
<source>No</source>
<translation></translation>
</message>
</context>
<context>
<name>UninstallHelperView</name>
<message>
<source>Do you want to remove the %1 account information?</source>
<translation type="obsolete"> %1 </translation>
</message>
<message>
<source>Form</source>
<translation type="obsolete">Form</translation>
</message>
<message>
<source>Yes</source>
<translation type="obsolete"></translation>
</message>
<message>
<source>No</source>
<translation type="obsolete"></translation>
</message>
</context>
<context>
<name>UninstallHelperWindow</name>
<message>
<source>Uninstall Seafile</source>
<translation type="obsolete"> Seafile</translation>
</message>
<message>
<source>Uninstall %1</source>
<translation type="obsolete"> %1</translation>
</message>
</context>
</TS>

7
qt.css
View file

@ -292,4 +292,11 @@ InitVirtualDriveDialog QLabel#mStatusText {
ServerStatusDialog QListView:item {
margin-bottom: 4px;
}
UninstallHelperDialog {
min-width: 400px;
max-width: 400px;
min-height: 100px;
max-height: 100px;
}

View file

@ -22,8 +22,26 @@
namespace {
void loadTranslation(QApplication *app)
{
// initialize i18n
QTranslator qtTranslator;
#if defined(Q_WS_WIN)
qtTranslator.load("qt_" + QLocale::system().name());
#else
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
qApp->installTranslator(&qtTranslator);
QTranslator myappTranslator;
myappTranslator.load(QString(":/i18n/seafile_%1.qm").arg(QLocale::system().name()));
qApp->installTranslator(&myappTranslator);
}
} // namespace
int main(int argc, char *argv[])
{
#ifdef Q_WS_MAC
@ -41,6 +59,29 @@ int main(int argc, char *argv[])
g_thread_init(NULL);
#endif
#ifdef Q_WS_MAC
Application app(argc, argv);
#else
QApplication app(argc, argv);
#endif
QDir::setCurrent(QApplication::applicationDirPath());
// loadTranslation();
// initialize i18n
QTranslator qtTranslator;
#if defined(Q_WS_WIN)
qtTranslator.load("qt_" + QLocale::system().name());
#else
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
app.installTranslator(&qtTranslator);
QTranslator myappTranslator;
myappTranslator.load(QString(":/i18n/seafile_%1.qm").arg(QLocale::system().name()));
app.installTranslator(&myappTranslator);
static const char *short_options = "KXc:";
static const struct option long_options[] = {
{ "config-dir", required_argument, NULL, 'c' },
@ -71,12 +112,6 @@ int main(int argc, char *argv[])
}
}
#ifdef Q_WS_MAC
Application app(argc, argv);
#else
QApplication app(argc, argv);
#endif
if (count_process(APPNAME) > 1) {
QMessageBox::warning(NULL, SEAFILE_CLIENT_BRAND,
QObject::tr("%1 is already running").arg(SEAFILE_CLIENT_BRAND),
@ -84,8 +119,6 @@ int main(int argc, char *argv[])
return -1;
}
QDir::setCurrent(QApplication::applicationDirPath());
app.setQuitOnLastWindowClosed(false);
// see QSettings documentation
@ -93,20 +126,6 @@ int main(int argc, char *argv[])
QCoreApplication::setOrganizationDomain("seafile.com");
QCoreApplication::setApplicationName(QString("%1 Client").arg(SEAFILE_CLIENT_BRAND));
// initialize i18n
QTranslator qtTranslator;
#if defined(Q_WS_WIN)
qtTranslator.load("qt_" + QLocale::system().name());
#else
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
app.installTranslator(&qtTranslator);
QTranslator myappTranslator;
myappTranslator.load(QString(":/i18n/seafile_%1.qm").arg(QLocale::system().name()));
app.installTranslator(&myappTranslator);
awesome = new QtAwesome(qApp);
awesome->initFontAwesome();

View file

@ -293,7 +293,7 @@ void SeafileApplet::onGetLatestVersionInfoSuccess(const QString& latest_version)
return;
}
QString msg = tr("A new vesrion of %1 client (%2) is available.\n"
QString msg = tr("A new version of %1 client (%2) is available.\n"
"Do you want to visit the download page?").arg(SEAFILE_CLIENT_BRAND).arg(latest_version);
if (!yesOrNoBox(msg, NULL, true)) {

View file

@ -33,7 +33,10 @@ MainWindow::MainWindow()
// Qt::Tool hides the taskbar entry on windows
// setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
setWindowFlags(Qt::FramelessWindowHint);
setWindowFlags(Qt::Window
| Qt::FramelessWindowHint
| Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint);
cloud_view_ = new CloudView;
@ -87,9 +90,8 @@ void MainWindow::changeEvent(QEvent *event)
if(windowState() & Qt::WindowMinimized ) {
//do something after minimize
} else {
setWindowFlags(Qt::Window); //show normal window
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
showNormal();
cloud_view_->hide();
cloud_view_->show();
}
}
#endif

View file

@ -285,8 +285,6 @@ void SeafileTrayIcon::toggleMainWindow()
MainWindow *main_win = seafApplet->mainWindow();
if (!main_win->isVisible()) {
main_win->showWindow();
main_win->raise();
main_win->activateWindow();
} else {
main_win->hide();
}

View file

@ -0,0 +1,87 @@
#include <QtGui>
#include "utils/uninstall-helpers.h"
#include "uninstall-helper-dialog.h"
UninstallHelperDialog::UninstallHelperDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
setWindowIcon(QIcon(":/images/seafile.png"));
setWindowTitle(tr("Uninstall %1").arg(SEAFILE_CLIENT_BRAND));
mText->setText(tr("Do you want to remove the %1 account information?").arg(SEAFILE_CLIENT_BRAND));
loadQss("qt.css") || loadQss(":/qt.css");
#if defined(Q_WS_WIN)
loadQss("qt-win.css") || loadQss(":/qt-win.css");
#elif defined(Q_WS_X11)
loadQss("qt-linux.css") || loadQss(":/qt-linux.css");
#else
loadQss("qt-mac.css") || loadQss(":/qt-mac.css");
#endif
const QRect screen = QApplication::desktop()->screenGeometry();
move(screen.center() - this->rect().center());
connect(mYesBtn, SIGNAL(clicked()),
this, SLOT(onYesClicked()));
connect(mNoBtn, SIGNAL(clicked()),
this, SLOT(onNoClicked()));
}
void UninstallHelperDialog::onYesClicked()
{
removeSeafileData();
::exit(0);
}
void UninstallHelperDialog::removeSeafileData()
{
mYesBtn->setEnabled(false);
mNoBtn->setEnabled(false);
mText->setText(tr("Removing account information..."));
qApp->processEvents();
QString ccnet_dir;
QString seafile_data_dir;
if (get_ccnet_dir(&ccnet_dir) < 0) {
fprintf (stderr, "ccnet dir not found");
return;
}
if (get_seafile_data_dir(ccnet_dir, &seafile_data_dir) < 0) {
delete_dir_recursively(ccnet_dir);
return;
}
delete_dir_recursively(ccnet_dir);
delete_dir_recursively(seafile_data_dir);
}
void UninstallHelperDialog::onNoClicked()
{
::exit(0);
}
bool UninstallHelperDialog::loadQss(const QString& path)
{
QFile file(path);
if (!QFileInfo(file).exists()) {
return false;
}
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return false;
}
QTextStream input(&file);
style_ += "\n";
style_ += input.readAll();
qApp->setStyleSheet(style_);
return true;
}

View file

@ -0,0 +1,28 @@
#ifndef SEAFILE_CLIENT_UNINSTALL_HELPER_WINDOW_H
#define SEAFILE_CLIENT_UNINSTALL_HELPER_WINDOW_H
#include <QDialog>
#include "ui_uninstall-helper-dialog.h"
class UninstallHelperDialog : public QDialog,
public Ui::UninstallHelperDialog
{
Q_OBJECT
public:
UninstallHelperDialog(QWidget *parent=0);
private slots:
void onYesClicked();
void onNoClicked();
void removeSeafileData();
private:
Q_DISABLE_COPY(UninstallHelperDialog)
bool loadQss(const QString& path);
QString style_;
};
#endif // SEAFILE_CLIENT_UNINSTALL_HELPER_WINDOW_H

View file

@ -16,18 +16,24 @@ extern "C" {
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QMessageBox>
#include <QIcon>
#include <QMainWindow>
#include "utils/utils.h"
#include "configurator.h"
#include "settings-mgr.h"
#include "ui/uninstall-helper-dialog.h"
#include "uninstall-helpers.h"
namespace {
const char *kAppletCommandsMQ = "applet.commands";
} // namespace
int delete_dir_recursively(const QString& path_in)
{
printf ("removing folder %s\n", toCStr(path_in));
@ -108,9 +114,6 @@ int get_seafile_data_dir(const QString& ccnet_dir, QString *ret)
}
} // namespace
void do_stop()
{
CcnetClient *sync_client = ccnet_client_new();
@ -134,25 +137,20 @@ void do_stop()
g_object_unref (sync_client);
}
void do_remove_user_data()
{
set_seafile_auto_start(false);
Configurator::removeVirtualDrive();
SettingsManager::removeAllSettings();
QString ccnet_dir;
QString seafile_data_dir;
if (get_ccnet_dir(&ccnet_dir) < 0) {
fprintf (stderr, "ccnet dir not found");
return;
}
if (get_seafile_data_dir(ccnet_dir, &seafile_data_dir) < 0) {
delete_dir_recursively(ccnet_dir);
fprintf (stderr, "seafile dir not found");
return;
}
UninstallHelperDialog *dialog = new UninstallHelperDialog;
delete_dir_recursively(ccnet_dir);
delete_dir_recursively(seafile_data_dir);
dialog->show();
dialog->raise();
dialog->activateWindow();
qApp->exec();
}

View file

@ -1,6 +1,8 @@
#ifndef SEAFILE_CLIENT_UTILS_UNINSTALL_HELPERS_H
#define SEAFILE_CLIENT_UTILS_UNINSTALL_HELPERS_H
#include <QString>
/**
* Stop running seafile client.
*/
@ -11,4 +13,8 @@ void do_stop();
*/
void do_remove_user_data();
int get_ccnet_dir(QString *ret);
int get_seafile_data_dir(const QString& ccnet_dir, QString *ret);
int delete_dir_recursively(const QString& path_in);
#endif // SEAFILE_CLIENT_UTILS_UNINSTALL_HELPERS_H

View file

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UninstallHelperDialog</class>
<widget class="QDialog" name="UninstallHelperDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>595</width>
<height>453</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>176</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="mText">
<property name="text">
<string>text</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>175</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="mYesBtn">
<property name="text">
<string>Yes</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mNoBtn">
<property name="text">
<string>No</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder>line</zorder>
</widget>
<resources/>
<connections/>
</ui>