Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 69ea05c

Browse files
committed
Config hatası düzeltildi
1 parent 0bcae93 commit 69ea05c

File tree

3 files changed

+42
-31
lines changed

3 files changed

+42
-31
lines changed

anka-browser.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,28 @@
99
import re
1010

1111

12-
config_path = "./config/config.conf"
12+
home = os.path.expanduser('~')
13+
config_anka = f"{home}/.config/Anka"
14+
15+
if not os.path.exists(config_anka):
16+
os.makedirs(config_anka)
17+
18+
config_path = f"{config_anka}/config.conf"
19+
20+
if not os.path.exists(config_path):
21+
with open(config_path, 'w') as cf:
22+
cf.write("""[Settings]
23+
search_engine = https://google.com
24+
25+
[Appearance]
26+
tab_color = #2aa1b3
27+
not_selected_tab_color = #22818f
28+
29+
[Language]
30+
language = tr-TR
31+
""")
32+
33+
1334
config = configparser.ConfigParser()
1435
config.read(config_path)
1536

@@ -19,28 +40,17 @@
1940
"en-US": "English",
2041
}
2142

22-
with open(f"./public/browser/languages/{language}.json", "r", encoding="UTF-8") as jsonn:
43+
with open(f"{config_anka}/public/browser/languages/{language}.json", "r", encoding="UTF-8") as jsonn:
2344
texts = json.load(jsonn)
2445

2546
tab_name = texts["tab-name"]
26-
history = "./public/browser/history.txt"
27-
bookmarks = "./public/browser/bookmarks.txt"
47+
history = f"{config_anka}/public/browser/history.txt"
48+
bookmarks = f"{config_anka}/public/browser/bookmarks.txt"
2849

2950
if not os.path.exists(history):
3051
with open(history, 'x') as history_file:
3152
pass
32-
if not os.path.exists(config_path):
33-
with open(config_path, 'w') as cf:
34-
cf.write("""[Settings]
35-
search_engine = https://google.com
36-
37-
[Appearance]
38-
tab_color = #2aa1b3
39-
not_selected_tab_color = #22818f
4053

41-
[Language]
42-
language = tr-TR
43-
""")
4454
if not os.path.exists(bookmarks):
4555
with open(bookmarks, 'x') as bf:
4656
pass
@@ -66,8 +76,6 @@ def __init__(self):
6676
height:25px;
6777
border-radius: 10px;
6878
padding: 5px;
69-
70-
7179
7280
}}
7381
QTabBar::tab::selected{{
@@ -79,7 +87,7 @@ def __init__(self):
7987

8088
self.tabs.tabCloseRequested.connect(self.close_tab)
8189

82-
self.setWindowIcon(QIcon("public/img/logo.ico"))
90+
self.setWindowIcon(QIcon(f"{config_anka}/public/img/logo.ico"))
8391

8492
self.add_new_tab(QUrl(search_engine), tab_name)
8593

@@ -93,47 +101,47 @@ def __init__(self):
93101

94102
self.back_button = QPushButton()
95103
self.back_button.clicked.connect(self.browser_back)
96-
self.back_button.setIcon(QIcon("./public/img/back.png"))
104+
self.back_button.setIcon(QIcon(f"{config_anka}/public/img/back.png"))
97105
self.back_button.setFixedSize(QSize(20, 20))
98106
self.back_button.setIconSize(QSize(20, 20))
99107
self.back_button.setStyleSheet("background-color: transparent; border: none;")
100108
self.back_button.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
101109

102110
self.forward_button = QPushButton()
103111
self.forward_button.clicked.connect(self.browser_forward)
104-
self.forward_button.setIcon(QIcon("public/img/forward.png"))
112+
self.forward_button.setIcon(QIcon(f"{config_anka}/public/img/forward.png"))
105113
self.forward_button.setFixedSize(QSize(20, 20))
106114
self.forward_button.setIconSize(QSize(20, 20))
107115
self.forward_button.setStyleSheet("background-color: transparent; border: none;")
108116
self.forward_button.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
109117

110118
self.new_tab_button = QPushButton()
111119
self.new_tab_button.clicked.connect(self.add_new_tab_button)
112-
self.new_tab_button.setIcon(QIcon("public/img/newtab.png"))
120+
self.new_tab_button.setIcon(QIcon(f"{config_anka}/public/img/newtab.png"))
113121
self.new_tab_button.setFixedSize(QSize(20, 20))
114122
self.new_tab_button.setIconSize(QSize(20, 20))
115123
self.new_tab_button.setStyleSheet("background-color: transparent; border: none;")
116124
self.new_tab_button.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
117125

118126
self.reload_button = QPushButton()
119127
self.reload_button.clicked.connect(self.browser_reload)
120-
self.reload_button.setIcon(QIcon("public/img/reload.png"))
128+
self.reload_button.setIcon(QIcon(f"{config_anka}/public/img/reload.png"))
121129
self.reload_button.setFixedSize(QSize(20, 20))
122130
self.reload_button.setIconSize(QSize(20, 20))
123131
self.reload_button.setStyleSheet("background-color: transparent; border: none;")
124132
self.reload_button.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
125133

126134
self.bookmark_button = QPushButton()
127135
self.bookmark_button.clicked.connect(self.bookmark)
128-
self.bookmark_button.setIcon(QIcon("public/img/bookmark-regular.png"))
136+
self.bookmark_button.setIcon(QIcon(f"{config_anka}/public/img/bookmark-regular.png"))
129137
self.bookmark_button.setFixedSize(QSize(20,20))
130138
self.bookmark_button.setIconSize(QSize(20,20))
131139
self.bookmark_button.setStyleSheet("background-color: transparent; border: none;")
132140
self.bookmark_button.setCursor(Qt.CursorShape.PointingHandCursor)
133141

134142

135143
self.settings_button = QPushButton()
136-
self.settings_button.setIcon(QIcon("public/img/settingsbar.png"))
144+
self.settings_button.setIcon(QIcon(f"{config_anka}/public/img/settingsbar.png"))
137145
self.settings_button.setFixedSize(QSize(20, 20))
138146
self.settings_button.setIconSize(QSize(20, 20))
139147
self.settings_button.setStyleSheet("background-color: transparent; border: none; margin-right: 8px;")
@@ -168,7 +176,7 @@ def __init__(self):
168176

169177
self.setWindowTitle("Anka")
170178
self.showMaximized()
171-
self.setWindowIcon(QIcon("public/img/logo.ico"))
179+
self.setWindowIcon(QIcon(f"{config_anka}/public/img/logo.ico"))
172180
self.resize(1920, 1080)
173181

174182
self.tabs.currentChanged.connect(self.update_url_from_tab)
@@ -328,7 +336,7 @@ def browser_save(self):
328336
current_browser.page().toHtml(self.save_html)
329337

330338
def save_html(self, html):
331-
file_name, _ = QFileDialog.getSaveFileName(self, "Kaydet", "", "HTML Dosyası (*.html);;WEBP Dosyası(*.webp);;Tüm Dosyalar (*)")
339+
file_name, _ = QFileDialog.getSaveFileName(self, texts['right-click-save'], "", f"{texts['html_file']} (*.html);;{texts['webp_file']}(*.webp);;{texts['all_files']} (*)")
332340
if file_name:
333341
with open(file_name, 'w', encoding='utf-8') as file:
334342
file.write(html)
@@ -358,9 +366,6 @@ def load_bookmarks(self, top_layout):
358366
bookmark_button.clicked.connect(lambda checked, url=url: self.add_new_tab(QUrl(url), url))
359367
top_layout.addWidget(bookmark_button)
360368

361-
362-
363-
364369

365370
class AnkaBrowserSettings(QDialog):
366371
def __init__(self, parent=None):
@@ -455,7 +460,7 @@ def ok(self):
455460
# Burada her bir dosya için ayrı ayrı kodu uzatmak yerine, kısaca Data'sına eşitlemesini sağladım.
456461
lan = self.language.currentData()
457462
config["Language"]["language"] = lan
458-
with open('config/config.conf', 'w' ) as configfile:
463+
with open(config_path, 'w' ) as configfile:
459464
config.write(configfile)
460465
self.accept()
461466

@@ -486,7 +491,7 @@ def __init__(self, parent=None):
486491
config["Appearance"]["tab_color"] = str(tabColor)
487492
config["Appearance"]["not_selected_tab_color"] = str(not_selected_tab_color)
488493

489-
with open('config/config.conf', 'w' ) as configfile:
494+
with open(config_path, 'w' ) as configfile:
490495
config.write(configfile)
491496

492497

public/browser/languages/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"right-click-forward" : "Forward",
99
"right-click-reload" : "Reload",
1010
"settings": "Settings",
11+
"html_file": "HTML File",
12+
"webp_file": "WEBP File",
13+
"all_files": "All Files",
1114
"settings-title" : "Anka | Settings",
1215
"settings-search-engine" : "Search Engine: ",
1316
"settings-tab-color-label" : "Select tab color: ",

public/browser/languages/tr-TR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"right-click-forward" : "İleri",
99
"right-click-reload" : "Yeniden Yükle",
1010
"settings": "Ayarlar",
11+
"html_file": "HTML Dosyası",
12+
"webp_file": "WEBP Dosyası",
13+
"all_files": "Tüm Dosyalar",
1114
"settings-title" : "Anka | Ayarlar",
1215
"settings-search-engine" : "Arama Motoru: ",
1316
"settings-tab-color-label" : "Sekme rengi seçin: ",

0 commit comments

Comments
 (0)