diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index 4206f832..74f3e540 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -53,8 +53,9 @@ ../images/7z.png ../images/pdf.png ../images/comicZip.png - ../images/comicRar.png - ../images/comicTar.png - ../images/comic7z.png + ../images/comicRar.png + ../images/comicTar.png + ../images/comic7z.png + ../images/serverConfigBackground.png \ No newline at end of file diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 1b4f1328..2ef2940f 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -18,8 +18,16 @@ int main( int argc, char ** argv ) app.setApplicationName("YACReaderLibrary"); #ifdef SERVER_RELEASE - s = new Startup(); - s->start(); + QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor + settings->beginGroup("libraryConfig"); + + s = new Startup(); + + if(settings->value(SERVER_ON,true).toBool()) + { + + s->start(); + } #endif LibraryWindow * mw = new LibraryWindow(); diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index 73c0bb24..b29de49f 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -4,8 +4,11 @@ #include #include #include +#include +#include #include "startup.h" +#include "yacreader_global.h" extern Startup * s; @@ -15,59 +18,119 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent) accept = new QPushButton(tr("Update IPs")); connect(accept,SIGNAL(clicked()),this,SLOT(generateQR())); qrCodeImage = new QPixmap(); - qrCode = new QLabel("xxxx",this); + qrCode = new QLabel(this); + qrCode->move(196,73); + qrCode->setFixedSize(200,200); - QGridLayout * gridEdits = new QGridLayout; - gridEdits->addWidget(new QLabel(tr("IP")),0,0); - gridEdits->addWidget(new QLabel(tr("Port")),0,1); - ip = new QComboBox(); + QLabel * title1 = new QLabel(tr("EASY SERVER CONNECTION"),this); + title1->move(37,30); + title1->setStyleSheet("QLabel {color:#1F1F1F; font-size:18px; font-family: Arial; font-weight: bold;}"); + + QLabel * title2 = new QLabel(tr("SERVER ADDRESS"),this); + title2->move(451,30); + title2->setStyleSheet("QLabel {color:#1F1F1F; font-size:18px; font-family: Arial; font-weight: bold;}"); + + QLabel * qrMessage = new QLabel(tr("just scan the code with your device!!"),this); + qrMessage->move(194,290);//373,627); + qrMessage->setStyleSheet("QLabel {color:#1F1F1F; font-size:16px; font-family: Arial; font-style: italic;}"); + qrMessage->setWordWrap(true); + qrMessage->setFixedWidth(200); + + QLabel * propaganda = new QLabel(tr("YACReader is now available for iOS devices page "),this); + propaganda->move(36,375); + propaganda->setStyleSheet("QLabel {color:#1F1F1F; font-size:16px; font-family: Arial; font-style: italic;}" + "QLabel::a {color:#1A1A1A}"); + propaganda->setWordWrap(true); + propaganda->setFixedWidth(590); + propaganda->setOpenExternalLinks(true); + + QLabel * ipLabel = new QLabel(tr("IP address"),this); + ipLabel->move(455,78); + ipLabel->setStyleSheet("QLabel {color:#1F1F1F; font-size:13px; font-family: Arial; font-weight: bold;}"); + + QLabel * portLabel = new QLabel(tr("Port"),this); + portLabel->move(455, 119); + portLabel->setStyleSheet("QLabel {color:#1F1F1F; font-size:13px; font-family: Arial; font-weight: bold;}"); + + ip = new QComboBox(this); connect(ip,SIGNAL(activated(const QString &)),this,SLOT(regenerateQR(const QString &))); - gridEdits->addWidget(ip,1,0); - port = new QLineEdit("8080"); + ip->move(531,71); + ip->setSizeAdjustPolicy(QComboBox::AdjustToContents); + + port = new QLineEdit("8080",this); + port->setReadOnly(true); port->setMaximumWidth(50); - gridEdits->addWidget(port,1,1); - gridEdits->setColumnStretch(0,1); - gridEdits->setColumnStretch(1,0); + port->move(571,110); - QHBoxLayout * codeLayout = new QHBoxLayout; - codeLayout->addStretch(); - QLabel * qrMessage = new QLabel(); - qrMessage->setPixmap(QPixmap(":/images/qrMessage.png")); - codeLayout->addWidget(qrMessage); - codeLayout->addWidget(qrCode); - - QVBoxLayout * configLayout = new QVBoxLayout; - configLayout->addLayout(gridEdits); - configLayout->addLayout(codeLayout); - configLayout->addStretch(); - configLayout->setSpacing(5); - - QHBoxLayout * elementsLayout = new QHBoxLayout; - - QLabel * iphone = new QLabel(); - iphone->setPixmap(QPixmap(":/images/iphoneConfig.png")); - elementsLayout->setSpacing(40); - elementsLayout->addWidget(iphone); - elementsLayout->addStretch(); - elementsLayout->addLayout(configLayout); + check = new QCheckBox(this); + check->move(453,314); + check->setText(tr("enable the server")); + check->setStyleSheet("QCheckBox {color:#1F1F1F; font-size:13px; font-family: Arial; font-weight: bold;}"); + + //check->setLayoutDirection(Qt::RightToLeft); + + //elementsLayout->setSpacing(40); + //elementsLayout->addWidget(iphone); + //elementsLayout->addStretch(); + //elementsLayout->addLayout(configLayout); QHBoxLayout * buttons = new QHBoxLayout; buttons->addStretch(); buttons->addWidget(accept); - QVBoxLayout * mainLayout = new QVBoxLayout; - mainLayout->addLayout(elementsLayout); - mainLayout->addLayout(buttons); + //QVBoxLayout * mainLayout = new QVBoxLayout; + //mainLayout->addLayout(elementsLayout); + //mainLayout->addLayout(buttons); //mainLayout->addWidget(qrCode,0,1); - this->setLayout(mainLayout); - generateQR(); + //this->setLayout(mainLayout); QPalette Pal(palette()); // set black background - Pal.setColor(QPalette::Background, Qt::white); - setAutoFillBackground(true); - setPalette(Pal); + QPalette palette; + QImage image(":/images/serverConfigBackground.png"); + palette.setBrush(this->backgroundRole(), QBrush(image)); + + setPalette(palette); + + this->setFixedSize(image.size()); + + QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor + settings->beginGroup("libraryConfig"); + + if(settings->value(SERVER_ON,true).toBool()) + { + check->setChecked(true); + generateQR(); + } + else + check->setChecked(false); + + settings->endGroup(); + + connect(check,SIGNAL(stateChanged(int)),this,SLOT(enableServer(int))); +} + +void ServerConfigDialog::enableServer(int status) +{ + QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor + settings->beginGroup("libraryConfig"); + + if(status == Qt::Checked) + { + s->start(); + this->generateQR(); + settings->setValue(SERVER_ON,true); + } + else + { + s->stop(); + qrCode->setPixmap(QPixmap()); + ip->clear(); + port->setText(""); + settings->setValue(SERVER_ON,false); + } + settings->endGroup(); } void ServerConfigDialog::generateQR() @@ -118,7 +181,7 @@ void ServerConfigDialog::generateQR(const QString & serverAddress) { qrGenerator = new QProcess(); QStringList attributes; - attributes << "-o" << "-" /*QCoreApplication::applicationDirPath()+"/utils/tmp.png"*/ << "-s" << "8" << "-l" << "H" << serverAddress; + attributes << "-o" << "-" /*QCoreApplication::applicationDirPath()+"/utils/tmp.png"*/ << "-s" << "8" << "-l" << "H" << "-m" << "0" << serverAddress; connect(qrGenerator,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateImage(void))); connect(qrGenerator,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError))); qrGenerator->start(QCoreApplication::applicationDirPath()+"/utils/qrencode",attributes); diff --git a/YACReaderLibrary/server_config_dialog.h b/YACReaderLibrary/server_config_dialog.h index 09760afc..f1c0478c 100644 --- a/YACReaderLibrary/server_config_dialog.h +++ b/YACReaderLibrary/server_config_dialog.h @@ -9,6 +9,7 @@ #include #include #include +#include class ServerConfigDialog : public QDialog { @@ -18,6 +19,9 @@ Q_OBJECT private: QComboBox * ip; QLineEdit * port; + + QCheckBox * check; + QPushButton * close; QPushButton * accept; QLabel * qrCode; @@ -29,6 +33,7 @@ Q_OBJECT void generateQR(const QString & serverAddress); void regenerateQR(const QString & ip); void updateImage(); + void enableServer(int status); signals: void portChanged(QString port); diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 4549366c..b75131ff 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -41,6 +41,7 @@ #define X_ROTATION "X_ROTATION" #define Y_COVER_OFFSET "Y_COVER_OFFSET" #define V_SYNC "V_SYNC" +#define SERVER_ON "SERVER_ON" enum FlowType { diff --git a/images/serverConfigBackground.png b/images/serverConfigBackground.png new file mode 100644 index 00000000..aa8053fe Binary files /dev/null and b/images/serverConfigBackground.png differ diff --git a/release/server/docroot/css/styles_ipad.css b/release/server/docroot/css/styles_ipad.css index a127c18c..b54e9f71 100644 --- a/release/server/docroot/css/styles_ipad.css +++ b/release/server/docroot/css/styles_ipad.css @@ -99,7 +99,7 @@ margin: 20px 12px 20px 0; .importButton { width: 57px; - height: 22px; + height: 18px; background: url("../images/bt_import.jpg") no-repeat scroll 0 0 transparent; border: none; text-align:center; @@ -112,8 +112,8 @@ margin: 20px 12px 20px 0; .importedButton { width: 67px; - height: 22px; - background: url("../images/bt_imported.jpg") no-repeat scroll 0 0 transparent; + height: 18px; + background: url("../images/bt_import.jpg") no-repeat scroll 0 -22px transparent; border: none; text-align:center; display: block; diff --git a/release/server/docroot/css/styles_iphone.css b/release/server/docroot/css/styles_iphone.css index 09fbc471..dc5b1ee6 100644 --- a/release/server/docroot/css/styles_iphone.css +++ b/release/server/docroot/css/styles_iphone.css @@ -81,21 +81,21 @@ margin: 20px 0 15px 0; .importButton { width: 67px; - height: 24px; + height: 20px; background: url("../images/bt_import.jpg") no-repeat scroll 0 0 transparent; border: none; text-align:center; display: block; float: left; margin: 0 0 0 8px; - padding: 5px 0 0 0; + padding: 4px 0 0 0; } .importedButton { - width: 67px; - height: 22px; - background: url("../images/bt_imported.jpg") no-repeat scroll 0 0 transparent; + width: 77px; + height: 20px; + background: url("../images/bt_import.jpg") no-repeat scroll 0 -24px transparent; border: none; text-align:center; display: block; diff --git a/release/server/docroot/images/bt_import_ipad.jpg b/release/server/docroot/images/bt_import_ipad.jpg index 0155298f..c7961f01 100644 Binary files a/release/server/docroot/images/bt_import_ipad.jpg and b/release/server/docroot/images/bt_import_ipad.jpg differ diff --git a/release/server/docroot/images/bt_import_iphone.jpg b/release/server/docroot/images/bt_import_iphone.jpg index ff2955a5..27100c20 100644 Binary files a/release/server/docroot/images/bt_import_iphone.jpg and b/release/server/docroot/images/bt_import_iphone.jpg differ