2021-01-07 10:16:32 +08:00
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "ukccabout.h"
#include "../utils/xatom-helper.h"
#include <QVariant>
2021-02-25 15:43:42 +08:00
#include <QDesktopServices>
#include <QUrl>
2021-01-07 10:16:32 +08:00
UkccAbout :: UkccAbout ( QWidget * parent )
: QDialog ( parent ) {
setFixedSize ( 420 , 560 );
XAtomHelper :: getInstance () -> setUKUIDecoraiontHint ( this -> winId (), true );
MotifWmHints hints ;
hints . flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS ;
hints . functions = MWM_FUNC_ALL ;
hints . decorations = MWM_DECOR_BORDER ;
XAtomHelper :: getInstance () -> setWindowMotifHint ( this -> winId (), hints );
initUI ();
initConnection ();
}
void UkccAbout :: initUI () {
mMainVLayout = new QVBoxLayout ();
mTitleLayout = new QHBoxLayout ();
mCenterIconLayout = new QHBoxLayout ();
mCenterTitleLayout = new QHBoxLayout ();
mCenterVersionLayout = new QHBoxLayout ();
mUkccDetailLayout = new QHBoxLayout ();
mUkccDeveloperLayout = new QHBoxLayout ();
mMainVLayout -> setContentsMargins ( 8 , 4 , 4 , 4 );
mTitleLayout -> setSpacing ( 0 );
QIcon titleIcon = QIcon :: fromTheme ( "ukui-control-center" );
mUkccIcon = new QLabel ();
mUkccIcon -> setPixmap ( titleIcon . pixmap ( titleIcon . actualSize ( QSize ( 24 , 24 ))));
2021-03-24 19:22:04 +08:00
mUkccTitle = new QLabel ( tr ( "Settings" ));
2021-01-07 10:16:32 +08:00
mUkccCloseBtn = new QPushButton ();
mUkccCloseBtn -> setIcon ( QIcon :: fromTheme ( "window-close-symbolic" ));
mUkccCloseBtn -> setProperty ( "isWindowButton" , 0x02 );
mUkccCloseBtn -> setProperty ( "useIconHighlightEffect" , 0x08 );
mUkccCloseBtn -> setFlat ( true );
mUkccCloseBtn -> setFixedSize ( 30 , 30 );
mTitleLayout -> addWidget ( mUkccIcon );
mTitleLayout -> addSpacing ( 8 );
mTitleLayout -> addWidget ( mUkccTitle );
mTitleLayout -> addStretch ();
mTitleLayout -> addWidget ( mUkccCloseBtn );
mUkccCenterIcon = new QLabel ();
mUkccCenterIcon -> setPixmap ( titleIcon . pixmap ( titleIcon . actualSize ( QSize ( 96 , 96 ))));
mCenterIconLayout -> addStretch ();
mCenterIconLayout -> addWidget ( mUkccCenterIcon );
mCenterIconLayout -> addStretch ();
2021-03-24 19:22:04 +08:00
mUkccCenterTitle = new QLabel ( tr ( "Settings" ));
2021-01-07 10:16:32 +08:00
mUkccCenterTitle -> setFixedHeight ( 28 );
mCenterTitleLayout -> addStretch ();
mCenterTitleLayout -> addWidget ( mUkccCenterTitle );
mCenterTitleLayout -> addStretch ();
mUkccVersion = new QLabel ( tr ( "Version: " ) + getUkccVersion ());
mUkccVersion -> setFixedHeight ( 24 );
mCenterVersionLayout -> addStretch ();
mCenterVersionLayout -> addWidget ( mUkccVersion );
mCenterVersionLayout -> addStretch ();
2021-01-13 15:09:59 +08:00
mUkccDetail = new QTextEdit ( tr ( "The control panel provides a friendly graphical user interface to manage common configuration items of the operating system. "
2021-01-07 10:16:32 +08:00
"System configuration provides system, equipment, personalization, network, account, time and date, account, time and date, update, notification and operation module operations. " ));
2021-02-24 19:33:36 +08:00
mUkccDetail -> setReadOnly ( true );
2021-01-07 10:16:32 +08:00
mUkccDetailLayout -> addSpacing ( 32 );
mUkccDetailLayout -> addWidget ( mUkccDetail );
mUkccDetailLayout -> addSpacing ( 32 );
2021-03-03 16:55:38 +08:00
mUkccDeveloper = new QLabel ( tr ( "Service and Support:" ));
2021-01-07 10:16:32 +08:00
mUkccDeveloperLayout -> addSpacing ( 32 );
mUkccDeveloperLayout -> addWidget ( mUkccDeveloper );
2021-02-25 15:43:42 +08:00
mUkccDeveloperEmailBtn = new QPushButton ( "support@kylinos.cn" );
mUkccDeveloperEmailBtn -> setFocusPolicy ( Qt :: NoFocus );
mUkccDeveloperEmailBtn -> setContentsMargins ( 0 , 0 , 0 , 0 );
2021-03-17 09:47:34 +08:00
mUkccDeveloperEmailBtn -> setCursor ( QCursor ( Qt :: PointingHandCursor ));
2021-03-02 19:23:16 +08:00
mUkccDeveloperEmailBtn -> setStyleSheet ( "QPushButton{background: transparent;border-radius: 4px;text-decoration: underline;} " );
2021-02-25 15:43:42 +08:00
mUkccDeveloperLayout -> addWidget ( mUkccDeveloperEmailBtn );
mUkccDeveloperLayout -> setAlignment ( Qt :: AlignLeft );
connect ( mUkccDeveloperEmailBtn , & QPushButton :: clicked , this ,[ = ] {
QDesktopServices :: openUrl ( QUrl ( QLatin1String ( "mailto:support@kylinos.cn" )));
});
2021-01-07 10:16:32 +08:00
mMainVLayout -> addLayout ( mTitleLayout );
mMainVLayout -> addSpacing ( 42 );
mMainVLayout -> addLayout ( mCenterIconLayout );
mMainVLayout -> addSpacing ( 16 );
mMainVLayout -> addLayout ( mCenterTitleLayout );
mMainVLayout -> addSpacing ( 12 );
mMainVLayout -> addLayout ( mCenterVersionLayout );
mMainVLayout -> addSpacing ( 12 );
mMainVLayout -> addLayout ( mUkccDetailLayout );
mMainVLayout -> addSpacing ( 24 );
mMainVLayout -> addLayout ( mUkccDeveloperLayout );
mMainVLayout -> addSpacing ( 40 );
this -> setLayout ( mMainVLayout );
}
void UkccAbout :: initConnection () {
connect ( mUkccCloseBtn , & QPushButton :: clicked , this , [ = ]() {
this -> close ();
});
}
QString UkccAbout :: getUkccVersion () {
FILE * pp = NULL ;
char * line = NULL ;
size_t len = 0 ;
ssize_t read ;
char * q = NULL ;
QString version = "none" ;
pp = popen ( "dpkg -l ukui-control-center | grep ukui-control-center" , "r" );
if ( NULL == pp )
return version ;
while (( read = getline ( & line , & len , pp )) != - 1 ){
q = strrchr ( line , '\n' );
* q = '\0' ;
QString content = line ;
QStringList list = content . split ( " " );
list . removeAll ( "" );
if ( list . size () >= 3 )
version = list . at ( 2 );
}
free ( line );
2021-02-20 18:18:06 +08:00
line = NULL ;
2021-01-07 10:16:32 +08:00
pclose ( pp );
return version ;
}