Skip to content

Commit aa3eb58

Browse files
committed
reduce icons size.
add Linux/*BSD desktop file. can use make install now.
1 parent 910d140 commit aa3eb58

12 files changed

+86
-37
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The odd minor version number (0.**X**) indicates development version. And the ev
99

1010
- This is not a standalone programme. It works along with ss-local binary from [shadowsocks-libev project](https://github.com/madeye/shadowsocks-libev).
1111
- The gui-config.json file is compatible with [shadowsocks-gui](https://github.com/shadowsocks/shadowsocks-gui). But add a new value named "app" to specify `ss-local` programme.
12-
- gui-config.json is located under /etc/shadowsocks/ for UNIX users, but under this app's directory for Windows users.
12+
- gui-config.json is located under ~/.config/shadowsocks for UNIX users, but under this app's directory for Windows users.
1313
- Although it's recommended to use both 64-bit ss-local and ss-qt5 if you're running 64-bit OS. Feel free to use 32-bit ss-local together with 64-bit ss-qt5, vice versa.
1414

1515
## BUILD FROM SOURCE ##

icon/colourful_icon.png

-128 KB
Binary file not shown.

icon/mono_icon.png

-7.56 KB
Loading

icon/running_icon.png

-6.6 KB
Loading

icon/shadowsocks-qt5.png

82.2 KB
Loading

icons.qrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<RCC>
22
<qresource prefix="/">
3-
<file>icon/colourful_icon.png</file>
3+
<file>icon/shadowsocks-qt5.png</file>
44
<file>icon/mono_icon.png</file>
55
<file>icon/running_icon.png</file>
66
</qresource>

main.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
#include "mainwindow.h"
2+
#include "profiles.h"
3+
#include "ss_process.h"
24
#include <QApplication>
35

46
int main(int argc, char *argv[])
57
{
68
QApplication a(argc, argv);
79
MainWindow w;
8-
w.show();
10+
11+
/*
12+
* autostart if there is a valid profile activated already.
13+
* and don't show the mainwindow
14+
*/
15+
//validate first
16+
//TODO: more accurate
17+
if (w.current_profile.local_port.toInt() > 0 &&
18+
w.current_profile.method != NULL &&
19+
w.current_profile.password != NULL &&
20+
w.current_profile.server != NULL &&
21+
w.current_profile.server_port.toInt() > 0 &&
22+
w.current_profile.timeout.toInt() > 0) {
23+
w.ss_local.start(w.current_profile);
24+
}
25+
else {//profile is not valid
26+
w.show();
27+
}
928

1029
return a.exec();
1130
}

mainwindow.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <QDesktopWidget>
12
#include <QFileDialog>
23
#include <QFile>
34
#include <QStandardPaths>
@@ -30,7 +31,7 @@ MainWindow::MainWindow(QWidget *parent) :
3031
#ifdef _WIN32
3132
jsonconfigFile = QCoreApplication::applicationDirPath() + "/gui-config.json";
3233
#else
33-
jsonconfigFile = "/etc/shadowsocks/gui-config.json";
34+
jsonconfigFile = QDir::homePath() + "/.config/shadowsocks/gui-config.json";
3435
#endif
3536
m_profile = new Profiles(jsonconfigFile);
3637
ui->sslocalEdit->setText(detectSSLocal());
@@ -42,10 +43,12 @@ MainWindow::MainWindow(QWidget *parent) :
4243
systrayMenu.addAction("Start/Stop", this, SLOT(startbuttonPressed()));
4344
systrayMenu.addAction("Exit", this, SLOT(close()));
4445
systray.setIcon(QIcon(":/icon/mono_icon.png"));
46+
systray.setToolTip(QString("Shadowsocks-Qt5"));
4547
systray.setContextMenu(&systrayMenu);
4648
systray.show();
4749

48-
autoStartSSLocal();
50+
//Move to the center of the screen
51+
this->move(QApplication::desktop()->screen()->rect().center() - this->rect().center());
4952
}
5053

5154
MainWindow::~MainWindow()
@@ -166,26 +169,6 @@ void MainWindow::deleteProfile()
166169
ui->serverComboBox->removeItem(i);
167170
}
168171

169-
/*
170-
* autostart if there is a valid profile activated already.
171-
* then minimize itself into systray.
172-
*/
173-
void MainWindow::autoStartSSLocal()
174-
{
175-
//validate first
176-
//TODO: more accurate
177-
if (current_profile.local_port.toInt() > 0 &&
178-
current_profile.method != NULL &&
179-
current_profile.password != NULL &&
180-
current_profile.server != NULL &&
181-
current_profile.server_port.toInt() > 0 &&
182-
current_profile.timeout.toInt() > 0)
183-
{
184-
ss_local.start(current_profile);
185-
hide();
186-
}
187-
}
188-
189172
void MainWindow::processStarted()
190173
{
191174
ui->startButton->setUserData(0, (QObjectUserData *)1);
@@ -207,10 +190,13 @@ void MainWindow::processStopped()
207190
void MainWindow::showorhideWindow()
208191
{
209192
if (this->isVisible()) {
210-
hide();
193+
this->hide();
211194
}
212195
else {
213-
show();
196+
this->show();
197+
this->setWindowState(Qt::WindowActive);
198+
this->activateWindow();
199+
ui->logButton->setFocus();
214200
}
215201
}
216202

@@ -220,3 +206,10 @@ void MainWindow::systrayActivated(QSystemTrayIcon::ActivationReason r)
220206
showorhideWindow();
221207
}
222208
}
209+
210+
void MainWindow::changeEvent(QEvent *e)
211+
{
212+
if (e->type()==QEvent::WindowStateChange && this->isMinimized()) {
213+
this->hide();
214+
}
215+
}

mainwindow.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class MainWindow : public QMainWindow
1919
public:
2020
explicit MainWindow(QWidget *parent = 0);
2121
~MainWindow();
22-
QProcess sslocal;
22+
SS_Process ss_local;
23+
SSProfile current_profile;
2324

2425
signals:
2526
void currentProfileChanged(int);
@@ -33,7 +34,6 @@ public slots:
3334
void showLogDialogue();
3435
void deleteProfile();
3536
void revertbuttonPressed();
36-
void autoStartSSLocal();
3737
void processStarted();
3838
void processStopped();
3939
void systrayActivated(QSystemTrayIcon::ActivationReason);
@@ -44,11 +44,12 @@ public slots:
4444
LogDialogue logdlg;
4545
QString detectSSLocal();
4646
QString jsonconfigFile;
47-
SSProfile current_profile;
4847
Profiles *m_profile;
49-
SS_Process ss_local;
5048
QSystemTrayIcon systray;
5149
QMenu systrayMenu;
50+
51+
protected:
52+
void changeEvent(QEvent *);
5253
};
5354

5455
#endif // MAINWINDOW_H

mainwindow.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>340</width>
10-
<height>252</height>
10+
<height>250</height>
1111
</rect>
1212
</property>
1313
<property name="minimumSize">
@@ -21,7 +21,7 @@
2121
</property>
2222
<property name="windowIcon">
2323
<iconset resource="icons.qrc">
24-
<normaloff>:/icon/colourful_icon.png</normaloff>:/icon/colourful_icon.png</iconset>
24+
<normaloff>:/icon/shadowsocks-qt5.png</normaloff>:/icon/shadowsocks-qt5.png</iconset>
2525
</property>
2626
<widget class="QWidget" name="centralWidget">
2727
<layout class="QVBoxLayout" name="verticalLayout">

shadowsocks-qt5.desktop

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Desktop Entry]
2+
Name=Shadowsocks-Qt5
3+
GenericName=Shadowsocks-Qt5
4+
Comment=A GUI Client for Shadowsocks
5+
Exec=ss-qt5
6+
Icon=shadowsocks-qt5
7+
Terminal=false
8+
Type=Application
9+
Categories=Network;
10+
StartupNotify=true

shadowsocks-qt5.pro

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,36 @@ HEADERS += mainwindow.h \
2424
FORMS += mainwindow.ui \
2525
logdialogue.ui
2626

27-
OTHER_FILES += \
28-
README.md \
29-
gui-config.json
27+
OTHER_FILES += README.md \
28+
gui-config.json \
29+
shadowsocks-qt5.desktop
30+
31+
binary_path = /usr/bin
32+
desktop.path = /usr/share/applications
33+
desktop.files = shadowsocks-qt5.desktop
34+
ssicon.path = /usr/share/icons/hicolor/512x512/apps
35+
ssicon.files = icon/shadowsocks-qt5.png
36+
37+
!equals($$(INSTALL_PREFIX), "") {
38+
unix: {
39+
binary_path = $$(INSTALL_PREFIX)/bin
40+
desktop.path = $$(INSTALL_PREFIX)/share/applications
41+
ssicon.path = $$(INSTALL_PREFIX)/share/icons/hicolor/512x512/apps
42+
}
43+
else: binary_path = $$(INSTALL_PREFIX)
44+
}
45+
46+
target.path = $$binary_path
47+
48+
unix: gui_conf.path = $$(HOME)/.config/shadowsocks
49+
else: gui_conf.path = target.path
50+
gui_conf.files = gui-config.json
51+
52+
INSTALLS += target \
53+
gui_conf
54+
55+
!mac:unix: INSTALLS += desktop ssicon
3056

3157
RESOURCES += icons.qrc
3258

33-
RC_FILE = ss-qt5.rc
59+
win32: RC_FILE = ss-qt5.rc

0 commit comments

Comments
 (0)