summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAlex Borisov <borisov.alexandr@rambler.ru>2011-11-13 14:03:39 +0200
committerAlex Borisov <borisov.alexandr@rambler.ru>2011-11-13 14:03:39 +0200
commitb8a4ef60a8fdde02460d329c8b5caac414c38ebd (patch)
treef388d41383857e2e89162de18302f672c574000d /client
parentd3f1d599d4a9d44f48ae91d84618e3cdc4651aa0 (diff)
style.qss exitstance check. FIX: reading config files issue
Diffstat (limited to 'client')
-rw-r--r--client/Config.cpp52
-rw-r--r--client/Dialog.cpp23
2 files changed, 39 insertions, 36 deletions
diff --git a/client/Config.cpp b/client/Config.cpp
index e6174c1..6b1d4f9 100644
--- a/client/Config.cpp
+++ b/client/Config.cpp
@@ -21,15 +21,15 @@ Config::Config(): StaticProxySpeedLow(50)
return;
}
- string config = "";
- const int str_size = 512;
- char str[str_size] = {0};
- while (!configFile.eof())
- {
- configFile.read(str, str_size);
- config += str;
- }
- ParseConfig(str);
+ configFile.seekg (0, ios::end);
+ int length = configFile.tellg();
+ configFile.seekg (0, ios::beg);
+ char *buffer = new char [length];
+ configFile.read (buffer, length);
+ configFile.close();
+ string config = buffer;
+ ParseConfig(config);
+ delete[] buffer;
}
void Config::AcquireConfig()
@@ -274,24 +274,22 @@ void Config::ReadGenericProxy()
string filname = QCoreApplication::applicationDirPath().toStdString() +
"/config/proxy_list.cfg";
- ifstream proxyFile(filname.c_str(), std::ios::in);
+ ifstream proxyFile(filname.c_str(), std::ios::binary | std::ios::in);
if (! proxyFile)
{
Logger::Error("Can't open file %s\n", filname.c_str());
return;
}
- string proxies = "";
- const int str_size = 512;
- char str[str_size] = {0};
- while (!proxyFile.eof())
- {
- proxyFile.read(str, str_size);
- proxies += str;
- }
+ proxyFile.seekg (0, ios::end);
+ int length = proxyFile.tellg();
+ proxyFile.seekg (0, ios::beg);
+ char *buffer = new char [length];
+ proxyFile.read (buffer, length);
proxyFile.close();
-
+ string proxies = buffer;
ParseGenericProxies(proxies);
+ delete[] buffer;
}
/**
@@ -310,17 +308,15 @@ void Config::ReadStaticProxy()
return;
}
- string proxies = "";
- const int str_size = 512;
- char str[str_size] = {0};
- while (!proxyFile.eof())
- {
- proxyFile.read(str, str_size);
- proxies += str;
- }
+ proxyFile.seekg (0, ios::end);
+ int length = proxyFile.tellg();
+ proxyFile.seekg (0, ios::beg);
+ char *buffer = new char [length];
+ proxyFile.read (buffer, length);
proxyFile.close();
-
+ string proxies = buffer;
ParseStaticPorxies(proxies);
+ delete[] buffer;
}
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index b750945..d943d58 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -92,14 +92,21 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent)
mainLayout->addLayout(bottomPanelLayout);
setLayout(mainLayout);
- QString cssPath = this_app->applicationDirPath()+ "/style.qss";
- QFile file(cssPath);
- file.open(QFile::ReadOnly);
- QString cssStr = QString::fromLocal8Bit(file.readAll());
- file.close();
-
- Logger::Debug("Going to apply css style: %s\n", cssStr.toLocal8Bit().data());
- setStyleSheet(cssStr);
+ QString cssFile = this_app->applicationDirPath()+ "/style.qss";
+ QFileInfo cssFIleInfo(cssFile);
+ if (cssFIleInfo.exists())
+ {
+ Logger::Info("CSS stylesheet found. Trying to apply.\n");
+ QFile file(cssFile);
+ file.open(QFile::ReadOnly);
+ QString cssStr = QString::fromLocal8Bit(file.readAll());
+ file.close();
+ setStyleSheet(cssStr);
+ }
+ else
+ {
+ Logger::Info("CSS stylesheet file 'style.qss' wasn't found.\n");
+ }
}
void ProxyDialog::CountryActivated(int index)