make it works normally

This commit is contained in:
李 翔 2017-12-22 14:24:30 +08:00
parent 55703a59ed
commit 023b096288
49 changed files with 2449 additions and 4305 deletions

View File

@ -1,4 +1,4 @@
youker-assistant
kylin-assistant
================
Attention
@ -7,38 +7,32 @@ It supports unity and mate for Ubuntu/Ubuntu Kylin.
Depends
=======
debhelper (>= 9),python-dev,python-lxml,python-piston-mini-client,python-xdg,libqt4-dev,pkg-config,python (>= 2.6.6-3~),libglib2.0-dev,libgtop2-dev
debhelper (>= 9),python-dev,python-lxml,python-piston-mini-client,python-xdg,qtbase5-dev,qt5-qmake,qtscript5-dev,qttools5-dev-tools,pkg-config,python (>= 2.6.6-3~),libglib2.0-dev,libgtop2-dev
Launchpad
GitHub
=======
https://launchpad.net/youker-assistant
https://github.com/KylinAppCenter/kylin-assistant
Internationalization
=======
lupdate youker-assistant.pro
linguist youker-assistant_zh_CN.ts
lrelease youker-assistant.pro
lupdate kylin-assistant.pro
linguist kylin-assistant_zh_CN.ts
lrelease kylin-assistant.pro
Python Internationalization
=======
xgettext -k_ -o youker-assistant.pot cpuinfo.py
youker-assistant.pot:修改charset为utf-8
cp youker-assistant.pot youker-assistant.po
msgfmt -o youker-assistant.mo youker-assistant.po
(sudo cp youker-assistant.mo /usr/share/locale/zh_CN/LC_MESSAGES/)
xgettext -k_ -o kylin-assistant.pot cpuinfo.py
kylin-assistant.pot:修改charset为utf-8
cp kylin-assistant.pot kylin-assistant.po
msgfmt -o kylin-assistant.mo kylin-assistant.po
(sudo cp kylin-assistant.mo /usr/share/locale/zh_CN/LC_MESSAGES/)
FT Version:
1)changelog like this:
youker-assistant (2.0.7kord) juniper; urgency=low
2)youker-assistant.dekstop
3)debian/source/format
replace quilt with native
changelog like this:
kylin-assistant (1.0.0kord) juniper; urgency=low
DEBUG:
gdb python

View File

@ -318,9 +318,9 @@ class Desktop_Autostart_Manage():
elif os.path.exists(iconpath1 + tempicon):
info.append('Icon:' + iconpath1 + tempicon)
else:
info.append('Icon:/usr/share/pixmaps/autostart-default.png')
info.append('Icon:/usr/share/pixmaps/app-autostart-default.png')
else:
info.append('Icon:/usr/share/pixmaps/autostart-default.png')
info.append('Icon:/usr/share/pixmaps/app-autostart-default.png')
return info

View File

@ -556,11 +556,11 @@ class CloudConfig(threading.Thread):
self.kuaipan_path = self.get_kuaipan_path() + '/[Ubuntu Kylin Sync]'
if not os.path.isdir(self.kuaipan_path):
os.makedirs(self.kuaipan_path)
self.kuaipan_path = self.kuaipan_path + '/youker-assistant'
self.kuaipan_path = self.kuaipan_path + '/kylin-assistant'
if not os.path.isdir(self.kuaipan_path):
os.makedirs(self.kuaipan_path)
self.youker_path = self.home + '/.config/ubuntukylin/youker-assistant/'
youker_abs_path = self.youker_path + 'youker-settings-cloud.conf'
self.youker_path = self.home + '/.config/ubuntukylin/kylin-assistant/'
youker_abs_path = self.youker_path + 'kylin-settings-cloud.conf'
self.save_configuration_to_local_file(youker_abs_path)
copy(youker_abs_path, self.kuaipan_path)
self.sysdaemon.upload_cloud_conf_signal('upload_ok')
@ -571,11 +571,11 @@ class CloudConfig(threading.Thread):
# 快盘没有启动或没有安装,提示用户安装并启动快盘才能下载
self.sysdaemon.download_cloud_conf_signal('download_norun')
return
self.youker_path = self.home + '/.config/ubuntukylin/youker-assistant/'
youker_abs_path = self.youker_path + 'youker-settings-cloud.conf'
self.youker_path = self.home + '/.config/ubuntukylin/kylin-assistant/'
youker_abs_path = self.youker_path + 'kylin-settings-cloud.conf'
if not os.path.exists(youker_abs_path):
os.mknod(youker_abs_path)
cloud_abs_path = self.get_kuaipan_path() + '/[Ubuntu Kylin Sync]/youker-assistant/youker-settings-cloud.conf'
cloud_abs_path = self.get_kuaipan_path() + '/[Ubuntu Kylin Sync]/kylin-assistant/kylin-settings-cloud.conf'
if not os.path.isfile(cloud_abs_path):
# 云端没有备份的配置文件
self.sysdaemon.download_cloud_conf_signal('download_notconf')

View File

@ -1 +1 @@
UK_ACTION_YOUKER = 'com.kylin.assistant.systemdaemon.action'
KYLIN_ASSISTANT_ACTION = 'com.kylin.assistant.systemdaemon.action'

View File

@ -36,7 +36,7 @@ from gi.repository import GObject
import threading
import thread
from server import PolicyKitService
from policykit import UK_ACTION_YOUKER
from policykit import KYLIN_ASSISTANT_ACTION
import time
import cleaner
from detailinfo.cpuinfo import DetailInfo
@ -292,7 +292,7 @@ class Daemon(PolicyKitService):
@dbus.service.method(INTERFACE, in_signature='s', out_signature='b', sender_keyword='sender')
def kill_root_process(self, pid, sender=None):
status = self._check_permission(sender, UK_ACTION_YOUKER)
status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
if not status:
return False
cmd = 'kill -9 %s' % pid
@ -470,7 +470,7 @@ class Daemon(PolicyKitService):
@dbus.service.method(INTERFACE, in_signature='as', out_signature='', sender_keyword='sender')
def onekey_clean_crufts_function(self, mode_list, sender=None):
status = self._check_permission(sender, UK_ACTION_YOUKER)
status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
if not status:
self.revoke_clean_onekey('yes')
return
@ -488,7 +488,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='as', out_signature='', sender_keyword='sender')
# def onekey_clean_crufts_function_by_threading(self, mode_list, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return
@ -510,7 +510,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender')
# def history_clean_records_function(self, flag, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.clean_complete_msg('')
# return
@ -524,7 +524,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender')
# def clean_system_history(self, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.clean_complete_msg('')
# return
@ -538,7 +538,7 @@ class Daemon(PolicyKitService):
#@dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender')
#def clean_dash_history(self, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.clean_complete_msg('')
# return
@ -552,7 +552,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature = 'as', out_signature = '', sender_keyword = 'sender')
# def cookies_clean_record_function(self, flag, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.clean_single_complete_msg('')
# return
@ -566,7 +566,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature = 's', out_signature = '', sender_keyword = 'sender')
# def cookies_clean_records_function(self, flag, sender = None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.quit_clean_work(flag)
# return
@ -582,7 +582,7 @@ class Daemon(PolicyKitService):
### input-['filepath', 'file...] output-''
# @dbus.service.method(INTERFACE, in_signature='ass', out_signature='', sender_keyword='sender')
# def clean_file_cruft(self, cruft_list, flagstr, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.clean_complete_msg('')
# return
@ -638,7 +638,7 @@ class Daemon(PolicyKitService):
### input-['packagename', 'pack...] output-''
# @dbus.service.method(INTERFACE, in_signature='ass', out_signature='', sender_keyword='sender')
# def clean_package_cruft(self, cruftlist, flag, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.finish_clean_msg('')
# return
@ -660,7 +660,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='a{sv}', out_signature='', sender_keyword='sender')
# def remove_select_items(self, mode_dic, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.quit_clean(False)
## self.quit_clean_work()
@ -714,7 +714,7 @@ class Daemon(PolicyKitService):
@dbus.service.method(INTERFACE, in_signature='a{sv}', out_signature='', sender_keyword='sender')
def remove_select_items(self, mode_dic, sender=None):
status = self._check_permission(sender, UK_ACTION_YOUKER)
status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
if not status:
self.quit_clean(False)
return
@ -723,7 +723,7 @@ class Daemon(PolicyKitService):
thread.start_new_thread(self.start_clean_all, (mode_dic,))
# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender')
# def remove_file(self, fp):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return
@ -733,7 +733,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender')
# def remove_package(self, pkgname, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return
@ -743,7 +743,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender')
# def remove_firefox_history(self, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return
@ -753,7 +753,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender')
# def remove_chromium_history(self, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return
@ -763,7 +763,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender')
# def remove_firefox_cookies(self, domain, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return
@ -773,7 +773,7 @@ class Daemon(PolicyKitService):
# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender')
# def remove_chromium_cookies(self, domain, sender=None):
# status = self._check_permission(sender, UK_ACTION_YOUKER)
# status = self._check_permission(sender, KYLIN_ASSISTANT_ACTION)
# if not status:
# self.revoke_clean_onekey('yes')
# return

View File

@ -28,10 +28,8 @@
#define PAGESPACE 20
#define ITEMWIDTH 650
#define VERSION "2.4.1"
const QString YOUKER_COMPANY_SETTING = "ubuntukylin/kylin-assistant";
const QString YOUKER_SETTING_FILE_NAME_SETTING = "kylin-assistant";
const QString KYLIN_COMPANY_SETTING = "kylin/kylin-assistant";
const QString KYLIN_SETTING_FILE_NAME_SETTING = "kylin-assistant";
typedef enum{
YOUKER_EN,

View File

@ -57,7 +57,7 @@ SystemDispatcher::~SystemDispatcher() {
void SystemDispatcher::initData()
{
systemiface = new QDBusInterface("com.kylin.assistant.systemdaemon",
"com/kylin/assistant/systemdaemon",
"/com/kylin/assistant/systemdaemon",
"com.kylin.assistant.systemdaemon",
QDBusConnection::systemBus());
@ -127,7 +127,7 @@ bool SystemDispatcher::update_myself()
q.quit();
}
return true;
// QDBusReply<bool> reply = systemiface->call("install", "youker-assistant");
// QDBusReply<bool> reply = systemiface->call("install", "kylin-assistant");
// return reply.value();
}

3
debian/changelog vendored
View File

@ -1,5 +1,6 @@
kylin-assistant (1.0.0-0ubuntu1) artful; urgency=low
kylin-assistant (1.0.0-0ubuntu1) bionic; urgency=low
* fork youker-assistant(commit:764)
* upgrade from Qt4 to Qt5.
-- lixiang <lixiang@kylinos.cn> Thu, 21 Dec 2017 14:52:56 +0800

46
debian/copyright vendored
View File

@ -1,35 +1,31 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: youker-assistant
Upstream-Name: kylin-assistant
Upstream-Contact: Ubuntu Kylin Team <ubuntukylin-members@lists.launchpad.net>
Source: https://launchpad.net/youker-assistant
Source: https://github.com/KylinAppCenter/kylin-assistant
Files: *
Copyright: 2013-2014, National University of Defense Technology(NUDT) & Kylin Ltd.
Copyright: 2013-2017, National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
License: GPL-3
Files: backends/youker-assistant-daemon/src/policykit/*
Files: backends/kylin-assistant-daemon/src/policykit/*
Copyright: Copyright (C) 2007-2011 Tualatrix Chou <tualatrix@gmail.com>
Copyright (C) 2013-2014 National University of Defense Technology(NUDT) & Kylin Ltd.
Copyright (C) 2013-2017 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
License: GPL-3
Files: backends/youker-assistant-daemon/src/systemdbus/server.py
Files: backends/kylin-assistant-daemon/src/systemdbus/server.py
Copyright: Copyright (C) 2008 Fluendo Embedded S.L.
Copyright (C) 2010 TualatriX <tualatrix@gmail.com>
Copyright (C) 2013-2014 National University of Defense Technology(NUDT) & Kylin Ltd.
Copyright (C) 2013-2017 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
License: GPL-2+
Files: backends/youker-assistant-daemon/src/beautify/common.py backends/youker-assistant-daemon/src/beautify/compizsettings.py
Files: backends/kylin-assistant-daemon/src/beautify/common.py backends/kylin-assistant-daemon/src/beautify/compizsettings.py
Copyright: Copyright (C) 2007-2011 Tualatrix Chou <tualatrix@gmail.com>
License: GPL-2+
Files: backends/youker-assistant-daemon/src/beautify/ccm/*
Files: backends/kylin-assistant-daemon/src/beautify/ccm/*
Copyright: Copyright (C) 2007 Quinn Storm
License: GPL-2+
Files: qtsingleapplication/*
Copyright: 2013 Digia Plc and/or its subsidiary(-ies)
License: BSD-3-clause
License: GPL-2+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@ -51,27 +47,3 @@ License: GPL-3
.
On Debian/Ubuntu systems, the full text of the GPL v3 can be found in
`/usr/share/common-licenses/GPL-3'
License: BSD-3-clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the organization nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,3 +1,3 @@
man/kylin-assistant.1
man/youkersession.1
man/youkersystem.1
man/kylin-assistant-session.1
man/kylin-assistant-system.1

View File

@ -0,0 +1,19 @@
.\" Hey, EMACS: -*- nroff -*-
.TH KYLIN-ASSISTANT-SESSION 1 "22 DEC 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
kylin-assistant-session \- launch backends
.SH SYNOPSIS
.B kylin-assistant-session
.SH DESCRIPTION
.B kylin-assistant-session
It is used to launch backends.
.PP
.SH SEE ALSO
.BR kylin-assistant-session (1),
.br
.SH AUTHOR
kylin-assistant-session was written by lixiang <lixiang@kylinos.cn>.
.PP
This manual page was written by lixiang <lixiang@kylinos.cn>.

View File

@ -0,0 +1,19 @@
.\" Hey, EMACS: -*- nroff -*-
.TH KYLIN-ASSISTANT-SYSTEM 1 "22 DEC 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
kylin-assistant-system \- launch backends
.SH SYNOPSIS
.B kylin-assistant-system
.SH DESCRIPTION
.B kylin-assistant-system
It is used to launch backends. Need to use root privilige.
.PP
.SH SEE ALSO
.BR kylin-assistant-system (1),
.br
.SH AUTHOR
kylin-assistant-system was written by lixiang <lixiang@kylinos.cn>.
.PP
This manual page was written by lixiang <lixiang@kylinos.cn>.

View File

@ -1,19 +1,19 @@
.\" Hey, EMACS: -*- nroff -*-
.TH YOUKER-ASSISTANT 1 "19 AUG 2013"
.TH KYLIN-ASSISTANT 1 "22 DEC 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
youker-assistant \- launch youker-assistant frontends
kylin-assistant \- launch kylin-assistant frontends
.SH SYNOPSIS
.B youker-assistant
.B kylin-assistant
.SH DESCRIPTION
.B youker-assistant
.B kylin-assistant
It is used to launch frontends.
.PP
.SH SEE ALSO
.BR youker-assistant (1),
.BR kylin-assistant (1),
.br
.SH AUTHOR
youker-assistant was written by Kobe <kobe24_lixiang@126.com>.
kylin-assistant was written by lixiang <lixiang@kylinos.cn>.
.PP
This manual page was written by shijing <jingshi@ubuntukylin.com>.
This manual page was written by lixiang <lixiang@kylinos.cn>.

View File

@ -1,19 +0,0 @@
.\" Hey, EMACS: -*- nroff -*-
.TH YOUKER-SESSION 1 "19 AUG 2013"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
youker-session \- launch backends
.SH SYNOPSIS
.B youker-session
.SH DESCRIPTION
.B youker-session
It is used to launch backends.
.PP
.SH SEE ALSO
.BR youker-session (1),
.br
.SH AUTHOR
youker-session was written by Kobe <kobe24_lixiang@126.com>.
.PP
This manual page was written by shijing <jingshi@ubuntukylin.com>.

View File

@ -1,19 +0,0 @@
.\" Hey, EMACS: -*- nroff -*-
.TH YOUKER-SYSTEM 1 "19 AUG 2013"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
youker-system \- launch backends
.SH SYNOPSIS
.B youker-system
.SH DESCRIPTION
.B youker-system
It is used to launch backends. Need to use root privilige.
.PP
.SH SEE ALSO
.BR youker-system (1),
.br
.SH AUTHOR
youker-system was written by Kobe <kobe24_lixiang@126.com>.
.PP
This manual page was written by shijing <jingshi@ubuntukylin.com>.

View File

@ -1,33 +0,0 @@
Qt Solutions Component: Single Application
The QtSingleApplication component provides support for
applications that can be only started once per user.
Version history:
2.0: - Version 1.3 ported to Qt 4.
2.1: - Fix compilation problem on Mac.
2.2: - Really fix the Mac compilation problem.
- Mac: fix crash due to wrong object releasing.
- Mac: Fix memory leak.
2.3: - Windows: Force creation of internal widget to make it work
with Qt 4.2.
2.4: - Fix the system for automatic window raising on message
reception. NOTE: minor API change.
2.5: - Mac: Fix isRunning() to work and report correctly.
2.6: - - initialize() is now obsolete, no longer necessary to call
it
- - Fixed race condition where multiple instances migth be started
- - QtSingleCoreApplication variant provided for non-GUI (console)
usage
- Complete reimplementation. Visible changes:
- LGPL release.

View File

@ -1,6 +0,0 @@
exists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib
TEMPLATE += fakelib
QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head)
TEMPLATE -= fakelib
QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib
unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR

View File

@ -1 +0,0 @@
#include "qtlockedfile.h"

View File

@ -1 +0,0 @@
#include "qtsingleapplication.h"

View File

@ -1,204 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtlocalpeer.h"
#include <QCoreApplication>
#include <QTime>
#include <QDataStream>
#if defined(Q_OS_WIN)
#include <QLibrary>
#include <qt_windows.h>
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
static PProcessIdToSessionId pProcessIdToSessionId = 0;
#endif
#if defined(Q_OS_UNIX)
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#endif
namespace QtLP_Private {
#include "qtlockedfile.cpp"
#if defined(Q_OS_WIN)
#include "qtlockedfile_win.cpp"
#else
#include "qtlockedfile_unix.cpp"
#endif
}
const char* QtLocalPeer::ack = "ack";
QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
: QObject(parent), id(appId)
{
QString prefix = id;
if (id.isEmpty()) {
id = QCoreApplication::applicationFilePath();
#if defined(Q_OS_WIN)
id = id.toLower();
#endif
prefix = id.section(QLatin1Char('/'), -1);
}
prefix.remove(QRegExp("[^a-zA-Z]"));
prefix.truncate(6);
QByteArray idc = id.toUtf8();
quint16 idNum = qChecksum(idc.constData(), idc.size());
socketName = QLatin1String("qtsingleapp-") + prefix
+ QLatin1Char('-') + QString::number(idNum, 16);
#if defined(Q_OS_WIN)
if (!pProcessIdToSessionId) {
QLibrary lib("kernel32");
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
}
if (pProcessIdToSessionId) {
DWORD sessionId = 0;
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += QLatin1Char('-') + QString::number(sessionId, 16);
}
#else
socketName += QLatin1Char('-') + QString::number(::getuid(), 16);
#endif
server = new QLocalServer(this);
QString lockName = QDir(QDir::tempPath()).absolutePath()
+ QLatin1Char('/') + socketName
+ QLatin1String("-lockfile");
lockFile.setFileName(lockName);
lockFile.open(QIODevice::ReadWrite);
}
bool QtLocalPeer::isClient()
{
if (lockFile.isLocked())
return false;
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
return true;
bool res = server->listen(socketName);
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
// ### Workaround
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
res = server->listen(socketName);
}
#endif
if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
return false;
}
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
{
if (!isClient())
return false;
QLocalSocket socket;
bool connOk = false;
for(int i = 0; i < 2; i++) {
// Try twice, in case the other instance is just starting up
socket.connectToServer(socketName);
connOk = socket.waitForConnected(timeout/2);
if (connOk || i)
break;
int ms = 250;
#if defined(Q_OS_WIN)
Sleep(DWORD(ms));
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
nanosleep(&ts, NULL);
#endif
}
if (!connOk)
return false;
QByteArray uMsg(message.toUtf8());
QDataStream ds(&socket);
ds.writeBytes(uMsg.constData(), uMsg.size());
bool res = socket.waitForBytesWritten(timeout);
if (res) {
res &= socket.waitForReadyRead(timeout); // wait for ack
if (res)
res &= (socket.read(qstrlen(ack)) == ack);
}
return res;
}
void QtLocalPeer::receiveConnection()
{
QLocalSocket* socket = server->nextPendingConnection();
if (!socket)
return;
while (socket->bytesAvailable() < (int)sizeof(quint32))
socket->waitForReadyRead();
QDataStream ds(socket);
QByteArray uMsg;
quint32 remaining;
ds >> remaining;
uMsg.resize(remaining);
int got = 0;
char* uMsgBuf = uMsg.data();
do {
got = ds.readRawData(uMsgBuf, remaining);
remaining -= got;
uMsgBuf += got;
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
if (got < 0) {
qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
delete socket;
return;
}
QString message(QString::fromUtf8(uMsg));
socket->write(ack, qstrlen(ack));
socket->waitForBytesWritten(1000);
socket->waitForDisconnected(1000); // make sure client reads ack
delete socket;
emit messageReceived(message); //### (might take a long time to return)
}

View File

@ -1,77 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTLOCALPEER_H
#define QTLOCALPEER_H
#include <QLocalServer>
#include <QLocalSocket>
#include <QDir>
#include "qtlockedfile.h"
class QtLocalPeer : public QObject
{
Q_OBJECT
public:
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
bool isClient();
bool sendMessage(const QString &message, int timeout);
QString applicationId() const
{ return id; }
Q_SIGNALS:
void messageReceived(const QString &message);
protected Q_SLOTS:
void receiveConnection();
protected:
QString id;
QString socketName;
QLocalServer* server;
QtLP_Private::QtLockedFile lockFile;
private:
static const char* ack;
};
#endif // QTLOCALPEER_H

View File

@ -1,193 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtlockedfile.h"
/*!
\class QtLockedFile
\brief The QtLockedFile class extends QFile with advisory locking
functions.
A file may be locked in read or write mode. Multiple instances of
\e QtLockedFile, created in multiple processes running on the same
machine, may have a file locked in read mode. Exactly one instance
may have it locked in write mode. A read and a write lock cannot
exist simultaneously on the same file.
The file locks are advisory. This means that nothing prevents
another process from manipulating a locked file using QFile or
file system functions offered by the OS. Serialization is only
guaranteed if all processes that access the file use
QLockedFile. Also, while holding a lock on a file, a process
must not open the same file again (through any API), or locks
can be unexpectedly lost.
The lock provided by an instance of \e QtLockedFile is released
whenever the program terminates. This is true even when the
program crashes and no destructors are called.
*/
/*! \enum QtLockedFile::LockMode
This enum describes the available lock modes.
\value ReadLock A read lock.
\value WriteLock A write lock.
\value NoLock Neither a read lock nor a write lock.
*/
/*!
Constructs an unlocked \e QtLockedFile object. This constructor
behaves in the same way as \e QFile::QFile().
\sa QFile::QFile()
*/
QtLockedFile::QtLockedFile()
: QFile()
{
#ifdef Q_OS_WIN
wmutex = 0;
rmutex = 0;
#endif
m_lock_mode = NoLock;
}
/*!
Constructs an unlocked QtLockedFile object with file \a name. This
constructor behaves in the same way as \e QFile::QFile(const
QString&).
\sa QFile::QFile()
*/
QtLockedFile::QtLockedFile(const QString &name)
: QFile(name)
{
#ifdef Q_OS_WIN
wmutex = 0;
rmutex = 0;
#endif
m_lock_mode = NoLock;
}
/*!
Opens the file in OpenMode \a mode.
This is identical to QFile::open(), with the one exception that the
Truncate mode flag is disallowed. Truncation would conflict with the
advisory file locking, since the file would be modified before the
write lock is obtained. If truncation is required, use resize(0)
after obtaining the write lock.
Returns true if successful; otherwise false.
\sa QFile::open(), QFile::resize()
*/
bool QtLockedFile::open(OpenMode mode)
{
if (mode & QIODevice::Truncate) {
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
return false;
}
return QFile::open(mode);
}
/*!
Returns \e true if this object has a in read or write lock;
otherwise returns \e false.
\sa lockMode()
*/
bool QtLockedFile::isLocked() const
{
return m_lock_mode != NoLock;
}
/*!
Returns the type of lock currently held by this object, or \e
QtLockedFile::NoLock.
\sa isLocked()
*/
QtLockedFile::LockMode QtLockedFile::lockMode() const
{
return m_lock_mode;
}
/*!
\fn bool QtLockedFile::lock(LockMode mode, bool block = true)
Obtains a lock of type \a mode. The file must be opened before it
can be locked.
If \a block is true, this function will block until the lock is
aquired. If \a block is false, this function returns \e false
immediately if the lock cannot be aquired.
If this object already has a lock of type \a mode, this function
returns \e true immediately. If this object has a lock of a
different type than \a mode, the lock is first released and then a
new lock is obtained.
This function returns \e true if, after it executes, the file is
locked by this object, and \e false otherwise.
\sa unlock(), isLocked(), lockMode()
*/
/*!
\fn bool QtLockedFile::unlock()
Releases a lock.
If the object has no lock, this function returns immediately.
This function returns \e true if, after it executes, the file is
not locked by this object, and \e false otherwise.
\sa lock(), isLocked(), lockMode()
*/
/*!
\fn QtLockedFile::~QtLockedFile()
Destroys the \e QtLockedFile object. If any locks were held, they
are released.
*/

View File

@ -1,97 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTLOCKEDFILE_H
#define QTLOCKEDFILE_H
#include <QFile>
#ifdef Q_OS_WIN
#include <QVector>
#endif
#if defined(Q_OS_WIN)
# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
# define QT_QTLOCKEDFILE_EXPORT
# elif defined(QT_QTLOCKEDFILE_IMPORT)
# if defined(QT_QTLOCKEDFILE_EXPORT)
# undef QT_QTLOCKEDFILE_EXPORT
# endif
# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport)
# elif defined(QT_QTLOCKEDFILE_EXPORT)
# undef QT_QTLOCKEDFILE_EXPORT
# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTLOCKEDFILE_EXPORT
#endif
namespace QtLP_Private {
class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
{
public:
enum LockMode { NoLock = 0, ReadLock, WriteLock };
QtLockedFile();
QtLockedFile(const QString &name);
~QtLockedFile();
bool open(OpenMode mode);
bool lock(LockMode mode, bool block = true);
bool unlock();
bool isLocked() const;
LockMode lockMode() const;
private:
#ifdef Q_OS_WIN
Qt::HANDLE wmutex;
Qt::HANDLE rmutex;
QVector<Qt::HANDLE> rmutexes;
QString mutexname;
Qt::HANDLE getMutexHandle(int idx, bool doCreate);
bool waitMutex(Qt::HANDLE mutex, bool doBlock);
#endif
LockMode m_lock_mode;
};
}
#endif

View File

@ -1,115 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "qtlockedfile.h"
bool QtLockedFile::lock(LockMode mode, bool block)
{
if (!isOpen()) {
qWarning("QtLockedFile::lock(): file is not opened");
return false;
}
if (mode == NoLock)
return unlock();
if (mode == m_lock_mode)
return true;
if (m_lock_mode != NoLock)
unlock();
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
int cmd = block ? F_SETLKW : F_SETLK;
int ret = fcntl(handle(), cmd, &fl);
if (ret == -1) {
if (errno != EINTR && errno != EAGAIN)
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
m_lock_mode = mode;
return true;
}
bool QtLockedFile::unlock()
{
if (!isOpen()) {
qWarning("QtLockedFile::unlock(): file is not opened");
return false;
}
if (!isLocked())
return true;
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = F_UNLCK;
int ret = fcntl(handle(), F_SETLKW, &fl);
if (ret == -1) {
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
m_lock_mode = NoLock;
return true;
}
QtLockedFile::~QtLockedFile()
{
if (isOpen())
unlock();
}

View File

@ -1,211 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtlockedfile.h"
#include <qt_windows.h>
#include <QFileInfo>
#define MUTEX_PREFIX "QtLockedFile mutex "
// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
#define MAX_READERS MAXIMUM_WAIT_OBJECTS
#if QT_VERSION >= 0x050000
#define QT_WA(unicode, ansi) unicode
#endif
Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
{
if (mutexname.isEmpty()) {
QFileInfo fi(*this);
mutexname = QString::fromLatin1(MUTEX_PREFIX)
+ fi.absoluteFilePath().toLower();
}
QString mname(mutexname);
if (idx >= 0)
mname += QString::number(idx);
Qt::HANDLE mutex;
if (doCreate) {
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
return 0;
}
}
else {
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
if (GetLastError() != ERROR_FILE_NOT_FOUND)
qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");
return 0;
}
}
return mutex;
}
bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock)
{
Q_ASSERT(mutex);
DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0);
switch (res) {
case WAIT_OBJECT_0:
case WAIT_ABANDONED:
return true;
break;
case WAIT_TIMEOUT:
break;
default:
qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed");
}
return false;
}
bool QtLockedFile::lock(LockMode mode, bool block)
{
if (!isOpen()) {
qWarning("QtLockedFile::lock(): file is not opened");
return false;
}
if (mode == NoLock)
return unlock();
if (mode == m_lock_mode)
return true;
if (m_lock_mode != NoLock)
unlock();
if (!wmutex && !(wmutex = getMutexHandle(-1, true)))
return false;
if (!waitMutex(wmutex, block))
return false;
if (mode == ReadLock) {
int idx = 0;
for (; idx < MAX_READERS; idx++) {
rmutex = getMutexHandle(idx, false);
if (!rmutex || waitMutex(rmutex, false))
break;
CloseHandle(rmutex);
}
bool ok = true;
if (idx >= MAX_READERS) {
qWarning("QtLockedFile::lock(): too many readers");
rmutex = 0;
ok = false;
}
else if (!rmutex) {
rmutex = getMutexHandle(idx, true);
if (!rmutex || !waitMutex(rmutex, false))
ok = false;
}
if (!ok && rmutex) {
CloseHandle(rmutex);
rmutex = 0;
}
ReleaseMutex(wmutex);
if (!ok)
return false;
}
else {
Q_ASSERT(rmutexes.isEmpty());
for (int i = 0; i < MAX_READERS; i++) {
Qt::HANDLE mutex = getMutexHandle(i, false);
if (mutex)
rmutexes.append(mutex);
}
if (rmutexes.size()) {
DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(),
TRUE, block ? INFINITE : 0);
if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) {
if (res != WAIT_TIMEOUT)
qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed");
m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky
unlock();
return false;
}
}
}
m_lock_mode = mode;
return true;
}
bool QtLockedFile::unlock()
{
if (!isOpen()) {
qWarning("QtLockedFile::unlock(): file is not opened");
return false;
}
if (!isLocked())
return true;
if (m_lock_mode == ReadLock) {
ReleaseMutex(rmutex);
CloseHandle(rmutex);
rmutex = 0;
}
else {
foreach(Qt::HANDLE mutex, rmutexes) {
ReleaseMutex(mutex);
CloseHandle(mutex);
}
rmutexes.clear();
ReleaseMutex(wmutex);
}
m_lock_mode = QtLockedFile::NoLock;
return true;
}
QtLockedFile::~QtLockedFile()
{
if (isOpen())
unlock();
if (wmutex)
CloseHandle(wmutex);
}

View File

@ -1,347 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtsingleapplication.h"
#include "qtlocalpeer.h"
#include <QWidget>
/*!
\class QtSingleApplication qtsingleapplication.h
\brief The QtSingleApplication class provides an API to detect and
communicate with running instances of an application.
This class allows you to create applications where only one
instance should be running at a time. I.e., if the user tries to
launch another instance, the already running instance will be
activated instead. Another usecase is a client-server system,
where the first started instance will assume the role of server,
and the later instances will act as clients of that server.
By default, the full path of the executable file is used to
determine whether two processes are instances of the same
application. You can also provide an explicit identifier string
that will be compared instead.
The application should create the QtSingleApplication object early
in the startup phase, and call isRunning() to find out if another
instance of this application is already running. If isRunning()
returns false, it means that no other instance is running, and
this instance has assumed the role as the running instance. In
this case, the application should continue with the initialization
of the application user interface before entering the event loop
with exec(), as normal.
The messageReceived() signal will be emitted when the running
application receives messages from another instance of the same
application. When a message is received it might be helpful to the
user to raise the application so that it becomes visible. To
facilitate this, QtSingleApplication provides the
setActivationWindow() function and the activateWindow() slot.
If isRunning() returns true, another instance is already
running. It may be alerted to the fact that another instance has
started by using the sendMessage() function. Also data such as
startup parameters (e.g. the name of the file the user wanted this
new instance to open) can be passed to the running instance with
this function. Then, the application should terminate (or enter
client mode).
If isRunning() returns true, but sendMessage() fails, that is an
indication that the running instance is frozen.
Here's an example that shows how to convert an existing
application to use QtSingleApplication. It is very simple and does
not make use of all QtSingleApplication's functionality (see the
examples for that).
\code
// Original
int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyMainWidget mmw;
mmw.show();
return app.exec();
}
// Single instance
int main(int argc, char **argv)
{
QtSingleApplication app(argc, argv);
if (app.isRunning())
return !app.sendMessage(someDataString);
MyMainWidget mmw;
app.setActivationWindow(&mmw);
mmw.show();
return app.exec();
}
\endcode
Once this QtSingleApplication instance is destroyed (normally when
the process exits or crashes), when the user next attempts to run the
application this instance will not, of course, be encountered. The
next instance to call isRunning() or sendMessage() will assume the
role as the new running instance.
For console (non-GUI) applications, QtSingleCoreApplication may be
used instead of this class, to avoid the dependency on the QtGui
library.
\sa QtSingleCoreApplication
*/
void QtSingleApplication::sysInit(const QString &appId)
{
actWin = 0;
peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a GUIenabled are passed on to the QAppliation constructor.
If you are creating a console application (i.e. setting \a
GUIenabled to false), you may consider using
QtSingleCoreApplication instead.
*/
QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled)
: QApplication(argc, argv, GUIenabled)
{
sysInit();
}
/*!
Creates a QtSingleApplication object with the application
identifier \a appId. \a argc and \a argv are passed on to the
QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
: QApplication(argc, argv)
{
sysInit(appId);
}
#if QT_VERSION < 0x050000
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a type are passed on to the QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
: QApplication(argc, argv, type)
{
sysInit();
}
# if defined(Q_WS_X11)
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
and \a cmap are passed on to the QApplication constructor.
*/
QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, visual, cmap)
{
sysInit();
}
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit();
}
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be \a appId. \a dpy, \a argc, \a
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit(appId);
}
# endif // Q_WS_X11
#endif // QT_VERSION < 0x050000
/*!
Returns true if another instance of this application is running;
otherwise false.
This function does not find instances of this application that are
being run by a different user (on Windows: that are running in
another session).
\sa sendMessage()
*/
bool QtSingleApplication::isRunning()
{
return peer->isClient();
}
/*!
Tries to send the text \a message to the currently running
instance. The QtSingleApplication object in the running instance
will emit the messageReceived() signal when it receives the
message.
This function returns true if the message has been sent to, and
processed by, the current instance. If there is no instance
currently running, or if the running instance fails to process the
message within \a timeout milliseconds, this function return false.
\sa isRunning(), messageReceived()
*/
bool QtSingleApplication::sendMessage(const QString &message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*!
Returns the application identifier. Two processes with the same
identifier will be regarded as instances of the same application.
*/
QString QtSingleApplication::id() const
{
return peer->applicationId();
}
/*!
Sets the activation window of this application to \a aw. The
activation window is the widget that will be activated by
activateWindow(). This is typically the application's main window.
If \a activateOnMessage is true (the default), the window will be
activated automatically every time a message is received, just prior
to the messageReceived() signal being emitted.
\sa activateWindow(), messageReceived()
*/
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
{
actWin = aw;
if (activateOnMessage)
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
else
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
}
/*!
Returns the applications activation window if one has been set by
calling setActivationWindow(), otherwise returns 0.
\sa setActivationWindow()
*/
QWidget* QtSingleApplication::activationWindow() const
{
return actWin;
}
/*!
De-minimizes, raises, and activates this application's activation window.
This function does nothing if no activation window has been set.
This is a convenience function to show the user that this
application instance has been activated when he has tried to start
another instance.
This function should typically be called in response to the
messageReceived() signal. By default, that will happen
automatically, if an activation window has been set.
\sa setActivationWindow(), messageReceived(), initialize()
*/
void QtSingleApplication::activateWindow()
{
if (actWin) {
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
actWin->raise();
actWin->activateWindow();
}
}
/*!
\fn void QtSingleApplication::messageReceived(const QString& message)
This signal is emitted when the current instance receives a \a
message from another instance of this application.
\sa sendMessage(), setActivationWindow(), activateWindow()
*/
/*!
\fn void QtSingleApplication::initialize(bool dummy = true)
\obsolete
*/

View File

@ -1,105 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTSINGLEAPPLICATION_H
#define QTSINGLEAPPLICATION_H
#include <QApplication>
class QtLocalPeer;
#if defined(Q_OS_WIN)
# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
# define QT_QTSINGLEAPPLICATION_EXPORT
# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
# if defined(QT_QTSINGLEAPPLICATION_EXPORT)
# undef QT_QTSINGLEAPPLICATION_EXPORT
# endif
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
# elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
# undef QT_QTSINGLEAPPLICATION_EXPORT
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTSINGLEAPPLICATION_EXPORT
#endif
class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
{
Q_OBJECT
public:
QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
QtSingleApplication(const QString &id, int &argc, char **argv);
#if QT_VERSION < 0x050000
QtSingleApplication(int &argc, char **argv, Type type);
# if defined(Q_WS_X11)
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
# endif // Q_WS_X11
#endif // QT_VERSION < 0x050000
bool isRunning();
QString id() const;
void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
QWidget* activationWindow() const;
// Obsolete:
void initialize(bool dummy = true)
{ isRunning(); Q_UNUSED(dummy) }
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
void activateWindow();
Q_SIGNALS:
void messageReceived(const QString &message);
private:
void sysInit(const QString &appId = QString());
QtLocalPeer *peer;
QWidget *actWin;
};
#endif // QTSINGLEAPPLICATION_H

View File

@ -1,17 +0,0 @@
include(../common.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
QT *= network
greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets
qtsingleapplication-uselib:!qtsingleapplication-buildlib {
LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME
} else {
SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp
HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h
}
win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT
else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT
}

View File

@ -1,149 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtsinglecoreapplication.h"
#include "qtlocalpeer.h"
/*!
\class QtSingleCoreApplication qtsinglecoreapplication.h
\brief A variant of the QtSingleApplication class for non-GUI applications.
This class is a variant of QtSingleApplication suited for use in
console (non-GUI) applications. It is an extension of
QCoreApplication (instead of QApplication). It does not require
the QtGui library.
The API and usage is identical to QtSingleApplication, except that
functions relating to the "activation window" are not present, for
obvious reasons. Please refer to the QtSingleApplication
documentation for explanation of the usage.
A QtSingleCoreApplication instance can communicate to a
QtSingleApplication instance if they share the same application
id. Hence, this class can be used to create a light-weight
command-line tool that sends commands to a GUI application.
\sa QtSingleApplication
*/
/*!
Creates a QtSingleCoreApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc and \a
argv are passed on to the QCoreAppliation constructor.
*/
QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
: QCoreApplication(argc, argv)
{
peer = new QtLocalPeer(this);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Creates a QtSingleCoreApplication object with the application
identifier \a appId. \a argc and \a argv are passed on to the
QCoreAppliation constructor.
*/
QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv)
: QCoreApplication(argc, argv)
{
peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Returns true if another instance of this application is running;
otherwise false.
This function does not find instances of this application that are
being run by a different user (on Windows: that are running in
another session).
\sa sendMessage()
*/
bool QtSingleCoreApplication::isRunning()
{
return peer->isClient();
}
/*!
Tries to send the text \a message to the currently running
instance. The QtSingleCoreApplication object in the running instance
will emit the messageReceived() signal when it receives the
message.
This function returns true if the message has been sent to, and
processed by, the current instance. If there is no instance
currently running, or if the running instance fails to process the
message within \a timeout milliseconds, this function return false.
\sa isRunning(), messageReceived()
*/
bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*!
Returns the application identifier. Two processes with the same
identifier will be regarded as instances of the same application.
*/
QString QtSingleCoreApplication::id() const
{
return peer->applicationId();
}
/*!
\fn void QtSingleCoreApplication::messageReceived(const QString& message)
This signal is emitted when the current instance receives a \a
message from another instance of this application.
\sa sendMessage()
*/

View File

@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTSINGLECOREAPPLICATION_H
#define QTSINGLECOREAPPLICATION_H
#include <QCoreApplication>
class QtLocalPeer;
class QtSingleCoreApplication : public QCoreApplication
{
Q_OBJECT
public:
QtSingleCoreApplication(int &argc, char **argv);
QtSingleCoreApplication(const QString &id, int &argc, char **argv);
bool isRunning();
QString id() const;
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
Q_SIGNALS:
void messageReceived(const QString &message);
private:
QtLocalPeer* peer;
};
#endif // QTSINGLECOREAPPLICATION_H

View File

@ -1,10 +0,0 @@
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h
SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp
QT *= network
win32:contains(TEMPLATE, lib):contains(CONFIG, shared) {
DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport)
}

View File

@ -41,7 +41,7 @@ ShredDialog::ShredDialog(ShredManager *plugin, QDialog *parent)
this->setFixedSize(500, 471);
process_plugin = plugin;
shredSettings = new QSettings(YOUKER_COMPANY_SETTING, YOUKER_SETTING_FILE_NAME_SETTING);
shredSettings = new QSettings(KYLIN_COMPANY_SETTING, KYLIN_SETTING_FILE_NAME_SETTING);
shredSettings->setIniCodec("UTF-8");
title_bar = new KylinTitleBar();

View File

@ -1,8 +1,8 @@
name: youker-assistant
version: '2.4.2'
name: kylin-assistant
version: '1.0.0'
summary: Integrated tool to aid in routine system maintenance tasks
description: |
Youker Assistant is a tool designed to help Ubuntu and Ubuntu Kylin
Kylin Assistant is a tool designed to help Ubuntu and Ubuntu Kylin
desktop users manage and maintain many aspects of their working
environment conveniently in a single application, providing a consistent
user experience.
@ -11,20 +11,20 @@ description: |
* Detecting and displaying general system information
* Unity and Mate user interface customization
* System garbage cleaning
* Upgrade from Qt4 to Qt5
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
apps:
youker-assistant:
command: desktop-launch youker-assistant
desktop: usr/share/applications/youker-assistant.desktop
kylin-assistant:
command: desktop-launch kylin-assistant
desktop: usr/share/applications/kylin-assistant.desktop
plugs: [home, unity7, desktop, desktop-legacy]
parts:
youker-assistant:
kylin-assistant:
plugin: qmake
qt-version: qt4
qt-version: qt5
source: .
build-packages: [g++, libqt4-dev, libglib2.0-dev]
after: [desktop-qt4]
build-packages: [g++, qtbase5-dev, qt5-qmake, qtscript5-dev, libglib2.0-dev]

View File

@ -72,15 +72,15 @@ AboutDialog::AboutDialog(QWidget *parent, /*const QString &version, */QString sk
nameLabel->setAlignment(Qt::AlignCenter);
// if (arch == "aarch64" || os == "Kylin" || os == "YHKylin") {//20161228
// close_btn->move(442-36, 0);
// nameLabel->setText(tr("Kylin Assisant") + " " + VERSION);
// nameLabel->setText(tr("Kylin Assisant") + " " + qApp->applicationVersion());
// }
// else {
// close_btn->move(0, 0);
// nameLabel->setText(tr("Kylin Assisant") + " " + VERSION);
// nameLabel->setText(tr("Kylin Assisant") + " " + qApp->applicationVersion());
// }
close_btn->move(442-36, 0);
nameLabel->setText(tr("Kylin Assistant") + " " + VERSION);
nameLabel->setText(tr("Kylin Assistant") + " " + qApp->applicationVersion());
// linkLabel->setAlignment(Qt::AlignRight);
// linkLabel->setText(QString::fromLocal8Bit("<a style='color: green;' href = https://launchpad.net/kylin-assistant> home page</a>"));

View File

@ -43,7 +43,6 @@ HomePage::HomePage(QWidget *parent, QString arch, QString os/*, const QString &v
// QPixmap pixmap("://res/scan.png");
// scan_button->setIcon(pixmap);
// scan_button->setIconSize(pixmap.size());
current_version = VERSION;
version_logo = new QLabel();
version_title = new QLabel();
version_tip = new QLabel();
@ -256,7 +255,7 @@ void HomePage::initConnect()
void HomePage::setLanguage()
{
version_title->setText(tr("Current Version Number") + " " + current_version);
version_title->setText(tr("Current Version Number") + " " + qApp->applicationVersion());
version_tip->setText(tr("Update to the lastest version, make it work better"));
check_btn->setText(tr("updating on the backend"));
box_title->setText(tr("Common toolbox"));

View File

@ -79,7 +79,6 @@ private:
MainWindow *p_mainwindow;
// AutoStartWidget *auto_start;
// CameraManager *camera_manager;
QString current_version;
QString osname;
QString osarch;
QList<ToolButton *> item_list;

View File

@ -21,7 +21,6 @@
#include <QApplication>
#include <QTextCodec>
#include <QTranslator>
#include <QtSingleApplication>
#include <QScreen>
#include <QDebug>
#include <QPixmap>
@ -121,7 +120,9 @@ int make_pid_file() {
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setOrganizationName("kylin");
app.setApplicationName("kylin-assistant");
app.setApplicationVersion("1.0.0");
//单程序运行处理
QSharedMemory mem("KA");
@ -136,14 +137,6 @@ int main(int argc, char *argv[])
qDebug() << "debug mode";
#endif
//单程序运行处理
/*QtSingleApplication app(argc, argv);
if (app.isRunning())
{
qDebug() << QObject::tr("kylin-assistant had already running!");
return 0;
}*/
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
@ -195,14 +188,14 @@ int main(int argc, char *argv[])
// mdlg.show();
//启动图片
QPixmap pixmap("://res/skin/x.png");
/*QPixmap pixmap("://res/skin/x.png");
QSplashScreen screen(pixmap);
screen.show();
screen.showMessage("START...", Qt::AlignCenter, Qt::white);
screen.showMessage("START...", Qt::AlignCenter, Qt::white);*/
MainWindow w(arch, sCount);
#if 0
/*#if 0
//延时
int delayTime = 3;
QElapsedTimer timer;
@ -211,7 +204,7 @@ int main(int argc, char *argv[])
app.processEvents();
}
screen.finish(&w);
#endif
#endif*/
w.setTranslator(&translator);

View File

@ -22,6 +22,7 @@
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QDesktopWidget>
#include <QGraphicsDropShadowEffect>
#include "shadowwidget.h"
//#include "cameramanager.h"
#include "../component/threadpool.h"
@ -73,10 +74,23 @@ MainWindow::MainWindow(QString cur_arch, int d_count, QWidget *parent) :
status = HOMEPAGE;
statusFlag = false;
// this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setAttribute(Qt::WA_ShowModal);
/*QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
shadow_effect->setBlurRadius(15.0);
shadow_effect->setColor(QColor(0, 0, 0, 100));//shadow_effect->setColor(Qt::gray);
shadow_effect->setOffset(1.0);//shadow_effect->setOffset(-5, 5);
this->setGraphicsEffect(shadow_effect);*/
sessioninterface = NULL;
systeminterface = NULL;
mSettings = new QSettings(YOUKER_COMPANY_SETTING, YOUKER_SETTING_FILE_NAME_SETTING);
mSettings = new QSettings(KYLIN_COMPANY_SETTING, KYLIN_SETTING_FILE_NAME_SETTING);
mSettings->setIniCodec("UTF-8");
@ -671,7 +685,7 @@ inline bool isRunningInstalled() {
inline QString getAppDirectory() {
if (isRunningInstalled()) {
return QString("/var/lib/youker-assistant-daemon/");
return QString("/var/lib/kylin-assistant-daemon/");
} else {
return QString(QCoreApplication::applicationDirPath());
}

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -10,7 +10,6 @@ CONFIG += c++11
CONFIG += qt warn_on
CONFIG += release
CONFIG += link_pkgconfig
INCLUDEPATH += .
QT += dbus
@ -22,7 +21,7 @@ inst3.files += res/default/
inst3.path = /var/lib/kylin-assistant-daemon/
inst4.files += res/custom/
inst4.path = /var/lib/kylin-assistant-daemon/
inst5.files += res/autostart-default.png
inst5.files += res/app-autostart-default.png
inst5.path = /usr/share/pixmaps
target.source += $$TARGET
target.path = /usr/bin
@ -33,8 +32,6 @@ INSTALLS += inst1 \
inst5 \
target
include(../qtsingleapplication/src/qtsingleapplication.pri)
QMAKE_CPPFLAGS *= $(shell dpkg-buildflags --get CPPFLAGS)
QMAKE_CFLAGS *= $(shell dpkg-buildflags --get CFLAGS)
QMAKE_CXXFLAGS *= $(shell dpkg-buildflags --get CXXFLAGS)
@ -45,9 +42,9 @@ isEqual(QT_MAJOR_VERSION, 5) {
}
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
}
SOURCES += main.cpp\

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="zh_CN">
<TS version="2.1" language="zh_CN">
<context>
<name>AboutDialog</name>
<message>
@ -124,7 +124,7 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>BoardWidget</name>
<message>
<location filename="../../info/boardwidget.cpp" line="83"/>
<location filename="../../info/boardwidget.cpp" line="98"/>
<source>Board Info</source>
<translation></translation>
</message>
@ -478,7 +478,7 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>CleanerItems</name>
<message>
<location filename="../../cleaner/cleaneritems.cpp" line="175"/>
<location filename="../../cleaner/cleaneritems.cpp" line="177"/>
<source>OK</source>
<translation></translation>
</message>
@ -1432,7 +1432,7 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>CpuWidget</name>
<message>
<location filename="../../info/cpuwidget.cpp" line="90"/>
<location filename="../../info/cpuwidget.cpp" line="105"/>
<source>CPU Info</source>
<translation></translation>
</message>
@ -1440,7 +1440,7 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>DesktopWidget</name>
<message>
<location filename="../../info/desktopwidget.cpp" line="82"/>
<location filename="../../info/desktopwidget.cpp" line="96"/>
<source>Desktop Info</source>
<translation></translation>
</message>
@ -1456,60 +1456,60 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>FontWidget</name>
<message>
<location filename="../../setting/fontwidget.cpp" line="87"/>
<location filename="../../setting/fontwidget.cpp" line="88"/>
<location filename="../../setting/fontwidget.cpp" line="89"/>
<location filename="../../setting/fontwidget.cpp" line="90"/>
<location filename="../../setting/fontwidget.cpp" line="91"/>
<location filename="../../setting/fontwidget.cpp" line="92"/>
<location filename="../../setting/fontwidget.cpp" line="93"/>
<source>Click here to change font</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="277"/>
<location filename="../../setting/fontwidget.cpp" line="279"/>
<source>Default Font</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="278"/>
<location filename="../../setting/fontwidget.cpp" line="280"/>
<source>Desktop Font</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="279"/>
<location filename="../../setting/fontwidget.cpp" line="281"/>
<source>Monospace Font</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="280"/>
<location filename="../../setting/fontwidget.cpp" line="282"/>
<source>Document Font</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="281"/>
<location filename="../../setting/fontwidget.cpp" line="283"/>
<source>Titlebar Font</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="282"/>
<location filename="../../setting/fontwidget.cpp" line="284"/>
<source>Global Font Scaling</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="283"/>
<location filename="../../setting/fontwidget.cpp" line="285"/>
<source>Hinting</source>
<translation></translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="284"/>
<location filename="../../setting/fontwidget.cpp" line="286"/>
<source>Antialiasing</source>
<translation>齿</translation>
</message>
<message>
<location filename="../../setting/fontwidget.cpp" line="285"/>
<location filename="../../setting/fontwidget.cpp" line="286"/>
<location filename="../../setting/fontwidget.cpp" line="287"/>
<location filename="../../setting/fontwidget.cpp" line="288"/>
<location filename="../../setting/fontwidget.cpp" line="289"/>
<location filename="../../setting/fontwidget.cpp" line="290"/>
<location filename="../../setting/fontwidget.cpp" line="291"/>
<source>Restore</source>
<translation></translation>
</message>
@ -1723,7 +1723,7 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>HomePage</name>
<message>
<location filename="../homepage.cpp" line="184"/>
<location filename="../homepage.cpp" line="183"/>
<source>Boot Manager</source>
<translation></translation>
</message>
@ -1732,42 +1732,42 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="../homepage.cpp" line="259"/>
<location filename="../homepage.cpp" line="258"/>
<source>Current Version Number</source>
<translation></translation>
</message>
<message>
<location filename="../homepage.cpp" line="260"/>
<location filename="../homepage.cpp" line="259"/>
<source>Update to the lastest version, make it work better</source>
<translation>使</translation>
</message>
<message>
<location filename="../homepage.cpp" line="261"/>
<location filename="../homepage.cpp" line="260"/>
<source>updating on the backend</source>
<translation></translation>
</message>
<message>
<location filename="../homepage.cpp" line="282"/>
<location filename="../homepage.cpp" line="281"/>
<source>Upgrade is complete</source>
<translation></translation>
</message>
<message>
<location filename="../homepage.cpp" line="284"/>
<location filename="../homepage.cpp" line="283"/>
<source>Updating on the backend</source>
<translation></translation>
</message>
<message>
<location filename="../homepage.cpp" line="262"/>
<location filename="../homepage.cpp" line="261"/>
<source>Common toolbox</source>
<translation></translation>
</message>
<message>
<location filename="../homepage.cpp" line="263"/>
<location filename="../homepage.cpp" line="262"/>
<source>Fast and practical, making the system more personalized</source>
<translation></translation>
</message>
<message>
<location filename="../homepage.cpp" line="184"/>
<location filename="../homepage.cpp" line="183"/>
<source>More</source>
<translation></translation>
</message>
@ -2048,14 +2048,14 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="54"/>
<location filename="../mainwindow.cpp" line="56"/>
<location filename="../mainwindow.cpp" line="61"/>
<source>Kylin Assistant</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="59"/>
<source>Youker Assistant</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
</context>
<context>
@ -2252,7 +2252,7 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>QObject</name>
<message>
<location filename="../main.cpp" line="127"/>
<location filename="../main.cpp" line="130"/>
<source>kylin-assistant had already running!</source>
<translation></translation>
</message>
@ -2472,8 +2472,8 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
</message>
<message>
<location filename="../../shredmanager/shreddialog.cpp" line="110"/>
<location filename="../../shredmanager/shreddialog.cpp" line="238"/>
<location filename="../../shredmanager/shreddialog.cpp" line="250"/>
<location filename="../../shredmanager/shreddialog.cpp" line="239"/>
<location filename="../../shredmanager/shreddialog.cpp" line="251"/>
<source>No select any file which need to be shredded</source>
<translation></translation>
</message>
@ -2488,22 +2488,21 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<translation></translation>
</message>
<message>
<location filename="../../shredmanager/shreddialog.cpp" line="209"/>
<source>Allfile(*)</source>
<translation>(*)</translation>
<translation type="vanished">(*)</translation>
</message>
<message>
<location filename="../../shredmanager/shreddialog.cpp" line="226"/>
<location filename="../../shredmanager/shreddialog.cpp" line="227"/>
<source>Select file!</source>
<translation></translation>
</message>
<message>
<location filename="../../shredmanager/shreddialog.cpp" line="237"/>
<location filename="../../shredmanager/shreddialog.cpp" line="238"/>
<source>Shred successfully!</source>
<translation></translation>
</message>
<message>
<location filename="../../shredmanager/shreddialog.cpp" line="243"/>
<location filename="../../shredmanager/shreddialog.cpp" line="244"/>
<source>Shred failed!</source>
<translation></translation>
</message>
@ -2511,12 +2510,12 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>ShredManager</name>
<message>
<location filename="../../shredmanager/shredmanager.cpp" line="40"/>
<location filename="../../shredmanager/shredmanager.cpp" line="44"/>
<source>Shred Manager</source>
<translation></translation>
</message>
<message>
<location filename="../../shredmanager/shredmanager.cpp" line="45"/>
<location filename="../../shredmanager/shredmanager.cpp" line="49"/>
<source>Delete files makes it unable to recover</source>
<translation>使</translation>
</message>
@ -2524,28 +2523,28 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>SkinCenter</name>
<message>
<location filename="../skincenter.cpp" line="37"/>
<location filename="../skincenter.cpp" line="66"/>
<location filename="../skincenter.cpp" line="38"/>
<location filename="../skincenter.cpp" line="67"/>
<source>Skin Setting</source>
<translation></translation>
</message>
<message>
<location filename="../skincenter.cpp" line="77"/>
<location filename="../skincenter.cpp" line="78"/>
<source>Default</source>
<translation></translation>
</message>
<message>
<location filename="../skincenter.cpp" line="80"/>
<location filename="../skincenter.cpp" line="81"/>
<source>Custom</source>
<translation></translation>
</message>
<message>
<location filename="../skincenter.cpp" line="503"/>
<location filename="../skincenter.cpp" line="504"/>
<source>Open File</source>
<translation></translation>
</message>
<message>
<location filename="../skincenter.cpp" line="504"/>
<location filename="../skincenter.cpp" line="505"/>
<source>Files(*.png *.jpg)</source>
<translation>(*.png *.jpg)</translation>
</message>
@ -2677,116 +2676,116 @@ Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</source>
<context>
<name>UpgradeDialog</name>
<message>
<location filename="../upgradedialog.cpp" line="61"/>
<location filename="../upgradedialog.cpp" line="60"/>
<source>check and update</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="103"/>
<location filename="../upgradedialog.cpp" line="398"/>
<location filename="../upgradedialog.cpp" line="102"/>
<location filename="../upgradedialog.cpp" line="397"/>
<source>Current verison:</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="139"/>
<location filename="../upgradedialog.cpp" line="138"/>
<source>Official version</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="162"/>
<location filename="../upgradedialog.cpp" line="161"/>
<source>An error occurred!</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="163"/>
<location filename="../upgradedialog.cpp" line="162"/>
<source>Network or local sources anomaly</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="164"/>
<location filename="../upgradedialog.cpp" line="278"/>
<location filename="../upgradedialog.cpp" line="163"/>
<location filename="../upgradedialog.cpp" line="277"/>
<source>Testing network and local sources...</source>
<translation>...</translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="172"/>
<location filename="../upgradedialog.cpp" line="171"/>
<source>Retry</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="185"/>
<location filename="../upgradedialog.cpp" line="184"/>
<source>Finish</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="192"/>
<location filename="../upgradedialog.cpp" line="191"/>
<source>Upgrade</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="254"/>
<location filename="../upgradedialog.cpp" line="337"/>
<location filename="../upgradedialog.cpp" line="253"/>
<location filename="../upgradedialog.cpp" line="336"/>
<source>Start to update the local sources</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="333"/>
<location filename="../upgradedialog.cpp" line="332"/>
<source>Start to download</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="382"/>
<location filename="../upgradedialog.cpp" line="381"/>
<source>Updating local sources...</source>
<translation>...</translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="397"/>
<location filename="../upgradedialog.cpp" line="396"/>
<source>Kylin Assistant is the latest version</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="410"/>
<location filename="../upgradedialog.cpp" line="409"/>
<source>Start to install</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="344"/>
<location filename="../upgradedialog.cpp" line="343"/>
<source>Download completely</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="355"/>
<location filename="../upgradedialog.cpp" line="354"/>
<source>Local sources updated</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="365"/>
<location filename="../upgradedialog.cpp" line="364"/>
<source>Found a new version</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="153"/>
<location filename="../upgradedialog.cpp" line="152"/>
<source>New version:</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="167"/>
<location filename="../upgradedialog.cpp" line="166"/>
<source>you can visit the&lt;a style=&apos;color: #3f96e4;&apos; href = http://www.ubuntukylin.com&gt; UK official website&lt;/a&gt; to download the lastest deb package</source>
<translation>访 &lt;a style=&apos;color: #3f96e4;&apos; href = http://www.ubuntukylin.com&gt; UK 官网&lt;/a&gt; 下载最新的deb包</translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="360"/>
<location filename="../upgradedialog.cpp" line="374"/>
<location filename="../upgradedialog.cpp" line="359"/>
<location filename="../upgradedialog.cpp" line="373"/>
<source>Not found</source>
<translation></translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="418"/>
<location filename="../upgradedialog.cpp" line="417"/>
<source>Upgrading the main program...</source>
<translation>...</translation>
</message>
<message>
<location filename="../upgradedialog.cpp" line="472"/>
<location filename="../upgradedialog.cpp" line="471"/>
<source>Start to upgrade the main program</source>
<translation></translation>
</message>

View File

@ -34,8 +34,7 @@ UpgradeDialog::UpgradeDialog(QWidget *parent, /*const QString &version, */QStrin
isBusy = false;
upgradeOver = false;
// cur_version = version;
cur_version = VERSION;
cur_version = qApp->applicationVersion();
baseWidget = new QWidget(this);
baseWidget->setGeometry(QRect(0, 0, 334, 191));
@ -100,7 +99,7 @@ UpgradeDialog::UpgradeDialog(QWidget *parent, /*const QString &version, */QStrin
version_label = new QLabel(this);
version_label->setObjectName("smallgrayLabel");
version_label->setGeometry(QRect(10, 440, 324, 20));
version_label->setText(tr("Current verison:") + VERSION);
version_label->setText(tr("Current verison:") + qApp->applicationVersion());
doing_label = new QLabel(this);
doing_label->setWordWrap(true);//QLabel自动换行
doing_label->setStyleSheet("QLabel{color:#000000;font-family: 方正黑体_GBK;font-size: 22px;text-align: center;}");