Skip to content

Commit

Permalink
write_config(self) method to write to configfile in preferences.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
muammar committed Aug 12, 2016
1 parent 5840dac commit ef8e339
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions mkchromecast/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ def reset_indexes(self):
def onActivatedbk(self, text):
self.config.read(self.configf)
self.config.set('settings','backend',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()
self.qccodec.clear()
if self.backendconf == 'node':
Expand Down Expand Up @@ -366,8 +365,7 @@ def onActivatedbk(self, text):
def onActivatedcc(self, text):
self.config.read(self.configf)
self.config.set('settings','codec',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()
self.qcbitrate.clear()
if self.codecconf == 'wav':
Expand Down Expand Up @@ -398,36 +396,31 @@ def onActivatedcc(self, text):
def onActivatedbt(self, text):
self.config.read(self.configf)
self.config.set('settings','bitrate',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()

def onActivatedsr(self, text):
self.config.read(self.configf)
self.config.set('settings','samplerate',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()

def onActivatednotify(self, text):
self.config.read(self.configf)
self.config.set('settings','notifications',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()

def onActivatedcolors(self, text):
self.config.read(self.configf)
self.config.set('settings','colors',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()

def onActivatedatlaunch(self, text):
self.config.read(self.configf)
self.config.set('settings','searchatlaunch',text)
with open(self.configf, 'w') as configfile:
self.config.write(configfile)
self.write_config())
self.read_defaults()

def read_defaults(self):
Expand All @@ -449,6 +442,12 @@ def read_defaults(self):
self.samplerateconf, self.notificationsconf, \
self.searchatlaunchconf, self.searchcolorsconf)

def write_config(self):
"""This method writes to configfile"""
with open(self.configf, 'w') as configfile:
self.config.write(configfile)


if __name__ == '__main__':
app = QApplication(sys.argv)
p = preferences()
Expand Down

0 comments on commit ef8e339

Please sign in to comment.